arduino / arduino/Arduino

Unable to burn bootloader with Atmel-ICE in Arduino IDE 1.8.13

Open
#11,107 31 comments 0 reactions 0 assignees View on GitHub
Architecture: AVR Component: Toolchain Type: Bug
Dominant language
Java
Stars
14.6k
Forks
7k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to burn an Arduino bootloader on an `Arduino UNO` board with the `Atmel-ICE` probe. Unfortunately, `avrdude` throws an error message when verifying the bytes.

1. Hardware setup

My hardware setup looks like this:

[![enter image description here][1]][1]

By the way - I'm working on a 64-bit Windows 10 PC.

2. Atmel-ICE driver

At first I thought that the `Atmel-ICE` doesn't require installation, because Windows recognizes it as an HID-device. However, I quickly learned that `avrdude` - launched by the Arduino IDE - needs another driver to interact with the `Atmel-ICE`. Therefore, I installed the `libusb-win32` driver with Zadig (just as suggested on the GitHub thread https://github.com/arduino/Arduino/issues/4368):

[![enter image description here][2]][2]

The driver installation succeeded, and I observe a change in the Windows Device Manager. The `Atmel-ICE` probe no longer appears as an HID-device but as a `libusb-win32` device instead:

[![enter image description here][3]][3]

I believe the `Atmel-ICE` is now ready to be used with `avrdude`.

3. Software setup

I'm running a fresh-installed Arduino IDE (version 1.8.13) on a Windows 10 PC. First I activate maximal verbosity for the console output (`File` > `Preferences` > `Show verbose output`). Next, I select the probe: `Tools` > `Programmer` > `Atmel-ICE (AVR)`

[![enter image description here][4]][4]

Next I select my board: `Tools` > `Board` > `Arduino AVR Boards` > `Arduino UNO`

[![enter image description here][5]][5]

Finally, I burn the bootloader: `Tools` > `Burn Bootloader`

[![enter image description here][6]][6]

In the console output, I can see two `avrdude` commands being launched.

3.1 First avrdude command

The first `avrdude` command looks like this:

```sh
avrdude -CC:\Program Files (x86)\.../avrdude.conf
-v
-patmega328p
-catmelice_isp
-Pusb
-e
-Ulock:w:0x3F:m
-Uefuse:w:0xFD:m
-Uhfuse:w:0xDE:m
-Ulfuse:w:0xFF:m
```

the output for this command is:

```sh
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 "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : usb
Using Programmer : atmelice_isp
avrdude: usbhid_open(): No device found
avrdude: usbdev_open(): Found Atmel-ICE CMSIS-DAP, serno: J42700007942
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
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 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 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 : JTAG3_ISP
Description : Atmel-ICE (ARM/AVR) in ISP mode
Vtarget : 5.0 V
SCK period : 125.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xff instead of 0x3f (double check with your datasheet first).
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDE"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDE:
avrdude: load data hfuse data from input file 0xDE:
avrdude: input file 0xDE contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified

avrdude done. Thank you.
```

That looks good.

3.2 Second avrdude command

The second `avrdude` command is:

```sh
avrdude -CC:\Program Files (x86)\.../avrdude.conf
-v
-patmega328p
-catmelice_isp
-Pusb
-Uflash:w:C:\Program Files (x86)\.../optiboot_atmega328.hex:i
-Ulock:w:0x0F:m
```

with the following output:

```sh
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 "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : usb
Using Programmer : atmelice_isp
avrdude: usbhid_open(): No device found
avrdude: usbdev_open(): Found Atmel-ICE CMSIS-DAP, serno: J42700007942
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
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 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 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 : JTAG3_ISP
Description : Atmel-ICE (ARM/AVR) in ISP mode
Vtarget : 5.0 V
SCK period : 125.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% -0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/optiboot/optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Error while burning bootloader.
Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0f
avrdude: verification error; content mismatch

avrdude done. Thank you.
```

3.3 The error message

As you can see, `avrdude` throws this error message:

```sh
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0f
avrdude: verification error; content mismatch
```

What should I do to solve this?

[1]: https://i.stack.imgur.com/ZqRfn.png
[2]: https://i.stack.imgur.com/L7Tvb.png
[3]: https://i.stack.imgur.com/y6JNZ.png
[4]: https://i.stack.imgur.com/VvJpI.png
[5]: https://i.stack.imgur.com/H7c5T.png
[6]: https://i.stack.imgur.com/C1MMH.png

Contributor guide

Open the contributing guide

Research direction

Reproduce the Arduino IDE 1.8.13 workflow on Windows 10 with an Arduino UNO and Atmel-ICE, using the logged avrdude commands and the optiboot_atmega328.hex path as references. Done means Burn Bootloader completes without the lock verification mismatch and avrdude reports the lock value verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.