Parsing bytecode from flash memory
Both arduino / esp idf can place read only data in flash ( at least 4MiB even on the cheapest esp8266 devboards ) arduino with PROGMEM and espidf with ICACHE_FLASH_ATTR attributes
nb: that's only for parser , i don' t know implication with memory at runtime later
eg
unsigned char PROGMEM app_wasm[] = {
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x94, 0x01, 0x14,but when reading those addresses some special function must be used because data is re mapped to iram via a spi read aligned to 4 bytes on esp*.
so a function like Read_u8 https://github.com/wasm3/wasm3-arduino/blob/bc181e11fba387119e306f1b0fcc6ca52aa96bd7/src/m3_core.c#L313 could be in fact written with a *_P function
M3Result Read_u8 (u8 * o_value, bytes_t * io_bytes, cbytes_t i_end)
{
const u8 * ptr = * io_bytes;
ptr += sizeof (u8);
if (ptr < i_end)
{
//* o_value = * ptr;
memcpy_P(o_value, *io_bytes, sizeof(u8));
* io_bytes = ptr;
return m3Err_none;
}
else return m3Err_wasmUnderrun;
}( tested on esp8266 works fine )
ref : https://bbs.espressif.com/viewtopic.php?t=1183 https://arduino-esp8266.readthedocs.io/en/latest/PROGMEM.html
Source: wasm3/wasm3