SAMD21 Bootloader - Page 1
Forum section: electronics / general

author: LukeW
author_rank: Frequent Contributor
timestamp: November 16, 2016, 06:33:05 am
content: We have an ATSAMD21G18A, brand new fresh silicon on a custom PCB, with access to the SWD pins, reset, and the native USB port, and power to the device.OpenOCD is used, with a Raspberry Pi serving as the hardware probe.https://learn.adafruit.com/programming-microcontrollers-using-openocd-on-raspberry-pi/wiring-and-testThis bootloader file is used:https://github.com/arduino/ArduinoCore-samd/raw/master/bootloaders/zero/samd21_sam_ba.binRunning OpenOCD seems to produce good sensible output - no obvious errors. See below.Now we take the board off and plug it into the PC (Linux).Nothing appears using lsusb - would we expect to see the board using lsusb?The goal is to set up the microcontroller firmware equivalent to an Arduino Zero, so it is "Arduino-compatible" and the Arduino IDE can be used via the native USB interface.Any advice about exactly how to do this would be appreciated.Code:xPSR: 0x61000003 pc: 0x2000002e msp: 0xffffffd8** Programming Started **auto erase enabledInfo : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)wrote 16384 bytes from file samd21_sam_ba.bin in 1.039263s (15.396 KiB/s)** Programming Finished **** Verify Started **verified 5972 bytes in 0.497035s (11.734 KiB/s)** Verified OK **at91samd21g18.cpu: target state: haltedtarget halted due to breakpoint, current mode: Handler HardFaultxPSR: 0x61000003 pc: 0x2000002e msp: 0xffffffd8shutdown command invoked

author: BurtyB
author_rank: Regular Contributor
timestamp: November 16, 2016, 07:58:16 am
content: Sticking that .bin file on my SAMD21 Arduino Zero like board (https://twitter.com/burtyb/status/794626696406253569) with Atmel-ICE it shows up in windows as "Arduino Zero bootloader" and "ID 2341:004d Arduino SA" in Linux and the LED on D13 fades on/off, programs OK via Arduino Software and a double tap on the reset button gets you into the bootloader.I haven't got OpenOCD installed to test with that but if you've got a LED on D13 you should see it fade on/off with just power (no USB connection) so if you have the LED and don't see it fading it might be worth checking the 32.768 kHz crystal is connected OK as it uses that to startup IIRC.

author: LukeW
author_rank: Frequent Contributor
timestamp: November 16, 2016, 09:25:15 am
content: Hmm, LED attached on PA17, it doesn't fade or blink.

author: LukeW
author_rank: Frequent Contributor
timestamp: December 06, 2016, 03:18:54 am
content: Unabridged paste:Code:pi@raspberrypi:~/bootloader $ sudo openocdOpen On-Chip Debugger 0.10.0-dev-00371-g81631e4 (2016-09-16-10:19)Licensed under GNU GPL v2For bug reports, readhttp://openocd.org/doc/doxygen/bugs.htmlBCM2835 GPIO nums: swclk = 25, swdio = 24srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srstsrst_only separate srst_gates_jtag srst_push_pull connect_deassert_srstadapter speed: 400 kHzcortex_m reset_config sysresetreqsrst_only separate srst_gates_jtag srst_push_pull connect_deassert_srstadapter_nsrst_delay: 100adapter_nsrst_assert_width: 100Info : BCM2835 GPIO JTAG/SWD bitbang driverInfo : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)Info : clock speed 400 kHzInfo : SWD DPIDR 0x0bc11477Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpointsTargetName Type Endian TapName State-- ------------------ ---------- ------ ------------------ ------------0* at91samd21g18.cpu cortex_m little at91samd21g18.cpu haltedat91samd21g18.cpu: target state: haltedtarget halted due to debug-request, current mode: ThreadxPSR: 0x61000000 pc: 0x2000002e msp: 0x20007fe4at91samd21g18.cpu: target state: haltedtarget halted due to debug-request, current mode: ThreadxPSR: 0x61000000 pc: 0x2000002e msp: 0x20007fe4** Programming Started **auto erase enabledInfo : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)wrote 16384 bytes from file samd21_sam_ba.bin in 1.037158s (15.427 KiB/s)** Programming Finished **** Verify Started **verified 5972 bytes in 0.027730s (210.315 KiB/s)** Verified OK **at91samd21g18.cpu: target state: haltedtarget halted due to breakpoint, current mode: ThreadxPSR: 0x61000000 pc: 0x2000002e msp: 0x20007fe4shutdown command invokedpi@raspberrypi:~/bootloader $