ESP8266 Developer Zone The Official ESP8266 Forum 2015-09-30T06:26:43+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1167 2015-09-30T06:26:43+08:00 2015-09-30T06:26:43+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1167&p=3924#p3924 <![CDATA[Re: why spi_flash_read/spi_flash_write requires uint32 *]]>
derekh wrote:
I would assume length must be multiples of 4-byte as well.
That is correct. I apologize for omitting that.

derekh wrote:
But I thought NOR flash is byte addressable and can be read/written on any boundary, length?
For reading, yes. For writing, most/many chips have a minimum size (a "page") that must be written. If you want to write fewer bytes than the page size you must do a read-modify-write. Some Flash chips are byte-writeable - you must read the datasheet for the chip to learn what the particulars are.

Be that as it may, I believe the the size, address alignment and data alignment restrictions arise due to the way that the Flash chip is mapped into the ESP8266 address space.

Statistics: Posted by dkinzer — Wed Sep 30, 2015 6:26 am


]]>
2015-09-30T04:01:50+08:00 2015-09-30T04:01:50+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1167&p=3923#p3923 <![CDATA[Re: why spi_flash_read/spi_flash_write requires uint32 *]]>
Thanks for the reply. I check the SDK doc again and did see it also clearly states that pointers must be int-aligned. I would
assume length must be multiples of 4-byte as well.

But I thought NOR flash is byte addressable and can be read/written on any boundary, length?

Thanks!

derek

Statistics: Posted by derekh — Wed Sep 30, 2015 4:01 am


]]>
2015-09-29T10:47:39+08:00 2015-09-29T10:47:39+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1167&p=3902#p3902 <![CDATA[Re: why spi_flash_read/spi_flash_write requires uint32 *]]>
derekh wrote:
Doe this mean the memory buffer has to be integer (32-bit) aligned?
Yes. Attempting to read/write from a Flash address that is not on a 32-bit boundary or using a buffer that is not 32-bit word aligned will (almost certainly) result in an exception. It is a simple matter to write helper routines that take arbitrary addresses and arbitrarily aligned buffers and perform properly aligned read/write operations.

As for your comment about the void * parameters, a void pointer might be 32-bit aligned or not. Similarly, a uint32_t pointer might be 32-bit aligned or not depending on compiler directives. It is up to the programmer to ensure that the proper alignment is used for any call. The provider's responsibility is to clearly describe what the requirements are.

Statistics: Posted by dkinzer — Tue Sep 29, 2015 10:47 am


]]>
2015-09-29T09:40:00+08:00 2015-09-29T09:40:00+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1167&p=3901#p3901 <![CDATA[why spi_flash_read/spi_flash_write requires uint32 *]]>
SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size);
SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size);

Here flash address is just uint32, but the memory side pointer (src_addr in write or des_addr in read) is pointer to uint32.

Why is that? Doe this mean the memory buffer has to be integer (32-bit) aligned?

Can the addr in flash side be any non-integer-aligned address?

This seems odd.

In rboot posted by rburton, he has this:

// esp8266 built in rom functions
extern uint32 SPIRead(uint32 addr, void *outptr, uint32 len);
extern uint32 SPIEraseSector(int);
extern uint32 SPIWrite(uint32 addr, void *inptr, uint32 len);

Note here both memory pointers are void *.

Can folks at Espressif please clarify this.

If memory side does not be integer-aligned, please fix the prototypes.

Thanks!

derek

Statistics: Posted by derekh — Tue Sep 29, 2015 9:40 am


]]>