flash alignment #5017
Replies: 1 comment
-
Posted at 2015-10-01 by tve Oops, scratch that comment. I now see that flash is read and written one byte at a time when called from JS!? Killer... The reason this is an issue is that flash is memory-mapped in the esp8266 because it executes most of the code directly from flash (there's a 32KB instruction cache). When reading or writing arbitrary cache locations the SDK first has to disable the memory mapping, then perform the SPI transactions, then re-enable the mapping. So there's quite some overhead. It may or may not matter for small stuff, like a few KB, but this would most likely not be a good interface to do the firmware upgrade through. Posted at 2015-10-02 by @gfwilliams Since flash is memory mapped, the reads can presumably just come right off the mapped memory, so are basically just a memcpy that doesn't have to be aligned? Enforcing alignment on read wouldn't be the end of the world, but I don't think it's needed? But yeah, write should always be aligned. I remember having to write the code to ensure it :) Posted at 2015-10-02 by tve I had to write the read-alignment code, but it's done now and works :-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-10-01 by tve
In the context of the esp8266 port, I'm wondering about flash read and write alignment. jswrap_flash_write documents and enforces 4-byte alignment, which is great: https://github.com/espruino/Espruino/blob/master/src/jswrap_flash.c#L88-L122 But jswrap_flash_read doesn't (and the comment talks about writing https://github.com/espruino/Espruino/blob/master/src/jswrap_flash.c#L132). Are unaligned reads necessary? (Yes, it does complicate the implementation.)
Beta Was this translation helpful? Give feedback.
All reactions