cancel
Showing results for 
Search instead for 
Did you mean: 

Linker / Scatter

jakob.brunhart
Associate III

Hello everybody

Controller: STM32H743ZI

I have a const uint8_t array which I want to place in the flash at a specific location. The location is Address: 0x08180000. For that reason I created a *.sct file. The used tag is "MXG5XX".

LOAD_FLASH_BANK 0x08000000 0x00200000
{ 
                                            
  EXEC_FLASH_BANK_1 0x08000000 0x00100000
  {    
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
  }
  
  EXEC_FLASH_BANK_2 0x08180000 0x00080000
  {        
    *(.MXG5XX)
  }    
  
  EXEC_DTCM 0x20000000 0x00020000                               
  {
   .ANY (+RW)
   .ANY (+ZI)
  }
                                                                
  EXEC_AXI 0x24010000 0x00070000                                
  {
    .ANY (+RW)
    .ANY (+ZI)
  }  
 
  EXEC_ITCM 0x00000000 0x10000
  {
    .ANY (itcm)
  }  
  
}

The const array is called mxg5xx_firmware_binary and is defined as follows:

__attribute__((section (".MXG5XX"))) 
const uint8_t mxg5xx_firmware_binary [] = {
	0xB0, 0x14, 0x00, 0x20, 0xDD, 0x11, 0x00, 0x00, 0xE5, 0x11, 0x00, 0x00, 0xE7, 0x11, 0x00, 0x00
};

After the build process the *.map shows the following for the array:

Image Symbol Table
...
mxg5xx_firmware_binary                   0x08180000   Data          16  main.o(.MXG5XX)
...

So far everything seems to be correct.

If I start debugging now the address for the const array is correct (0x08180000) but the memory at this address shows only 0xFF and not the values defined for the array.

0693W000001ssRrQAI.png

I have a minimum project for NUCLEO-H743ZI.

Any Idea? Thank you.

Regards

Jakob

1 ACCEPTED SOLUTION

Accepted Solutions

The base addresses need to be consistent, you can't have the data floating in the middle of the load region, the scatter loader wants to unpack it.​

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

View solution in original post

5 REPLIES 5

Split into two load regions, with the second describing the last 512KB, and put the second execution region inside that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jakob.brunhart
Associate III

Hi Clive

Thank you for your response.

Do you mean like this:

LOAD_FLASH_BANK_1 0x08000000 0x00100000
{                                          
  EXEC_FLASH_BANK 0x08000000 0x00100000
  {    
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
  }
 
  EXEC_DTCM 0x20000000 0x00020000                               
  {
   .ANY (+RW)
   .ANY (+ZI)
  }
                                                                
  EXEC_AXI 0x24010000 0x00070000                                
  {
    .ANY (+RW)
    .ANY (+ZI)
  }  
 
  EXEC_ITCM 0x00000000 0x10000
  {
    .ANY (itcm)
  }
}
 
LOAD_FLASH_BANK_2 0x08100000 0x00100000
{ 
  ;EXEC_FLASH_BANK_2_1 0x08100000 0x00080000
  ;{
    
  ;}
  
  EXEC_FLASH_BANK_2_2 0x08180000 0x00080000
  {        
    *(.MXG5XX)
  } 
}

It behaves the same.

Regards

Jakob

Hi Clive

Please se my answer below.

Thank you.

The base addresses need to be consistent, you can't have the data floating in the middle of the load region, the scatter loader wants to unpack it.​

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

... Thank you. This version works.

LOAD_FLASH_BANK_1 0x08000000 0x00100000
{                                          
  EXEC_FLASH_BANK_1 0x08000000 0x00100000
  {    
    *.o (RESET, +First)
    *(InRoot$$Sections)
    .ANY (+RO)
    .ANY (+XO)
  }
 
  EXEC_DTCM 0x20000000 0x00020000                               
  {
   .ANY (+RW)
   .ANY (+ZI)
  }
                                                                
  EXEC_AXI 0x24010000 0x00070000                                
  {
    .ANY (+RW)
    .ANY (+ZI)
  }  
 
  EXEC_ITCM 0x00000000 0x10000
  {
    .ANY (itcm)
  }
}
 
LOAD_FLASH_BANK_2 0x08180000 0x00080000
{ 
  EXEC_FLASH_BANK_2 0x08180000 0x00008000
  {
    *(.MXG5XX)  
  }
}

.