A bare metal programming guide
github.com26 pointsby drozd7 comments
// C
void setmem(uint8_t *ptr, int index, int value) {
ptr[index] = value;
}
// mJS
let setmem = ffi('void setmem(void *, int, int)');
let malloc = ffi('void *malloc(int)');
let mem = malloc(10);
setmem(mem, 3, 5);
But the firmware image (that resides on flash), which has .text and .data concatenated, has that .data section in Flash region, obviously. So we have .data section residing in Flash region, but all its addresses in the RAM memory range. That's why it is necessary to copy it over manually.
Hope this is clear... Let me know if not!