Running code off of sd card

I want to make a smartwatch type thing similar to the one made by Zack Freedman (can't get the video URL on my phone sry) that can have cool modules attach to it and do pretty much everything but tell the time; but if I want to make a good amount of modules, I'll also need the code for all of them. It would also probably be impractical to have to add new code to the end of the same program each time I make a new module.
This leads me to wonder whether I can program the code for each module and add them all to an sd card, so that way the teensy can access only the code for the modules currently installed.
I'm not the best with punctuation and wording so sorry if my question is a bit hard to understand, I'll try to clarify myself if anybody is confused. (I'm using a teensy 4.0 if that helps btw)
 
This wouldn't be possible without a lot of low-level knowledge. You're talking about implementing loadable libraries on a platform that doesn't have an operating system or even paged memory.

(The current Teensys can hold a lot of code; the T4.1 holds nearly 8MB and the smaller micromod doubles that.)
 
I did something kind of like that for the Teensy 3.6.
It has my version of the eForth language running. At startup it checks a pin and depending on if a jumper is installed or not it does one of two things:
1) Enter the Forth interpreter. (Good for code development.)
2) Compile Forth code from the SD card.
 
Not what you want to do directly but it is possible to have teensy firmware that upgrades itself with code off an SD card.

So you could have an SD card with a large collection of different firmware modules / operating modes, on power up the system could check which modules are fitted, scan the SD card, decide which of the avalible firmware images is most appropriate, re-flash itself with that version (if not already running) and then reboot.

Also the flash is large enough to hold multiple versions of firmware, you can create a bootloader system that on startup can pick which of the avalible firmware images in stored in flash to load.

It doesn't give you the ability to have loadable modules but does let you pick between a number of different fixed firmware images at runtime.
 
Back
Top