12/3/2016 - You can now contribute to developers of the Black Magic Probe project (which isn't me) using paypal. Find and click the paypal contribute button here: https://github.com/blacksphere/blackmagic
12/8/2016 - Instead of using this port of Black Magic Probe, it is a lot easier to just compile the PROBE_HOST=stlink and load that onto your bluepill. The bluepill hardware is the same as the stlink v1/v2 hardware. Just follow the steps from the Black Magic Probe software for building and installing the BMP stlink platform. The advantage being, you will get the latest BMP version and you will be able to update future versions just using the USB cable on the bluepill with a program called usb-util. The posts in this thread can be thought of as an interesting read on my journey from bluepill newbie to a somewhat proficient users of it.
The Black Magic Probe is a modern, in-application programmer and debugging software for embedded microprocessors. It allows you to see what is going on 'inside' an application running on an embedded microprocessor while it executes. It is able to control and examine the state of the target microprocessor using a JTAG or SWD (Serial Wire debugging) port and on-chip debug logic provided by the microprocessor. The probe connects to a host computer using a standard USB interface. The user is able to control exactly what happens using the GNU source level debugging software, GDB. Read more about it here: https://github.com/blacksphere/blackmagic/wiki
However, the stm32duino crowd here will find the open source Black Magic firmware more appealing than the hardware. The Black Magic Probe firmware can be loaded onto the low cost stm32c8t6 boards you find on eBay. You can then use that clone board with BMP firmware to take the place of an ST-Link programmer. Once the BMP firmware is loaded on a clone board, it provides the ability to upload to the flash of another target board. It does this using a gdb server built into the BMP firmware. This allows for hardware debugging using just arm-none-eabi-gdb without any host server code.
I started with the latest github version of the Black Magic Probe software and added platform support for the stm32f103c8t6 boards you find on ebay. I call it the 'jc66_coreboard' platform, as that is the label printed on the silk screen. Any board with the same pin outs should work (See Red Pill Blue Pill post for more info about the hardware). The new platform is based mostly on the already existing stlink platform source with changes to support the different hardware pin outs and features.
The ebay "Red Pill" board loaded with the Black Magic Probe firmware acting like a programmer:
by Rick Kimball, on Flickr
Target board (another "Red Pill" board) connections from the "Red Pill" BMP programmer:
I've attached a zip file containing the blackmagic.bin file, the blackmagic elf file, and patch file for the source. ( NOTE: I will fork BMP github code and create a branch with the source changes). For now, just download and unpack the zip and then upload the bin or elf file to your jc66_coreboard.
If you want to build the source yourself, do something like the following:
Code: Select all
$ git clone https://github.com/blacksphere/blackmagic Cloning into 'blackmagic'... remote: Counting objects: 3463, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3463 (delta 0), reused 0 (delta 0), pack-reused 3461 Receiving objects: 100% (3463/3463), 1.70 MiB | 0 bytes/s, done. Resolving deltas: 100% (2331/2331), done. Checking connectivity... done. $ cd blackmagic $ unzip ../bmp_jc66_coreboard.zip Archive: ../bmp_jc66_coreboard.zip inflating: blackmagic inflating: blackmagic.bin inflating: bmp_jc66_coreboard.patch $ patch -p1 <bmp_jc66_coreboard.patch patching file src/Makefile patching file src/command.c patching file src/platforms/common/cdcacm.c patching file src/platforms/jc66_coreboard/Makefile.inc patching file src/platforms/jc66_coreboard/Readme patching file src/platforms/jc66_coreboard/jc66_coreboard.png patching file src/platforms/jc66_coreboard/platform.c patching file src/platforms/jc66_coreboard/platform.h $ make $ cd src $ make install # assuming it go OK, you will have to change the path for the st-write utility to match your system
Code: Select all
TARGETBOARD JC66_COREBOARD GND GND SWDIO PA4 * SWCLK PA5 * POWER 3.3V from someplace with a common ground. Probably easiest to plug both boards in to USB
Code: Select all
$ lsusb -d 1d50: Bus 001 Device 117: ID 1d50:6018 OpenMoko, Inc.
So the simple way to use this is turn on the verbose compilation option in the Arduino Preferences Dialog. Then build something. Then cd to /tmp/buildxxxx .. where xxx is the directory where you find the .elf file.
Then do something like this:
Code: Select all
$ pwd /tmp/build676879315209412495.tmp $ arm-none-eabi-gdb -b 115200 Blink.cpp.elf GNU gdb (GNU Tools for ARM Embedded Processors) 22.214.171.12440731-cvs Copyright (C) 2013 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=i686-linux-gnu --target=arm-none-eabi". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /tmp/build676879315209412495.tmp/Blink.cpp.elf...done. (gdb) directory /mnt/vbox/shared/Arduino_STM32RK_Sketch/Blink Source directories searched: /mnt/vbox/shared/Arduino_STM32RK_Sketch/Blink:$cdir:$cwd (gdb) target extended-remote /dev/ttyACM0 Remote debugging using /dev/ttyACM0 (gdb) monitor swdp_scan Target voltage: 3.35V Available Targets: No. Att Driver 1 STM32, Medium density. (gdb) attach 1 Attaching to program: /tmp/build676879315209412495.tmp/Blink.cpp.elf, Remote target 0x08002170 in delay_us (us=11999) at /mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F1/system/libmaple/include/libmaple/delay.h:58 58 : "r0"); (gdb) monitor erase_mass (gdb) load Loading section .text, size 0x2d4c lma 0x8000000 Loading section .ARM.exidx, size 0x8 lma 0x8002d50 Loading section .data, size 0xd78 lma 0x8002d58 Loading section .rodata, size 0x12c lma 0x8003ad0 Start address 0x8000170, load size 15352 Transfer rate: 13 KB/sec, 852 bytes/write. (gdb) break setup Breakpoint 1 at 0x8000140: file Blink.ino, line 8. (gdb) c Continuing. Note: automatically using hardware breakpoints for read-only addresses. Breakpoint 1, setup () at Blink.ino:8 8 pinMode(PC13, OUTPUT); (gdb) disassemble $pc Dump of assembler code for function setup(): => 0x08000140 <+0>: movs r0, #32 0x08000142 <+2>: movs r1, #0 0x08000144 <+4>: b.w 0x8002080 <pinMode(unsigned char, WiringPinMode)> End of assembler dump. (gdb) c Continuing. ^C Program received signal SIGINT, Interrupt. 0x08002172 in delay_us (us=11999) at /mnt/vbox/shared/Arduino_STM32RK_Sketch/hardware/stm32duino/STM32F1/system/libmaple/include/libmaple/delay.h:58 58 : "r0"); (gdb) exit Undefined command: "exit". Try "help". (gdb) quit A debugging session is active. Inferior 1 [Remote target] will be detached. Quit anyway? (y or n) y Detaching from program: /tmp/build676879315209412495.tmp/Blink.cpp.elf, Remote target $
- /mnt/vbox/shared/Arduino_STM32RK_Sketch/Blink is my sketch directory. Use yours
- registers can be used if you type them in lower case $pc is the PROGRAM COUNTER. $sp - Stack pointer, $r1 .. etc
- type layout split to get a terminal based 3 window setup source on top , asm , then a command entry window