cancel
Showing results for 
Search instead for 
Did you mean: 

SBSFU and userApp bigelf size

sute
Associate III

Hello,

I am trying to generate the combined elf file with SBSFU and user app. The provided postbuild scripts use the following code to create the file:

command=$programmertool" -ms "$elf" "$headerbin" "$sbsfuelf

There is a problem that the combined elf file is huge. For my own application it is 147M and for the example userApp 59M. Why is the file so big? How do I get a normal combination elf file? The combination bin-file is normal and works.

5 REPLIES 5
Jocelyn RICARD
ST Employee

Hello @MS.12utela​ 

I checked on simple STM32L476 example on last SBSFU 2.5.0 and I get 23M elf file.

Looking inside, it is full of zeros. I don't know why.

STM32CubeIDE provides elf tools in (for CubeIDE 1.8.0)

plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\bin\

arm-none-eabi-readelf.exe UserApp.elf  shows a very big section .shstrtab

Then, I tried using command

arm-none-eabi-objcopy.exe --strip-unneeded UserApp.elf

elf size is now 78 KB

Now, I'm not sure this combined elf feature is well tested in SBSFU.

What are you trying to do with it ?

Best regards

Jocelyn

sute
Associate III

Hi thanks for help!

I am trying to get an elf file that I can debug on the MCU.

Indeed, running arm-none-eabi-objcopy on my own application I am able to decrease the elf size, however I get two warnings:

st4M9tlx: section .isr_vector lma 0x8010034 adjusted to 0x8018400

st4M9tlx: warning: allocated section `Header' not in segment

The first one seems OK, but not the second one. I am also unable to run the elf file on target.

Jocelyn RICARD
ST Employee

Hello @MS.12utela​ 

OK so in order to debug I would suggest doing the following:

1) Flash the big binary generated

2) setup your debugger to only load symbols: You can load symbols of SBSFU, SE and application with associated elf files (deactivate generation with programmer)

3) Attach to target and debug

Best regards

Jocelyn

sute
Associate III

Thanks. I have been debugging and it seems to me that STM32_Programmer_CLI places the Header section to wrong place. Here are the section headers using arm-none-eabi-readelf from combined bootloader and userApp elf file from the SBSFU examples:

Section Headers:                                                                                                                                                                                                                              [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al                                                                                                                                                              [ 0]                   NULL            00000000 000000 000000 00      0   0  0                                                                                                                                                              [ 1] .isr_vector       PROGBITS        08018400 0001b4 000400 00   A  0   0  1                                                                                                                                                              [ 2] .text             PROGBITS        08018800 00f47c 0052d8 00  AX  0   0 16                                                                                                                                                              [ 3] .rodata           PROGBITS        0801dad8 014754 000f40 00   A  0   0  4                                                                                                                                                              [ 4] .ARM.extab        PROGBITS        0801ea18 015b3c 000000 00   W  0   0  1                                                                                                                                                              [ 5] .ARM              ARM_EXIDX       0801ea18 015694 000008 00  AL  2   0  4                                                                                                                                                              [ 6] .preinit_array    PREINIT_ARRAY   0801ea20 01569c 000000 04  WA  0   0  1                                                                                                                                                              [ 7] .init_array       INIT_ARRAY      0801ea20 01569c 000008 04  WA  0   0  4                                                                                                                                                              [ 8] .fini_array       FINI_ARRAY      0801ea28 0156a4 000008 04  WA  0   0  4                                                                                                                                                              [ 9] .data             PROGBITS        20001000 0156ac 000078 00  WA  0   0  4                                                                                                                                                              [10] .align32          PROGBITS        0801eaa8 015724 000018 00  WA  0   0  1                                                                                                                                                              [11] .bss              NOBITS          20001078 015b3c 0005ac 00  WA  0   0  4                                                                                                                                                              [12] ._user_heap_stack NOBITS          20001624 015b3c 000a04 00  WA  0   0  1                                                                                                                                                              [13] .ARM.attributes   ARM_ATTRIBUTES  00000000 015b3c 00002e 00      0   0  1                                                                                                                                                              [14] .comment          PROGBITS        00000000 015b6a 000053 01  MS  0   0  1                                                                                                                                                              [15] SBSFU0            PROGBITS        08000000 0005b4 0002b0 00  WA  0   0  4                                                                                                                                                              [16] SBSFU1            PROGBITS        08000404 000864 005154 00  WA  0   0  4                                                                                                                                                              [17] SBSFU2            PROGBITS        08006000 0059b8 0007cc 00  WA  0   0  4                                                                                                                                                              [18] SBSFU3            PROGBITS        08006900 006184 000088 00  WA  0   0  4                                                                                                                                                              [19] SBSFU4            PROGBITS        08006a00 00620c 009270 00  WA  0   0  4                                                                                                                                                              [20] Header            PROGBITS        20000c78 01573c 000400 00  WA  0   0  4                                                                                                                                                              [21] .shstrtab         STRTAB          00000000 015bbd 0000c5 00      0   0  1

Note that the address for Header is 0x20000c78 while it should be 0x0801800 according to mapping_fwimg.ld. Is this a bug or am I doing something wrong?

Is there a simple way to fix this?

Jocelyn RICARD
ST Employee

Hello @MS.12utela​ 

As I said, I'm not sure this feature is working well.

So, to debug please use original elf files generated by the compiler.

Best regards

Jocelyn