I've made a handful of one-off Arduino gadgets, but have only played with dev boards. I'm now trying to make my own custom PCB for the first time, and am getting stuck at the bootloader stage, without enough terminology to successfully Google. I think it's to with configuring the bootloader. Any help would be amazing!
Overview of the problem
- I am trying to convert a working Arduino MKR Zero prototype into a custom PCB, that I can then program with the Arduino IDE
- It's intended to be a simple HID device that uses data from a single I2C sensor, with some addressable LEDs
- The custom PCB has been made, and it powers on
- I can also get a bootloader onto it using an ATMEL-ICE via SWD in Atmel Studio 7
- After this point, I haven't been able to get sketches onto the SAMD21 via the Arduino IDE
More context
- I can verify and toggle Fuses on the SAMD21, including BOOTPROT (see below)
- If I use existing bootloaders, examples inclulding ones taken from ArduinoCore-samd/bootloaders/zero or Sparkfun SAMD21_Dev_Breakout, the device appears in Windows Device Manager as expected
- However, if I try upload a test sketch from the Arduino IDE (such as blink, or a basic Serial.println("Hello World")), the sketch uploads, but when the board resets at the end of the upload, it doesn't reappear as a device in Windows Device Manager
- I've tried this with BOOTPROT set to 0 Bytes and 8192 Bytes, and in both cases, the sketch appears to upload, but when the device reboots, it doesn't reappear in Windows
- I need to double-tap the reset switch on the PCB to get it back into bootloader mode to appear in Device Manager and the Arduino IDE, but the previously loaded sketch doesn't work
I think the issue has something to do with me not configuring the bootloader correctly for my layout, or board.txt, or something like that. I haven't played around with these yet - I don't know where to begin. Otherwise, maybe I've made a mistake in my PCB design, missing pull-up/pull-downs somewhere, or a coupling capacitor?
My strongest hunch is that I don't have an external crystal/oscillator (having read that the SAMD21 doesn't need one), and that I've got to configure that somehow.
I've got an overview of my schematic for the PCB below.
- USB-C to a 3.3V regulator and 5.1k resistors on the CC1/CC2 lines and a protection diode
- SAMD21 with a reset switch, a programming header, a power LED and an activity LED (this doesn't seem to work)
- Some addressable LEDs come off 25
- I2C device not shown here, gets me coordinates for this joystick/gizmo
The official Arduino Zero Bootloader has a Makefile that I haven't tinkered with. I've seen somewhere that if you don't have an external oscillator, you have to define a -DCRYSTALLESS flag. This seemed to build and got me to the device being recognised in Windows, but nothing further - possibly something in board.txt?


