How to copy the bootloader of a avr microcontroller to another empty new avr?

Hello everyone:

I have two boards.

The first one have a atmega1281-16au microcontroller on a board, and the bootloader has been burned in atmega1281 when I buy it from a factory, I can program this board using the USB cable.

The second board is the same with the first, but with a empty new atmega1281-16au microcontroller on it.

I want to program the second board using the USB cable too, but I don't have the bootloader(I need the bootloader the same with the first board), I want to copy the bootloader from the first board to the second board, How do I implement it?

I downloaded a ISP programming software, and I read the flash and eeprom from the first board using this software, it seems to read successfully.

then I write the binary file has been read into the second board's flash and eeprom, it seems to write successfully too.

But I failed, the second board didn't work properly, I don't know why, can someone help me? how can I achieve my goal.

many thanks

'2561 is similar to '2560 for bootloading; 64 pin package vs 100 so fewer ports are available to the user.

On the 2nd board, did you set the fuses?
If not, system clock will default to 8 MHz internal oscillator with divide-by-8 prescaler, resulting in 1 MHz operation, 1/16 of what everything else may be expecting in Arduino-land for comparison.

Hello CrossRoads:

Thank you for your help, but I don't quite understand what you said, in fact I am completely a beginner.

What do you mean the method I copy the program is right? just some of the details wrong? or is there have a better way to achieve my goal?

Many thanks

There are 3 fuse bytes - High Fuse, Low Fuse, Extended Fuse.
These need to be programmed by the ISP. Read the data sheet, then look the Mega section of boards.txt to see how the Mega sets them.

29.2 Fuse Bits
The ATmega640/1280/1281/2560/2561 has three Fuse bytes. Table 29-3 through Table 29-5 on
page 337 describe briefly the functionality of all the fuses and how they are mapped into the
Fuse bytes. Note that the fuses are read as logical zero, “0”, if they are programmed.

Hello CrossRoads:

Thank you very much for your reminder, this is the fuse&lock I readed from the first board.

Low Fuse High Fuse Extended Fuse LockBits

CKDIV8 (1) RSTDISBL(1) NC (1) NC (1)
CKOUT (1) DWEN (1) NC (1) NC (1)
SUT1 (0) SPIEN (0) NC (1) BLB12(1)
SUT0 (1) WDTON (1) NC (1) BLB11(1)
CKSEL3 (1) EESAVE (0) NC (0) BLB02(1)
CKSEL2 (1) BOOTSZ1(0) BODLEVEL2(1) BLB01(1)
CKSEL1 (1) BOOTSZ0(0) BODLEVEL1(0) LB2 (1)
CKSEL0 (1) BOOTRST(0) BODLEVEL0(1) LB1 (1)
DF D0 F5 FF

Then I write the Fuse&Lock into the second empty new board, and write successfully.

I also read the Flash and Eprom from the first board, and read successfully.

This is tip of read bytes. Flash: 129202/131072, Eprom:4096/4096.

Then I write the Flash and Eprom into the second empty new board, and write successfully.

I think the bootloader and sketch has been write in successfully, because when I turn on the switch, the new board's led lights flashing as same as the first board, this is due to the control of the bootloader.

But the second board still can't programming via USB, and not output anything to serial monitor, and can't work normally, where am I still wrong?

Ask for help.

Many thanks

Hmm, got me stumped then. Sounds like things are programmed correctly. Any chance of a wiring error somewhere?

I want to program the second board using the USB cable too, but I don't have the bootloader(I need the bootloader the same with the first board), I want to copy th

If you know Windows batch, it can be done like this:
http://www.hackster.io/rayburne/avr-firmware-duplicator

Nick Gammon has a sketch that can do it, i f I remember correctly:
Nick Gammon

Ray

Hello CrossRoads:

Thank you very much, your tips are always useful, the cause of problem is indeed on the wiring.

Best regards.