cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 QSPI external flash loader issue

johnLocke
Associate II

Hi.

In a project I'm working on, I have to use external flash because the internal flash memory is low.I decided to use the MT25QU512ABB chip as it supports QSPI. After some research on the internet, I found the video of STMicroelectronics on youtube and followed the steps.

Link:

https://www.youtube.com/watch?v=XqCq0xtQmbI&t=608s

I also downloaded the necessary files from STMicroelectronics' github page and created my project.but even though there is no error in my project and I load the .elf file in ST32CubeProgrammer without any problems, the program does not start.

MCU STM32h750VB

IDE CubeIDE

I look forward to your help

thank you.

5 REPLIES 5

>>..the program does not start.

Which The Program? The loader, or the code you uploaded?

The QSPI would need to be brought up early in the boot process, if you touch it before that the processor will Hard Fault. Have the Hard Fault routine output useful/actionable information. Bring the QSPI up in SystemInit, test and ensure your QSPI BSP code functions properly. Dump the content, build some routines to read and checksum, so you can validate PC side, and STM32 side integrity of the memory. That way you can focus your debugging on the right problems.

The External Loaders are non-trivial, what pins are you using?

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

The sample code I uploaded with STM32CubeProgrammer does not work. As you said, the loader starts at systeminit. Also, to be able to test the QSPI code, I have a routine that first erase the memory, then writes it, and finally validates it. and in this routine everything goes well.

Do I need to install any Boot code on the internal flash to run my sample code that I uploaded with STM32CubeProgrammer?,

The pins I use are for Bank2 with Quad SPI lines mode.

QUADSPI_CLK->PB2

QUADSPI_BK2_IO0->PE7

QUADSPI_BK2_IO1->PE8

QUADSPI_BK2_IO2->PE9

QUADSPI_BK2_IO3->PE10

QUADSPI_BK2_NCS->PC11

thank you.

Yes, you'll need some code in Internal FLASH to bring up the interface and map it into the address space.

I would recommend the contract between the loader and app be that the loader brings up all the processor/bus clocks, PLL, QSPI, and that the application doesn't touch those things.

The loader should ideally test/validate the External FLASH image before jumping to it, and provide a means to upload/recover the situation if the image is corrupt. It could perhaps implement a USB DFU loader type functionality, or pull data off a MicroSD card.

Ok, so BANK2

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

After what you said, I'm trying to use the boot codes from the STM32Cube_FW_H7_V1.9.0\Projects\STM32H743I-EVAL\Applications\ExtMem_CodeExecution\ExtMem_Boot example.

the codes are as follows:

int main(void)
{
CPU_CACHE_Enable();
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  MX_QUADSPI_Init();
	if (Memory_Startup() != MEMORY_OK)
	{
		Error_Handler();
	}
	CPU_CACHE_Disable();
	SysTick->CTRL=0;
JumptoApplication=(pFunction)(*(__IO uint32_t*)(APPLICATION_ADDRESS+4));
__set_MSP(*(__IO uint32_t*)APPLICATION_ADDRESS);
JumptoApplication();
 
  while (1);
 
 
 
 
uint32_t Memory_Startup(void)
{
  uint32_t status = HAL_OK;
  /* Non-Volatile Memory Configuration */
#if (CODE_AREA == USE_QSPI) || (BINARY_AREA == USE_SPI_NOR)
  status |= QSPI_Startup(QSPI_MODE);
#endif
  return status;
}
static void CPU_CACHE_Enable(void)
{
  SCB_EnableICache();
  SCB_EnableDCache();
}
static void CPU_CACHE_Disable(void)
{
  SCB_DisableICache();
  SCB_DisableDCache();
}

but I am getting timeout error in QSPI_AutoPollingMemReady() function.

https://community.st.com/s/question/0D50X0000AeW6I3SQK/qspiflagsm-timing-out-on-qspi-flash-test

the problem with the connection is the same as mine.i tried the solution in the link but i keep getting timeout error.

I would be grateful for any help.

If it is failing in the polling loop one might double check if the memory thinks its in SPI vs QPI mode, in SPI mode it's not going to be responsive to commands sent in 4-bit mode. So perhaps something earlier in the initialization, or that the part wasn't reset properly, or isn't responding.

Try running out of a fresh power-up.

Also watch that the default dummy cycles for the device differ from the value coded in the software, and so need to be configure to be consistent.

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