Can you have some code stored in memory separate from main compiled program?

The topic pretty much says it. For example, could I have code on a SD card that I load into memory and execute? I understand this can’t be C++ or C code. Isn’t something like this how drivers work?

Any tips are appreciated.


I don't think you can put instructions in SRAM and the bootloader partition is the only code that can write into FLASH. By making a custom bootloader you should be able to copy programs from an SD card to FLASH and then execute them.

If you have two Arduinos you can have one upload sketches to the other via the ICSP interface. The Arduino doing the programming can keep the compiled sketches (.hex files) on an SD card.

You could also code an interpreter on the arduino and run code in your interpreted language that was stored on your SD card. Unless you're doing this for fun though, you're probably looking at the wrong platform for your application.

What are you trying to do?

It really is more for fun. Been studying operating systems and trying to duplicate some of it on a small scale.

You can'd have compiled code in SD, but you check this one out: - Arduino Playground - Bitlash -

you might extent it to reading from SD

you might extent it to reading from SD

From what I remember from reading the documentation, I think it supports that feature already.

even better!