I need to:
- specify a custom bootloader.bin to write to 0x1000
- specify a custom_firmware.bin to write to the factory partition (dont know the address by heart)
- specify a spiffs.bin to write to the adress where spiffs storage starts (the spiffs.bin is generated from the actual projects firmware.bin file)
What is the best way to do this so that all this happens when i click upload in platformio?
You didn’t even post what microcontroller or platform you’re working on, but I’ll assume ESP32 and Arduino as the framework.
The upload logic and sources for that are mainly in
You can specify a custom bootloader by overriding the build.arduino.custom_bootloader
attribute which is respected here by either a custom board JSON file or the platformio.ini
:
board_build.arduino.custom_bootloader = ...
So this is not the output of the PlatformIO build (.pio/build/<env>/firmware.bin
)?
The “Upload Filesystem Image” task already does that. The SPIFFS start address is read from the active partition table.
Overall, it may seem like a better solution to instead hack the “Upload” task and also include the SPIFFS and a custom firmware.bin in that, to just add a new task button via scripting that executes one esptool.py
command that flashes all files (and generates them as needed beforehand).
Oops yeah, its ESP32 with Arduino framework.
Thank you for the upload logic and sources (not sure if I have to modify these scripts to get my desired result?)
No, the custom_firmware.bin is not the output of the PlatformIO build .pio/build//firmware.bin. Do you also know how to flash the custom_firmware.bin to the factory partition?
The problem with the upload filesystem task is that I need to manually copy the .pio/build//firmware.bin into the data folder each time and then use a button other than upload. I would prefer if this all happened when I use the upload button.
But if I understood correctly, making a new button would be a better solution?
I managed to modify the upload process by using a python script in extra_scripts (like you said) that modifies the uploadcmd command before the flash process
env[‘UPLOADCMD’] = ""$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS 0x10000 " + firmware_path