SAME70 QSPI XIP Quad SPI External Flash Memory SMM Write Problem

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

I am trying to write to a flash memory (S25FL064L) via QSPI, I have enabled SMM (serial memory mode) in the QSPI module. I use XIP (execute-in-place) example from Atmel Start.

 

I can read from it just fine, but when I try to write, my logic analyser shows that the SAME70 is appending at least 3 bytes per byte to the buffer, e.g. if I write 0x30, it will output 0x30, 0x20, 0xFF, 0xFF.

I tried to change the pointer type from uint8_t to uint32_t, it just made the matter worse.

 

The library access the flash memory via location 0x80000000 (SMM). Seems like this block from hpl_qspi.c is causing problem (dst is 0x80000000):

/**
 * \brief Memory copy function.
 *
 * \param dst  Pointer to destination buffer.
 * \param src  Pointer to source buffer.
 * \param count  Bytes to be copied.
 */
static void _qspi_memcpy(uint8_t *dst, uint8_t *src, uint32_t count)
{
	while (count--) {
		*dst++ = *src++;
	}
}

 

I have read an appnote: https://www.microchip.com/wwwApp...

 

It did mention about strongly ordered memory, but, I am not sure how to enable it using the APIs from Atmel Start.

 

Any ideas?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The problem can be seen in the following logic analyser capture:

 

QSPI Issue

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
static void _qspi_memcpy(uint64_t *dst, uint64_t *src, uint32_t count)
{
	while (count--) {
		*dst++ = *src++;
	}
}

 

Well, I found a workaround, but, it is not pretty.

I can read in uint8_t, but, I can only write in uint64_t.

For consistency, I decided to do both read and write in uint64_t.

Basically, I just change both dst and src pointer type from uint8_t to uint64_t.

This will allow me to only read/write in 8-byte chunks. Not ideal, but, it will do for now.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just ran into this same problem.  Single byte writes to a serial flash chip using a SAM E70 QSPI module in Serial Memory Mode sends seven unwanted extra bytes.  In your timing diagram it looks like those seven extra bytes are always 0xff.  I'm seeing garbage bytes for those extra seven bytes.

 

I did see some notes about making sure to setup the Memory Protection Unit (MPU) prior to writing.  No effect though - it seems to be more important to reset it for XIP during read cycles to prevent memory access privilege errors.

 

The good news is the work around you posted to write in 8-byte chunks behaves as expected.  The downside is the caller must ensure writes occur in 8-byte chunks AND the incoming pointers are aligned to 8-byte boundaries to prevent Hard Faults.