I’ve been using the 1BitSquared Blackmagic Probe for a couple weeks now (see my earlier post about setting up the device here) and overall it’s been a pretty useful tool. Unfortunately, earlier this week it suddenly quit breaking at main after trying to upload code.
I fired up GDB to connect and a monitor swdp_scan [mon s] command was showing me an nRF51 target.
(gdb) mon s
Target voltage: 3.3V
No. Att Driver
1 Nordic nRF51
Definitely not the chip I’m using. Not exactly sure what happened, but I think the hex file I tried to load went outside the device’s memory map.
I did some reading and saw the typical debug path is to build a PC hosted version of the firmware and connect to the device. I recommend checking UweBonnes’ blackmagic repo since he seems to have the most active branches. You’ll want the cortexm_romtable branch, assuming it hasn’t already been merged.
Clone, cd src, then “make PROBE_HOST=hosted” (i recommend a -j4 or however many threads you can use to speed up compilation)
Then do a plain make to build the firmware. You’ll need dfu-util to load the new firmware, so get that if you don’t already have it.
FYI to anyone using virtualbox to passthrough the USB connection You have to add two USB filter rules – one for application mode, and one for firmware updating. Enter bootloader mode by holding the blackmagic probe button during powerup, then add the second rule.
You may need to force bootloader entry with the button, but either way, you see this output from dfu-util:
sudo dfu-util -d 1d50:6018,:6017 -s0x08002000:leave -D blackmagic.bin dfu-util 0.9 ... dfu-util: Invalid DFU suffix signature dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! Opening DFU capable USB device... ID 1d50:6017 Run-time device DFU version 011a Claiming USB DFU Interface... Setting Alternate Setting #0 ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing DFU mode device DFU version 011a Device returned transfer size 1024 DfuSe interface name: "Internal Flash " Downloading to address = 0x08002000, size = 96816 Download [=========================] 100% 96816 bytes Download done. File downloaded successfully Transitioning to dfuMANIFEST state
Your cortex chip should be detected correctly now. Power the target and you should be able to use the PC hosted blackmagic executable to dump the swd scan output like this:
sudo ./blackmagic -t -p Using 1d50:6018 C1D1B2B9 Black Sphere Technologies Black Magic Probe Remote is Black Magic Probe v1.6.1-535-g242ad55 Running in Test Mode Target voltage: 3.3V Volt Please update BMP firmware for substantial speed increase! RESET_SEQ failed AP 0: IDR=04770031 CFG=00000000 BASE=41003003 CSW=03000040 DHCSR start 01080000, success 00020003 after 16ms ROM: Table BASE=0x41003000 SYSMEM=0x00000001, designer 1f Partno cd0 ROM: Table BASE=0xe00ff000 SYSMEM=0x00000001, designer 43b Partno 4c0 0 0xe000e000: Generic IP component - Cortex-M0 SCS (System Control Space) (PIDR = 0x04000bb008) -> cortexm_probe 1 0xe0001000: Generic IP component - Cortex-M0 DWT (Data Watchpoint and Trace) (PIDR = 0x04000bb00a) 2 0xe0002000: Generic IP component - Cortex-M0 BPU (Breakpoint Unit) (PIDR = 0x04000bb00b) ROM: Table END 1 0x41006000: Debug component - CoreSight MTB-M0+ (Simple Execution Trace) (PIDR = 0x04001bb932) ROM: Table END *** 1 Atmel SAMD21G18A (rev D) M0+ Ram Start: 0x20000000, length 0x8000 Flash Start: 0x00000000, length 0x40000, blocksize 0x100
The target shows Atmel SAMD21G18A again! Back up and hacking – step through debug, breakpoints and memory inspection have been restored.