Let us assume I had a very large program that was about 10kbytes. Let us also assume I had this eeprom:
Is there a way that I can store the program on the eeprom, and then write a program for the arduino that executes it?
I sort of want to replace the onboard flash with the external eeprom. Is there a way I can trick the atmega into changing memories?
I have been told about bitlash, but that seems to be more for smaller programs.
Thanks!
Practically no, a running sketch can not modify flash memory. Only the bootloader has access to that capability. Perhaps someone more knowledgeable then I can explain it better. I think part of it is that flash memory can have zeros values written, but only a chip erase function can 'write' back ones.
The only way to do what you want directly is to rewrite the bootloader, but it won't be easy and it won't be quick.
As usual, if you have to ask the question...
Depending on what you want to do, some form of interpreter may be the answer, with some form of external ROM.
I did tell you. I am wondering if it is possible to expand the arduino's program memory to allow for larger programs. I don't have a large program, but I do have large libraries that could potentially exceed the limit.
I have the 168, and I want to expand the flash [Program] memory.
A 328 has double the flash memory (and double the SRAM & EEPROM as well), fits in the same socket, no other changes required, just select the proper board type in the IDE. You can get one for $6 with the bootloader already burned in.
OK. From reading post over the last two years here, it seems to me that people running out of SRAM space (variables, arrays and stack space) is the most likely road bump they come up against. But that's in practice not THEORY.
The larger AVRs allow you to extend RAM memory space (at the expense of I/O pins), but none of the family allows you to extend program memory space.
As I've already said, it is possible to page-in program memory from external sources like SD, but the added complexity of a custom bootloader and effort expended on tools to provide linkage would make it one of those 'wow-that's-clever-but-what's-the-point?' sort of projects.
On the other hand, storing an interpreted program on SD, and keeping the interpreter in program memory (which is, in principle, how home computers worked 30 years ago) is perfectly doable.
Wait a sec...
Let's say that I have a single program, a few thousand lines long, and it is, let's say, 50k. I store it on an SD Card and write a complex, but small interpreter. Now....
Let's also assume that I have a function which is defined at the top of the file, line 10-50. Then, at line 6544, I call the function. If the arduino, and the old computers you have mentioned, don't can't store the program, how do they know where the function is? Do they store its location a first when they compile?