Hello Y'all.
I was able to finally program my attiny24a. Is there a way to read or clone one that I have?
I moved your topic to an appropriate forum category @christov13.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Hi @christov13. Here are the instructions:
Reading the program from the board into a file
A. Generate model command
First, we're going to do a dummy upload in Arduino IDE in order to get it to help us generate the avrdude
command used to read the program from the Arduino board:
- Select File > New from the Arduino IDE menus.
- Select your board from Arduino IDE's Tools > Board menu and make any other menu selections necessary to upload to the board.
- VERY IMPORTANT : If the board you want to clone is connected to your computer, disconnect it to avoid overwriting its program.
- Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open. - Check the box next to "Show verbose output during: ☐ upload" in the "Preferences" dialog.
- Click the "OK" button.
- Trigger an upload as you would normally do when uploading to the ATtiny24A.
- Wait for the upload to fail.
- Scroll up the black console window at the bottom of the Arduino IDE window until you see the
avrdude
command that was generated for the upload.
It will look something like this:"C:\Users\username\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\username\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM35" -b115200 -D "-Uflash:w:C:\Users\username\AppData\Local\Temp\arduino\sketches\2550236D1AAA5295D4F743C245319248/sketch_aug7a.ino.hex:i"
- Select the full text of the upload command.
- Press the Ctrl+C keyboard shortcut.
This will copy the selected text to the clipboard.
B. Prepare read command
Next, you need to adjust the command you obtained via the procedure above so that it will read the hex file out of your Arduino board instead of writing:
- Start any text editor program.
- In the text editor window, Press the Ctrl+V keyboard shortcut.
This will paste the command you copied while following the instructions above into the text editor. - The end of the command will look something like this:
This is the flag that tells AVRDUDE to write."-Uflash:w:C:\Users\username\AppData\Local\Temp\arduino\sketches\2550236D1AAA5295D4F743C245319248/sketch_aug7a.ino.hex:i"
Replace that flag with the flag that tells AVRDUDE to read:
The full command should now look something like this:-Uflash:r:readfile.hex:i
"C:\Users\username\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\username\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM35" -b115200 -D -Uflash:r:readfile.hex:i
- If the paths in the command contain spaces, make sure they are wrapped in quotes.
- Press the Ctrl+A keyboard shortcut to select all the text of the command in the text editor.
- Press the Ctrl+C keyboard shortcut to copy the selected text to the clipboard.
C. Run the command
Now the read command is all prepared. It's time to run it!
- Plug the USB cable of the Arduino board that contains the program you want to read into your computer.
- Open a command line terminal.
I'll provide some links to instructions for doing that on each operating system: - Press the Ctrl+V keyboard shortcut in the terminal window to paste the command you copied while following the instructions above at the command line prompt.
- Press the Enter key.
- Wait for the command to finish successfully.
You should now find a file named "readfile.hex
" in whichever folder you opened the command line terminal in. That is the hex file of the program read from the Arduino board.
Writing the file to a board
You can follow a similar procedure to write the hex file to another Arduino board.
Remember that this file was compiled specifically for the Arduino board you read it from. You can't use it with an Arduino board that has a different configuration. For example, if you read it from an Uno, it is compiled for an ATmega328P running at 16 MHz, and won't work correctly on a board with a different microcontroller or clock speed.
A. Prepare write command
You need to adjust the command you obtained via the procedure above so that it will write the hex file you read via the "Reading the program from the board into a file" procedure:
- Start any text editor program.
- In the text editor window, Press the Ctrl+V keyboard shortcut.
This will paste the command you copied while following the instructions above into the text editor. - The end of the command will look something like this:
This is the flag that tells AVRDUDE to write."-Uflash:w:C:\Users\username\AppData\Local\Temp\arduino\sketches\2550236D1AAA5295D4F743C245319248/sketch_aug7a.ino.hex:i"
Replace the filename in that flag with the name of the file you read:
The full command should now look something like this:-Uflash:w:readfile.hex:i
"C:\Users\username\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\username\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM35" -b115200 -D -Uflash:w:readfile.hex:i
- If the paths in the command contain spaces, make sure they are wrapped in quotes.
- Press the Ctrl+A keyboard shortcut to select all the text of the command in the text editor.
- Press the Ctrl+C keyboard shortcut to copy the selected text to the clipboard.
B. Run the command
Now the write command is all prepared. It's time to run it!
- Plug the USB cable of the Arduino board you want to write to into your computer.
- Open a command line terminal in the folder that contains the hex file, as you did while running the read command.
- Press the Ctrl+V keyboard shortcut in the terminal window to paste the command you copied while following the instructions above at the command line prompt.
- Press the Enter key.
- Wait for the command to finish successfully.
Thank you ptillisch.
I will give it a shot. I'll let you know if I get it.
That worked great. Thank you again ptillisch.
New problem.
I have an old board that has an ATTINY on it. It does not seem like I can read it.
Device signature = 0xff00ff
Expected sig, for Attiny24 is 0x1E910B
Any ideas?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.