How can I allocate .text section to FLASH and FLASH2 at STM32CUBEIDE (STM32H743VGT6)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 2:17 AM
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???
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 6:50 AM - edited ‎2024-08-13 6:55 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 3:31 AM
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?
- Please post an update with details once you've solved your issue. Your experience may help others.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 3:54 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 4:59 AM - edited ‎2024-08-13 5:00 AM
@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.
- Please post an update with details once you've solved your issue. Your experience may help others.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 5:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 5:29 AM - edited ‎2024-08-13 5:35 AM
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.
- Please post an update with details once you've solved your issue. Your experience may help others.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 5:48 AM
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 5:50 AM
thanks!
how to write about "*(.text2*)"
I tried to modified like this .But .debug_info is very big ,and it allocated at FLASH2 ,FLASH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 5:50 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-13 6:50 AM - edited ‎2024-08-13 6:55 AM
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.
