Skip to main content
SSmit.13
Senior
April 5, 2024
Solved

ELF file and converted BIN far too large

  • April 5, 2024
  • 3 replies
  • 8667 views

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

 

 

 

This topic has been closed for replies.
Best answer by MM..1

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

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

3 replies

Andrew Neil
Super User
April 5, 2024

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.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
SSmit.13
SSmit.13Author
Senior
April 5, 2024

Hi

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

 

Many thanks

Scott

 

Pavel A.
Super User
April 5, 2024

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.

SSmit.13
SSmit.13Author
Senior
April 5, 2024

Hi

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

 

Many thanks

Scott

Tesla DeLorean
Guru
April 5, 2024

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 VenmoUp vote any posts that you find helpful, it shows what's working..
SSmit.13
SSmit.13Author
Senior
April 5, 2024

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

Andrew Neil
Super User
April 5, 2024

@SSmit.13 wrote:

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


Really - 128 M bytes ?

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.