Showing results for 
Search instead for 
Did you mean: 

STM32WLEx: Generated Binary file size is too large

Associate II

Before release of package v1.3.0 binary size were <90kb and .ld has 3 partition in memory as below,

/* Memories definition */



 ROM  (rx)  : ORIGIN = 0x08000000, LENGTH = 256K

 RAM1  (xrw)  : ORIGIN = 0x20000000, LENGTH = 32K  /* Non-backup SRAM1 */

 RAM2  (xrw)  : ORIGIN = 0x20008000, LENGTH = 32K  /* Backup SRAM2 */


But release package v1.3.0 has generated large binary size 250KB for Release and Debug build of LoRaWAN example. In this release ST has introduced the changes in .ld file as below,

/* Memories definition */



 RAM1  (xrw)  : ORIGIN = 0x20000000, LENGTH = 32K

 NVM_RAM (rw)  : ORIGIN = 0x20008000, LENGTH = 4K

 RAM2  (xrw)  : ORIGIN = 0x20009000, LENGTH = 28K

 FLASH  (rx)  : ORIGIN = 0x08000000, LENGTH = 248K

 USER_Key_region_ROM (rx)  : ORIGIN = 0x0803E500, LENGTH = 768


Here, USER_Key_region_ROM (rx) partition is newly introduced and due to this change binary size is become way to large. 

 Link for v1.3.0

Can you please suggest me how can i reduce the binary file size in the release v1.3.0?

Attaching .ld file of release v1.3.0 for more details

Associate II

Made changes in .ld file to reduce the size of the binary. Created USER_FLASH partition with szie of 1kb between FLASH and USER_Key_region_ROM and used fill() command to initialize memory of USER_FLASH partition.

In this case binary size is fixed to the length(around 118K) of FLASH partition but it is working. Not sure this is an appropriate solution or not. also with this solution binary size will always fixed to the LENGTH of FLASH

Attaching modified .ld file

The problem with a binary image is that it must be a singular contiguous blob.

If you've created holes / voids you should perhaps be using a .HEX or object file format.

Some tools can decompose a multi-section object into multiple .BIN files.

At the moment you have one .BIN describing memory from 0x08000000 thru at least 0x0803E500, so 249KB+

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Associate II

I do not undestand the new memory definition...

What is  NVM_RAM (rw)??

From my point of view, i undestand that this  FLASH  (rx)  : ORIGIN = 0x08000000, LENGTH = 248K means that you have 248K for your binary  from 0x08000000 thru at least 0x0803E500 (0x08000000- 0x0803E500= 0x3E500 in decimal 248K).

Then, you have from  0x0803E500 to  0x0803E800 USER_Key_region_ROM (rx). 768 bytes.

But you have 248KB + 768 Bytes assignned, and FLASH memory have 256KB of capacity. You have more than 7KB unsigned...

In the code in Lorawan_end_node i can see that use the last two pages of FLASH to store Lorawan context info( in LORAWAN_NVM_BASE_ADDRESS          ((void *)0x0803F000UL). Save data structure 1484 bytes in pre-allocated ROM page of 2 Kbytes.

Why FLASH only have 248KB? Would be needed to add another section called FLASH_USER or similar with the rest 7KB of FLASH unassigned?