I am trying to write data into a flash ram and then reading it back. I don’t understand why the flashRAM->read() call does not return the same bytes that I have written via flashRAM->write(). Below is a short test program. if you run it make sure to open the serial connection to be able to see the dump of the original data. After 5 secs it dumps the original data and after 10 secs the flashRAM bytes and they don’t match.
I am having major problems using the flashee library. Here is a code that creates 1 red blink (Hardware error I believe) and I dont know why. Is there any more comprehensive manual or examples than the description found under the git link?
@kennethlimcp: I am not sure I understand your comment. Why would the location of the destination buffer play a role? You might have suggested what is show below, but it crashes with the same error. See the line with the comment. If you do not specify location and size of the FlashRam then it does not crash:
@mdma: thanks for the clarification on the usage of the lib. I changed the code to 10*4096 and it works now.
I am only writing 8 bytes per minute, is that within the assumed usage?
If you don’t need to use the rest of the flash then make the area much larger, e.g. 1284096 - the larger the area the more free pages and the greater erase count. With the addressErase scheme you get ca. 100,000free pages erases. You may get a lot more - It depends where you’re writing those 8 bytes to - or more specifically what they are overwriting.
Thanks for posting the code - very useful tool in trying to reproduce the problem.
However, the system doesn’t crash for me. It’s been running for 30 minutes with no crash. It could be a result of corrupted data in your external flash. As a precaution, you could clear the flash memory - this is done by adding this call:
Flashee::Devices::userFlash().eraseAll()
However, ideally flashee should never crash regardless of what is in the flash memory from before. Perhaps you could help me diagnose the problem by taking a copy of your external flash first before clearing, so I can investigate? You can do that using dfu-util:
dfu-util -d 1d50:607f -a 1 -s 0x00080000:0x180000 -D sflash.bin
@mdma: I tried your command and this is the result, it did not write the file because of ‘No such file or directory’
dfu-util 0.7
Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org
Filter on vendor = 0x1d50 product = 0x607f
Opening DFU capable USB device... ID 1d50:607f
Run-time device DFU version 011a
Found DFU: [1d50:607f] devnum=0, cfg=1, intf=0, alt=1, name="@SPI Flash : SST25x/0x00000000/512*04Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
sflash.bin: No such file or directory
@mdma: did the memory dump lead you anywhere?
Using Flashee::Devices::userFlash().eraseAll() solved the problem and it does not crash any more.
Is there a way to find out if calling eraseAll() is necessary?