Is it possible to put a sketch (.HEX file) to an SD card and run it from there? My objective is to utilize SD storage instead of flash memory for a program.
If yes, are there any libraries doing exactly this?
All i found was "flashing arduino from sd card", which is not what i need.
UPDATE:
the sketch's loop calling is implemented in the bootloader.
so i assume there is something like this in the bootloader:
while(true)
{
call_sketch_loop();
}
can it be changed to this? :
//signature changed from void loop() to int loop()
while(true)
{
int retval = call_sketch_loop(); //get loop call's return value
if( 0 == retval )
continue; // if 0, iterate the loop as usual
else
{
//copy 1.HEX from sd to flash and reboot
copy_hex_from_sd_to_flash( retval + ".HEX" );
reboot();
}
}
- change loop singature to
int loop() - put {int}.HEX files to an SD card -
1.HEX , 2.HEX , 3.HEX - the loop() call returns
0 - continue with next iteration as usual
- the loop() call returns
2 - copy file
2.HEXfrom SD card into program flash memory - reboot device
with this approach, we can run flash-capacity-exceeding programs if we split them up to smaller subprograms.