Skip to main content
MMARI.1
Senior II
February 7, 2025
Solved

qspi data not compiling

  • February 7, 2025
  • 3 replies
  • 1523 views

hi,

I am trying to external loader connect with stm32h723zgt6 + w25q128 .

before loading  the stldr file into debugger  i need know why cube ide not compiling the data into qspi location ? 

In the main.c file constant data  has been declared as below .

const __attribute__((section(".extFlash"))) uint8_t buff[] = "Hello world from H723 QSPI";

In the flash id file has been modified as below.

QSPI_FLASH (r) : ORIGIN = 0x90000000, LENGTH = 16M 


.extFlash :
 {
 *(.extFlash) 
 } >QSPI

 after compiling why memory details not showing in the below menu 

MMARI1_0-1738907478474.png

 

Best answer by unsigned_char_array

@MMARI.1 wrote:

hi @unsigned_char_array @mƎALLEm 

I have declared constant data only as above , not used Since this constant data to suppose to write in external flash. I do agree cube ide skip the unused variable  during the compiling . I am not sure  cube ide will skip the unused constant data  for the external flash since stldr file going to handle this !.


If unused it won't be linked. CubeIDE doesn't skip anything as it doesn't compile, it just calls the compiler/linker. If not linked it won't end up in the elf file and it won't be flashed regardless of what flashing tool will be used.

Either use it (reference it) in your code or add __attribute__((used))

 

 

const uint8_t buff[] __attribute__((section(".extFlash"))) __attribute__((used))= "Hello world from H723 QSPI";

 

 

https://developer.arm.com/documentation/dui0472/m/Compiler-specific-Features/--attribute----used---variable-attribute

 

 

 

3 replies

mƎALLEm
Technical Moderator
February 7, 2025

hello,

Try:

uint8_t buff[] __attribute__((section(".extFlash")));
"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
MMARI.1
MMARI.1Author
Senior II
February 7, 2025

hi,

i have modified as below : 

uint8_t buff[] __attribute__((section(".extFlash")))= "hello world";

 but still problem continues as same !. it not showing as earlier attached picture 

Lead II
February 7, 2025

Have you refreshed the build analyzer? Sometimes it doesn't refresh on its own. Rebuild and click the refresh icon:

unsigned_char_array_0-1738919012084.png

 

Also, why did you remove const? You cannot put a variable in ROM, only constants. The linker won't like it. And if it somehow builds you will get a hardfault error if the MCU tries to modify the object.

Is the object used? If not, it might be optimized away by the linker.

"Kudo posts if you have the same problem and kudo replies if the solution works.Click ""Accept as Solution"" if a reply solved your problem. If no solution was posted please answer with your own."
MMARI.1
MMARI.1Author
Senior II
February 7, 2025

hi,

i have modified constant as below 

const uint8_t buff[] __attribute__((section(".extFlash"))) = "Hello world from H723 QSPI";

 i have refreshed many times and build the  project many times but problem is same as continues. 

mƎALLEm
Technical Moderator
February 7, 2025

Did you use it in your application or you've only declared it? it could be optimized by the tool if you didn't use it.

If you put buff in the live expression are you able to see the content?

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
Tesla DeLorean
Guru
February 7, 2025

The linker will do dead-code elimination based on what's called and what's used.

You can use the KEEP() directive in the linker script

https://github.com/cturvey/stm32extldr/blob/main/ExternalLoader_H5.ld#L43

.extFlash :
 {
 *(.extFlash)
 *(.extFlash*) 
 } >QSPI

This will address .extFlash.xxx .extFlash.yyy naming, say the compiler's using a "section per function" directive to give fine grain granularity to cherry picking what blocks of code are dependent in the dead-code removal, when dealing with .C files in similar ways to .A/.LIB

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..