Hi all,
I'm working on a project where I need to load and execute code dynamically from an SD card. Specifically, I’m allocating memory in RAM2 using malloc(), copying precompiled function code into that memory region, and then trying to call it via a function pointer.
The code seems to load fine, but when I try to call the function pointer, the Teensy 4.0 crashes after a few seconds (when attempting to run the set function but it doesn't run it).
Digging through the i.MXRT1062 reference manual, I came across the IOMUXC_GPR_GPR17 register, which appears to control executable regions among other things. In my current setup (after loading the SD card code and initializing everything else), this register ends up having the value 0xAAAAAAAF.
I’m wondering:
I'm working on a project where I need to load and execute code dynamically from an SD card. Specifically, I’m allocating memory in RAM2 using malloc(), copying precompiled function code into that memory region, and then trying to call it via a function pointer.
The code seems to load fine, but when I try to call the function pointer, the Teensy 4.0 crashes after a few seconds (when attempting to run the set function but it doesn't run it).
Digging through the i.MXRT1062 reference manual, I came across the IOMUXC_GPR_GPR17 register, which appears to control executable regions among other things. In my current setup (after loading the SD card code and initializing everything else), this register ends up having the value 0xAAAAAAAF.
I’m wondering:
- Can you run executable code from RAM2 on the Teensy 4.0?
- Do I need to modify IOMUXC_GPR_GPR17 to make this possible?
- Is there anything else that needs to be configured to allow execution from RAM2?