Long story short, I have an arduino mega-based custom board (…that directly copies the Atmega2560 and atmega16u2 configuration as on the Mega board.)
On my new board, I can put code in through ISP (using Arduino-as-ISP), but not through USB. I have flashed the atmega16U2 chip and it is working (and showing up in the IDE as a Mega 2560) However, programming via USB always times out. Using a scope I can see that the first byte from the IDE is getting all the way to the RX pin on the Atmega2560, but nothing is coming back out as a response. The Atmega2560 isn’t doing anything.
I looked at actual ‘good’ arduino mega board and used Nick Gammon’s ‘Atmega_Board_Detector’ sketch. Among the Fuses and bootloader there are only two things that did not match with my custom board
‘good’ Mega board:
Lock byte = 0xFF
Clock calibration = 0x8D
‘bad’ custom board:
Lock byte = 0xCF
Clock calibration = 0x82
From what can tell in the data sheet, the ‘clock calibration’ byte seems unrelated to bootloading.
My next step is to write the lock byte on the bad board to match the 0xFF seen on the good board. When I try to do THAT with avrdude, I keep getting a ‘failed’ message when it actually tries to write to the lock byte.
soo… Anyone have any idea how/why those two variables are causing my board to not be programmable from the IDE?