blackmagic part 2 : Software under linux


The blackmagic will show itself as 2 ttyACM devices
They can have different names depending on what is connected to the system

To solve that, following the blackmagic wiki, the simplest is to create a file
in /etc/udev/rules.d/10-blackmagic.rules
containing
                                         
SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic GDB Server", SYMLINK+="ttyBmpGdb"
SUBSYSTEM=="tty", ATTRS{interface}=="Black Magic UART Port",SYMLINK+="ttyBmpTarg"  


Reboot or use udevadm trigger , replug the blackmagic and you should see two  devices /dev/ttyBmpGdb and /dev/ttyBmpTarg

These names will stay the same

Next, let's write two simple shell scripts to make our life easier :


blackmagic.sh: This will flash the file given as argument

#!/bin/sh
export PORT=ttyBmpGdb
${PREFIX}arm-none-eabi-gdb -ex "target extended-remote /dev/$PORT" -ex "monitor swdp_scan" -ex "attach 1" -ex "load $1" -ex "compare-sections" -ex "set confirm off" -ex "quit" 


debug.sh : This will enter a gdb debugging session for the file given


#!/bin/sh
export PORT=ttyBmpGdb
${PREFIX}arm-none-eabi-gdb -ex "target extended-remote /dev/$PORT" -ex "monitor swdp_scan" -ex "attach 1" -ex "load $1" -ex "compare-sections" -ex "set confirm off" -ex "file $1"

NB : If you dont have arm-none-eabi-gdb in your path, you can set PREFIX to point to your toolchain path

So now that you have built foobar.elf just either
* sh ~/blackmagic.sh foobar.elf to load it
* sh ~/debug.sh foobar.elf to debug it

If you dont have good debug capabilities, make sure you compiled it with "-g"

Comments

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

Fixing the INA3221

INA3221, weird wiring