How can I write machine code into RAM and then execute it?
Posted: Sat Jul 17, 2021 3:33 pm
I want to write RISC-V machine code instructions to RAM from a program on an ESP32-C3-DevKitM-1 and then execute them.
If I define my code area as:
then I get the following error when I try to execute the machine code:
Guru Meditation Error: Core 0 panic'ed (Instruction access fault). Exception was unhandled.
If I define my code as:
I get the following error when I try to write to it:
Guru Meditation Error: Core 0 panic'ed (Memory protection fault).
memory type: IRAM0_SRAM
faulting address: 0x40380210
world: 0
operation type: X
Is there a RAM attribute that will allow me to both write to it and execute it, or any other suggestions?
If I define my code area as:
Code: Select all
uint8_t MyCode[64];
Guru Meditation Error: Core 0 panic'ed (Instruction access fault). Exception was unhandled.
If I define my code as:
Code: Select all
IRAM_ATTR uint8_t MyCode[64];
Guru Meditation Error: Core 0 panic'ed (Memory protection fault).
memory type: IRAM0_SRAM
faulting address: 0x40380210
world: 0
operation type: X
Is there a RAM attribute that will allow me to both write to it and execute it, or any other suggestions?