Possible to peek/poke to access RAM directly ? #5901
Replies: 1 comment
-
Posted at 2017-10-26 by @gfwilliams You should still be able to use peek and poke to access RAM. You wouldn't be able to allocate it, but you could at least find an area that was free and pray. However it's worth noting that typed arrays (apart from a 16 byte header) store bytes 1:1 - so realistically you might as well just do a big Posted at 2017-10-26 by Polypod Happy to hear that. How to find such a free area ? What address should I look for ? All I know is that RAM starts at 0x20000000. Should I start to write there until something bad happens ? The Uint8Array header seem to be 3 blocks long, even for short arrays. But apart from that, its store bytes 1:1 like you said. Thanks a lot, I will use that.
Posted at 2017-10-26 by @gfwilliams Ahh, now there's a question. There is And yes - sorry - there's the Uint8Array block, an ArrayBuffer block, and then a backing 'flat string' for the data - so 3 blocks. Posted at 2017-10-27 by @allObjects You can avoid the hassle of thinking of (absolute) addresses... As @gfwilliams mentions, allocation an Uint8Array (at the begin of your code) and using all kinds of views are a very easy and convenient way to do what you might want to do... (Nothing wrong with praying... - it's a very wise thing... just not for covering up subpar choices...) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-10-26 by Polypod
Hi,
Is it possible to read/write data directly in RAM at byte level with peek/poke ? I think of possibly storing more data in less memory than the limit of ~10bytes per byte with strings or typed arrays. It would be nice to be able to do a 1byte/byte data storage in ram like we do in flash.
In this thread (http://forum.espruino.com/conversations/288002/), they use peek to write at stackEndAddress in memory with ARM. But except the end of the stack with arm, is there a way in other boards, e.g. ESP8266, to allocate an area of RAM and get it's address for poking freely and safely ?
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions