Skip to main content
Associate
April 10, 2025
Question

Unable to Jump from Bootloader to Application loaded into SDRAM

  • April 10, 2025
  • 3 replies
  • 907 views

Hi,

My board consists of stm32h733 that interfaces SDRAM via FMC. I want to execute code from SDRAM. Code is loaded from external flash(OCTOSPI) to SDRAM at address 0xc0700000.
But running the code from this region causes hard-fault disabling the Debug Port. After this I'm unable to flash firmware into the hardware. I have to bring board into "connection under reset" by connecting BOOT0 to 3.3v and NRST to GND. I have tried with multiple test firmware but always got into hard-fault. Why MCU disables, it's debug port?

While debugging in the disassembly I can execute firmware running from SDRAM one by one line, but at some point code hard-fault, causing it to stuck into the above told situation. Here is the MPU config for SDRAM;

/* Configure the MPU attributes for SDRAM */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0xC0000000; // Start address of SDRAM Bank 1
MPU_InitStruct.Size = MPU_REGION_SIZE_8MB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER3; // MPU region number
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);

Why am I not able to execute code from SDRAM after jump from bootloader???

Thanks,

Umair

3 replies

Tesla DeLorean
Guru
April 10, 2025

Perhaps Instrument your code, via output to the serial port, and have a HardFault Handler that outputs actionable information from the running system.

The SDRAM will not be working until initialized, the debugger typically doesn't bring it up. Ideally it would be done in SystemInit() so it would work for static copies and initialization, and by the time you hit main()

Determine what instruction and address is actually faulting, and let's diagnose the issue from there..

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

Hey @Tesla DeLorean @TDK @MM..1 @Saket_Om 

 

I'm facing the same issue and i would really appreciate if you can help me out.

 

Thanks

TDK
Super User
April 11, 2025

Since you can access and execute SDRAM during debug, seems MPU config and overall code is fine.

> While debugging in the disassembly I can execute firmware running from SDRAM one by one line, but at some point code hard-fault,

At what point does it hard fault?

Does SDRAM pass sanity checks for read/write access over the entire region?

"If you feel a post has answered your question, please click ""Accept as Solution""."
UmairAuthor
Associate
April 11, 2025

The SDRAM will not be working until initialized, the debugger typically doesn't bring it up. Ideally it would be done in SystemInit() so it would work for static copies and initialization, and by the time you hit main()

Are you talking about SDRAM initialization in bootloader or application. SDRAM is being initialized in bootloader and I can successfully perform erase/read/write operations to it. Do I have to reinitialize the SDRAM from application, or if the initialization done in bootloader will be enough? Although I have also tried by disabling the FMC in application, but that also didn't work.

 

At what point does it hard fault?

I would like to add a point here, while line by line execution. The stack got loaded with 0xdeadbeee after the instruction 0xC070059A(in case of blinky test application as I have update the Flash address to 0xC0700000 in ld file(is this right?)) got executed. As I have seen this behavior with multiple test firmwares, the issue seems to be related to applications'(MCU) Startup code after jump.

  • Maybe reversing the binary will help!

 

Does SDRAM pass sanity checks for read/write access over the entire region?

I'm not sure what do you mean by SDRAM's sanity checks but in bootloader, I'm able to erase the last MB of the SDRAM, move code from external flash to SDRAM. I have also verified the content of flashed binary with external flash as well as SDRAM.

Technical Moderator
April 15, 2025

Hello @Umair 

The bootloader does not support external memory (SDRAM), so executing code from SDRAM is not possible. However, we provide an example of an open bootloader in H7Rs that you can use as a reference.

"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.Saket_Om"