cancel
Showing results for 
Search instead for 
Did you mean: 

Files for STM32H563 External Loader

PFlor.2
Senior II

Anybody have Linker.ld and Loader_src.c file for STM32H563?  I have done one for the STM32H743 on another project and made an attempt to modify these for the STM32H563 but it's not working.  Appreciate any guidance.

I changed the RAM location from 0x24000000 for the H7 to 0x20000000 for the H5 but not sure what else is different as it pertains to a loader.

Something with the Init could be wrong...

int Init(void) {
  *(uint32_t*)0xE000EDF0 = 0xA05F0000; //enable interrupts in debug

  // Added per suggestion from ST to clear out QSPI structure
  memset(&hospi1, 0, sizeof(hospi1));

  SystemInit();

  /* ADAPTATION TO THE DEVICE
   *
   * change VTOR setting for H5 device
   * SCB->VTOR = 0x20000000 | 0x200;
   *
   * change VTOR setting for other devices
   * SCB->VTOR = 0x20000000 | 0x200;
   *
   * */
  SCB->VTOR = 0x20000000 | 0x200;

  __set_PRIMASK(0); //enable interrupts

  HAL_Init();

  SystemClock_Config();

  MX_GPIO_Init();

  __HAL_RCC_OSPI1_FORCE_RESET();  //completely reset peripheral
  __HAL_RCC_OSPI1_RELEASE_RESET();

  if (CSP_QUADSPI_Init() != HAL_OK) {
    __set_PRIMASK(1); //disable interrupts
    return LOADER_FAIL;
  }

  if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK) {
    __set_PRIMASK(1); //disable interrupts
    return LOADER_FAIL;
  }

  /*Trigger read access before HAL_QSPI_Abort() otherwise abort functionality gets stuck*/
  uint32_t a = *(uint32_t*) 0x90000000;
  a++;

  __set_PRIMASK(1); //disable interrupts
  return LOADER_OK;
}
1 ACCEPTED SOLUTION

Accepted Solutions

The VTOR address would be 0x20003000 | 0x200 if using interrupts, like ST does. The address is aligned to 0x200 (ie 8 zeros) boundaries.

The H7 build at 0x24000004, most others at 0x20000004. It's basically the address of the primary RAM

The .map file should provide some confirmation of where g_pfnVectors resides in the build

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

9 REPLIES 9

ST builds the H5 loaders for 0x20003004

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

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

Thanks for the tip!  Does the Vector Table Offset Register (VTOR) need to be adjusted for this device like the H7?  Maybe 0x20003004 | 200?

PFlor2_0-1734108270615.png

Also I assume the H5 still uses 0x90000000 as the virtual address for external Flash over QSPI?

The VTOR address would be 0x20003000 | 0x200 if using interrupts, like ST does. The address is aligned to 0x200 (ie 8 zeros) boundaries.

The H7 build at 0x24000004, most others at 0x20000004. It's basically the address of the primary RAM

The .map file should provide some confirmation of where g_pfnVectors resides in the build

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

Yes, that's what I ended up using and got it working with some slight modifications to my OSPI drivers and loader_src.c.  For some reason this one didn't like to use Abort to get out of memory mapped mode so I needed to do call the QSPI initialization at the start of each operation (read, write, or erase).

Hi there, @Tesla DeLorean,  For External Loader Application, after adding the .stldr file to the debug configuration and enabling both the checkboxes of "enabled" and "initialize" (kindly refer to the below fig.) of the main project (not the one used to generate the loader file), my HAL_Delay() is not working at the main.c, if not "initialize" at the debug configuration of the main project  or "when on board reset button is pressed at the debug time" the HAL_Delay() is working properly. I am guessing it could be the reason that the control is not finding a valid location to place the VTOR present in the Loader_Src.c of lines  *(uint32_t*)0xE000EDF0 = 0xA05F0000; //enable interrupts in debug and  SCB->VTOR = 0x24000000 | 0x200;.  I also tried with the address you have provided i.e. 0x20003000 | 0x200 (for other boards, in my case as i am using stm32l496zg-p with at25q128a nor flash). Kindly let me know how to make HAL_Delay() work for my application. (Application is TouchGFX images upload to the main core mcu using external loader file with nor flash).

Abhiram_12_0-1744377809770.png

 

When I encountered the HAL_Delay not working it was because the interrupt priority in NVIC settings was too low.  Need to make the clock you are using for system timer the highest priority.

Not sure how the loader leaves things. You should check the code around the function entry/exit points.

SCB->VTOR is notionally set at 0x08000000 in your app's SystemInit()

You should enable_irq() if your loader disables it.

Check NVIC settings and any pending interrupts. The tail-chaining mechanism can't clear/unwind itself if not used.

Check NVIC priorities, the SysTick is a System Handler rather than an IRQ Handler

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

Thank You @Tesla DeLorean @PFlor.2