bmp_traceswo
bmp_traceswo copied to clipboard
A Makefile rule for loading, setting up traceswo, and starting the target.
Hi @nickd4
I would like to share the following GNU-Makefile rule that I use for loading and setting up traceswo
:
flashdbg: $(BUILD_DIR)/$(TARGET).elf
gdb-multiarch -nx -nh --batch \
-ex 'target extended-remote /dev/ttyBmpGdb' \
-ex 'monitor tpwr disable' \
-ex 'monitor connect_srst enable' \
-ex 'monitor swdp_scan' \
-ex 'attach 1' \
-ex 'load' \
-ex 'compare-sections' \
-ex 'monitor traceswo' \
-ex 'set mem inaccessible-by-default off' \
-ex 'kill' $<
Once the above snippet is in (or included into) your Makefile
, it's a simple matter of running:
make flashdbg
Now the .elf
is flashed to the target and running. The next step is to start bmp_tracesw
in order to see the output of the ITM_SendChar
calls in the target's code. Simple & sweet! :)
You are welcome to add this information to your top-level README, or where-ever.
Thanks & regards
Very nice! I use a gdbinit file which is sort of similar but I launch from a shell script rather than Makefile. Having said that, in my day job we use "make monitor" to launch a serial terminal and I must say it is kind of handy to have this sort of thing in Makefiles not scripts.
By the way, I discovered something since I posted the github repo of bmp_traceswo. In the source code repo of the Blackmagic probe there is a program called swolisten.c which does the same function as bmp_traceswo but more elegantly, it creates named pipes/sockets called chan00, chan01 and handles demultiplexing and other things. Similarly to bmp_traceswo it tries to remain connected. I now use that.
Although the sample code and udev rules in bmp_traceswo may still be useful, I will at some point update wiki pages and discontinue bmp_traceswo. If I knew about swolisten.c from Blackmagic wiki it would have saved me some time in the first place.
I think I may have discovered a more optimal start up sequence for the SWO output too, it used to skip the first line or two of output using the Stm32 code I posted and Stm32CubeMx. I now use libopencm3, I spent ages trying to persuade my client/boss to switch over to libopencm3 and he would not let me, basically he loves to whip up a quick circuit in Altium while playing with the chip view and pinout in CubeMx and can't appreciate why CubeMx is very limiting for long term development. As soon as I heard he was no longer part of the project and my contact would be his former boss who is less technical, I immediately took the chance to change everything over to libopencm3 which took several weeks and required difficult debugging, but provides immense benefit in terms of having proper control.
Good to hear from you, I will let you know when/if I am able to insert your contribution into Blackmagic wiki pages.
cheers, Nick
On Wed., 8 Apr. 2020, 10:37 pm Pieter du Preez, [email protected] wrote:
Hi @nickd4 https://github.com/nickd4
I would like to share the following GNU-Makefile rule that I use for loading and setting up traceswo:
flashdbg: $(BUILD_DIR)/$(TARGET).elf gdb-multiarch -nx -nh --batch
-ex 'target extended-remote /dev/ttyBmpGdb'
-ex 'monitor tpwr disable'
-ex 'monitor connect_srst enable'
-ex 'monitor swdp_scan'
-ex 'attach 1'
-ex 'load'
-ex 'compare-sections'
-ex 'monitor traceswo'
-ex 'set mem inaccessible-by-default off'
-ex 'kill' $<Once the above snippet is in (or included into) your Makefile, it's a simple matter of running:
make flashdbg
Now the .elf is flashed to the target and running. The next step is to start bmp_tracesw in order to see the output of the ITM_SendChar calls in the target's code. Simple & sweet! :)
You are welcome to add this information to your top-level README, or where-ever.
Thanks & regards
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nickd4/bmp_traceswo/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFB2QND6ZN6SGDRCKNGWJKLRLRVXDANCNFSM4MD4UTIA .