Just as a layman for return from RAM App to Flash: wouldn't be this handled automatically by the CPU when returning from
Steve, I think I have seen in the assembly code generated that saving the registers is left to the function being called, not the one calling it. I may be wrong, but I think that's what I saw.
If that is the case, then I'm sure it is not being done in the App code, since the compiler is using the standard startup code, which is not written to return back to anything later.
Also the App has no way to just return with a "return" in c, because at most that would jump back to main(), then we would have to jump back from main() too.
I think it is easier to rather just jump to the return address, and restore registers, SP, VTOR etc, from there.
I'm thinking that an sdcard loader should easily fit in a maple mini, so less than 20KB of RAM. I can use an RET board to reserve bottom 10-20KB for the loader (or just compile for a RBT target), then load a bin program and run it from the next chunk of RAM, reserving the top 10-15KB for variables. heap and stack.
Loader RAM ---- App Code ---- App RAM
Sorry I am not as good as Pito at drawing diagrams