Compiling and uploading with Arduino framework but not using bootloader


Using arduino framework I am running out of memory with my atmega32 project on custom board.

I require to program using the usbasp ICSP board and to not use bootloader. At the moment the AVR is fresh from the fab house and untouched by any programmer.

I have in platformio.ini (excluding all the lib_deps)

platform = atmelavr
board = ATmega32
framework = arduino
upload_protocol = custom
upload_port = usb
upload_flags =
    ; use "tool-avrdude-megaavr" for the atmelmegaavr platform

upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

I have spent some hours searching for how to build and upload this project to my newly recevied atmega32 boards without the bootloader being present. To my simple mind there are a mish-mash of concepts and instructions around bootloaders, fuses and avrdude and platformio, the atmel framework and the arduino framework. It seems straightofrward in the arduino IDE but I never want to go back to that !

Would some knowledgeable person be able to just tell me what I do to my project so that run pio --target upload will actually compile and upload my file and not use a bootloader. Is it just a few lines in the platformio.ini ? Is it a few terminal commands ? A combination ?

Help !



It already is. Unless you do a pio run -t bootloader, the uploaded binary does not include a bootloader (Optiboot).

Thank you very much. That makes sense and is what I originally thought.

I am distracted by the fact that whether I select a USBasp programmer, or use a bootloader option the generated hexfile is identical. To reiterate:

Start a new project with a board, ATmega32 in my case. Build and get a hexfile.
Now intorduce the previously mentioned directives in platformio.ini to identify that we are using a programmer.
Clean (tried cleanall too) and repeat build to obtain new hexfile.

Both hexfiles are identical.

I must be misunderstanding something, but I was expecting the second hexfile to be different, and smaller.

Using avr-objectdump to dissassemble the hex files I can see they are identical.

If they are identical how does that fit with the idea that there is no bootloader added to the code ?

Thanks again for taking the time and trouble to deal with this.



Cancel the last post. I have double checked everything and platformio is indeed reporting 32768 available for flash when using the programmer and 32256 when not using the programmer.

Apologies for the distraction!