I'm working on a project to ruggedize and expand the Arduino architecture for long term projects and one feature I've wanted to add to the system is to automatically upload my source code to an SD Card anytime I upload a new sketch to the AVR. I'm creating the boards from scratch so I've got some flexibility in that regard, and I'm not afraid to modify any source if need be, I just don't know where to begin. Currently I'm working off of an Atmega8535 instead of the 328p, and I'll be uploading through serial, rather than a 16U2.
My current thoughts of ways to accomplish this would be:
Add some fancy circuitry to redirect the FT232 to write the source to the SD card (not sure if that is even possible)
Write in extra functions and transfer the source tot he SD card through the AVR after the sketch was uploaded.
Add a 16U2 or, preferably any DIP packaged AVR, with modified firmware to upload the source code to the SD card after programming the 8535.
So far, 3, sounds to be the most straight forward approach, though I'd like to try other alternatives if possible. Any route I go, I'll have to modify the IDE.
Suggestions, comments, criticisms?
Quite simply, my arduino projects last a long time, and get passed on from year to year to different people. Source code get's lost, or deleted. In academia, students are quite bad about keeping things consistent from year to year. So, it's far more convenient to have it stored on the device, just as it would be on a PLC. The ability to come back 3 years later, and download the source material from the dvice, modify, expand it what have you, and then upload it back from the same IDE is very convenient and saves many headaches.
That's a very interesting and sensible idea.
Would it be sufficient to use the PC to upload the source code to the SD card and then just store the card on the device. And put it back in the PC if you every need to downlaod the code in the future. Indeed it might be possible to use the SD Card as the PC's source for the program code from the very start of the project. That way you also keep all the variations of the code on the SD Card.
I have heard that the SD Card library uses a huge amount of the Arduino's SRAM so it might not be practicable to use the Arduino to write/read the SD Card.
I had considered that. Although, some projects have had very compact enclosures which makes access to the SD card not easily accessible.
My current prototyping endeavor is to add a 328p as an ISP and let that do the programming of the Arduino then write to the SD card. My thought was also that if I had the SD card already there for storing the active source, then it could also be used for data logging. Of course if I have to consider large SRAM usage, I may have to revisit the idea entirely.
Your idea for a "special" 328 as an ISP with additional functions is interesting.
I've been wondering about SD Cards recently. As far as I can see if you don't need them to be compatible with a PC you could write to them without using the FAT system using a much smaller Arduino code.
This, in turn, got me wondering about I2C EEPROMs which look like they would be much easier to use and much cheaper. Of course they don't have the Gigabytes of capacity that an SD Card has - but that may not be a problem for your situation. There seem to be plenty of DIP I2c EEPROMs which would be very easy to add to a project - and could be removed from the device at a later stage if required.
I may go that route, atleast for uploading the source code. Data logging projects come up from time to time so having the SD card in there somewhere is of advantage. I may have to find another SD library if resources become a problem.
- Add some fancy circuitry to redirect the FT232 to write the source to the SD card (not sure if that is even possible)
Don't forget to take a look at the FT232H. Extremely flexible. The FT232H could do the re-direct itself - directly write to the SD card then switch over to the AVR and upload a new sketch.
Very interesting Dllyod, I didn't know there were other Ft232's that would do that, I may have to give that a shot.
It's becoming more apparent that having an SD card for data logging purposes as well as storing the source code. Are there SD card controllers? Something to use rather than having a large library for SD card interface on the uC? Would it be advantageous to just have a uC that only communicates between the master device and the SD card, handling all that logic?
Would it be advantageous to just have a uC that only communicates between the master device and the SD card, handling all that logic?
If you are prepared to have two uCs why not have two 328s - one with the SD Card code and some software that can communicate with the other 328. That should be possible without writing any complex code.
Or what about using a Yun?