-
-
Notifications
You must be signed in to change notification settings - Fork 779
Hacking
The Black Magic Probe consists of both hardware and firmware components. Both are under open-source licenses and available on Github.
- Firmware: https://github.com/blacksphere/blackmagic (GPLv3)
- Hardware: https://github.com/blacksphere/blackmagic-hardware (CC-BY-SA)
The project resides in a GitHub git repository
Clone this repository (or fork and clone) using your desired method. Typically:
git clone https://github.com/blacksphere/blackmagic.git
The project uses libopencm3, which is included as a git submodule. Thus, prior to building the project, one must initialize this submodule:
cd /path/to/blackmagic
git submodule init
git submodule update
To build the firmware for the standard hardware platform run make
in the
top-level directory. You will require a GCC cross compiler for ARM Cortex-M3
targets. A good option is gcc-arm-embedded.
The default makefile assumes the target prefix is arm-none-eabi-
. Then only
make
is needded. If your compilers uses some other prefix, you can override this on the command line like e.g.:
make CROSS_COMPILE=arm-cortexm3-eabi-
This will result in binary files:
blackmagic.elf
- ELF binary of the Black Magic debug probe.
blackmagic.bin
- Flat binary of the Black Magic debug probe, load at 0x8002000
.
blackmagic_dfu
- ELF binary of the Black Magic DFU bootloader.
blackmagic_dfu.bin
- Flat binary of the DFU bootloader, load at 0x8000000
.
A number of users have contributed alternative hardware designs that are compatible with the native firmware. Some of these designs are in the hardware repo. Check the README files for details. E.g. to compile a BMP for an STLINKV2 to run as alternative to the ST firmware, compile
make PROBE_HOST=stlink ST_BOOTLOADER=1"
replug the STLink to get into the bootlaoder and load with [stlink-tools] (https://github.com/jeanthom/stlink-tool)
stlink-tools blackmagic.bin
Sid Price wrote a detailed step by step guide describing how to set up CygWin and compile the Black Magic Probe firmware.
The Black Magic application can also be compiled as a native PC application. Supported probes are BMP (with recent firmware), StlinkV2/3, FTDI-MPSSE probes, JLINK and CMSIS-Dap.
Compile the application with the command:
make PROBE_HOST=hosted
Easiest way is to compile a PC-hosted BMP. Run blackmagic -v 1 so that all infos are printed on the controlling terminal. Argument to -v is a bitmask, with -v 31 very verbose. If you do not succeed in compiling PC-hosted, use following steps as a last resort to compile in the debug messages when building the firmware:
make ENABLE_DEBUG=1
Then enable debug messages in gdb with the new command
monitor debug_bmp enable
The debug messages appear on the debug UART. On a BMP the USB UART device is used.
screen /dev/ttyACM2 115200
For native platform or as long as no STM32F103x8 is involved, any dfu tool is usable. BMP itself provides the blackmagic_upgrade utility to compile a program that when run updates the firmware in the upgrade directory and additional a python2 uploader stm32_mem.py in the script directory.
To handle a STM32F103x8 as STM32F103xB, use scripts/stm32_mem.py, a python2 application
Upgrade procedure with stm32_mem.py
- Build the firmware according your needs or use the daily compilation
- Run scripts/stm32_mem.py src/blackmagic.bin (or where the downloaded binary is located)