Storage not able to write, but Flash can? #7632
Replies: 1 comment
-
Posted at 2021-05-08 by @fanoush at least P8 watch has SPI shared with display, didn't you try writing to display? also the flash chip can be sleeping, you can try something like
hopefully it should print something else than all zeroes or all FFs Posted at 2021-05-09 by Mark_wllms Thanks @fanoush. The flash module appears to work, so I doubt anything is wrong with SPI interface. I know storage module does wear levelling, so I assume it caches its state somewhere, and maybe that has become corrupted. Is there a way to wipe the storage entirely and start again? I tried, but managed to wipe the bootloader instead! Posted at 2021-05-09 by Mark_wllms Sorry, worked it out - I had misunderstood the process.memory readout! It reads: flash_code_start: 1610612736, flash_length: 524288 So I just did this and everything works:
Posted at 2021-05-09 by @fanoush oh, there is Posted at 2021-05-09 by Mark_wllms I tried that several times, but it didn't help. I'm not sure why, I've looked at the code, and it does erase the same area. Posted at 2021-05-09 by @fanoush
The code above that worked is writing internal nrf52 flash, not SPI flash. Something was probably wrong with SPI flash at that time - you got the " InternalError: Timeout on jshFlashWrite at line 1 col 44" which looks like bad communication over SPI. Anyway, looks like it is working now. Posted at 2021-05-10 by Mark_wllms Thanks for the help, and explaining the difference between internal and external flash. I'm glad it started working, but I'm at a loss to work out what made it better. It's possible the battery ran down and it restarted. Posted at 2021-05-10 by @fanoush Flash API was previously only for internal nrf52 flash, with Bangle.js Gordon added virtual mapping of SPI flash to 0x60000000 so now it does both based on address, see https://github.com/espruino/Espruino/blob/master/targets/nrf5x/jshardware.c#L2289 the
the SPI code I pasted could wake it up from sleep or setup SPI pins again, but if it worked before then I don't know, power cycling could help of course too |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-05-08 by Mark_wllms
I am running the P8 SPIFLASH version of Espruino by @fanoush on a similar smart watch, but I have managed to get the Flash memory into a strange state whereby I cannot write to it with the Storage class.
The Flash is writeable - I can update the bootloader and flash Espruino builds to it. I can also erase, read and write flash pages, but any attempt to write a file fails with a timeout. Rebooting doesn't help. This device has been working well, and I had been reading and writing to Storage, but it seems that something is out of alignment!
process.memory()
={ free: 2490, usage: 75, total: 2565, history: 50,
gc: 0, gctime: 3.69262695312, blocksize: 16, stackEndAddress: 536928984, flash_start: 0,
flash_binary_end: 396828, flash_code_start: 1610612736, flash_length: 524288 }
require("Flash").getFree()
=[
{ addr: 397312, length: 86016 }
]
require("Storage").getFree()
=4194304
require("Flash").read(8,397312)
=new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255])
require("Flash").write("hello",397312)
=undefined
require("Flash").read(8,397312)
=new Uint8Array([104, 101, 108, 108, 111, 255, 255, 255])
require("Storage").list()
=[ ]
require("Storage").write("test.dat","hello")
Uncaught InternalError: Timeout on jshFlashWrite
at line 1 col 44
require("Storage").write("test.dat","hello")
Attachments:
Beta Was this translation helpful? Give feedback.
All reactions