JAndrassy / ArduinoOTA

Arduino library to upload sketch over network to Arduino board with WiFi or Ethernet libraries
GNU Lesser General Public License v2.1
435 stars 89 forks source link

STM32F407 - Flash Size issue #223

Closed gcharles81 closed 9 months ago

gcharles81 commented 10 months ago

Hello I have been using this great library for OTA over Wifi of my project using STM32F407VE mcu with 512kb of flash.

Everything was working fine for months but now as my code evolves the .bin file is getting large and 155kb in size and with this size the update will be halted with serial message "There is not enough space to store the update. Can't continue with update."

After that I have updated the MCU from STM32F407VE 512KB to STM32F407VG 1Mb but the issue still happen , can it be the Internalstorage class is calculating the available space wrong for the STM32F407VG ?

STM32F407VE compilation details - firmware uses of Flash: [=== ] 30.2% (used 158208 bytes from 524288 bytes) image

STM32F407VG compilation details - firmware uses of Flash: [== ] 15.1% (used 158208 bytes from 1048576 bytes) image

JAndrassy commented 10 months ago

The F4 flash is split into sectors. 0 to 3 are 16 kB, 4 is 64 kB and the rest are 128 kB. ArduinoOTA is set to store the update starting from sector 5. (half of a 512kB flash).

You can change the sector to use with define OTA_STORAGE_STM32_SECTOR in boards.local.txt

Create a file boards.local.txt next to boards.txt file in hardware package. There you can set build.extra_flags for individual boards, like this:

GenF4.menu.pnum.DIYMORE_F407VGT.build.extra_flags=-DOTA_STORAGE_STM32_SECTOR=8 
gcharles81 commented 10 months ago

file in hardware package. There you can set build.extra_flags for individual boards, like this:

Thank you for the answer and the hint but its too complex to do that I do not know the exact locations where the board.txt files are very difficult to find out what exactly I have to do

I tried to change the sector from 5 to 8 in InternalStorageSTM32.cpp as per below image but I got the same error as not enough space Thanks for the help so far , any other possible causes ? image

Also If I leave the sector set to 5 as original and I include the below serial print statement for InternalStorage.maxSize I get the Flash size of 131 kb so it seems that the bootloader is 381 kb is that possible ?

uint32_t test = InternalStorage.maxSize();

Serial.print("FLASH Size kb= "); Serial.println(test);

"Serial print from terminal " - FLASH Size kb= 131072

JAndrassy commented 10 months ago

C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.9.0

maxsize is the space for the sketch. sector 5 starts at 128 kB so it is 131072 bytes in sector 0 to 4

(128 kB is 131072 bytes)

gcharles81 commented 10 months ago

Hello I created the board.local.txt file but I still have the same issue that not enough space is available

image

image

JAndrassy commented 9 months ago

did you restart the IDE?

gcharles81 commented 9 months ago

Yes have restarted platformio multiple times ,

JAndrassy commented 9 months ago

PlatformIO? maybe it has the boards package somewhere else or it doesn't process local.txt files

gcharles81 commented 9 months ago

Thanks for all your help I managed to get it working by adding -DOTA_STORAGE_STM32_SECTOR=9 as a build flag in platformio.ini i attached below for anyone as a reference in future image

JAndrassy commented 9 months ago

so yes, Arduino doesn't have a project configuration file. that is better in plaformio