3

I am dealing with an Arduino Nano board rev 3.0 from Gravitech. There is a program inside that I'd like to download to a HEX file. Thus I can upload it to other Arduino Nano boards.

I'm a newbie with Arduino. Therefore I've read much documentation on the internet and I came to the point to use avrdude in the command line as Arduino IDE does not provide a feature to perform a download to an HEX file (as far as I've understood).

I've installed all the necessary software on my Mac OS Mojave (avrdude v7.0 using 'Mac Ports'). And after powering up and connecting the Arduino Nano board to a USB port of my Mac, I launched the following command line:

avrdude -p m328p -D -c arduino -P /dev/tty.usbserial-A9077L99 -U flash:r:programme_arduino.bin:r -v -x attempts=4

I obtain the classical message

stk500_recv(): programmer is not responding

I've noticed that the 'Rx' led and the 'L' led were blinking during the attempts.

From your perspective, do the options look good (-p -c ...)?

Arduino Nano Gravitech v3.0

4
  • Thank you jsotola for your comment. Arduino IDE allows to upload a sketch to the Arduino board. The command line utility 'avrdude' should allow to download the Flash ROM content of the Arduino board to a hex file or binary file. Correct in my command line I put 'programme_arduino.bin' instead of 'programme_arduino.hex'. However I think it doesn't make a difference.
    – DavidM31
    Jun 5, 2023 at 8:15
  • I add a precision, I used 'programme_arduino.bin' based on the settings I found on the website evilmadscientist.com/2011/…
    – DavidM31
    Jun 5, 2023 at 8:39
  • my apologies, I misunderstood what you are asking ... start with a blank Arduino Nano and the Arduino IDE ... in settings, turn on show verbose output during upload ... upload an empty sketch to the Nano ... the Arduino IDE will display the avrdude command line that is required to upload a sketch ... then edit the command line to do a download instead
    – jsotola
    Jun 5, 2023 at 15:24
  • show verbose output during upload sounds a good hint to get a good reference for my command line. However as I don't want to overwrite my existing code, I've tried this setting with my board disconnected. Arduino IDE does not display the command line as no port is connected.
    – DavidM31
    Jun 6, 2023 at 8:40

1 Answer 1

2

Your first problem is the no-response complaint. You said "I've noticed that the 'Rx' led and the 'L' led blank during the attempts." Is "blank" a typo (i.e., the LEDs do blink?) or did you mean they do nothing? Are you using the same cable you used to program the nano? Can you swap with another cable? Test this cable with another nano? Is the port ID typed correctly (/dev/...etc)?

Double-check the programmer ID (-c option) and part number (-p option) by querying AVRDUDE (specify '?' instead of a valid value on each of those).

For the -U option, you'll want to name the output file with a .hex extension, and specify the file-format as 'i' for intel hex:
-U flash:r:programme_arduino.hex:i

Here is the AVRDUDE reference I used.

Update:

I agree that your port ID must be correct and the cable is working, since your LEDs are blinking. But you get an error message about "not responding". Does the Nano have a bootloader in it? Could the boot-loader have been damaged when you uploaded the code (e.g., the code is large enough to over-write some of the bootloader)?

Is binary code in the Nano the only copy, or do you have the source code for it? If you have the source, you can recompile it (if necessary) and retrieve the resulting .hex file. Would that solve your problem? By setting the IDE to produce verbose output, you'll see the path to the temporary files, including the .hex file. Then use Finder (or a Terminal command, if you are comfortable with that) to copy that temporary .hex file to someplace safe.

Update 2:

Are bootloader ROM area and Flash ROM area two different memory areas?

Not separate - the boot-loader is placed at the top of Flash. It is possible for a large enough program to over-write it - I'm not sure whether that has to be specifically allowed, such as by setting fuses. If it does get over-written, it obviously becomes unusable.

I wonder if the flash can be read using a hardware programmer? Do note that these chips have lockout-fuses that can be set to prevent further programming or reading of the flash.

Since the code in this device seems valuable to you, I would suggest putting this Nano board aside, and only experiment with another, hopefully identical, board. On the new board -

  • Upload a sketch to it;
  • Copy the AVRDUDE command line used to by the IDE to upload it, and modify it as you've already described. Of course, this command will already have the board-specific parameters;
  • Use the modified command to download the sketch to another file, and compare it to the file that was just uploaded.

Once you can do this successfully, apply that last step to copy the sketch from your valuable Nano, then put that board away again. Load and test the downloaded code on your experimental Nano. Don't forget to include the valuable Nano's EEPROM - it might contain some critical data.

9
  • About 'blank' I wrote it incorrectly (excuse my English I am French ;-)). I meant 'blink' i.e. the led is blinking during the avrdude attempt.
    – DavidM31
    Jun 5, 2023 at 8:18
  • I tried with 2 mini-B USB cables. The behavior is strictly the same. To notice that those cables are not original ones delivered with the Arduino board.
    – DavidM31
    Jun 5, 2023 at 8:22
  • I have only one Arduino Nano board. I can not try with another one.
    – DavidM31
    Jun 5, 2023 at 8:22
  • I consider the port ID is typed correctly as during the avrdude attempts I see the leds blinking (Rx, L). It means there are some data going through the Arduino USB Rx line at least...
    – DavidM31
    Jun 5, 2023 at 8:23
  • About the programmer ID (-c option), here is something I don't understand well. I have a doubt about the one to choose, 'arduino', 'usbtiny', ... I keep 'arduino' as I have a bit of communication with it at least...
    – DavidM31
    Jun 5, 2023 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.