Skip to main content
Lagodolio
Associate III
January 20, 2021
Question

QSPI W25q128 and TouchGFX: error in the final launch stage

  • January 20, 2021
  • 9 replies
  • 5840 views

Hello!

I'm using TouchGFX for a project, LCD and touch module are OK, but I have some problems with the QSPI driver (W25Q128 module).

I'm able to compile all the code and I see QSPI flash memory as used, but it gives me an error in "final launch sequence".

After including stm32746g_qspi.h (well, my board is an H743, but this file is modified by the vendor Waveshare: even if the name seems wrong, as you can see, it includes H7 headers):

//This is the stm32746g_qspi.h initial part
...
#ifndef __STM32746G_QSPI_H
#define __STM32746G_QSPI_H
 
#ifdef __cplusplus
 extern "C" {
#endif 
 
/* Includes ------------------------------------------------------------------*/
#include "stm32H7xx_hal.h"
#include "w25q128fv.h"
 ...

 So I put some initialization lines in MX_QUADSPI_Init() function:

void MX_QUADSPI_Init(void)
{
 
 hqspi.Instance = QUADSPI;
 hqspi.Init.ClockPrescaler = 10;
 hqspi.Init.FifoThreshold = 4;
 hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE;
 hqspi.Init.FlashSize = 23;
 hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE;
 hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
 hqspi.Init.FlashID = QSPI_FLASH_ID_1;
 hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
 if (HAL_QSPI_Init(&hqspi) != HAL_OK)
 {
 Error_Handler();
 }
 
 
 BSP_QSPI_Init();
 BSP_QSPI_MemoryMappedMode();
 HAL_NVIC_DisableIRQ(QUADSPI_IRQn);
}

 The function BSP_QSPI_MemoryMappedMode() function is not present in vendor's stm32746g_qspi.c , so I wrote this :

uint8_t BSP_QSPI_EnableMemoryMappedMode(void)
{
 QSPI_CommandTypeDef s_command;
 QSPI_MemoryMappedTypeDef s_mem_mapped_cfg;
 
 /* Configure the command for the read instruction */
 s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE;
 s_command.Instruction = QUAD_INOUT_FAST_READ_CMD;
 s_command.AddressMode = QSPI_ADDRESS_4_LINES;
 s_command.AddressSize = QSPI_ADDRESS_24_BITS;
 s_command.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
 s_command.DataMode = QSPI_DATA_4_LINES;
 s_command.DummyCycles = W25Q128FV_DUMMY_CYCLES_READ_QUAD;
 s_command.DdrMode = QSPI_DDR_MODE_DISABLE;
 s_command.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
 s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
 
 /* Configure the memory mapped mode */
 s_mem_mapped_cfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
 s_mem_mapped_cfg.TimeOutPeriod = 0;
 
 if (HAL_QSPI_MemoryMapped(&QSPIHandle, &s_command, &s_mem_mapped_cfg) != HAL_OK)
 {
 return QSPI_ERROR;
 }
 
 return QSPI_OK;
}

and, in stm32746g_qspi.h

#define BSP_QSPI_MemoryMappedMode BSP_QSPI_EnableMemoryMappedMode

Finally, I modified my linker file and after compiling (without error) I can see the ToughGFX ExtFlashSection loaded in QUAD SPI.

0693W000007C3MqQAK.pngThe problem is that the firmware isn't loaded on my board and I have this error:

0693W000007C3QOQA0.pngCan someone help me?

Thanks and Best Regards!

This topic has been closed for replies.

9 replies

Tesla DeLorean
Guru
January 20, 2021

>> but it gives me an error in "final launch sequence".

You've got to love the steaming heap that's been delivered here..

Yeah, so that's probably not related to your code, but rather the need for an external loader at the download/debug level that can handle your custom hardware. The processor doesn't have any internal way to deliver data to external memories (random devices, using random pins, etc, billions of possibilities)

Tools like STM32 Cube Programmer need a custom "External Loader", as small RAM based loader applet that configures the clocks, pins, peripherals and implements Erase, Write and Read functionality.

If you have an External Loader (.stldr) you need to tell the tools about it, where to find it, etc.

If you don't have one, you've got to write one. Or find one. I've posted ones for the W25Q128 in the past.

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
January 20, 2021
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
January 20, 2021

Pro-tip, don't attach half-a-dozen files, ZIP them up as a set, with a UNIQUE name and upload that.

Also files with not useful content should be omitted if you're attaching a sub-set of things, quadspi.h is 99.9% boilerplant

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Lagodolio
LagodolioAuthor
Associate III
January 21, 2021

Well, you are right but I thought that it should be more practical having single files... In addition, I noticed that it lost the extension (.c, .h aren't present any longer).

So I'll re-upload the files, as you suggested. Thanks!

Lagodolio
LagodolioAuthor
Associate III
January 21, 2021

Now I'm trying to create my external loader: in STM video MOOC(video n°5) a quadspi.c and a quadspi.h are copied from the QSPI Drivers directory (in external loader example). In quadspi.c some functions use defined values:

uint8_t CSP_QSPI_WriteMemory(uint8_t* buffer, uint32_t address,uint32_t buffer_size) {
 
	QSPI_CommandTypeDef sCommand;
	uint32_t end_addr, current_size, current_addr;
 
	..... //some code lines
 
	sCommand.Instruction = QUAD_IN_FAST_PROG_CMD;
	sCommand.AddressMode = QSPI_ADDRESS_4_LINES;
	
 ..... //some code lines

Because I'm using a different product (W25Q128) I have to modify quadspi.h according to my chip ... but "QUAD_IN_FAST_PROG_CMD" isn't defined in my W25q128.h file (attached in my prev message), only QUAD_INPUT_PAGE_PROG_CMD! The same happens with other instructions.

Can someone help me?

Tesla DeLorean
Guru
January 21, 2021

There isn't uniformity in the naming between ST, WAVESHARE and WINBOND vs MICRON, suggest you pull the data sheet so you understand the expectations in address and data widths..

#define QUAD_INPUT_PAGE_PROG_CMD            0x32

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Lagodolio
LagodolioAuthor
Associate III
January 22, 2021

Ok, Thanks Tesla DeLorean for your kindness.

My idea is to create, step-by-step, an ExtLoader also for a "didactical" approach, but I think that the porting of a driver is not so simple...

I have a question: if I use CLIVEONE-W25Q128_STM32H7XX-PB2-PB6-PF8-PF9-PE2-PF6.stldr with a simple program (just an initialization of QSPI device on proper pins) -after disabling the "verify flash download"- I have no problems (but I don't try to access QSPI Flash). 

With TouchGFX all seems more problematic: the compiling phase is OK but the screen shows no images.

During the programming, a message "handle_vCont_c, continue thread" is displayed . Is it normal?

  ------ Switching context ----- 

Target connection mode: Under reset

Reading ROM table for AP 0 @0xe00fefd0

Hardware watchpoint supported by the target 

COM frequency = 4000 kHz

ST-LINK Firmware version : V2J37M26

Device ID: 0x450

PC: 0x8004d20

ST-LINK detects target voltage = 0.10 V

ST-LINK device status: HALT_MODE

Run external memory initializer

ST-LINK device status: RUN_MODE

ST-LINK device status: HALT_MODE

ST-LINK device initialization OK

handle_vCont_c, continue thread

Debugger connection lost.

Shutting down...

PCabr.1
Associate II
July 14, 2021

Hello @Peter Szucs​ 

I'm having the same problem in my project, i can write, erase sector, read the memory W25Q128JV, but I'm trying to generate a custom loader for my project using the touchGFX for STM32H7B3VI with mappedmode, but nothing is working for now.

Could you share your example project to generate the custom loader with me?

I saw the link from github that @Community member​  sent you, but none of those have my pinout.

 /**OCTOSPI1 GPIO Configuration

  PA7   ------> OCTOSPIM_P1_IO2

  PB2   ------> OCTOSPIM_P1_CLK

  PD11   ------> OCTOSPIM_P1_IO0

  PD12   ------> OCTOSPIM_P1_IO1

  PD13   ------> OCTOSPIM_P1_IO3

  PB6   ------> OCTOSPIM_P1_NCS

I don't know if my linker file have something wrong or the loader_SRC file as well, i was following the ST Video to generate this customer loader.

Tesla DeLorean
Guru
July 14, 2021

The H7Ax/Bx have OCTOSPI, and are a little different in implementation to the H74x/75x code I currently have running.

I'll probably need to port the code, adding it to my TODO list.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
PCabr.1
Associate II
July 14, 2021

thanks for your message, but let me ask something.

when you say a little different, you mean about the all of routines to read, write, erase, mappedmode, polling??? because i have this functions working.

or about the Loader_SRC, Dev_inf files to generate the external loader properly? this i really don't know what exactly is right or no.

Tesla DeLorean
Guru
July 14, 2021

I'm not using CubeMX, I'm using HAL code, with a version of the library with only QSPI/QUADSPI support, I'll need to migrate that to a newer version of the library using OCTOSPI, and the newer/slower H7.

I might just be able to change the pin table, but I'm currently skeptical it will be that easy.

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
July 14, 2021

IO2 PA7:AF10 is only available on the H7Ax/Bx parts

More generally I'm likely going to need to wire a ZIF socket up to a NUCLEO-H7A3ZI to get some level of confidence in the code/implementation.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
PCabr.1
Associate II
July 15, 2021

Yes you are right, this parts are pretty good to IHM application, if helps i have my C code for communication with the memory, the function are working, and as you told are some difference between QSPI and OSPI code.

I'm working now at the file LOADER_SRC to adapt this one to generate the right external loader, based on the post of below.

https://community.st.com/s/question/0D53W00000e1oaTSAQ/external-loader-works-on-stm32cubeprogrammer-but-read-operation-returns-incorrect-data

https://github.com/manoloaterol/MCUDEV_DevEBox_H743-W25Q64-EL/blob/master/Core/Src/Loader_Src.c

PCabr.1
Associate II
July 29, 2021

hi @Community member​  this is good.

i Did work my custom loader for STM32H7B3 with W25Q128. please look my project, everything is working. the project now is okay, we have to make some initialization on the main.c to the touchgfx works well.