cancel
Showing results for 
Search instead for 
Did you mean: 

How can I allocate .text section to FLASH and FLASH2 at STM32CUBEIDE (STM32H743VGT6)

SDFSDFDSF
Associate II

STM32H743VGT6 has 1M FLASH, but the flash memory is divided into two independent banks.

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K

FLASH2 (rx) : ORIGIN = 0x08100000, LENGTH = 512K

 

Now my code size is bigger.

The section .text is over 512K.

So,How can I allocate .text to FLASH and FLASH2???

1 ACCEPTED SOLUTION

Accepted Solutions

The OP has STM32H743VGT6 with 2*512K flash and a hole between the banks - see reply of TDK.

AFAIK the standard GNU linker cannot automatically manage this, so tuning of .ld is needed.

More advanced linkers (IAR, Keil...) can do this automatically. That's a selling point.

The OP can perform link with continuous 1M memory (as if they had a normal, 2MB STM32H743) which must succeed. Then analyze the .map file and manually distribute object modules to two banks (or write a script).  For example, part of object modules goes to FLASH2, the rest and any libraries go to FLASH1.

Then re-link with the customized .ld file.

 

View solution in original post

9 REPLIES 9
BarryWhit
Senior III

Why do you think the independent banks are a problem? if you're trying to link a large program and getting an error or warning, you should shows us what it is. If you're not getting an error, what's the problem?

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.
Rim LANDOLSI
ST Employee

Hello @SDFSDFDSF ,

 

Please let us know if you have any build errors.
Otherwise, allocating the .text section to both FLASH and FLASH2 requires modifying the linker script to specify the memory regions and how the .text section should be allocated.
You can add .text sections for FLASH2 as follows:

.text2 :
  {
    . = ALIGN(4);
    *(.text2*)
    . = ALIGN(4);
  } > FLASH2

 

Hope this helps!

Thanks,

Rim.

@Rim LANDOLSI , are there circumstances under which the compiler automatically places "extra" code under .text2 instead of  the .text section of the object file? Because I've never seen this before, and without it I'm not sure the linker script fragment (by itself) makes sense.

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.
TDK
Guru

Duplicate/continuation of:

Download elf to STM32H743 failed when code over 51... - STMicroelectronics Community

 

The linker for GCC cannot do this seamlessly. You will need to create two sections and explicitly assign some amount of code/data to the second flash section.

If you feel a post has answered your question, please click "Accept as Solution".
BarryWhit
Senior III

That makes more sense.

 

See AN4296 for an (different but related) example of how to modify linker script appropriately, and how to assign specific functions to the new section.

 

This is interesting. I looked into a question on linking with keil a few days ago and looked at he docs for the armlink linker (part of the toolchain) used by keil. IIUC, it has support for "overflow" in the scatter file (i.e. linker script) by specifying +RWX "wildcards". You can define multiple sections as holder of code (or RO data, or zero-initialized data, etc'), and if one section fills up the code overflows to the next section.

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

I'm poor about the knowledge of ld language. I dont know how to modify the ld file.

Is there have some official example for this?

 

And I think it should be easy for us .

thanks!

how to write about "*(.text2*)"

I tried to modified like this .But .debug_info is very big ,and it allocated at FLASH2 ,FLASH.

I'm poor about the knowledge of ld language. I dont know how to modify the ld file.

Is there have some official example for this?

The OP has STM32H743VGT6 with 2*512K flash and a hole between the banks - see reply of TDK.

AFAIK the standard GNU linker cannot automatically manage this, so tuning of .ld is needed.

More advanced linkers (IAR, Keil...) can do this automatically. That's a selling point.

The OP can perform link with continuous 1M memory (as if they had a normal, 2MB STM32H743) which must succeed. Then analyze the .map file and manually distribute object modules to two banks (or write a script).  For example, part of object modules goes to FLASH2, the rest and any libraries go to FLASH1.

Then re-link with the customized .ld file.