I’m using an Atmel ICE to try and load a bootloader on Pololu Romi, which uses the ATmega32u4 chip that is also found on the Leonardo. I have it hooked up correctly, as I am able to connect to the chip (and I’ve done this before), but I’m getting unexpected results and it hangs.
The first oddity is the warning:
WARNING: invalid value for unused bits in fuse "lock"...
but it seems to get past that. Not sure if it’s critical. Not sure what to do to fix it.
Then, there is a byte mismatch on byte 0x0000, so something is not correct (perhaps with the fuse?). It hangs at that point.
The complete output is below. The contents of the json is below that. Note that I used the json for leonardo (adding the VID:PID for the Romi’s values). Pointers or suggestions are welcome.
% pio run -t bootloader -v
Processing a-star32U4 (platform: atmelavr; board: leonardo; framework: arduino; upload_protocol: atmelice_isp)
------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/leonardo.html
PLATFORM: Atmel AVR (5.3.0) > Arduino Leonardo
HARDWARE: ATMEGA32U4 16MHz, 2.50KB RAM, 28KB Flash
DEBUG: Current (simavr) External (simavr)
PACKAGES:
- framework-arduino-avr @ 5.4.0
- tool-avrdude @ 1.60300.200527 (6.3.0)
- toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Using bootloader image:
/Users/<username>/.platformio/packages/framework-arduino-avr/bootloaders/caterina/Caterina-Leonardo.hex
Selected fuses: [lfuse = 0xFF, hfuse = 0xD8, efuse = 0xCB]
avrdude -p atmega32u4 -C /Users/<username>/.platformio/packages/tool-avrdude/avrdude.conf -e -c atmelice_isp -Ulock:w:0x3F:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m -Uefuse:w:0xCB:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9587 (probably m32u4)
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.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 "0xD8"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.09s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD8:
avrdude: load data hfuse data from input file 0xD8:
avrdude: input file 0xD8 contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
0xd0 != 0xd8
avrdude: verification error; content mismatch
avrdude: safemode: hfuse changed! Was d8, and is now d0
At which point, it hangs.
Here is leonardo.json:
{
"build": {
"core": "arduino",
"extra_flags": "-DARDUINO_AVR_LEONARDO",
"f_cpu": "16000000L",
"hwids": [
[
"0x2341",
"0x8036"
],
[
"0x2341",
"0x0036"
],
[
"0x2A03",
"0x0036"
],
[
"0x03eb",
"0x2141"
],
[
"0x2A03",
"0x8036"
]
],
"mcu": "atmega32u4",
"usb_product": "Arduino Leonardo",
"variant": "leonardo"
},
"bootloader": {
"efuse": "0xCB",
"file": "caterina/Caterina-Leonardo.hex",
"hfuse": "0xD8",
"lock_bits": "0x2F",
"lfuse": "0xFF",
"unlock_bits": "0x3F"
},
"debug": {
"simavr_target": "atmega32u4"
},
"frameworks": [
"arduino"
],
"name": "Arduino Leonardo",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 2560,
"maximum_size": 28672,
"protocol": "avr109",
"require_upload_port": true,
"speed": 57600,
"use_1200bps_touch": true,
"wait_for_upload_port": true
},
"url": "https://www.arduino.cc/en/Main/ArduinoBoardLeonardo",
"vendor": "Arduino"
}