2023-01-01 07:40 AM
Hi
I have a project where I am using RAM_D2 for DMA buffers and the .text section is loaded into QSPI flash. I need to use STM32_Programmer_CLI in my development.
I added section in .ld file:
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
...
.memory_dma (NOLOAD) :
{
. = ALIGN(8);
*(.memory_dma*)
} >RAM_D2
, and code to use variable in main.c:
/* USER CODE BEGIN PV */
typedef struct {
unsigned char buffer[1024];
int bufferIdx;
} consoleBuffer ;
consoleBuffer __attribute__((section(".memory_dma"))) txBuffer[2] ;
/* USER CODE END PV */
/* USER CODE BEGIN 2 */
txBuffer[0].bufferIdx = 0;
txBuffer[1].bufferIdx = 0;
/* USER CODE END 2 */
The code is compiled and all variables are put where they suppose to be.
The STM32CubeIDE is able to download .text into FLASH (using external loader) and debug the project.
Since I need to use STM32_Programmer_CLI for development, the issue is the STM32_Programmer_CLI will not download .text into FLASH memory, but it is downloading the RAM_D2 only!
$ STM32_Programmer_CLI -el /Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin/ExternalLoader/ART-PI-QSPILoader.stldr -c port=SWD -d Debug/simple-c.elf
-------------------------------------------------------------------
STM32CubeProgrammer v2.12.0
-------------------------------------------------------------------
ST-LINK SN : 066CFF505750888667144210
ST-LINK FW : V2J40M27
Board : --
Voltage : 3.26V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x450
Revision ID : Rev V
Device name : STM32H7xx
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M7
BL Version : 0x90
Memory Programming ...
Opening and parsing file: simple-c.elf
File : simple-c.elf
Size : 34.09 KB
Address : 0x30000000
Erasing memory corresponding to segment 1:
Erasing external memory sectors [0 8]
Download in Progress:
[==================================================] 100%
File download complete
Time elapsed during download operation: 00:00:02.727
When I check on section order in the .elf file the RAM_D2 is listed first despite the NOLOAD attribute:
$ arm-none-eabi-readelf -l Debug/simple-c.elf
Elf file type is EXEC (Executable file)
Entry point 0x90000d4d
There are 4 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x30000000 0x30000000 0x00000 0x00808 RW 0x10000
LOAD 0x010000 0x90000000 0x90000000 0x087e8 0x087e8 RWE 0x10000
LOAD 0x020000 0x24000000 0x900087e8 0x00078 0x04b94 RW 0x10000
LOAD 0x004b94 0x24004b94 0x90008860 0x00000 0x00604 RW 0x10000
Section to Segment mapping:
Segment Sections...
00 .memory_dma
01 .isr_vector .text .rodata .ARM .init_array .fini_array
02 .data .bss
03 ._user_heap_stack
I am not sure where the issue is, with STM32_Programmer_CLI not able to pick correct segments, or linker/linker script incorrectly placing or marking segments.
Is anyone had similar issue and how can I resolve it?
All project files are attached.
Thanks you
Solved! Go to Solution.
2023-01-01 10:07 AM
The `(NOLOAD)' directive will mark a section to not be loaded at run time
Opening and parsing elf not equal load.
Erasing memory corresponding to segment 1: is segment QSPI.
2023-01-01 10:07 AM
The `(NOLOAD)' directive will mark a section to not be loaded at run time
Opening and parsing elf not equal load.
Erasing memory corresponding to segment 1: is segment QSPI.
2023-01-01 10:26 AM
Thanks to point me out. I was clearly unable to notice that.
The 0x30000000 was unexpected and it shadow the rest of the information for me.
2023-01-01 10:37 AM
Yes but you have right with unclean or buggy show LOAD
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x30000000 0x30000000 0x00000 0x00808 RW 0x10000
but sections is clean
Segment Sections...
00 .memory_dma
01 .isr_vector .text .rodata .ARM .init_array .fini_array
02 .data .bss
03 ._user_heap_stack