Ok, maybe I don't understand the complexity of the problem, but.. rather than use the MPU and fancy stuff, why not just put a hook in the malloc() function used by the OS and make sure it does not allocate memory in that range? And this hook can be also used to check if the OS is running..
our code planted into RAM when OS is not started yet. there are no mallocs at this stage.
and it is unknown which OS actually we starting - we just return control to ROM boot address - 0xFFFF0000.
main idea of proposed approach to make resident code wich could survive OS start and latter could use hi-level OS functions found by signatures.
lets see some applications of such approach:
1) universal dumper. current version uses low-level sector reading/writing functions to save ROM dump. it works but it would work better if it used fopen, fread, fwrite, fclose functions.
2) universal chdk binary + supplied text file with information specific to some model (sensor size, functions/data addresses).
supose porting process:
- man loads universal diskboot.bin into NEW not-ported camera.( we assume that universal binary can find atleast fopen, fwrite, fclose functions)
- binary writes file ROM dump and automatically found function addresses to SD/CF/etc card.
- at this stage chdk already particulary working.
- then man gets dump and disassembler to find lacking functions. then he updates text file.
- annnnd - CHDK is fully ported - no need to compile anything....