Skip to main content
istepne
Associate III
September 14, 2019
Question

QSPI with stm32cubeIDE on custom stm32f746IGT board

Is there any one to help me on get QSPI work?

I am using n25q128 and the SPI pins;

 /**QUADSPI GPIO Configuration   

   PE2    ------> QUADSPI_BK1_IO2

   PF9    ------> QUADSPI_BK1_IO1

   PB2    ------> QUADSPI_CLK

   PD11    ------> QUADSPI_BK1_IO0

   PD13    ------> QUADSPI_BK1_IO3

   PB6    ------> QUADSPI_BK1_NCS

   */

I am trying to find out a sample code to get it work. I tried to test my hardware is OK or not via ST-Link External memory read&write but my hardware olsa used different pins. So, how can I change *.stldr file according to my hardware easily?

Regards,

Murat

void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)

{

 GPIO_InitTypeDef GPIO_InitStruct = {0};

 if(hqspi->Instance==QUADSPI)

 {

 /* USER CODE BEGIN QUADSPI_MspInit 0 */

 /* USER CODE END QUADSPI_MspInit 0 */

   /* Peripheral clock enable */

   __HAL_RCC_QSPI_CLK_ENABLE();

   __HAL_RCC_GPIOE_CLK_ENABLE();

   __HAL_RCC_GPIOF_CLK_ENABLE();

   __HAL_RCC_GPIOB_CLK_ENABLE();

   __HAL_RCC_GPIOD_CLK_ENABLE();

   /**QUADSPI GPIO Configuration   

   PE2    ------> QUADSPI_BK1_IO2

   PF9    ------> QUADSPI_BK1_IO1

   PB2    ------> QUADSPI_CLK

   PD11    ------> QUADSPI_BK1_IO0

   PD13    ------> QUADSPI_BK1_IO3

   PB6    ------> QUADSPI_BK1_NCS

   */

   GPIO_InitStruct.Pin = GPIO_PIN_2;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;

   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_9;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;

   HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_2;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;

   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_13;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;

   HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

   GPIO_InitStruct.Pin = GPIO_PIN_6;

   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

   GPIO_InitStruct.Pull = GPIO_NOPULL;

   GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

   GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;

   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

   /* QUADSPI interrupt Init */

   HAL_NVIC_SetPriority(QUADSPI_IRQn, 0, 0);

   HAL_NVIC_EnableIRQ(QUADSPI_IRQn);

 /* USER CODE BEGIN QUADSPI_MspInit 1 */

 /* USER CODE END QUADSPI_MspInit 1 */

 }

}

This topic has been closed for replies.

19 replies

AVI-crak
Senior
September 14, 2019

The algorithm for working with memory n25q128 is located in the documentation for this chip.

The algorithm for working with the qspi interface is in the stm32f746IGT documentation.

The program code for working n25q128 together with stm32f746IGT is already a driver, it will be unique in any case.

I can provide my example for the S25FL256S chip https://bitbucket.org/AVI-crak/system_f746/src/default/qspi_driver_S25FL256S/qspi_rw.c

Tesla DeLorean
Guru
September 14, 2019

You need to prove out your HW from your own application.

The STLDR are not particularly easy nor reliable.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
September 14, 2019

I accept PayPal

STM32F746IG

N25Q128A

CS PB6 AF10

CLK PB2 AF9

D0 PD11 AF9

D1 PF9 AF10

D2 PE2 AF9

D3 PD13 AF9

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Tesla DeLorean
Guru
September 15, 2019

Slightly different configuration

STM32F750N8

N25Q128A

CS PB6 AF10

CLK PB2 AF9

D0 PD11 AF9

D1 PD12 AF9

D2 PF7 AF9

D3 PD13 AF9

#STLDR

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
istepne
istepneAuthor
Associate III
September 20, 2019

Found the problem!

I have a look up the datasheet and the instructions that I send.

And the instruction 81h was not on the datasheet of the QSPI IC (winbond). I changed the W25Q128JVSIM (winbond) to MT25QL128ABA1ESE (Micron).

After that I can read and write via External Memory on CubeProgrammer (Sometimes can not RW).

And also I realized that the write operations to QSPI IC, can only change bits 1 to 0. So, I have to manage the write operations as; firstly reading 4096bytes from QSPI to RAM and Sector_Erase command and finally writing from RAM to QSPI with 4096bytes operation.

Regards,

Murat

Dams
Associate III
October 25, 2019

Hello,

I'm also using a SMT32F746IG with a MT25QL128ABA1E but my Hardware configuration seems to be slightly different:

  /**QUADSPI GPIO Configuration   

  PE2   ------> QUADSPI_BK1_IO2

  PF6   ------> QUADSPI_BK1_IO3

  PF8   ------> QUADSPI_BK1_IO0

  PF9   ------> QUADSPI_BK1_IO1

  PB2   ------> QUADSPI_CLK

  PB6   ------> QUADSPI_BK1_NCS 

  */

When I'm using .stldr file I'm not able to write on the external memory and when I read I get 0x99999999. Is the problem come from the stldr file ?

Any help shall be appreciated !

Regards,

Dams

Tesla DeLorean
Guru
October 25, 2019

Noted, I'll get to this in a bit..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
HP_it
Senior II
November 28, 2019

Any luck with this configuration?

Also - Would you care to shed a bit of light on the process of developing that .stldr file? I still can't find a single word of documentation on it...

istepne
istepneAuthor
Associate III
October 25, 2019

Hi Dams,

The .stldr file must be compiled and created according to your own hardware. In my case Mr Clive Two.Zero (thanks to him again) has created the .stldr file and I have successfully tested with MT25QL128ABA1ESE (Micron). First of all, check that the IC is compatible or not because the IC that I used was not compatible.

The second think The STM32CubeProgrammer is also can read & write the external QSPI memory. But, "Device Memory" window, displaying the memory, sometimes reads as all 0x00 and seems to be work. Try to connect and disconect to get back working with QSPI.

STM32CubeProgrammer "Download Flash" section (external loader enabled) when programming is works.

And also mostly failed when mapped mode is activated with trying TouchGFX tests.

Now, I switched to STemWin and currently I am using the QSPI memory as storage.

Regards,

Murat

Dams
Associate III
October 25, 2019

Hi,

Thanks for all advices.

I now have something pretty working, I can read and write data but the problem is that after switch the power off , data disapear. I read 0xff everywhere after power again the board.

If I connect -> write data -> disconnect (from soft) -> reconnect -> data are correctly read.

It's like if data are written on MCU RAM instead of QSPI Flash.

If someone has an idea, thanks to give it to me :)

Regards,

Dams