How should one resolve the issue when that does arise ?
As far as I can tell the only option is to clone the parts of the Pico SDK which contain the called functions in Flash, edit those to make them local 'run in RAM' functions, repeat for everything those call in Flash.
It seems it would be possible to scan one's own source see what is 'run in RAM' and should not call Flash, run through Pico SDK to find those routines, clone them as 'run in RAM', and repeat recursively but that would seem to be a lot of work, having to handle pre-processing directives and macros or one is likely to miss something.
Is there such a tool already ?
Or some way to use CMake to build object code with the RAM-based functions which uses normal includes, make that all 'run in RAM' and then link it with the rest of the code which runs in Flash ?
I know one can build an entire project to 'run in RAM' or 'copy to RAM' but in my case it's MicroPython which is too large to run from RAM but I'm needing to call routines which must, along with all they call, run solely in RAM.
So far my 'run in RAM' module calls 'save_and_disable_interrupts', 'flash_range_erase', flash_range_program' and 'watchdog_reboot'. The first is "inline" so I'm presuming it will be in-lined into RAM ( but is that guaranteed ? ), the erase and program are '__no_inline_not_in_flash_func' so safe to call, but 'watchdog_reboot' is in Flash and I haven't dug down into what that calls.
That should be possible to solve by hand but I am expecting my calls from RAM into Pico SDK to expand.
Code: Select all
.-----------------------------------.----------------------------.
| MicroPython - Run in Flash | Pico SDK - Run in Flash |
`-------.---------------------------^----------------------------'
| /|\
/ | .---------. .-------------------. |
| `-->| My func |--->| disable interupts | |
| | |--->| erase flash | |
RAM | | |--->| write flash | |
| | | `-------------------' |
| | | |
| | |----- watchdog reboot -------'
\ `---------'