Arduino Pro Micro without Bootloader

Hello,

I want to use 32K flash memory on arduino pro micro so I decide uploading sketch through Arduino as ISP (use pro mini as a programmer).

Before uploading, I change the maximum memory in "board.txt" to 32K (instead of 28K).

Everything works fine. I can send data over USB (PC detects the USB, I don't know whether the bootloader still exists in the board). Now I can upload sketch that consume more than 28K. BUT it works fine until the sketch reaches approximately 30500 bytes. (~30K).

The question is

  1. Bootloader still exists?
  2. If bootloader was remove, can PC detect USB as a COM port?
  3. If what I did is wrong, how to remove bootloader and I can use 32K flash memory with the USB connection to PC.
  4. Do I need to config other things in board.txt for example low_fuse, high_fuse? I am a novice and don't know what they are.

THANKS.

When you upload a sketch via ISP the bootloader is erased. If the bootloader is erased, you can still use the USB as COM port, just not for uploading a sketch. So once you upload a sketch via ISP, you need to continue to upload revised sketches or other sketches via ISP. Until you burn the bootloader again, and then from that point you can use the bootloader and upload in the common manner.

Here's the deal with fuses:
Go into the IDE preferences and check show verbose output during upload. Then connect the ISP and Burn Bootloader. The avrdude commands (2 separate commands) that are used to set the fuses, erase the chip, upload the bootloader, etc. will be shown to you. Copy them to a notepad.

You can study the data sheet for the ATmega32U4 (the MCU on the Pro Micro, you may know it is the same as on Leonardo). And also google for an online fuse calculator. You can google for avrdude command line options, and learn what is happening and why when you burn the bootloader. You can look at the boards.txt file that is part of the IDE installation to see the default fuse values used on your Pro Micro. You can figure out how to construct your own avrdude command line that sets whatever fuses you want and skips the chip erase and bootloader write options.

You do need to be careful, because some fuse values will make your ATmega32U4 no longer programmable, so it becomes bricked. An example of that kind of fuse is SPIEN, which is by default programmed (set to 0). If you were to unprogram that fuse bit, it disables further ISP programming. The only way to fix that would be to make a high voltage programmer and connect it to many pins of the ATmega32U4, and that would be difficult on an SMD chip. For this reason, you may want to consider experimenting with cheap clone Pro Micros from Aliexpress that only cost you a couple dollars, before you go messing with fuses on a Sparkfun Pro Micro that may have cost you $20, or don't go messing with fuses as a novice on your one-and-only board when you have a "project due" a few days from now. :slight_smile:

OK, finally, the news you didn't know you were waiting for (I'm long-winded today, apparently):
The BOOTRST fuse is programmed. That fuse tells the processor to start executing at the bootloader location in high memory (FLASH) upon power up or reset. If the bootloader is not there, do-nothing instructions are executed until end of memory is reached, and then instructions begin executing at beginning of memory where your sketch is located. So you do not notice anything bad until your sketch becomes so big it occupies parts of memory where the bootloader resides. Then, parts of your sketch may start executing right in the middle of your program, which will give garbage and unpredictable weird stuff happens. Bottom line, it won't work. The solution is to unprogram the BOOTRST fuse when you want to use the ATmega32U4 without a bootloader and just upload sketches via ISP. That tells the chip to begin execution at beginning of memory (your sketch) upon power up or reset.

The IDE only writes fresh fuses during the Burn Bootloader function, when you upload sketches it does not alter the fuses.

Thanks a lot dmjlambert, I deeply appreciate your reply. :slight_smile:

Below is the setting in the file "board.txt"

################################################################################
######################## Pro Micro w/o Bootloader ##############################
################################################################################
promicro1.name=Arduino Pro Micro w/o Bootloader

promicro1.upload.tool=avrdude
promicro1.upload.protocol=avr109
promicro1.upload.maximum_size=32768
promicro1.upload.maximum_data_size=2560
promicro1.upload.speed=57600
promicro1.upload.disable_flushing=true
promicro1.upload.use_1200bps_touch=true
promicro1.upload.wait_for_upload_port=true

promicro1.bootloader.tool=avrdude
promicro1.bootloader.unlock_bits=0x3F
promicro1.bootloader.lock_bits=0x2F
promicro1.bootloader.low_fuses=0xFF
promicro1.bootloader.high_fuses=0xD8

promicro1.build.board=AVR_PROMICRO
promicro1.build.core=arduino:arduino
promicro1.build.variant=promicro
promicro1.build.mcu=atmega32u4
promicro1.build.usb_product="SparkFun Pro Micro"
promicro1.build.vid=0x1b4f
promicro1.build.extra_flags={build.usb_flags}

######################### Pro Micro 3.3V / 8MHz ################################
promicro1.menu.cpu.8MHzatmega32U4=ATmega32U4 (3.3V, 8 MHz)

