cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H523 QUADSPI W25Q64 External Loader

MMira.4
Associate II

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

2 REPLIES 2

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 Venmo
Up vote any posts that you find helpful, it shows what's working..

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;
}