cancel
Showing results for 
Search instead for 
Did you mean: 

Have a problem with write Scatter-Loading Description File for STM32H743.

AOrlo.2
Associate II

Have a problem with write Scatter-Loading Description File for STM32H743 (arm keil).

I need to map SDRAM memory.

Regular I do it like:

RW_RAM1 0xD0000000 0x00800000 { ; fmc bank 2

  *(SDRAM)

 }

On all other MCU's it's work perfect, but not for stm32H7. 

It's fail on BX R0 command from startup file:

LDR   R0, =SystemInit

         BLX   R0

         LDR   R0, =__main

         BX   R0 //after this command

1 ACCEPTED SOLUTION

Accepted Solutions

@ukzw wrote:

I met exactly the same problem. By step-in to __main assembly, found the reason is that, __scatterload is trying to copy variables from load address to exec address, which include copy to external SDRAM (0xd0000000), but at this time, external SDRAM not initialized yet, this caused hard fault. 


You need that SDRAM is initialized before calling the main() otherwise you will fall in Hardfault.

You can refer to the X-CUBE-H7-PERF

 and see how the scatter file under: Projects\STM32H743I_EVAL\stm32h7x3_cpu_perf\MDK-ARM\scatter_file\6-M7-ITCM_rwExtSDRAM.sct

and the SDRAM is configured in SystemInit_ExtMemCtl() in system_stm32h7xx.c are made: need to activate the definition of DATA_IN_ExtSDRAM

And becarefull if you are trying to execute from 0xD0000000, you will fall also in a fault as that region is Execute-Never as described by ARM. So you need to disable it with MPU.

SofLit_0-1729266469191.png

 

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.

View solution in original post

19 REPLIES 19
FBL
ST Employee

Hello @AOrlo.2​ 

Could you share a screenshot of your faults state using CubeProgrammer (in hot plug mode) or on Keil using Faults report?

You may refer to configuration 6 using scatter file remapping SDRAM.

X-CUBE-PERF-H7 - STM32H7 performance software expansion for STM32Cube (AN4891) - STMicroelectronics

Hope this help!

Firas

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.

Have a Hard Fault Handler that outputs actionable information.

Make sure the FPU is enabled.

Look at what gets moved or loaded in SDRAM

Makes sure the SDRAM is initialized in SystemInit() not later in main()​

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

Hello,

Some video of debug from start to error (with registers and call stack):

https://youtu.be/G6puIUYvZVo

With Faults Report panel

https://youtu.be/63jFlBYZvQM

The SDRAM is still not initialized, but just for debuging, I don't call and don't use this memory in code. So on this state, compiler don't try to create any initialized(zeroed) memory in SDRAM.

I just want to create region.

Hi again @AOrlo.2​,

It appears that the linker has placed some variables in the SDRAM memory region starting at address 0xD0000000.

You can check the map file to find out what is located in this region.

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.

AOrlo.2
Associate II

From map file:

  Execution Region RW_RAM1 (Exec base: 0xd0000000, Load base: 0x0800e9c0, Size: 0x00000000, Max: 0x00800000, ABSOLUTE)

  **** No section assigned to this execution region ****

From a map file:

  Execution Region RW_RAM1 (Exec base: 0xd0000000, Load base: 0x0800e9c0, Size: 0x00000000, Max: 0x00800000, ABSOLUTE)

  **** No section assigned to this execution region ****

Ok, I recheck it now...

If no section assigned to 0xd0000000, no errors.

I move FMC&SDRAM initialization to SystemInit().

Add some variable to sdram, and it go to error.

If I use sdram by absolut adress like:

uint32_t *bufersdram = (uint32_t *) 0xD0000000; //it's work

uint16_t bufersdram[10] __attribute__ ((section("SDRAM"))); //go to error after SystemInit()

Is it possible to run a simple test in order to read/write SDRAM after SystemInit() execution?

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.

If I use declaration like uint32_t *bufersdram = (uint32_t *) 0xD0000000;

So I can write and read it.

My test before main loop:

uint32_t *bufersdram = (uint32_t *) 0xD0000000;

HAL_StatusTypeDef hal_stat = HAL_OK;

  int i;

  for(i=0;i<16;i++){

     bufersdram [i]=i;

  }

   

  for(i=0;i<16;i++){

     hal_stat+=(i != bufersdram [i]);

     if(hal_stat! = HAL_OK)

{

printf("SDRAM Error");

break;

}

  }