promicro1.menu.cpu.8MHzatmega32U4.build.pid.0=0x9203
promicro1.menu.cpu.8MHzatmega32U4.build.pid.1=0x9204
promicro1.menu.cpu.8MHzatmega32U4.build.pid=0x9204
promicro1.menu.cpu.8MHzatmega32U4.build.f_cpu=8000000L

promicro1.menu.cpu.8MHzatmega32U4.bootloader.extended_fuses=0xFE
promicro1.menu.cpu.8MHzatmega32U4.bootloader.file=caterina/Caterina-promicro8.hex

############################################################

What I need to do for being able to use 32K flash memory is to change the LSB of the promicro1.bootloader.high_fuses in which BOOTRST bit resides to "unprogrammed", and then go to arduino IDE, and Burn Bootloader again to assign new fuse, Right???

Yes, burn the bootloader to set the fuses. You can use the default boards.txt entry with default fuses for a regular Pro Micro. You do not need to build a special boards.txt entry. In the IDE preferences show verbose output during upload. Burn Bootloader. Take the command line shown to you that has the fuse setting that is applying the high fuse and copy it to the command line. Remove the other stuff that command line does, things such as lock bits, efuse, lfuse, -e for chip erase. Set only the high fuse to the updated value you need that unprograms the BOOTRST fuse.

Use an online fuse calculator to determine the value. Enter the default value shown in your boards.txt entry in the fuse calculator, then uncheck BOOTRST, and look at the new value it gives. Run the avrdude command line to set the fuse. Here is the answer so you can check your homework: The high fuses D8 is with BOOTRST programmed, and D9 is with BOOTRST unprogrammed.

Since you are already on the track of making a custom boards.txt entry, you should be able to do that if you wish. The only difference between the default boards.txt entry and the new one is the high fuse setting of D9.

I already did!! and now I can upload sketch consuming more 30K flash memory.

THANKS A LOT dmjlambert

:slight_smile:

i cant understand any of it.......

where can i find boards.txt?'
and doesn't the pro micro uses arduino leonardo's bootloader?
and i only have a nano to use as isp....., how can i do that?
it would be really helpful if i can use a nano as isp and extend the pro micro's maximum memory!

If you can't understand any of it, you may just have a lot of studying to do, research and reading and experimenting. That's how I did it. This thread is an advanced topic.

I don't remember where boards.txt is, but I don't try to remember it. Whenever I want to know, I just google it. For example, I googled it just now and found this
https://forum.arduino.cc/index.php?topic=455407.0

You can use a Nano or other Arduino as ISP programmer. There is a sketch in the examples for using an Arduino as ISP, and inside the sketch there is guidance in the comments. You will need to google to find and then try some guides in the forum and on the Internet to learn how to use an Arduino as an ISP programmer to burn the bootloader on a target chip or Arduino, and practice.

Note that in this thread, the original poster hesheit did not extend the Pro Micro's memory. He simply wanted to change what the memory is used for. In the factory configuration, the Pro Micro has a bootloader that occupies several K of flash memory, and the remaining memory is used for user a user program (a sketch). The bootloader makes it convenient to load a new program, because you don't need to use a separate programmer to upload a program. He decided he did not want that convenience but would rather use all of the available flash space just for a program. So, he told the Arduino IDE (by making a custom boards.txt entry) that the full flash space is available instead of just 28K, and that allowed compilation and upload of a bigger sketch. But he had to use ISP to load the program, instead of using the bootloader. And he changed the fuse value that determines at what memory location the MCU begins running the program.

The Arduino Micro, Sparkfun Pro Micro, Arduino Leonardo, Adafruit ItsyBitsy, DF Robot Beetle, and other Arduino-compatible boards that use the ATmega32u4 MCU usually use the caterina bootloader. The bootloader was compiled with slightly different code for each board. The most noticeable difference is what LEDs on the board are used to let the user know activity of RX and TX, and to let the user know the bootloader as started by pulsing the ping 13 or other LED, and the USB VID/PID is different on different boards.

but can i use a pro mini's bootloader on a pro micro? if i can i just have to go to tools>boards>pro mini and follow all the steps then burn the bootloader right?

The Pro Micro normally comes with the ATmegaBOOT bootloader, which would have to be recompiled for Pro Micro, and as far as I know, nobody has done that and there probably would not be a reason to do that.

The Optiboot bootloader that is used on the Uno is generally considered superior and it can be used on the Pro Mini just by bootloading it as an Uno. Some people do that, just upgrade all their ATmega328-based Arduinos to essentially be Unos by putting the Optiboot bootloader on them.

If you wanted to use Optiboot on a Pro Micro, you would have to compile the bootloader for the ATmega32u4 and install it. If you did that, you would no longer use the Pro Micro's USB connector to upload sketches to the Pro Micro, but instead you would use a serial adapter or bluetooth module connected to the RX and TX pins. That is also an advanced topic. https://www.instructables.com/id/How-to-upload-sketches-to-Pro-MicroLeonardo-via-se/

Using the Optiboot bootloader on a Pro Micro would allow you to use less flash for the bootloader, and more flash space for the user program. I believe you would gain 3584 bytes.