I have an Arduino Leonardo that is controlling an LED matrix, and I want to store sketches on an SD card, that can be called from the SD Card and flashed onto the Arduino Leonardo for display on the Matrix. This would be selectable via a TFT screen or something similar. Is this possible to do straight from the SD card, or is it better to use another arduino and have the leonardo as a slave?
I was also thinking to use a raspberry pi, but I also dont want it would be too complicated.
I basically want to have a menu system, where various sketches can be selected and "flashed" on a need basis to the led matrix.
I've used a special bootloader that allows you to load sketches from and SD card:
When the bootloader starts it looks on the SD card for a file named FIRMWARE.BIN and flashes that file to the Arduino. I have never tried it, but I have always thought this could be used for allowing multiple sketches to be loaded from an SD card. The way it would work is that you select the sketch you want to load on the screen, then the Arduino makes a copy of that file named FIRMWARE.bin and then resets to activate the bootloader. This means that every sketch would need to contain the code for the sketch selection menu and sketch file handling. I have little experience with working with SD cards and Arduino so I don't know how difficult or slow the sketch copying process would be. You would also need to check if the avr_boot bootloader gets activated after a watchdog reset, some bootloaders do, some don't. If not you would either need to modify the bootloader or do a hardware reset on the Leonardo. It seems like it would be a cool way to greatly expand the program memory of the Arduino, though in a very limiting way.
The main reason to do something like that is because your programs are much larger than would fit in the flash memory of and Arduino if combined. I would definitely consider whether this is the case with the Leonardo. If so, the Mega has so much flash memory it's hard to imagine filling it up. I wouldn't recommend attempting this SD card thing just because you don't want to do the work of merging multiple small sketches together because it's fairly complex.