Just wanted to document the process to burn a boot loader to a Mechaduino using a Black Magic Probe from 1Bitsy.
"The bmp is a JTAG and SWD Adapter used for programming and debugging ARM Cortex MCUs. Its the best friend of any ARM microcontroller developer.
Black Magic Probe gets rid of intermediate programs like OpenOCD or STLink server. This makes the operation faster and more reliable. You just open your GNU Debugger (GDB) and select the virtual com port offered by BMPM2 as your extended remote target."
My assumptions are that you have already installed the bmp and set up your arm-none-eabi-gdb toolchain. The ARM Toolchain setup is outside the scope of this post but there is lots of info available online.
Here is a handy youtube video tutorial on Setting up the BMP if you need some help with that.
Essentially you are connecting the bmp to your computer via with USB micro cable and then connecting the bmp to the Mechaduino with a 10pin .05 pitch ribbon cable. On the Mechaduino note that the orientation of pin one (the red side) points to the top of the board away from the USB micro connector. There are some male connectors at VHS if you need to solder these to your board. See the following pic.
You do not need to power your Mechaduino as the bmp supplies the voltage.
So once your connections are made you should grab a copy of the samd21_sam_ba.hex boot loader from github and drop this in some directory.
Next up is to fire up your debugger and pass it the name of the boot loader hex file.
You will be typing the line after ‘==============’
==============================================
MJs-Air-Ride:~/Documents/VHS/MechaduinoStuff/bootloader$ arm-none-eabi-gdb samd21_sam_ba.hex
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160616-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type “show copying”
and “show warranty” for details.
This GDB was configured as “–host=x86_64-apple-darwin10 --target=arm-none-eabi”.
Type “show configuration” for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type “help”.
Type “apropos word” to search for commands related to “word”…
Reading symbols from samd21_sam_ba.hex…(no debugging symbols found)…done.
==============================================
(gdb) target extended-remote /dev/cu.usbmodem7BAD8791 (You will need to determine your port id)
Remote debugging using /dev/cu.usbmodem7BAD8791
==============================================
(gdb) monitor tpwr enable (allow the BMP to supply voltage to your board)
==============================================
(gdb) monitor swdp_scan (look for swp targets)
Target voltage: 3.3V
Available Targets:
No. Att Driver
1 Atmel SAMD21G18A (rev D)
==============================================
(gdb) attach 1 (attach to the first target)
Attaching to program: /Users/majicj/Documents/VHS/MechaduinoStuff/bootloader/samd21_sam_ba.hex, Remote target
0x00005294 in ?? ()
==============================================
(gdb) monitor erase_mass (erase everything - don’t have to do this if you don’t want to)
Erase successful!
==============================================
(gdb) load (burn the hex file to the flash)
Loading section .sec1, size 0x1968 lma 0x0
Start address 0x614, load size 6504
Transfer rate: 18 KB/sec, 929 bytes/write.
==============================================
(gdb) compare-sections (compare the flash to your file. These should match if everything went well)
Section .sec1, range 0x0 – 0x1968: matched.
That’s it you have now burned a boot loader. You should be able to program your Mechaduino using your Arduino IDE as you normally would.
There is a ton of more stuff that you can do with the debugger but that a topic for another post.
Mark