LowPowerLab Forum

Hardware support => General topics => Topic started by: TomWS on February 04, 2015, 03:58:35 PM

Title: Question about SPIFlash writeBytes function
Post by: TomWS on February 04, 2015, 03:58:35 PM
Felix, I got bit earlier in the week when I discovered that writeBytes won't write more than 256 bytes into flash.  I'm now wondering if I have to check to see if a block of data crosses a 256 byte boundary.  Do I?

The simple thing in the first case was to do multiple calls to writeBytes, sending no more than 256 bytes at a time, but I'm not sure why you don't take care of this case in the library function (considering how easy it is) AND, if this was done, then boundary checking (if it's necessary by the hardware) could/should be done there too...

Tom
PS: If you agree with both of these conclusions then some nice user just might do the code for you...
Title: Re: Question about SPIFlash writeBytes function
Post by: Felix on February 04, 2015, 08:52:36 PM
The limitation is because of the way these chips can write to their internal arrays.
The lib is very bare bones when it comes to writing data. It's easier to write 1 byte at 1 time as done in the WirelessHEX69 library for writing a large piece of code in the flash chip.
That's not to say that accepting an "endless" byte buffer to write should not be added to the lib as enhancement, it's something I will consider.
Title: Re: Question about SPIFlash writeBytes function
Post by: TomWS on February 05, 2015, 08:49:05 AM
I'll update SPIflash with a branch and send you a pull request.  ISTM that users of this library shouldn't need to be aware of the flash's organization and limitations.

Tom
BTW, as a head's up, as you know, I'm working with Kiwisincebirth on the SPI transactions update and these changes need to be applied to SPIflash as well.  I'll do this on a separate branch, however.
Title: Re: Question about SPIFlash writeBytes function
Post by: Felix on February 05, 2015, 08:57:20 AM
Your contributions are appreciated, thanks. I agree the user should not be aware how the flash stores data.
I believe Kiwisincebirth already submitted a pull request that I haven't had time to analyze yet, it's a really major change so not something I can quickly browse through.
Title: Re: Question about SPIFlash writeBytes function
Post by: TomWS on February 05, 2015, 09:51:34 AM
Quote from: Felix on February 05, 2015, 08:57:20 AM
I believe Kiwisincebirth already submitted a pull request that I haven't had time to analyze yet, it's a really major change so not something I can quickly browse through.
I just looked and didn't see a fork or a pull request from anyone.  He has a pull request on RFM69 and that may be what you're thinking.  I've forked SPIFlash and will update with this writeBytes change.

Tom
Title: Re: Question about SPIFlash writeBytes function
Post by: TomWS on February 07, 2015, 08:07:55 PM
Quote from: TomWS on February 05, 2015, 09:51:34 AM
Quote from: Felix on February 05, 2015, 08:57:20 AM
I believe Kiwisincebirth already submitted a pull request that I haven't had time to analyze yet, it's a really major change so not something I can quickly browse through.
I just looked and didn't see a fork or a pull request from anyone.  He has a pull request on RFM69 and that may be what you're thinking.  I've forked SPIFlash and will update with this writeBytes change.

Tom
Branch is here with a pullrequest:
https://github.com/TomWS1/SPIFlash/tree/writeBytes-Update

Tom