loading software modules from the SDcard

I need to dynamically load sections of software into an Arduino Uno and run them.

Basically I have a very large sketch that will not fit on a Uno but much of the Sketch is not all used at the same time. Different functions need different portions so when a certain button is pressed it will load and run that portion of the hex file.

I use to do it using dos on a very old windows machine that had less memory than my brain after a long drinking session!

I am thinking the technique would be to create the modules and save to the SD card (with appropriate names) and then upload the main control sketch that would allocate a memory block to load the necessary files into. Then it will have the ability to jump to that block, run the hex file and then be able to return to do it all again with another file. Sure the system will have to wait for the loads but I can live with that.

Any ideas?

Check post 4 on this thread

Also you could take a look at the "MiniCore" 8-bit AVR core. It has an alternate bootloader to facilitate writing to/reading from flash memory in your code.

An example is provided with the core:- ">Optiboot flash read/write >SerialReadWrite.ino".
After the core is installed, that example will be available in ">File >Examples".

There's a thread on the "MiniCore" here:- MiniCore Thread - An Arduino core for the ATmega8 48 88 168 328

The Github page is here:- MCUdudeMiniCore An Arduino core for the ATmega8, ATmega48, ATmega88, ATmega168 and ATmega328

And for a "Boards Manager" installation, you add this line to "Additional Boards Manager URLs" in the IDE ">File Preferences":-
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json

N.B. You need to burn the modified Optiboot bootloader provided with the core for flash reading/writing to work.


OOps - posted before I'd finished. :frowning:


If you don't want the extras supported by that full core, ie Extra clock and BOD options, ATMega328 (not P) support and the other chips, there's this, (basically the bootloader included in the above-mentioned core):-
Writing to FLASH from application. Please test and enjoy :slight_smile:

Edit: I just installed and tested the "MiniCore". The modified bootloader and flash program memory access functions are easy to use and work well. Thanks for getting me motivated to finally test it. :slight_smile: