Description
1. My setup
I burn a bootloader to my Arduino Mega board with my Atmel-ICE probe, using avrdude
. In fact, I was unable to burn any bootloader at all with the Atmel-ICE, until @facchinm applied a fix and released a new build for avrdude
(see #11107). Thank you for that fix.
2. The problem
Unfortunately, there's still a minor issue with the new build. The bootloader burning procedure stops twice for about a minute (once for Writing
and once for Reading
something) but the progressbar doesn't work. The progressbar reaches 100% immediately - you can't even see it filling up - and remains there for a minute.
This is the output I see when starting the bootloader burning:
avrdude -C "C:/embeetle/beetle_tools/windows/gnu_avr_toolchain_7.3.0_32b/etc/avrdude.conf" \
-v \
-patmega2560 \
-catmelice_isp \
-Pusb \
-e \
-Ulock:w:0x3F:m \
-Uefuse:w:0xFD:m \
-Uhfuse:w:0xDE:m \
-Ulfuse:w:0xFF:m
avrdude: Version 6.3-20210108
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:/embeetle/beetle_tools/windows/gnu_avr_toolchain_7.3.0_32b/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: max packet size expected 912, but found 512 due to EP 0x01's wMaxPacketSize
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
AVR Part : ATmega2560
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 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 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 : JTAG3_ISP
Description : Atmel-ICE (ARM/AVR) in ISP mode
Vtarget : 4.8 V
SCK period : 125.00 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):
Writing | ################################################## | 100% 0.03s
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.00s
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.03s
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.02s
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.03s
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.01s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude done. Thank you.
avrdude -C "C:/embeetle/beetle_tools/windows/gnu_avr_toolchain_7.3.0_32b/etc/avrdude.conf" \
-v \
-patmega2560 \
-catmelice_isp \
-Pusb \
-Uflash:w:../config/bootloaders/stk500boot_v2_mega2560.hex:i \
-Ulock:w:0xCF:m
avrdude: Version 6.3-20210108
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:/embeetle/beetle_tools/windows/gnu_avr_toolchain_7.3.0_32b/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: max packet size expected 912, but found 512 due to EP 0x01's wMaxPacketSize
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
AVR Part : ATmega2560
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 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 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 : 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.02s
avrdude: Device signature = 0x1e9801 (probably m2560)
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 "../config/bootloaders/stk500boot_v2_mega2560.hex"
avrdude: writing flash (261406 bytes):
Writing | ################################################## | 100% 0.00s
Here the output stops for a minute (with a full progressbar). Then it continues:
avrdude: 261406 bytes of flash written
avrdude: verifying flash memory against ../config/bootloaders/stk500boot_v2_mega2560.hex:
avrdude: load data flash data from input file ../config/bootloaders/stk500boot_v2_mega2560.hex:
avrdude: input file ../config/bootloaders/stk500boot_v2_mega2560.hex contains 261406 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% -0.00s
Now the output stops for the second time (again with a full progressbar). After a minute, it continues:
avrdude: verifying ...
avrdude: 261406 bytes of flash verified
avrdude: reading input file "0xCF"
avrdude: writing lock (1 bytes):
Writing | ################################################## | 100% 0.02s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xCF:
avrdude: load data lock data from input file 0xCF:
avrdude: input file 0xCF contains 1 bytes
avrdude: reading on-chip lock data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude done. Thank you.
Now the procedure is completed.
Little side-question: the LED starts blinking again after burning the bootloader, probably because I had a blinky program flashed onto the Arduino before burning the new bootloader. Is this normal? Shouldn't burning a new bootloader first wipe all the memory?
3. Why is this a problem?
Of course, the issue with the progressbar is not a disaster for personal use. However, I'm a bit worried for people that don't know this. We're building an IDE (see https://embeetle.com) and I'm worried that our users will simply close the console because they think the bootloader burning has frozen/crashed.
4. Notes
The problem is the same for Arduino Uno, but it doesn't bother as much. The moments of interruption are much shorter - just a few seconds.