MegaCoreX
MegaCoreX copied to clipboard
Odd behaviour when programming with UPDI
Hi MCUdude,
I'm having odd behavior with an ATMega4809 when trying to program it via UPDI. I'm able to burn a bootloader via UPDI and using an Arduino Nano (Nano+4.7K+10uF). In that conditions, I can program the ATMega4809 with FTDI.
The problem is when I try to program directly with UPDI, i.e., with the same setup used to burn the bootloader but uploading with no bootloader
option and JTAG2UPDI
as a programmer (I'm using Arduino IDE 1.8.13). Everything compiles and no error is shown, but the program is not being uploaded. I'm testing with a simple blink example. This is the log:
/Applications/Arduino 2.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware /Applications/Arduino 2.app/Contents/Java/hardware -hardware /Users/miguelwon/Library/Arduino15/packages -hardware /Users/miguelwon/Documents/Arduino/hardware -tools /Applications/Arduino 2.app/Contents/Java/tools-builder -tools /Applications/Arduino 2.app/Contents/Java/hardware/tools/avr -tools /Users/miguelwon/Library/Arduino15/packages -built-in-libraries /Applications/Arduino 2.app/Contents/Java/libraries -libraries /Users/miguelwon/Documents/Arduino/libraries -fqbn=MegaCoreX:megaavr:4809:pinout=48pin_standard,resetpin=reset,BOD=2v6,clock=internal_16MHz,bootloader=no_bootloader -vid-pid=0000_0000 -ide-version=10813 -build-path /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460 -warnings=none -build-cache /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_cache_685124 -prefs=build.warn_data_percentage=75 -verbose /Applications/Arduino.app/Contents/Java/examples/01.Basics/Blink/Blink.ino
/Applications/Arduino 2.app/Contents/Java/arduino-builder -compile -logger=machine -hardware /Applications/Arduino 2.app/Contents/Java/hardware -hardware /Users/miguelwon/Library/Arduino15/packages -hardware /Users/miguelwon/Documents/Arduino/hardware -tools /Applications/Arduino 2.app/Contents/Java/tools-builder -tools /Applications/Arduino 2.app/Contents/Java/hardware/tools/avr -tools /Users/miguelwon/Library/Arduino15/packages -built-in-libraries /Applications/Arduino 2.app/Contents/Java/libraries -libraries /Users/miguelwon/Documents/Arduino/libraries -fqbn=MegaCoreX:megaavr:4809:pinout=48pin_standard,resetpin=reset,BOD=2v6,clock=internal_16MHz,bootloader=no_bootloader -vid-pid=0000_0000 -ide-version=10813 -build-path /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460 -warnings=none -build-cache /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_cache_685124 -prefs=build.warn_data_percentage=75 -verbose /Applications/Arduino.app/Contents/Java/examples/01.Basics/Blink/Blink.ino
Using board '4809' from platform in folder: /Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4
Using core 'coreX-corefiles' from platform in folder: /Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4
Detecting libraries used...
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_ATmega4809 -DARDUINO_ARCH_MEGAAVR -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/cores/coreX-corefiles/api/deprecated -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/cores/coreX-corefiles -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/variants/48pin-standard /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/sketch/Blink.ino.cpp -o /dev/null -DARDUINO_LIB_DISCOVERY_PHASE
Generating function prototypes...
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_ATmega4809 -DARDUINO_ARCH_MEGAAVR -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/cores/coreX-corefiles/api/deprecated -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/cores/coreX-corefiles -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/variants/48pin-standard /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/sketch/Blink.ino.cpp -o /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/preproc/ctags_target_for_gcc_minus_e.cpp -DARDUINO_LIB_DISCOVERY_PHASE
"/Applications/Arduino 2.app/Contents/Java/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/preproc/ctags_target_for_gcc_minus_e.cpp
Compiling sketch...
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega4809 -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_ATmega4809 -DARDUINO_ARCH_MEGAAVR -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/cores/coreX-corefiles/api/deprecated -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/cores/coreX-corefiles -I/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/variants/48pin-standard /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/sketch/Blink.ino.cpp -o /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/sketch/Blink.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_cache_685124/core/core_6eb6bfbec527c59c671f15260da7d45e.a
Linking everything together...
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -Wl,--section-start=.text=0x0 -mmcu=atmega4809 -o /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.elf /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/sketch/Blink.ino.cpp.o /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/../arduino_cache_685124/core/core_6eb6bfbec527c59c671f15260da7d45e.a -L/var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460 -lm
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.elf /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.eep
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy" -O ihex -R .eeprom /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.elf /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.hex
chmod +x /Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/scripts/create_disassembler_listing.sh
/Users/miguelwon/Library/Arduino15/packages/MegaCoreX/hardware/megaavr/1.0.4/scripts/create_disassembler_listing.sh "/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-objdump" "--disassemble --source --line-numbers --demangle --section=.text" /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.elf /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.lst
"/Applications/Arduino 2.app/Contents/Java/hardware/tools/avr/bin/avr-size" -A /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.elf
Sketch uses 776 bytes (1%) of program storage space. Maximum is 49152 bytes.
Global variables use 4 bytes (0%) of dynamic memory, leaving 6140 bytes for local variables. Maximum is 6144 bytes.
/Users/miguelwon/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/Users/miguelwon/Documents/Arduino/hardware/MegaCoreX/megaavr/avrdude.conf -v -patmega4809 -cjtag2updi -P/dev/cu.usbserial-1440 -Uflash:w:/var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.with_bootloader.hex:i -Ufuse0:w:0x00:m -Ufuse1:w:0x54:m -Ufuse2:w:0x01:m -Ufuse4:w:0x00:m -Ufuse5:w:0xC9:m -Ufuse6:w:0x06:m -Ufuse7:w:0x00:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m
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 "/Users/miguelwon/Documents/Arduino/hardware/MegaCoreX/megaavr/avrdude.conf"
User configuration file is "/Users/miguelwon/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.usbserial-1440
Using Programmer : jtag2updi
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
boot-loader FW version: 1
firmware version: 6.00
hardware version: 1
S_MCU:
boot-loader FW version: 1
firmware version: 6.00
hardware version: 1
Serial number: 00:00:00:00:00:00
Device ID: JTAGICE mkII
AVR Part : ATmega4809
Chip Erase delay : 0 us
PAGEL : P00
BS2 : P00
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 0
StabDelay : 0
CmdexeDelay : 0
SyncLoops : 0
ByteDelay : 0
PollIndex : 0
PollValue : 0x00
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
prodsig 0 0 0 0 no 61 61 0 0 0 0x00 0x00
fuses 0 0 0 0 no 9 0 0 0 0 0x00 0x00
fuse0 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse1 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse2 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse4 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse5 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse6 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse7 0 0 0 0 no 1 0 0 0 0 0x00 0x00
fuse8 0 0 0 0 no 1 0 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 0 0 0 0 0x00 0x00
data 0 0 0 0 no 0 0 0 0 0 0x00 0x00
usersig 0 0 0 0 no 64 64 0 0 0 0x00 0x00
flash 0 0 0 0 no 49152 128 0 0 0 0x00 0x00
eeprom 0 0 0 0 no 256 64 0 0 0 0x00 0x00
Programmer Type : JTAGMKII_PDI
Description : JTAGv2 to UPDI bridge
M_MCU hardware version: 1
M_MCU firmware version: 6.00
S_MCU hardware version: 1
S_MCU firmware version: 6.00
Serial number: 00:00:00:00:00:00
Vtarget : 5.0 V
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.09s
avrdude: Device signature = 0x1e9651 (probably m4809)
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 "/var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.with_bootloader.hex"
avrdude: writing flash (2 bytes):
Writing | ################################################## | 100% 0.03s
avrdude: 2 bytes of flash written
avrdude: verifying flash memory against /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.with_bootloader.hex:
avrdude: load data flash data from input file /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.with_bootloader.hex:
avrdude: input file /var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.with_bootloader.hex contains 2 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: 2 bytes of flash verified
avrdude: reading input file "0x00"
avrdude: writing fuse0 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse0 written
avrdude: verifying fuse0 memory against 0x00:
avrdude: load data fuse0 data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip fuse0 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse0 verified
avrdude: reading input file "0x54"
avrdude: writing fuse1 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse1 written
avrdude: verifying fuse1 memory against 0x54:
avrdude: load data fuse1 data from input file 0x54:
avrdude: input file 0x54 contains 1 bytes
avrdude: reading on-chip fuse1 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse1 verified
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse2 written
avrdude: verifying fuse2 memory against 0x01:
avrdude: load data fuse2 data from input file 0x01:
avrdude: input file 0x01 contains 1 bytes
avrdude: reading on-chip fuse2 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse2 verified
avrdude: reading input file "0x00"
avrdude: writing fuse4 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse4 written
avrdude: verifying fuse4 memory against 0x00:
avrdude: load data fuse4 data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip fuse4 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse4 verified
avrdude: reading input file "0xC9"
avrdude: writing fuse5 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse5 written
avrdude: verifying fuse5 memory against 0xC9:
avrdude: load data fuse5 data from input file 0xC9:
avrdude: input file 0xC9 contains 1 bytes
avrdude: reading on-chip fuse5 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse5 verified
avrdude: reading input file "0x06"
avrdude: writing fuse6 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse6 written
avrdude: verifying fuse6 memory against 0x06:
avrdude: load data fuse6 data from input file 0x06:
avrdude: input file 0x06 contains 1 bytes
avrdude: reading on-chip fuse6 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse6 verified
avrdude: reading input file "0x00"
avrdude: writing fuse7 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse7 written
avrdude: verifying fuse7 memory against 0x00:
avrdude: load data fuse7 data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip fuse7 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse7 verified
avrdude: reading input file "0x00"
avrdude: writing fuse8 (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of fuse8 written
avrdude: verifying fuse8 memory against 0x00:
avrdude: load data fuse8 data from input file 0x00:
avrdude: input file 0x00 contains 1 bytes
avrdude: reading on-chip fuse8 data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of fuse8 verified
avrdude: reading input file "0xC5"
avrdude: writing lock (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xC5:
avrdude: load data lock data from input file 0xC5:
avrdude: input file 0xC5 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.
That's strange! What happens if you re-arrange the avrdude command, so that the last thing that happens is that the hex file is written?
Here's your Avrdude command, but slightly modified where the flashing happens at the end.
/Users/miguelwon/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/Users/miguelwon/Documents/Arduino/hardware/MegaCoreX/megaavr/avrdude.conf -v -patmega4809 -cjtag2updi -P/dev/cu.usbserial-1440 -Ufuse0:w:0x00:m -Ufuse1:w:0x54:m -Ufuse2:w:0x01:m -Ufuse4:w:0x00:m -Ufuse5:w:0xC9:m -Ufuse6:w:0x06:m -Ufuse7:w:0x00:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m -Uflash:w:/var/folders/vp/2f2lk6gj16v00znk4lc6yrkw0000gn/T/arduino_build_755460/Blink.ino.with_bootloader.hex:i
I found that the command works if I replace Blink.ino.with_bootloader.hex:i
with Blink.ino.hex:i
When I compile the sketch with Arduino IDE, two .hex files are generated (and saved in arduino_build_755460
folder) : Blink.ino.with_bootloader.hex
and Blink.ino.hex
.
I think the problem is that for some reason when I upload the sketch, Arduino IDE tries to write Blink.ino.with_bootloader.hex:i
, instead of Blink.ino.hex:i
, although I have defined the option no bootloader
.
The problem is when I try to program directly with UPDI, i.e., with the same setup used to burn the bootloader but uploading with no bootloader option and JTAG2UPDI as a programmer (I'm using Arduino IDE 1.8.13).
I am not so sure how this can happen. Maybe an IDE bug which may have been fixed. Ref:
- https://github.com/MCUdude/MegaCoreX/issues/156#issuecomment-1196536701
I think this issue can be closed.