Issue Overview:
I'm encountering difficulties when attempting to use UART other than UART 0 and UART 1 for uploading programs to the Arduino Mega using MegaCore (Idea came from: Uploading sketch to Mega 2560 through serial2 or serial3?). Specifically, I suspect the problem lies with the autobaud rate detection, as mentioned in the readme of MegaCore.
Relevant Information from MegaCore Readme:
The readme for MegaCore states:
Make sure you connect an ISP programmer, and select the correct one in the "Programmers" menu. For time-critical operations, an external crystal/oscillator is recommended. The Urboot bootloader has automatic baud rate detection (except when using UART2 and UART3 on ATmega640/1280/2560), so UART uploads should work fine even though the oscillator is a little too fast or too slow.
Detailed Log Comparison:
Here's a comparison of the log for selecting UART 0 vs. UART 3:
UART 0:
avrdude: AVR device initialized and ready to accept instructions
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: processing -U flash:w:~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/autobaud/uart0_rxe0_txe1/led+b7/urboot_atmega2560_pr_ee_ce.hex:i
avrdude: reading input file ~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/autobaud/uart0_rxe0_txe1/led+b7/urboot_atmega2560_pr_ee_ce.hex for flash
with 396 bytes in 2 sections within [0x3fe00, 0x3ffff]
using 2 pages and 116 pad bytes
avrdude: writing 396 bytes flash ...
Writing | ################################################## | 100% 0.16s
avrdude: 396 bytes of flash written
avrdude: verifying flash memory against ~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/autobaud/uart0_rxe0_txe1/led+b7/urboot_atmega2560_pr_ee_ce.hex
Reading | ################################################## | 100% 0.00s
avrdude: 396 bytes of flash verified
avrdude: processing -U lock:w:0xff:m
avrdude: reading input file 0xff for lock
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xff
avrdude: 1 byte of lock verified
avrdude done. Thank you.
UART 3:
Programmer Type : STK500
Description : Atmel STK500 version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
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: processing -U flash:w:~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/external_oscillator/16000000_hz/115200/uart3_rxj0_txj1/led+b7/urboot_atmega2560_pr_ee_ce.hex:i
avrdude fileio_segments_normalise() OS error: cannot open input file ~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/external_oscillator/16000000_hz/115200/uart3_rxj0_txj1/led+b7/urboot_atmega2560_pr_ee_ce.hex: No such file or directory
avrdude do_op() error: read from file ~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/external_oscillator/16000000_hz/115200/uart3_rxj0_txj1/led+b7/urboot_atmega2560_pr_ee_ce.hex failed
avrdude done. Thank you.
Failed to burn bootloader: uploading error: exit status 1
Error Encountered with UART 3:
avrdude ioerror() OS error: file ~/Library/Arduino15/packages/MegaCore/hardware/avr/3.0.1/bootloaders/urboot/atmega2560/watchdog_1_s/external_oscillator/16000000_hz/115200/uart3_rxj0_txj1/led+b7/urboot_atmega2560_pr_ee_ce.hex is not readable: No such file or directory
Is there anything I can do to resolve the issue?