[Sorry for the long post, but I hope it will help other n00bs like me in the future if I ever find a solution…] I have just received today the board that I have designed (a derivative of Arduino Mega, with a bunch of peripheral stuff). It is based on the same circuits as the Arduino Mega (I did not want to change the heart of the device) : - A USB processor (ATMega 16U2) - A main processor (ATMega 2560)
I now need to program the processors, that are totally empty out of fab. I tried without success to program the main processor with an Arduino UNO working as an AVR ISP (seen here: http://arduino.cc/en/Tutorial/ArduinoISP) and burning the code from .../Arduino.app/Contents/Resources/Java/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex… Each time it ended up with :
avrdude: verification error, first mismatch at byte 0x1e000
After hours of Web browsing, terminal invocation of avrdude in interactive mode (I could dump the memory, but my Flash remained painfully empty at address 0x1e000…) and head scratching, I discovered Nick Gammon's magic solution: http://www.gammon.com.au/forum/?id=11635
While looking at his code, I discovered that he was reading address 0x3e000 in the Flash… and after checking in avrdude, in found my program sitting there !! Why on Earth was the ArduinoISP trying to find it at 0x1e000 is beyond my understanding…
Nevertheless, as Nick seems to be the most knowledgeable people here, I switched to his programming sketch… and it worked within a few seconds!!! Amazing !! :sweat_smile:
Now I tried to program the USB processor, this time again using ArduinoISP and the code found here : https://github.com/arduino/Arduino/blob/6e8e13d7b3679775dae70d9066f05e2f314fe1c1/hardware/arduino/firmwares/arduino-usbserial/Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex
It seemed to program OK (at least Arduino IDE did not complain), so I tried plugging my board on my Mac. Looking at the system details, I see a new USB device, named Arduino (looks good!).
So I tried to upload a blinking sketch… and unfortunately it did not go through :
avrdude: ser_recv(): programmer is not responding
I tried to upload it with the Arduino ISP connected to the main processor (and selecting upload with programmer in the IDE menu), it seems not to complain, but then nothing happens when I reset the board.
I'm puzzled… So now the questions: - when the Mac sees the USB device, does it mean the USB processor is properly programmed? - what can I try to progress/validate programming? - what is the "canonical" way to program such a virgin board? - is there something wrong with my board? What should I investigate? - how can I check that the system is alive (after unplugging the Arduino ISP) ? - where can I learn more about the programming process?
Thanks for your help!! =(
[Edit : changed the title to help understand the issue]