cancel
Showing results for 
Search instead for 
Did you mean: 

Custom External Quad SPI Loader

Yunus ARI
Senior

Hi everyone,

I am trying to create an external loader for my project by ST's "How to create an external QSPI loader MOOC" lesson. Actually lesson's github repository have microcontroller and quad spi flash configurations that I use.  I just change some pin configurations for my board's need.

Although I do everything like lesson but my external loader doesn't work correctly. It load flash shifting a byte. For example if my first 4 byte is {11 22 33 44}, external loader is loading these bytes flash like this {22 33 44 xx}. My all data is becoming can't usable because of this problem. 

What am I do wrong? Somebody help me pls :(.

Thanks in advance. Be healthy.

9 REPLIES 9

Implement and test your BSP code outside the loader context where you can debug it and understand what's going on.

Create a test harness/fixture for the loader itself if that helps.

Byte shift could be a disagreement about dummy cycles.

All the UART and LEDs on your board are usable for diagnostic output/signalling.

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

Actually lessons code have a test harness. I implemented this section to my project like this;

  	uint8_t buffer_test[MEMORY_SECTOR_SIZE];
      uint32_t var = 0;
 
  	CSP_QUADSPI_Init();
 
  	for (var = 0; var < MEMORY_SECTOR_SIZE; var++) {
  		buffer_test[var] = (var & 0xff);
  	}
 
  	for (var = 0; var < SECTORS_COUNT; var++) {
 
  		if (CSP_QSPI_EraseSector(var * MEMORY_SECTOR_SIZE,
  				(var + 1) * MEMORY_SECTOR_SIZE - 1) != HAL_OK) {
 
  			while (1)
  				;  //breakpoint - error detected
  		}
 
  		if (CSP_QSPI_WriteMemory(buffer_test, var * MEMORY_SECTOR_SIZE,
  				sizeof(buffer_test)) != HAL_OK) {
 
  			while (1)
  				;  //breakpoint - error detected
  		}
 
  	}
 
  	if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK) {
 
  		while (1)
  			; //breakpoint - error detected
  	}
 
  	for (var = 0; var < SECTORS_COUNT; var++) {
  		if (memcmp(buffer_test,
  				(uint8_t*) (0x90000000 + var * MEMORY_SECTOR_SIZE),
  				MEMORY_SECTOR_SIZE) != HAL_OK) {
  			while (1)
  				;  //breakpoint - error detected - otherwise QSPI works properly
  		}
  	}

When I debug code with this, code stopped to last "while". My quad spi configuration like this;

0693W000007Z8kPQAS.png 

Thanks for reply.

Not sure what I'm supposed to do with the code/config presented.

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

maybe you can see something I didn't realize?

It's all pretty top-level superficial stuff.

You'd want to look at the commands being sent, the dummy cycle configurations, and the mode settings and expectations of the device, say quad mode, and 3 or 4 byte addressing.

I'd probably have 1-bit and 4-bit read operations immediately after the write to cross-check that works before doing the memory mapping.

Right now I have no idea what STM32, which pins, what QSPI Memory device are involved here.

Figuring a 256 Mbit (32MB) device, needing 4-byte addressing.

For the H7 I'd watch for the end-of-memory errata on the QSPI

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

I use STM32H743XI microcontroller and MT25QL512 quad spi nor flash. I am using exact same Loader files and quad spi drivers in this repository. Maybe these would be revealing

I will look up to your saying.

Did you pull the appropriate quadspi.c / quadspi.h files? The default ones have a broken implementation with respect to configuring the Micron parts.

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

Yes, I did. Repository has just user side of code. When compiled cubemx project it creating needed stuff inside the source/header files. Project cubemx side is based on me. So I pretty sure problem is here. :grinning_face_with_sweat:

Yunus ARI
Senior

I did everything the same with the yours lesson and example code but still my code didn't work. Is there any advice to solve problem?

@Tilen MAJERLE​  @christophe cadoret​