cancel
Showing results for 
Search instead for 
Did you mean: 

QuadSPI with STM32L4 and Micron-QSPI-Flash

Nor Sch
Associate III
Posted on December 22, 2016 at 14:38

I use a STM32L4 with a Micron N25Q032A (32 Mbit, 4Mx8). I have some Questions about this or similar Micron-Chips and hope to get here some Hints.

  1. After a PageWrite (Command 0x12 QUAD_IN_FAST_PROG) you have to poll the Status-Register until the WriteInProgress-Flag is getting from 1=busy to 0=ready. After this the Flash should be ready for next Command. But if I do not wait after this some more Time (1-2 ms) I will get Errors. I use FreeRTOS and so I use the osDelay. With 1ms there is a 10%-Chance that this will be not enough. With osDelay(2) I can write without further Problems. But why I have to wait here? This is not explained in the Datasheet of the QSPI-Flash ...
  2. This Variant is not supported by the ST-Link-Utility. To have a Solution out of the Box, for Instance a N25Q128 (8Mx16 with 16MB) could be used. This one is used for the STM32L476-Discovery-Board but it's not usable for my Project. But maybe someone has allready a new Driver / Plugin or a good and easy Howto to get the needed Plugin for the small 4-MB-Flash?
  3. Has anybody a Solution for Eclipse (System Workbench) how to integrate this Flash for XIP? Yeah, I have to define a Section, ok. And than? How I can tell the Eclipse (GCC / GPP) to generate one bin-File for Main-Project and a second one which I have to program into the QSPI-Flash? Is there a Solution to do this second program-Step with Eclipse so that I still can Debug even the Code executed from the QSPI-Flash?

#xip #qspi #quadspi #micron
4 REPLIES 4
Nesrine M_O
Lead II
Posted on December 22, 2016 at 16:27

Hi

Sch.Nor

‌,

I recommend you to refer to

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/b0/7e/46/a8/5e/c1/48/01/DM00227538/files/DM002275pdf/jcr:content/translations/en.DM002275pdf

a generic application note aboutthe Quad-SPI interface on the STM32 microcontrollers.

This documentexplains how to use the module to configure, program, and read external Quad-SPI memories.

Hope that help you to answer all your questions.

Also you can find a set of examples under the STM32L4 cube firmware package:

STM32Cube_FW_L4_V1.6.0\Projects\STM32L476G-Discovery\Examples\QSPI

-Nesrine-

Ifmy suggestanswers your question, please mark it as correct.

Nor Sch
Associate III
Posted on January 26, 2017 at 10:57

If you read my Questions it should be clear, that I already worked with the AN4760 and the Discovery-Example. So my Questions are still not answered.

(But maybe I will not have this Chip in the actual Project and so this Topic is for me not soooo important for now ... But maybe somebody else will need it or me again later.)

Nor Sch
Associate III
Posted on March 01, 2017 at 17:31

I'm back to this Topic and still have some Trouble to get it run.

What I have:

- HW as above

- Project with System Workbench (was a hard Way to get the needed Configurations it from the Examples ...)

- everything is located in RAM and at least the Debugging (into the Init) works

My Dev_Inf.c :

__attribute__((used)) struct StorageInfo const StorageInfo = {
 'N25Q032A_STM32L476', // Device Name + EVAL Borad name
 NOR_FLASH, // Device Type
 0x90000000, // Device Start Address
 0x00400000, // Device Size in Bytes (4MBytes)
 0x100, // Programming Page Size 256Bytes
 0xFF, // Initial Content of Erased Memory
 // Specify Size and Address of Sectors (view example below)
 0x00000040, 0x00010000, // Sector Num : 64 ,Sector Size: 64KBytes
 0x00000000, 0x00000000,
};�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

And my Loader_Src.h has these Function Prototypes:

int Init (void);
KeepInCompilation int MassErase (void);
KeepInCompilation int Read (uint32_t Address, uint32_t Size, uint8_t* buffer);
KeepInCompilation int SectorErase (uint32_t EraseStartAddress ,uint32_t EraseEndAddress);
KeepInCompilation uint64_t Verify (uint32_t MemoryAddr, uint32_t RAMBufferAddr, uint32_t Size, uint32_t missalignement);
KeepInCompilation int Write (uint32_t Address, uint32_t Size, uint8_t* buffer);
void QSPI_WriteEnable (QSPI_HandleTypeDef *hqspi);
HAL_StatusTypeDef QSPI_WaitFlagStateUntilTimeout (QSPI_HandleTypeDef *hqspi, uint32_t Flag, FlagStatus State, uint32_t Timeout);
void QSPI_WritePage (uint32_t Address, uint32_t Size , uint8_t* buffer);
//int QUADSPI_EraseSector (uint32_t address); // taken from own QUADSPI-Lib
void ResetMemory (QSPI_HandleTypeDef *hqspi);
void QUADSPI_SendData8 (uint8_t Data);
FlagStatus QUADSPI_GetFlagStatus (uint32_t QUADSPI_FLAG);
void QSPI_DummyCyclesCfg (QSPI_HandleTypeDef *hqspi);
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

So yes, I found and implemented Functions Read() and MassErase() which are missed in most Examples. With normal Debugging I directly jump into the Init() which makes the Stuff which is normally located in the here never called main() and I initialize there the QSPI as done in the Examples too. The Init() has no Main-Loop and is ended by a return 1 as all of the Functions having int as return-Type.

After renaming and copying the Elf to the STLink Utility I can add it as External Loader. Name, Size and Address are shown right. But if I try to connect to the External Flash I get this Error:

Some mandatory functions are missing in the elf loader.

There is no (useful) Documentation about the API and my exported Functions are looking right (for me) ... So after what I should look? Maybe something still is missing or must be configered in another Way? Every Hint is welcome ... But pls don't tell me anything about AN4760 or UM0892, they are Garbage for writing such an External Loader.

Nor Sch
Associate III
Posted on March 10, 2017 at 13:51

After getting it to work properly here some Hints for Others with same QSPI-STDLR-Task:

There is following Define in the Loader_Src.h:

#define KeepInCompilation __attribute__((used))�?

This is used for some of the Functions which are not called by the Init() or LS_Init() but needed from the STLink Utility. For me this was not working! Don't know why this should work with Atollic and GCC (Example-Project) but not with System Workbench and GCC ...

Anyway, you should use the Tool 'readelf' from the GNU Bin Utils (MinGW) to compare an working STDLR-File with your Elf. Another important Point is, that you should keep care about not enabling (or really fast disabling) the SysTick, look here:

https://community.st.com/0D50X00009XkhOASAZ

.

The Rest is mostly a

diligence Task.

By the Way you can remove a lot of the STM-QSPI-Code, because there is pretty much duplicate or useless Stuff ...