cancel
Showing results for 
Search instead for 
Did you mean: 

ELF file and converted BIN far too large

SSmit.13
Senior

Hi

  I have an STM32L433CBT processor and created a project using STM32 IDE version 1.14. I created the project on STM32 MX version 6.9.1 .  The project works in debug and I created a release version , but the elf file is far too large. I have the following running in the post build steps:

arm-none-eabi-objcopy -S -O binary "Project.elf" "Project.bin" 

then use the bin file to program the chip out in the field. For some reason the elf file generated in release is 232KB, and the converted bin is 131,073KB.   Compared to previous larger projects where the elf is size 176KB and converted bin is 68KB. 

When I build the application I get the following in the console:

arm-none-eabi-gcc -o "Project.elf" @"objects.list" -mcpu=cortex-m4 -T"D:\Work\air\STM32\Project\STM32L433CBTX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Project.map" -Wl,--gc-sections -static -u _printf_float --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -Wl,--start-group -lc -lm -Wl,--end-group

Finished building target: Project.elf

 

arm-none-eabi-size Project.elf

arm-none-eabi-objdump -h -S Project.elf > "Project.list"

text data bss dec hex filename

57196 1190 14392 72778 11c4a Project.elf

Finished building: default.size.stdout

 

Finished building: Project.list

 

arm-none-eabi-objcopy -S -O binary "Project.elf" "Project.bin"

 

 

A previous project that works as expected, I get :

arm-none-eabi-gcc -o "Project2.elf" @"objects.list" -mcpu=cortex-m4 -T"../STM32L433VC_BM.ld" --specs=nosys.specs -Wl,-Map="Project2.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -Wl,--start-group -lc -lm -Wl,--end-group

Finished building target: Project2.elf

 

arm-none-eabi-size Project2.elf

text data bss dec hex filename

68060 872 14104 83036 1445c Project2.elf

Finished building: default.size.stdout

 

arm-none-eabi-objdump -h -S Project2.elf > "Project2.list"

Finished building: Project2.list

 

arm-none-eabi-objcopy -S -O binary "Project2.elf" "Project2.bin"

 

Both projects have the same setup as below:

SSmit13_0-1712322217944.png

 

 

Preprocessor:

SSmit13_1-1712322284193.png

 

Link setup:

SSmit13_2-1712322477259.png

 

If someone can help, this would be great as I am stuck till I fix this issue.

Best Regards

Scott

 

 

 

12 REPLIES 12

Hi

  I see the issue , but dont know the way to sort it.  This project is using STANDBY mode, and also accessing the RAM2 so I can preserve some memory when it wakes up. If I remove this, then it looks good , to 57K.

 

I have the following in my code to use this memory:

 

 

#define PERM_RAM2 __attribute__((section(".Permanent_buffer")))

char RTCValid PERM_RAM2;

char NodeStatus PERM_RAM2;

 

 

The linker file has:

/* Highest address of the user mode stack */

_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */

 

_Min_Heap_Size = 0x200; /* required amount of heap */

_Min_Stack_Size = 0x400; /* required amount of stack */

 

/* Memories definition */

MEMORY

{

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K

RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 16K

FLASH (rx) : ORIGIN = 0x08003000, LENGTH = (256K-12K)

}

.Permanent_buffer :

{

KEEP(*(.Permanent_buffer))

} >RAM2

 

Is this the wrong way of doing this? In debug mode it works, as when wakeup , the memory still holds the original values.

 

Best Regards

Scott

 

 

You self reply, wrong way. Try use NOLOAD or other method.

memory - Understanding linker script NOLOAD sections in embedded software - Stack Overflow

Hi

  Many thanks, that worked, I simply added the NOLOAD as you suggested.

 

.Permanent_buffer (NOLOAD):

{

KEEP(*(.Permanent_buffer))

} >RAM2

 

Many thanks, this has made my weekend :grinning_face:

 

Scott