Burning Arduino bootloader on MCU SAMD21G

samd21g arduino bootloader swd

A custom crystalless PCB with SAMD21G and PWD pins are required to upload the Arduino bootloader in the bare micro-controller.

Create the bootloader file

  1. Clone ArduinoCore-samd
  2. Go to folder /bootloaders/zero
  3. (Option) Edit Makefile line 66 for crystalless board
     CFLAGS_EXTRA=-D__SAMD21G18A__ -DBOARD_ID_$(BOARD_ID) -D$(SAM_BA_INTERFACES) -DCRYSTALLESS
    
  4. (Optional) Edit board_definitions_arduino_zero.h line 26 to change product name
     #define STRING_PRODUCT "Pine"
    
  5. (Optional) Edit sam_ba_usb.c line 156 to change manufacturer name
     #define STRING_MANUFACTURER "Hutscape"
    
  6. Run make
  7. Ensure files bootloaders/zero/samd21_sam_ba.bin and bootloaders/zero/samd21_sam_ba.hex are created

Burn the bootloader

  1. Download and open SEGGER J-Flash Lite
  2. Connect the J-Link SEGGER with PWD pins to the PCB J-Link pinout mapping to SWD pins Connecting the J-Link SEGGER via the ribbon cable to the pogo pins
  3. Choose the created bootloader data file samd21_sam_ba.bin
  4. Click Program Device
  5. Disconnect J-Link SEGGER and connect the PCB to the laptop
  6. Double press the reset button to bring it into the bootloader mode
  7. Query ls -al /dev/cu.usbmodem* to ensure the port is detected
  8. Query arduino-cli board list | grep arduino to ensure the board is detected
      /dev/cu.usbmodem14101           Serial Port (USB) Arduino Zero (Native USB Port) arduino:samd:arduino_zero_native arduino:samd
    
  9. Flash the blinky LED program with crystalless option

Prototype

A photo of the actual setup.

Burning Arduino bootloader on MCU SAMD21G prototype

Schematic

Wire up the hardware accordingly

Burning Arduino bootloader on MCU SAMD21G schematic

References