Building with BOARD=GPY has max firmware image size ~2MB
techykermit last edited by
We are trying to compile down our code and flash it on our devices, eventually with SecureBoot. I have encountered an interesting thing in this process though. Running the following commands:
#In pycom-micropython-sigfox cd esp32 #Download our firmware echo "Downloading Firmware..." cd frozen/Base git clone -b "production" https://github.com/XXXX/XXXX.git mv firmware/* . #Move the downloaded firmware into the Base directory echo "Firmware downloaded and unpacked." cd .. cd .. #Move back to base dir make BOARD=GPY clean make V=1 BOARD=GPY TARGET=boot #Add V=1 for extra debugging make BOARD=GPY TARGET=app make BOARD=GPY flash
gives an error on the last one, when trying to flash the image:
2031856 bytes => Firmware size exceeds available space 2027520 on board
This sounds strange in my ears, since the GPy is supposed to have 8MB of external flash according to the specsheet? The code can be flashed onto the device using Visual Studio Code (non-frozen using PyCom's plugin) without getting any size-related errors.
Is the approach to extracting frozen code wrong, or is there something that is done wrong here, hence the size-related errors?
robert-hh last edited by
@techykermit You have to increase the partition sizes. There are two places which you have to change in the tools directory.:
a) tools/size_chk.sh: line 14 has the limit for the image size.
b) tools/script_8MB: That is the template for the partition table. Each entry contains the start and the size. Note that otadata sits between the factory and ota_0 partitions.
If you change the partitions, the file system will have to be rebuilt.
I do not know whether the encryption keys are affected. But there is a good chance that changing the partitions does not affect the encryption keys.
techykermit last edited by
Bumping this since we've kind of hit a point where the raw Python code on the device is bigger than the ~2MB limit, making further development troublesome unless the issue is solved. @jcaron, I first want to apologize that I didn't thank you last year for replying and giving some pointers:)) I looked into the source and there are multiple files there: https://github.com/pycom/pycom-micropython-sigfox/tree/Dev/esp32/boards/GPY. Which one would be the one to edit? The structure doesn't seem very clear to me. You gave an example of that it's possible to reduce the file system - is it possible to grow it? And I assume after changing where the partitions end, I can just build it normally? Would changing the sizes alter previously generated encryption keys for the device, or can I use the same keys for signing the firmware? And with "fully erasing the whole flash", I assume you mean using something like PyCom's firmware update tool CLI with this option:
$ pycom-fwtool-cli -h [...] erase_all Erase entire flash! [...]
@techykermit the flash partition layout splits the total available flash between the boot loader, 2 copies of the firmware (for secure OTA), the “NVRAM” data and the file system.
Can’t find the current layout right away, but I wouldn’t be surprised if there were about 2 MB for each of the firmware partitions and 4 for the file system or something similar.
It’s possible to adjust the partition layout (to reduce the file system for instance), but that requires you to fully erase the whole flash. I believe that should be somewhere in the files in esp32/boards/GPY.