Reading an ATTINY24a

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:

  1. Select File > New from the Arduino IDE menus.
  2. Select your board from Arduino IDE's Tools > Board menu and make any other menu selections necessary to upload to the board.
  3. :warning: VERY IMPORTANT :warning:: If the board you want to clone is connected to your computer, disconnect it to avoid overwriting its program.
  4. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  5. Check the box next to "Show verbose output during: ☐ upload" in the "Preferences" dialog.
  6. Click the "OK" button.
  7. Trigger an upload as you would normally do when uploading to the ATtiny24A.
  8. Wait for the upload to fail.
  9. 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"
    
  10. Select the full text of the upload command.
  11. 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:

  1. Start any text editor program.
  2. 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.
  3. The end of the command will look something like this:
    "-Uflash:w:C:\Users\username\AppData\Local\Temp\arduino\sketches\2550236D1AAA5295D4F743C245319248/sketch_aug7a.ino.hex:i"
    
    This is the flag that tells AVRDUDE to write.
    Replace that flag with the flag that tells AVRDUDE to read:
    -Uflash:r:readfile.hex:i
    
    The full command should now 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:r:readfile.hex:i
    
  4. If the paths in the command contain spaces, make sure they are wrapped in quotes.
  5. Press the Ctrl+A keyboard shortcut to select all the text of the command in the text editor.
  6. 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!

  1. Plug the USB cable of the Arduino board that contains the program you want to read into your computer.
  2. Open a command line terminal.
    I'll provide some links to instructions for doing that on each operating system:
  3. 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.
  4. Press the Enter key.
  5. 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.


:exclamation: 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:

  1. Start any text editor program.
  2. 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.
  3. The end of the command will look something like this:
    "-Uflash:w:C:\Users\username\AppData\Local\Temp\arduino\sketches\2550236D1AAA5295D4F743C245319248/sketch_aug7a.ino.hex:i"
    
    This is the flag that tells AVRDUDE to write.
    Replace the filename in that flag with the name of the file you read:
    -Uflash:w:readfile.hex:i
    
    The full command should now 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:readfile.hex:i
    
  4. If the paths in the command contain spaces, make sure they are wrapped in quotes.
  5. Press the Ctrl+A keyboard shortcut to select all the text of the command in the text editor.
  6. 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!

  1. Plug the USB cable of the Arduino board you want to write to into your computer.
  2. Open a command line terminal in the folder that contains the hex file, as you did while running the read command.
  3. 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.
  4. Press the Enter key.
  5. 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.

1 Like

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.