SparkFun Forums 

Where electronics enthusiasts find answers.

By brianuno
#193681
I was delighted to discover that after code was uploaded the cable from the computer could be disconnected and the circuit works under power from an AC adapter. The code is on the board's control chip. Wow! So, I was wondering, after code is uploaded, is there any way to download it? Suppose you find a board with no circuit attached, no idea what code is loaded. Is there a way to read it?
By Valen
#193685
Short answer: No.

Long answer: With a different bootloader program (that receives the programcode from IDE on pc an programs it into memory) maybe. But I have not found any that do.
By brianuno
#193711
I did not think it possible -unless by the author of the bootloader, in this instance Arduino. And, that's not open source, amirite?
By Valen
#193714
No, even the bootloader is open source. Somewhere higher up the tree in this page is the bootloader section: https://github.com/arduino/Arduino

Or you might read this page about it and find the link at the bottom: https://www.arduino.cc/en/Hacking/Bootl ... Bootloader

But you'd have to know what you are doing if you want to suggest or make changes. It would need to be compatible with other arduino boards with the same chips (and various IDE versions!). Especially if you want to share it. Though you would be free to experiment for your own purposes. A bug in that code could make it unresponsive. Although not unrecoverable.

Most other products with microcontrollers however have custom and not open source bootloaders, or code. Simply because they want to protect their creative rights.
By brianuno
#193716
I was searching old posts for another project, and I came across the term EEPROM, or electrically erasable programmable read-only memory. The key idea being read-only. I suppose that is why any code existing on a board can't be discovered. I searched EEPROM and near the top of the results is this link to Arduino's site: https://www.arduino.cc/en/Reference/EEPROM. All that is needed to try the examples is a board, cable, and software. The "read EEPROM and send its values to the computer" example looks interesting, but I can't figure out if it will print anything but it's own code. Is this the type of code that can be inserted into a sketch, as a check? The I am thinking of posting a question about EEPROM on the Arduino Forum. What do you say?
By Valen
#193718
The eeprom memory is different from the memory that contains the program-code. Your program-code is contained in flash-memory (32kB, boot loader is also in there in protected sections). And I think is not readable or writeable by the code itself at runtime. Only by the bootloader to check if saving succeeded without data-corruption. It is also possible to store static data in there like constant-tables or whatever. But it cannot be changed.

The eeprom memory is much smaller (1 kB). This is more intended to store configuration or calibration data at run-time. To allow some settings to survive a powerdown or reset. That can be programmed by your program. But it is slow to read and write, needing special instructions.
By brianuno
#193720
This is getting mind-boggling, again. I am also getting side-tracked from what I intended to do, but the topic is fascinating. It reminds me of using command prompt on a PC. Theoretically, the IDE might be installed on a PC computer. Then you need a display to view the serial monitor, larger memory, inputs, power source, and so on. Can a computer be built on an Arduino board?
By Valen
#193721
Hardly, if you mean like the functionality of a PC. It comes close to old home computers like the venerable Commodore 64. A Raspberry Pi board would fit that modern purpose though.