Skip to content

Instantly share code, notes, and snippets.

@Ilgrim
Forked from micooke/Blackmagicprobe_compile.md
Created January 12, 2024 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ilgrim/2125c59bc6fd1f14d67a9da08f1c1638 to your computer and use it in GitHub Desktop.
Save Ilgrim/2125c59bc6fd1f14d67a9da08f1c1638 to your computer and use it in GitHub Desktop.
blackmagic probe binaries for stlink v2 baite module
## Tested the blue pill on 10/09/2018
## 1. install pre-requisites
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt update
sudo apt install gcc-arm-embedded
# If it reports error message of conflict to gcc-arm-none-eabi, which is likely if upgrading from 4.x to 5+, please uninstall it first with:
# "sudo apt-get remove gcc-arm-none-eabi"

sudo apt -y install lib32z1 lib32ncurses5 lib32bz2-1.0 

## 2. Build your blackmagic probe of choice
# Note: the reset --hard lines are optional.
# 		they are there to reference the exact commit the attached binary were built against

# blue pill: get the main blackmagic probe
git clone https://github.com/blacksphere/blackmagic.git
cd blackmagic
git reset --hard 3a598a0cf357a19065568435371096dc18948087 # blue pill - current as of 10/09/2018
git submodule init
git submodule update
make
cd src
make clean
make PROBE_HOST=stlink 
cd ../

# blue pill/baite: get and build UweBonnes baite branch
git clone https://github.com/UweBonnes/blackmagic.git UweBonnes_bmp
cd UweBonnes_bmp
git checkout baite
git reset --hard ef0d8e450018ad19d03aa4418412035ce4affb9f # baite - current as of 10/09/2018
git submodule init
git submodule update
make
cd src
make clean
make PROBE_HOST=stlink 
cd ../

# baite: get and build tsaitgaist baite-platform branch
git clone https://github.com/tsaitgaist/blackmagic.git tsaitgaist_bmp
cd tsaitgaist_bmp
git checkout baite-platform
git reset --hard 36a2e6ac1d9d270be5165366c8ff7a71267a8994 # baite - current as of 10/09/2018
git submodule init
git submodule update
make
cd src
make clean
make PROBE_HOST=baite
cd ../

# copy the created binaries
cp UweBonnes_bmp/src/blackmagic.bin UweBonnes.bin
cp UweBonnes_bmp/src/blackmagic_dfu.bin UweBonnes_dfu.bin
cp tsaitgaist_bmp/src/blackmagic.bin tsaitgaist.bin
cp tsaitgaist_bmp/src/blackmagic_dfu.bin tsaitgaist_dfu.bin
cp blackmagic/src/blackmagic.bin blackmagic.bin
cp blackmagic/src/blackmagic_dfu.bin blackmagic_dfu.bin

## 
# USB Tx -> A10, USB Rx -> A9
# BOOT0 = 1 (default is 0)
# BOOT1 = 0 # BOOT1 is the closest jumper to the reset button

# install the stm32flash utility
sudo apt install stm32flash

# disable flash read protection
stm32flash -k /dev/ttyUSB0
# disable flash write protection
stm32flash -u /dev/ttyUSB0
# erase flash
stm32flash -o /dev/ttyUSB0
# flash the DFU bootloader
stm32flash -w blackmagic_dfu.bin -v /dev/ttyUSB0
# disconnect the UART
# BOOT0 = 0 (default is 0)
# BOOT1 = 0 # BOOT1 is the closest jumper to the reset button
# flash the main firmware
# note : dfu-util will error out at the end if you try using that as the binary is greater than 64k.
# the stm32_mem.py doesnt care about this, so use that (theres enough space on the blue pill)
# see - https://github.com/blacksphere/blackmagic/blob/master/src/platforms/stlink/Flashsize_F103
sudo python2 blackmagic/scripts/stm32_mem.py blackmagic.bin
# reset device, smile

# For Arduino on linux:
# /dev/ttyACM0 = BMP programming port
# /dev/ttyACM1 = BMP UART port (Tx,Rx) = (A9,A10) on the bluepill
# Make sure you burn a bootloader (even if you select 'None' to erase it) prior to uploading your sketch!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment