2025-09-12 8:23 PM - last edited on 2025-09-15 2:14 AM by Andrew Neil
I am working on an STM32H7S3L8 Nucleo board and building a bare-metal project with the Mongoose networking library (no RTOS, no LwIP).
The project compiles successfully after adjusting flash size in the linker script, but fails to load into the MCU via STM32CubeIDE or STM32CubeProgrammer.
I consistently see this error:
Error in final launch sequence:
Failed to execute MI command:
load ".../Mongoose_Webserver_Boot.elf"
Error message from debugger back end:
Load failed
And from CubeProgrammer logs:
Memory Programming ...
File : Mongoose_Webserver_Boot.elf
Size : 68.86 KB
Address : 0x08000000
Download in Progress:
Error: file size is bigger than the flash memory size.
Error: failed to download Segment[0]
Even though the ELF file size is only ~69 KB, CubeProgrammer reports it does not fit in flash.
Board: NUCLEO-H7S3L8 (STM32H7S3L8Hx)
IDE: STM32CubeIDE 1.17.0
Toolchain: GNU Tools for STM32 12.3.rel1
Debugger: ST-LINK V3
External libs: Mongoose (baremetal, no RTOS, no LwIP
Adjusted flash and RAM sizes in linker script (STM32H7S3L8HX_FLASH.ld)
Confirmed MCU datasheet: 2 MB Flash, 560 KB RAM
Verified MEMORY map in linker file matches device reference manual
Cleaned project and rebuilt
Enabled .bin output from CubeIDE and attempted programming that
Tried both CubeIDE Debug and STM32CubeProgrammer direct load
__FLASH_BEGIN = 0x08000000;
__FLASH_SIZE = 0x00200000; /* 2 MB flash */
__RAM_BEGIN = 0x24000000;
__RAM_SIZE = 0x0008C000; /* 560 KB RAM */
__RAM_NONCACHEABLEBUFFER_SIZE = 0x400;
MEMORY
{
RAM (xrw) : ORIGIN = __RAM_BEGIN, LENGTH = __RAM_SIZE - __RAM_NONCACHEABLEBUFFER_SIZE
RAM_NONCACHEABLEBUFFER (xrw) : ORIGIN = __RAM_BEGIN + __RAM_SIZE - __RAM_NONCACHEABLEBUFFER_SIZE, LENGTH = __RAM_NONCACHEABLEBUFFER_SIZE
ITCM (xrw) : ORIGIN = 0x00000000, LENGTH = 0x00010000
DTCM (rw) : ORIGIN = 0x20000000, LENGTH = 0x00010000
SRAMAHB (rw) : ORIGIN = 0x30000000, LENGTH = 0x00008000
BKPSRAM (rw) : ORIGIN = 0x38800000, LENGTH = 0x00001000
FLASH (rx) : ORIGIN = __FLASH_BEGIN, LENGTH = __FLASH_SIZE
}
The generated ELF file is ~68 KB, so it should easily fit in 2 MB flash.
Binary output (.bin) is around 40 KB.
Still, CubeProgrammer rejects the ELF.
I suspect there might be:
A toolchain section misalignment issue (sections mapped beyond 0x0820_0000)
A possible bug in STM32CubeIDE → STM32CubeProgrammer integration
Some hidden MCU configuration in project properties that overrides the linker script
Why does CubeProgrammer report “file size is bigger than flash” when my ELF is only ~69 KB?
Is there a known issue with STM32CubeIDE 1.17.0 + GNU Tools 12.3.rel1 where the ELF mapping is misinterpreted?
For STM32H7S3L8 (2 MB flash, 560 KB RAM), is my linker script correct?
CubeIDE Load Error when Flash is set 2MB
STM32H7S3L8HX_FLASH.ld file
Build fail while Flash memory set 64KB
CubeProgrammer Load Error - elf file
CubeProgrammer Load Error - bin file
2025-09-13 6:44 PM - edited 2025-09-13 6:47 PM
As you probably know, STM32H7S has a very small internal flash at 0x08000000. The 2MB flash should be external, located at other address. Your link script does not specify the external flash but specifies 2MB size for the internal flash. Where have you found this file?
2025-09-14 12:29 AM
Thanks for clarifying. I now understand that the STM32H7S3L8 internal flash is only 64 KB.
I mistakenly assumed it had 2 MB of internal flash. My project currently links all code at 0x08000000, assuming 2 MB, which is incorrect.
I would like guidance on the best way to proceed with internal flash programming. How can I reduce my Mongoose bootloader + webserver to fit within 64 KB of internal flash?
2025-09-14 7:23 AM
You actually dont. The Nucleo H7S3L8 is designed to work with a bootloader and application, and even though you coul split up the flash into 32KB of flash in context boot and 32KB in context appli, it isnt best practice. What you would want to do is work with the onboard external flash, which has 256MB, each on XSPI1 and XSPI2.
I prefer using XSPI2 for external flash, but you can also use XSPI1.
You will then make a minimalized bootloader( DMA, MPU, CLK, XSPI, GPIO, EXTMEMMANAGER, Cache) and application, which will sit in 0x7000_0000.
You would want something like this:
Depending on your operating voltage, set the HSLV bit in CubeProgrammar, and load the appli.elf into the XSPI via the external_memory_manager. Be aware that you need all subprojects in advanced mode before generating the code.
If you need more help, dont hesitate to ask!
Best regards//
Htxy