Dobrica Pavlinušić's random unstructured stuff
Black Magic Probe: Revision 12


Black Magic Probe

https://github.com/blacksphere/blackmagic

links

blue pill

http://wiki.stm32duino.com/index.php?title=Blue_Pill

dpavlin@klin:/rest/cvs/blackmagic/src$ make PROBE_HOST=stli

  LD      blackmagic
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: address 0x8010dd0 of blackmagic section `.text' is not within region `rom'
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: blackmagic section `.data' will not fit in region `rom'
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: address 0x8010dd0 of blackmagic section `.text' is not within region `rom'
/usr/lib/gcc/arm-none-eabi/5.4.1/../../../arm-none-eabi/bin/ld: region `rom' overflowed by 3768 bytes
collect2: error: ld returned 1 exit status
Makefile:66: recipe for target 'blackmagic' failed
make: *** [blackmagic] Error 1

git remote add mubes https://github.com/mubes/blackmagic
git fetch mubes
git checkout -b bluepill mubes/bluepill

make clean

# gcc 5 generates too big binaries!
export PATH=/opt/DesignLab-1.0.8/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/:$PATH

make PROBE_HOST=bluepill

/nuc/stm32/stlink/build/Release/st-flash erase

/nuc/stm32/stlink/build/Release/st-flash write blackmagic_dfu.bin 0x8000000

/nuc/stm32/stlink/build/Release/st-flash write blackmagic.bin 0x8002000

# power cycle blue pill

dpavlin@nuc:/nuc/stm32/blackmagic/src$ dmesg | tail -8 | cut -c18-
usb 2-4.4: new full-speed USB device number 12 using xhci_hcd
usb 2-4.4: New USB device found, idVendor=1d50, idProduct=6018
usb 2-4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-4.4: Product: Black Magic Probe (Bluepill), (Firmware v1.6-rc0-274-g39197b7)
usb 2-4.4: Manufacturer: Black Sphere Technologies
usb 2-4.4: SerialNumber: BED69CDC
cdc_acm 2-4.4:1.0: ttyACM0: USB ACM device
cdc_acm 2-4.4:1.2: ttyACM1: USB ACM device



st-link

https://github.com/texane/stlink


dpavlin@nuc:/nuc/stm32$ git clone https://github.com/texane/stlink

dpavlin@nuc:/nuc/stm32/stlink$ ./build/Release/st-info --probe
Found 1 stlink programmers
 serial: 533f6a06483f55532144033f
openocd: "\x53\x3f\x6a\x06\x48\x3f\x55\x53\x21\x44\x03\x3f"
  flash: 65536 (pagesize: 1024)
   sram: 20480
 chipid: 0x0410
  descr: F1 Medium-density device
dpavlin@nuc:/nuc/stm32/stlink$ 


dpavlin@nuc:/nuc/stm32/stlink$ ./build/Release/st-flash erase
st-flash 1.3.1-14-geb03b7c
2017-04-07T17:37:27 INFO src/common.c: Loading device parameters....
2017-04-07T17:37:27 INFO src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2017-04-07T17:37:27 INFO src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
Mass erasing


dpavlin@nuc:/nuc/stm32/blackmagic/src$ make HOST_PROBE=stlink

dpavlin@nuc:/nuc/stm32/blackmagic/src$ ../../stlink/build/Release/st-flash write blackmagic_dfu.bin 0x8000000
st-flash 1.3.1-14-geb03b7c
2017-04-07T17:41:59 INFO src/common.c: Loading device parameters....
2017-04-07T17:41:59 INFO src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2017-04-07T17:41:59 INFO src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
2017-04-07T17:41:59 INFO src/common.c: Attempting to write 6780 (0x1a7c) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08001800 erased
2017-04-07T17:41:59 INFO src/common.c: Finished erasing 7 pages of 1024 (0x400) bytes
2017-04-07T17:41:59 INFO src/common.c: Starting Flash write for VL/F0/F3 core id
2017-04-07T17:41:59 INFO src/flash_loader.c: Successfully loaded flash loader in sram
  6/6 pages written
2017-04-07T17:41:59 INFO src/common.c: Starting verification of write complete
2017-04-07T17:41:59 INFO src/common.c: Flash written and verified! jolly good!



dpavlin@nuc:/nuc/stm32/blackmagic/src$ ../../stlink/build/Release/st-flash --reset --flash=128k write blackmagic.bin 0x8002000
st-flash 1.3.1-14-geb03b7c
2017-04-07T17:45:52 INFO src/common.c: Loading device parameters....
2017-04-07T17:45:52 INFO src/common.c: Device connected is: F1 Medium-density device, id 0x20036410
2017-04-07T17:45:52 INFO src/common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
Forcing flash size: --flash=0x00020000
2017-04-07T17:45:52 INFO src/common.c: Attempting to write 77076 (0x12d14) bytes to stm32 address: 134225920 (0x8002000)
Flash page at addr: 0x08014c00 erased
2017-04-07T17:45:54 INFO src/common.c: Finished erasing 76 pages of 1024 (0x400) bytes
2017-04-07T17:45:54 INFO src/common.c: Starting Flash write for VL/F0/F3 core id
2017-04-07T17:45:54 INFO src/flash_loader.c: Successfully loaded flash loader in sram
 75/75 pages written
2017-04-07T17:45:58 INFO src/common.c: Starting verification of write complete
2017-04-07T17:45:59 INFO src/common.c: Flash written and verified! jolly good!


this flash instructions doesn't work, recepie above for blue pill is more recent