Go Down

Topic: Run code off SD card? (Read 2 times) previous topic - next topic

Chicken325

Look.  I know this has been asked a MILLION times but I'm still confused as to the answer.  Is it AT ALL possible to run Arduino-language code off an SD card?  I assume you'd have to mess with the bootloader but how do you do that?  Thanks!

Aeturnalus

No.

"Arduino language" code gets compiled to CPU instructions, which are loaded by the CPU from its internal flash.  Adding an SD card via the bootloader doesn't help, since the code STILL needs to be loaded onto the ATmega at some point. 

Of course, you could write your own interpreter for C/C++ and load a text file off an SD card, but it'd probably be a huge undertaking for very little gain.

If you're actually using more than 32 kilobytes of compiled code (that's something near 10000 lines, extrapolating from my existing code) in an Arduino, its past time for you to either a) optimize or b) use a bigger/better/faster controller.

dcb

As Aeturnalus points out you cannot run arduino compiled code straight from a sd card.  The code must be in flash memory.

There are some options but they are a long shot.

You can put "logic" on the sd card that drives some pre-arranged functionality, but it is well outside the lines of arduino to do so.  It would be like defining your own virtual machine language interpreter and putting the bytecode on the sd card.  It needent be quite that formal however, it could just be a handful of functions and some virtual registers to tie the functions together with the order of operations stored on the sd.  Probably a performance hit, but could save space.

Also not in scope would be to store executable code on the sd card and load it into flash as needed.  This would be ok for a rarely called function, but you will be testing the limits of your flash to rewrite it frequently, and you have to write a page at a time and play with fuses.

mowcius


PaulS

Quote
Look.  I know this has been asked a MILLION times but I'm still confused as to the answer.

How many times do you have to read NO, without ever reading YES, to stop being confused?

Go Up