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

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
12 REPLIES 12
Andrew Neil
Evangelist III

Do the files work?

Have you removed the Debug info, etc, from the ELF ?

Remember that an ELF can be "sparse", whereas a BIN must contain a value for every single byte within the range of the image.

Pavel A.
Evangelist III

Try to compare .map files & get an idea whether all text sections grew bigger or the new toolchain added some new sections.

Or even better, just install the older toolchain into your new CubeIDE and call it done.

Hi

  Thanks for the reply. What files are required to copy the older toolchain?

 

Many thanks

Scott

Hi

  Thanks for your reply. Apart from the "DEBUG" in the PreProcessor tab within the compiler, how is this done?

 

Many thanks

Scott

 

Ok, but what's the actual issue?

That you don't know what's in the file, or what causes it to get bigger?

The .MAP file should let you know what's going into the file.

Object files contain a lot of information that doesn't go onto the chip itself. Perhaps review with objdump ?

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

Hi

  Thanks for your reply.  In previous projects I use the the command:

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

to create the binary to go into the chip , but this time the bin file size is converted bin is 131,073KB , too big for the chip.

Regards

Scott


@SSmit.13 wrote:

the bin file size is converted bin is 131,073KB


Really - 128 M bytes ?

 

Hi Andrew

 Yes, older projects have been around 68K, see below directory.

SSmit13_0-1712327962931.png

 

Ok, so if it is 131MB, it suggests you've got it initializing very distant memory areas, not just 0x08000000 + 128KB to 256KB

Is it describing 0x20000000 or 0x90000000 ? These would tend to approach GB binaries, and the sections would need to be extracted individually, not as a single monolithic image.

DUMP the SECTIONS in the object file.

REVIEW the LINKER SCRIPT, where's it putting things?

UNDERSTAND what getting into the file

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