Skip to content

Progressbars stuck when burning bootloader #11515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kristofmulier opened this issue May 11, 2021 · 3 comments
Closed

Progressbars stuck when burning bootloader #11515

kristofmulier opened this issue May 11, 2021 · 3 comments
Labels
Component: IDE The Arduino IDE Type: Bug Waiting for feedback More information must be provided before we can proceed

Comments

@kristofmulier
Copy link

kristofmulier commented May 11, 2021

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.

@per1234
Copy link
Collaborator

per1234 commented May 11, 2021

Hi @kristofmulier do you observe the same behavior when you run the same commands from the command line?

Note: There are two sets of commands. One to program the fuses and unlock

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

the other to flash the bootloader and lock:

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

@per1234 per1234 added Component: IDE The Arduino IDE Type: Bug Waiting for feedback More information must be provided before we can proceed labels May 11, 2021
@LumitoLuma
Copy link

LumitoLuma commented May 27, 2021

Hello @kristofmulier. This is an issue related with AVRDUDE and not with the Arduino IDE. An usual HEX file has a separator between the normal code section and the bootloader part. AVRDUDE's progress bar shows the upload progress of the code section but not the progress of the bootloader upload.

You may want to try Arduino's build on this link (Windows), this one (Linux x64) or try to reconfigure AVRDUDE with optimization flags like -O3

Finally, I don't have an Arduino Mega, so I can't exactly experience the side issue you say. But I have an Arduino MKR WiFi 1010 and when burning the bootloader it doesn't override the current program. This may be because the bootloader and the program section are also different, so sometimes if you override the bootloader the sketch section isn't modified.

I hope that this helps you.

@per1234
Copy link
Collaborator

per1234 commented Jun 1, 2022

Closing due to lack of response.

@kristofmulier if you will provide the requested information by commenting here, I'll be happy to re-open this issue.

@per1234 per1234 closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE Type: Bug Waiting for feedback More information must be provided before we can proceed
Projects
None yet
Development

No branches or pull requests

3 participants