Author Topic: SAMD21 Bootloader  (Read 1803 times)

0 Members and 1 Guest are viewing this topic.

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 630
SAMD21 Bootloader
« on: November 16, 2016, 05:33:05 pm »
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-test
This bootloader file is used: https://github.com/arduino/ArduinoCore-samd/raw/master/bootloaders/zero/samd21_sam_ba.bin

Running 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: [Select]
xPSR: 0x61000003 pc: 0x2000002e msp: 0xffffffd8
** Programming Started **
auto erase enabled
Info : 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: halted
target halted due to breakpoint, current mode: Handler HardFault
xPSR: 0x61000003 pc: 0x2000002e msp: 0xffffffd8
shutdown command invoked

 

Online BurtyB

  • Regular Contributor
  • *
  • Posts: 66
  • Country: gb
    • 8086 Consultancy
Re: SAMD21 Bootloader
« Reply #1 on: November 16, 2016, 06:58:16 pm »
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.
 

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 630
Re: SAMD21 Bootloader
« Reply #2 on: November 16, 2016, 08:25:15 pm »
Hmm, LED attached on PA17, it doesn't fade or blink.
 

Offline LukeW

  • Frequent Contributor
  • **
  • Posts: 630
Re: SAMD21 Bootloader
« Reply #3 on: December 06, 2016, 02:18:54 pm »
Unabridged paste:

Code: [Select]
pi@raspberrypi:~/bootloader $ sudo openocd
Open On-Chip Debugger 0.10.0-dev-00371-g81631e4 (2016-09-16-10:19)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
BCM2835 GPIO nums: swclk = 25, swdio = 24
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
adapter_nsrst_delay: 100
adapter_nsrst_assert_width: 100
Info : BCM2835 GPIO JTAG/SWD bitbang driver
Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* at91samd21g18.cpu  cortex_m   little at91samd21g18.cpu  halted
at91samd21g18.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20007fe4
at91samd21g18.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20007fe4
** Programming Started **
auto erase enabled
Info : 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: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20007fe4
shutdown command invoked
pi@raspberrypi:~/bootloader $
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf