0

Hello I have just got my Arduino to read text from a text file and it is running perfectly. I was interested in being able to load a sketch into the Arduino and having it execute it, from and SD card. The Arduino wouldn't be connected to my laptop at all. I researched it and it is possible, with a different boot loader. Which is a bit annoying because I don't want to change the boot loader on my Arduino. I could put it on a standalone atmega chip but lets pretend I don't have those. So I was thinking if you had pre-compiled Arduino code. Which is in hex format and ready to be put on the board, would it be able to be loaded from the SD card? If so how would I go about doing this?

0

Yes it is possible:

With a different bootloader.

You need something which will erase the old sketch from the chip, read the data from the SD card, and write that into the flash of the chip. The only thing that can do that is the bootloader or some external device (another ATMega328p chip which we have to pretend you don't have).

Due to the way the architecture works you can only execute code out of the flash, so you need to program your sketch into the flash somehow. And that is the role of the bootloader.

  • what if I had a sketch uploaded to the Arduino that uses about 50% of the flash space or more/less. If I had my really basic kind of language that I can load as a text file into a set of strings in the sketch's progmen. That part is possible. The sketch I write would be able to understand what the text file means.It might be just something like: print "hello world". That part is possible. Now the part I don't know about. When the sketch is finished with that "homemade language programme" it would have to clear it from its progmem and use those strings to load an new homemade language programme – user2279603 Feb 15 '16 at 16:40
  • If you were going to do that you could just read the text line by line from the SD card and act on it - no need to program anything into the flash. – Majenko Feb 15 '16 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.