Get compiled code from a feather 32u4 board to another exaclty the same

Hi,

i don't have the source code and want to make a copy of the configurations and compiled code from a feather 32u4 board and write it to another, i want to make it work exactly like the first one.

I already have Arduino software installed on my windows PC and connect with the board through USB cable (com3)

Thanks

First, we’re going to do a dummy upload in the Arduino IDE in order to get it to help us generate the avrdude command used to read the program from the Arduino board:

Plug your Arduino board into your computer.

Select your board from the Arduino IDE’s Tools > Board menu.

Select your board’s port from the Tools > Port menu.

VERY IMPORTANT: Unplug your board from your computer.

File > Preferences

Check the box next to “Show verbose output during > upload”.

Click “OK”.

Sketch > Upload

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:

E:\Arduino\hardware\tools\avr\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i

Select the full text of the upload command.

Press Ctrl + C. This will copy the upload command to the clipboard.

Next, you need to modify the upload command to read the hex file out of your Arduino board:

Start a text editor program.

In the text editor window, press Ctrl + V. This will paste the command into the text editor. The end of the command will look something like this:

-D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i

That is the part of the command that tells it to write.

Replace that part of the command with the command that tells AVRDUDE to read:

-Uflash:r:readfile.hex:i

That will cause the read file to be named “readfile.hex”, which will be saved to whichever folder you run the command from. So now the full command looks something like this:

E:\Arduino\hardware\tools\avr\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:r:readfile.hex:i

If the paths in the command contain spaces, wrap the paths in quotes.

Plug your Arduino board into your computer.

Copy and paste the command from the text editor to the command line and run it.

Wait for the command to finish successfully.


You can follow a similar procedure to write the 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 with a boot section of 0.5 kB.

First, we’re going to do a dummy upload in the Arduino IDE in order to get it to help us generate the avrdude command used to write the program to the Arduino board:

Plug the Arduino board you want to write to into your computer.

Select your board from the Arduino IDE’s Tools > Board menu.

Select your board’s port from the Tools > Port menu.

File > Preferences

Check the box next to “Show verbose output during > upload”.

Click “OK”.

Sketch > Upload

Wait for the upload to finish.

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:

E:\Arduino\hardware\tools\avr\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i

Select the full text of the upload command.

Press Ctrl + C. This will copy the upload command to the clipboard.

Next, you need to modify the upload command to write the hex file you read from your other Arduino board:

Start a text editor program.

In the text editor window, press Ctrl + V. This will paste the command into the text editor. The end of the command will look something like this:

-D -Uflash:w:C:\Users\per\AppData\Local\Temp\arduino_build_91864/sketch_jan22b.ino.hex:i

That is the part of the command that tells it to write.

Replace the filename in that part of the command with the name of the file you read:

-Uflash:w:readfile.hex:i

So now the full command looks something like this:

E:\Arduino\hardware\tools\avr\avrdude -CE:\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM17 -b115200 -D -Uflash:w:readfile.hex:i

If the paths in the command contain spaces, wrap the paths in quotes.

Plug your Arduino board into your computer.

Copy and paste the command from the text editor to the command line and run it.

If you are uploading to an ATmega23U4-based board (e.g., Leonardo, Micro, Yun), you’ll need to press and release the reset button on the board immediately after running the command. If you are using a Pro Micro, use a wire to momentarily connect the RST and GND pins. If you are using a Yun, press and release the “32U4 RST” button quickly twice.

Wait for the upload to finish successfully.

HI

Thank you for your help.

Everything was running ok, but it stops in this error:
"
D:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude -CD:\avrdude.conf -v -V -patmega32u4 -cavr109 -PCOM3 -b57600 -D -Uflash:r:readfile.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "D:\avrdude.conf"

Using Port : COM3
Using Programmer : avr109
Overriding Baud Rate : 57600
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding

Do you know what's happening?

Thanks

Hi,

AVRDUDE stops working through command line but works through Arduino software

It stops with this error:

"D:\Program Files (x86)\Arduino\hardware\tools\avr\bin>avrdude -CD:\Program" "Files" "(x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -V -patmega32u4 -cavr109 -PCOM3 -b57600 -D -Uflash:w:C:\Users\grpin\AppData\Local\Temp\arduino_build_51991/atcommand.ino.hex:i

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "D:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM3
Using Programmer : avr109
Overriding Baud Rate : 57600
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack


eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding

avrdude: butterfly_recv(): programmer is not responding
"

Thanks

Sorry, I forgot a step in my instructions. Before you run the command, you must press the reset button on your feather 32u4 board. This activates the bootloader. Note that the COM port usually changes when the bootloader is running. The command you got from the Arduino IDE should have the correct port for the bootloader, but you might have modified the port after getting a "can't open device" error when you ran the command without resetting.

The reset timing is a little bit tricky. You need to wait maybe a second after pressing reset before running the command. The idea is to wait long enough for the OS to enumerate the bootloader's COM port, but not wait so long that the bootloader times out and exits. You should see the onboard LED pulsing while the bootloader is running.

i don't have the source code and want to make a copy of the configurations and compiled code from a feather 32u4 board and write it to another, i want to make it work exactly like the first one.

Could you please elaborate on that ? How come you don't have the source code ? what do you need the new feather 32u4 for ?

It works. Thanks!

I use the feather 32u4 with NPN Sensors. I load the code before, but i don't know witch code was and don't have access to the computer that i worked before.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per