Skip to main content
Associate III
March 27, 2024
Solved

Facing issue while creating external flash loader

  • March 27, 2024
  • 14 replies
  • 13812 views

I am using NUCLEO-H563ZI evaluation board and i want to create external flash loader for IS25LP128 QSPI flash memory. I used external loader files from GIT HUB and .stldr file in STCUBE programmer external loader folder location. when i try to read from 0x90000000 location, i am getting read failure error. I used the below path to create external loader for IS25LP128 QSPI flash memory,

stm32-external-loader/Loader_Files/other devices at contrib · STMicroelectronics/stm32-external-loader · GitHub

Could you please help me to solve the below issue?

 

Nagarajan_2-1711548543593.png

 

 

    Best answer by Tesla DeLorean

    >>What could be the reason for Init function not called?

    I don't know, use your imagination.

    Set the STM32 Cube Programmer side to Verbose Logging Level 3, see what it's doing.

    Make sure it pulls in the loader image to RAM, that it correctly identifies the Init() entry point, and calls it. Use objdump or fromelf to dump/disassemble the .STLDR

    Other H5 loaders use 0x20003004 as the basis, not 0x20000004 or 0x24000004

    C:\STM32Cube\STM32CubeProgrammer_v2.15.0\bin\ExternalLoader>C:\Keil537\ARM\ARMCLANG\bin\fromelf.exe -csd MX25LM51245G_STM32H573I-DK.stldr
    
    ========================================================================
    
    ** ELF Header Information
    
     File Name: MX25LM51245G_STM32H573I-DK.stldr
    
     Machine class: ELFCLASS32 (32-bit)
     Data encoding: ELFDATA2LSB (Little endian)
     Header version: EV_CURRENT (Current version)
     Operating System ABI: none
     ABI Version: 0
     File Type: ET_EXEC (Executable) (2)
     Machine: EM_ARM (ARM)
    
     Image Entry point: 0x20003005
     Flags: None (0x05000000)
    
     ARM ELF revision: 5 (ABI version 2)
    
     Conforms to Base float procedure-call standard
    
     Header size: 52 bytes (0x34)
     Program header entry size: 32 bytes (0x20)
     Section header entry size: 40 bytes (0x28)
    
     Program header entries: 2
     Section header entries: 20
    
     Program header offset: 159376 (0x00026e90)
     Section header offset: 159440 (0x00026ed0)
    
     Section header string table index: 1
    
    ========================================================================
    
    ** Program header #0 (PT_LOAD) [PF_R]
     Size : 200 bytes
     Virtual address: 0x00000000 (Alignment 4)
    
    
    ====================================
    
    ** Program header #1 (PT_LOAD) [PF_X + PF_W + PF_R]
     Size : 16205 bytes
     Virtual address: 0x20003004 (Alignment 4)
    
    
    ========================================================================
    ...
     267 Init 0x20003005 Gb 5 Code De 0x66
     268 MassErase 0x2000306b Gb 5 Code De 0x3e
     269 Write 0x200030a9 Gb 5 Code De 0x46
     270 SectorErase 0x200030ef Gb 5 Code De 0x60
     271 CheckSum 0x2000320d Gb 5 Code De 0xd4
     272 Verify 0x200032e1 Gb 5 Code De 0x5e
    ...

    14 replies

    Tesla DeLorean
    Guru
    March 27, 2024

    Test and debug your loader and BSP code in application space, using a harness or fixture to allow you to exercise the basic functionality.

    With the loader you can use any/all of the resources of your hardware, ie UART/VCP, to provide diagnostic and telemetry as to what's happening internally. The interactions on the STM32 Cube Programmer side can be seen via the log at an appropriate verbosity level.

    Here Init() or Read() function are not completing without an error/failure. On a NOR_FLASH Init() is expected to memory map the device, and return without an error.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    NagarajanAuthor
    Associate III
    April 24, 2024

    Is the any video or procedure link to know how to debug the loader file through UART?

    Tesla DeLorean
    Guru
    April 24, 2024

    Well you can use any hardware on your board for diagnostics.

    You can use the UART to output things like function entry, parameters and success/failure indication. This way you can understand the dynamic interaction between the loader and the STM32 Cube Programmer tool.

    Code with the assumption you don't have printf() or interrupts

    #ifdef DEBUG_UART
     OutString("Read: Enter");
     OutString(DumpHex(Address));
     OutString(DumpHex((uint32_t)Buffer));
     OutString(DumpHex(Size));
     OutChar('\n');
    #endif // DEBUG_UART

    Could use LEDs for a pass/fail indication

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    NagarajanAuthor
    Associate III
    March 28, 2024

    While debugging i found out that if it is charcter string, i am able to wirte n number of bytes but if it is numerical value, i am able to store only 8 bytes.

    for example, i am trying to store 1 to 24 values in flash but it is storing 1 to 8 only after that it is writing/reading some junk values. Could you please help me to solve this issue.

    for(int i=0; i<24; i++)

    {

    data_Fl[i] = i;

    }

    Enter_QPI_Mode();

    HAL_Delay(50);

    QSPI_data_erase_handler_4Lines(ERASE_BLOCK, (uint32_t)BLOCK0_64K_ADDR);

    HAL_Delay(500);

    QSPI_data_write_handler_4Lines((uint32_t)BLOCK0_64K_ADDR, &data_Fl[0], sizeof(data_Fl));

    HAL_Delay(500);

     

    Nagarajan_0-1711608414976.png

     

    Tesla DeLorean
    Guru
    March 28, 2024

    Likely an issue with the write code not shown. Either the transfer or waiting for the completion. Don't view the peripheral registers in the debugger, it will break the FIFO

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    NagarajanAuthor
    Associate III
    March 28, 2024

    The execution didn't stop Anyware in transmission function and it came out of the function with success only. i would like to know any difference is there for string and numeric data to write into flash memory. My OCTO SPI clk freq is 32MHz. I connected eval board and external flash memory with short wires.

    KDJEM.1
    Technical Moderator
    March 28, 2024

    Hello @Nagarajan and welcome to the Community :),

    Could you please check the OCTOSPI configuration parameters like as Chip select boundary (CSBOUND) configured depending on the memory datasheet. The chip select must go high when crossing the page boundary (2^CSBOUND bytes defines the page size).

    May be this "MOOC - External QSPI loader how to" can help you.

    Thank you.

    Kaouthar

    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.
    NagarajanAuthor
    Associate III
    March 28, 2024

    I tried CSBOUND register by giving different values but no luck.
    This code is working fine for string but it is not working for numerical values.
    The below configuration only I am using, also attached my full code with chat.
    Please help me to solve the issue.


    static void MX_OCTOSPI1_Init(void)

    {

    /* USER CODE BEGIN OCTOSPI1_Init 0 */

     

    /* USER CODE END OCTOSPI1_Init 0 */

     

    /* USER CODE BEGIN OCTOSPI1_Init 1 */

     

    /* USER CODE END OCTOSPI1_Init 1 */

    /* OCTOSPI1 parameter configuration*/

    hospi1.Instance = OCTOSPI1;

    hospi1.Init.FifoThresholdByte = 4;

    hospi1.Init.MemoryMode = HAL_XSPI_SINGLE_MEM;

    hospi1.Init.MemoryType = HAL_XSPI_MEMTYPE_MICRON;

    hospi1.Init.MemorySize = HAL_XSPI_SIZE_16MB;

    hospi1.Init.ChipSelectHighTimeCycle = 1;

    hospi1.Init.FreeRunningClock = HAL_XSPI_FREERUNCLK_DISABLE;

    hospi1.Init.ClockMode = HAL_XSPI_CLOCK_MODE_0;

    hospi1.Init.WrapSize = HAL_XSPI_WRAP_NOT_SUPPORTED;

    hospi1.Init.ClockPrescaler = 1;

    hospi1.Init.SampleShifting = HAL_XSPI_SAMPLE_SHIFT_NONE;

    hospi1.Init.DelayHoldQuarterCycle = HAL_XSPI_DHQC_DISABLE;

    hospi1.Init.ChipSelectBoundary = HAL_XSPI_BONDARYOF_NONE;

    hospi1.Init.DelayBlockBypass = HAL_XSPI_DELAY_BLOCK_BYPASS;

    hospi1.Init.Refresh = 0;

    if (HAL_XSPI_Init(&hospi1) != HAL_OK)

    {

    Error_Handler();

    }

    /* USER CODE BEGIN OCTOSPI1_Init 2 */

    /* USER CODE END OCTOSPI1_Init 2 */

    }

     

     

    Tesla DeLorean
    Guru
    March 29, 2024

    A bit confused about the mixed use of XSPI and SPI peripherals here.

    Can you provide a pin designation list for how this IS25LP128 is connected too the STM32H5 chip?

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

    In SPI mode i tested the same code it is working perfectly. I am able to write multi page and multi sectors, so there is no issue with flash memory. I feel like there is a problem with configuring XSPI in STM32H5 chip only. Is it possible to get XSPI configuration code for STM32H5 chip interface with IS25LP128 flash memory from ST?

    Please find the pin details below,

    PE11 - CE

    PF10 - SCK

    PF8 - SI/IO0

    PF9 - SO/IO1

    PE2 - WP/IO2 

    PF6 - HOLD/IO3

    KDJEM.1
    Technical Moderator
    March 29, 2024

    Hi @Nagarajan ,

    Thank you for updating post and sharing these details.

    About the code configuration, please make sure that :

    • Sample shifting (SSHT) enabled in STR mode and disabled in DTR mode.
    •  Delay hold quarter cycle (DHQC) enabled in DTR mode and disabled in STR mode
    • DEVSIZE: The memory sizes = 2^(DEVSIZE+1)

    I hope this help you!

    Thank you.

    Kaouthar

    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.
    NagarajanAuthor
    Associate III
    March 29, 2024

    I corrected the memory size from 16Mega bits to 128 Mega bits and sample shifting i enabled. DHQC is disabled only as it is in STR mode but still i am facing the same issue. Now my configuration is like below,

     

    hospi1.Instance = OCTOSPI1;
    hospi1.Init.FifoThresholdByte = 1;
    hospi1.Init.MemoryMode = HAL_XSPI_SINGLE_MEM;
    hospi1.Init.MemoryType = HAL_XSPI_MEMTYPE_MICRON;
    hospi1.Init.MemorySize = HAL_XSPI_SIZE_128MB;
    hospi1.Init.ChipSelectHighTimeCycle = 1;
    hospi1.Init.FreeRunningClock = HAL_XSPI_FREERUNCLK_DISABLE;
    hospi1.Init.ClockMode = HAL_XSPI_CLOCK_MODE_0;
    hospi1.Init.WrapSize = HAL_XSPI_WRAP_NOT_SUPPORTED;
    hospi1.Init.ClockPrescaler = 1;
    hospi1.Init.SampleShifting = HAL_XSPI_SAMPLE_SHIFT_HALFCYCLE;
    hospi1.Init.DelayHoldQuarterCycle = HAL_XSPI_DHQC_DISABLE;
    hospi1.Init.ChipSelectBoundary = HAL_XSPI_BONDARYOF_NONE;
    hospi1.Init.DelayBlockBypass = HAL_XSPI_DELAY_BLOCK_BYPASS;
    hospi1.Init.Refresh = 0;

    NagarajanAuthor
    Associate III
    April 4, 2024

    It seems like I am facing connecting wires issue. Is there any specific high frequency shielded type connecting wires available for SPI pins?

    NagarajanAuthor
    Associate III
    April 11, 2024

    After putting external pull up and pull down resistor in HOLD and WP pins accordingly, i am able to pass main test but still i am facing data read failure with external loader file. I feel like there is a problem with Loader_src.c file. Anybody having STM32H5 series working loader files?

    NagarajanAuthor
    Associate III
    April 25, 2024

    There are two changes needed in Loader files. One is RAM address need to be changed to 0x20003004 in linker.ld and Loader_Src.c files. Another one is We need to deinit and init QuadSPI everytime when we do erase and write In Loader_Src.c file. With those changes external loader works fine for STM32H563 controller.

    ABasi.2
    Senior
    July 24, 2024

    hello!

    did you succes in making the external loader?

    i have tried your suggestion but mine don't work

    i have a working driver for MX25L512 but  i 'm not able to have a working external loader

    if you succed can you share your project?

     

    thank yoy 

     

    Andrea

    Associate III
    June 2, 2024

    Could You provide us with a working external loader for this memory chip? I have the same one and I didn't come nearly as far as you to use it for my program.

    Tesla DeLorean
    Guru
    June 2, 2024

    Express parts and pin utilizations..

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