Generated Software size - .elf file size - MBD toolbox 3.0.0 - Devkit MPC5744P

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generated Software size - .elf file size - MBD toolbox 3.0.0 - Devkit MPC5744P

Jump to solution
2,110 Views
rafael_barbosa
Contributor IV

Hello,

Can you help me on how to reduce the generated .elf file size without changing the model?

What is the content of the .elf file?

Also I am curious why the project built in S32 Design studio presents the software size metrics different from the generated .elf file as shown below:

BaseMotorControl_DEV:

pastedImage_15.png

_____________________________________________________________________________________

Copy_of_BaseMotorControl_DEV:

pastedImage_16.png

________________________________________________________________________________________

Copy_2_of_BaseMotorControl_DEV:

pastedImage_17.png

Finally, which size shall be considered as the limitation when flashing the file into the microcontroller flash memory?

pastedImage_1.png

Kind Regards, Rafael

1 Solution
1,981 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Rafael, 

Can you help me on how to reduce the generated .elf file size without changing the model?

You can reduce the elf size in 2 different modes:

  1. remove the debug information from the elf. 
  2. enable optimizations related with code size (if the .text is larger) or data size (if .data is larger). This can be done from 2 stages:
    • Stage Code-Generation in MATLAB settings to control how the generated code will look like.pastedImage_3.png
    • Stage Cross Compiler arguments that controls how the compiler generates the final application code. Here you can change the optimization level or add the -Os. More on the compile optimizations here: Using the GNU Compiler Collection (GCC): Optimize Options pastedImage_4.png

What is the content of the .elf file?

ELF is just a container. The Bootloader do not use all the information from this file. For the application to work on the MCU all you need are specific sections of .text, .data, .bss

A very good explanation of the elf file can be found here: Executable and Linkable Format - Wikipedia 

NXP is offering elf dump tools that allows you to parse the elf and see exactly what is inside. You can find this tools inside the ..\\tools\S32DS\build_tools\powerpc-eabivle-4_9\bin\ of your MBDT installation.

pastedImage_14.png

As you can see, almost half of the sections are related with debug information. These sections are NOT flashed into the MCU memory. They exist only in the elf and ONLY an IDE/Debugger running on the host PC can access such information.

Look for A flag. Only the sections that have A-allocation flag will be written to the target.

Also I am curious why the project built in S32 Design studio presents the software size metrics different from the generated .elf file as shown below:

The number reported by the ELF powerpc-eabivle-size resports only for .text, .data and .bss sections. The number returned is expressed in number of bytes/octets.

The number reported by the S32DS is for the entire file (will all the sections)

In Windows OS, the size = size on disk which is different than the file actual size.

pastedImage_5.png

Finally, which size shall be considered as the limitation when flashing the file into the microcontroller flash memory?

Assuming you want to flash the application permanently into the MCU, then you need to consider the .text and .data size.

BUT, it also depends on other key sections that might be added in the linker by the user. Anyone can define an allocate sections in the ELF. Hence is hard to pinpoint which section is limiting factor. I would say: compute the size of all sections that have the A flag and make sure the total size is smaller than the flash memory.

Hope this helps!

Daniel

View solution in original post

2 Replies
1,982 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Rafael, 

Can you help me on how to reduce the generated .elf file size without changing the model?

You can reduce the elf size in 2 different modes:

  1. remove the debug information from the elf. 
  2. enable optimizations related with code size (if the .text is larger) or data size (if .data is larger). This can be done from 2 stages:
    • Stage Code-Generation in MATLAB settings to control how the generated code will look like.pastedImage_3.png
    • Stage Cross Compiler arguments that controls how the compiler generates the final application code. Here you can change the optimization level or add the -Os. More on the compile optimizations here: Using the GNU Compiler Collection (GCC): Optimize Options pastedImage_4.png

What is the content of the .elf file?

ELF is just a container. The Bootloader do not use all the information from this file. For the application to work on the MCU all you need are specific sections of .text, .data, .bss

A very good explanation of the elf file can be found here: Executable and Linkable Format - Wikipedia 

NXP is offering elf dump tools that allows you to parse the elf and see exactly what is inside. You can find this tools inside the ..\\tools\S32DS\build_tools\powerpc-eabivle-4_9\bin\ of your MBDT installation.

pastedImage_14.png

As you can see, almost half of the sections are related with debug information. These sections are NOT flashed into the MCU memory. They exist only in the elf and ONLY an IDE/Debugger running on the host PC can access such information.

Look for A flag. Only the sections that have A-allocation flag will be written to the target.

Also I am curious why the project built in S32 Design studio presents the software size metrics different from the generated .elf file as shown below:

The number reported by the ELF powerpc-eabivle-size resports only for .text, .data and .bss sections. The number returned is expressed in number of bytes/octets.

The number reported by the S32DS is for the entire file (will all the sections)

In Windows OS, the size = size on disk which is different than the file actual size.

pastedImage_5.png

Finally, which size shall be considered as the limitation when flashing the file into the microcontroller flash memory?

Assuming you want to flash the application permanently into the MCU, then you need to consider the .text and .data size.

BUT, it also depends on other key sections that might be added in the linker by the user. Anyone can define an allocate sections in the ELF. Hence is hard to pinpoint which section is limiting factor. I would say: compute the size of all sections that have the A flag and make sure the total size is smaller than the flash memory.

Hope this helps!

Daniel

1,981 Views
rafael_barbosa
Contributor IV

Hello dumitru-daniel.popa‌,

Thank you very much for the complete response.

Kind Regards, Rafael

0 Kudos