MonkeyEnFuego wrote:
These Applets would have to be small (5k?) and abide by a protocol to exit (press and hold for 3 seconds?), but the watch would download this data into memory.
Either they would have to abide by it, or there would need to still be a resident amount of code that handles the interface to the rest of the runtime system.
Quote:
After downloading, it would create a function pointer to the beginning of the data downloaded and deference it to start the applet running (e.g the equivalent of void main()). When the applet returns, the original app continues to execute.
I'd be hesitant to hand over all control the app; there should still be some form of a monitor that keeps track of outside things (like, say, battery state).
If the code is all compiled with -fpic, it wouldn't even matter where the loader put it. My thinking is that each app could expose a small structure of function pointers for the different events (init, loop, button, etc) and the monitor would dispatch through those tables (this is how my
multi-app framework does it). And if all data were accessed through a pointer (i.e., no globals), then it wouldn't need the common block hack.
Eric -- when we get my watch working again, I'd be interested in doing some tests with storing code in the spiflash section to try to build a general purpose segment loader.