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

7 REPLIES 7

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

 

Tentative for the H523, different AF for them vs earlier H56x

https://github.com/cturvey/stm32extldr/blob/main/h5_w25q64/CLIVEONE-W25Q64_STM32H523-PB2-PA15-PB1-PB0-PA7-PA6.stldr

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

Hi Clive,

 

It worked very well, amazing! Why your stldr's have a very small size?

 

I will continuing try to make my code works :)

 

MMira4_0-1738845597460.png

 

>>Why your stldr's have a very small size?

Well I'm using GNU/GCC w/MAKE, keeping a relatively small HAL foot-print, not interrupts/callbacks, and I built a tool to remove a lot of clutter from the .ELF object file

 

>>I will continuing try to make my code works :)

I think it calls Init(), you need to watch that no static initialization is done, so Reset_Handler / main() are not executed. Perhaps it gets stuck in a loop or Error_Handler(), but doesn't time out. For debugging / diagnostics I tend to use one of the available UART's

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

Is It possible to use SWV instead UART? My board is prepared with SWO, but I can do some modifications to take uart.

UPDATE:

 

I toke a USART3 to debug instead SWV. I'coded at Init function this:

    SCB->VTOR = 0x20003000 | 0x200;

    __set_PRIMASK(0); //enable interrupts

    HAL_Init();

    SystemClock_Config();

    MX_GPIO_Init();
    MX_USART3_UART_Init();

    uint8_t TxBuffer[] = "Ola\n";
    HAL_UART_Transmit(&huart3, TxBuffer, strlen((char*)TxBuffer), 100U);

 but It does not print anything