Skip to main content
MMira.4
Associate II
February 5, 2025
Question

STM32H523 QUADSPI W25Q64 External Loader

  • February 5, 2025
  • 3 replies
  • 2397 views

Hi, I'm trying to do an external loader according ST's MOOC and this forum https://community.st.com/t5/stm32-mcus-products/stm32h5-external-loader/td-p/601134.

My code pass on all ST's tests of memory, but when I generate a stldr it does not read on cubeprog.

I attached my project and log of cubeprog.

I already do the same with a G474 without problems.

 

BR

3 replies

Tesla DeLorean
Guru
February 5, 2025

The log implies Init() failed, so might want to instrument that

I'd expect Write() needs to leave with memory mapping, depends what STM32 Cube Programmers expectations are to be able to read the memory directly, as NOR_FLASH does not use Read() function.

 

/**
 * @brief Program memory.
 * Address: page address
 * Size : size of data
 * buffer : pointer to data buffer
 * @retval LOADER_OK = 1 : Operation succeeded
 * @retval LOADER_FAIL = 0 : Operation failed
 */
int Write(uint32_t Address, uint32_t Size, uint8_t* buffer) {

	__set_PRIMASK(0); //enable interrupts

// Abort out of memory mapped

	if (HAL_XSPI_GetState(&hospi1) != HAL_XSPI_STATE_READY) {
	 if (HAL_XSPI_Abort(&hospi1) != HAL_OK) {
 //console(consoleDefault,"WRITE abort err\r\n");
		 __set_PRIMASK(1); //disable interrupts
		 return LOADER_FAIL;
	 }
	}

 if (CSP_QSPI_WriteMemory((uint8_t*) buffer, (Address & (0x0fffffff)), Size) != HAL_OK) {
 __set_PRIMASK(1); //disable interrupts
 return LOADER_FAIL;
 }

#if 1 // re-enable memory mapped
 if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK) {
 __set_PRIMASK(1); //disable interrupts
 return LOADER_FAIL;
 }
#endif

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

 

STM32H523 / WINBOND W25Q64

PB2:AF9 CLK

PA15:AF9 NCS

PB1:AF6 IO0

PB0:AF6 IO1

PA7:AF10 IO2

PA6:AF6 IO3

https://www.st.com/resource/en/reference_manual/rm0481-stm32h52333xx-stm32h56263xx-and-stm32h573xx-armbased-32bit-mcus-stmicroelectronics.pdf

DEV_ID[11:0]: Device identification
0x484: STM32H562/563/573
0x478: STM32H523/533

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MMira.4
MMira.4Author
Associate II
February 5, 2025

I wrote LED_ON in all points of Init, but LED is not turning on, like stldr not calling Init()

int Init(void) {

 *(uint32_t*)0xE000EDF0 = 0xA05F0000; //enable interrupts in debug

 SystemInit();

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

 SCB->VTOR = 0x20003000 | 0x200;

 __set_PRIMASK(0); //enable interrupts

 HAL_Init();

 SystemClock_Config();

 MX_GPIO_Init();
 LED_ON();

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

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

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

 

Visitor II
November 27, 2025

Hello everyone!
I'm having a similar problem. I can't get the external bootloader for the STM32H523 to work in CubeProg. The log file also indicates a problem with Init...
MMira.4, have you resolved the issue?
I'd appreciate any help...

Visitor II
November 28, 2025

Dear colleagues,
Update.
I got the bootloader working. The problem was with the linker and its settings. I followed the instructions in https://community.st.com/t5/stm32-mcus-products/stm32h563-custom-external-loader-issues/td-p/705685
and it started working. I didn't have such problems with the H7 series.

Visitor II
November 28, 2025

And yes, I forgot...
Before each function (Read, Erase), you need to re-init for OSPI. At the end of the init, I had to insert a small delay.

MMira.4
MMira.4Author
Associate II
December 4, 2025

Hi, and I'm trying yet....can you share your code?