Hookup GDB to Black Magic Probe V2.3, Might have to compile

Hookup GDB to Black Magic Probe V2.3, Might have to compile


Check previous Post for some details all ready described there

Edit  config.txt file to have these contents







https://github.com/WiringPi/   Gordon's Arduino wiring-like WiringPi Library for the Raspberry Pi (Unofficial Mirror for WiringPi bindings)


dmesg | tail -20 
wlan1: link state changed to DOWN
wlan1: bpf attached
wlan1: bpf attached
wlan1: Ethernet address: 7c:5c:f8:68:5a:c9
lo0: link state changed to UP
wlan1: link state changed to UP
ugen0.7: <Black Sphere Technologies Black Magic Probe> at usbus0
umodem0 on uhub2
umodem0: <Black Magic GDB Server> on usbus0
umodem0: data interface 1, has no CM over data, has no break
umodem1 on uhub2
umodem1: <Black Magic UART Port> on usbus0
umodem1: data interface 3, has no CM over data, has no break/

Setup Umodem0 or Umodem1  non existent ports in /dev under FreeBSD

or how I learned to use the existing /dev/ttyU0 for gdb and /dev/ttyU1 for the virtual serial port

25.2.2. Connecting to USB Device Mode Serial Ports from FreeBSD

To connect to a board configured to provide USB device mode serial ports, connect the USB host, such as a laptop, to the boards USB OTG or USB client port. Use pstat -t on the host to list the terminal lines. Near the end of the list you should see a USB serial port, eg "ttyU0". To open the connection, use:

# cu -l /dev/ttyU0

After pressing the Enter key a few times you will see a login prompt.


https://www.freebsd.org/cgi/man.cgi?query=ucom  USB tty support communications for serial devices
  The ucom driver attaches to USB modems, serial ports, and other devices
     that need to look like a tty. 
https://www.freebsd.org/cgi/man.cgi?query=uslcom&sektion=4
NAME
     uslcom -- Silicon Laboratories CP2101/CP2102/CP2103/CP2104/CP2105 based
     USB serial	adapter


https://www.freebsd.org/cgi/man.cgi?query=uchcom CH340 and CH341 USB to RS-232 driver chip
NAME
     uchcom -- WinChipHead CH341/CH340 serial adapter driver
DESCRIPTION
     The uchcom	driver provides	support	for the	WinChipHead CH341/CH340	USB-
     to-RS-232 Bridge chip.

     The device	is accessed through the	ucom(4)	driver which makes it behave
     like a tty(4).

https://www.tnpi.net/computing/freebsd/crystalfontz.shtml  Crystal Fontz LCD driver and setup a good read that explains how to setup and test a  usb serial port.  Why I included this here.  Great examples and explanation of what is happening to setup usb serial on FreeBSD.

FreeBSD + Crystalfontz USB LCD Displays

Matt Simerson (matt@tnpi.biz)

v1.0, 17 Feb 2004


This document describes how to get a Crystalfontz USB LCD display to work with FreeBSD.


Introduction

There are a quite a variety of LCD displays now available. Many are serial versions and thus work quite well on any platform, assuming you can run some version of LCD software on your platform or plan to write your own. Considering that options are available ranging from client/server packages to simple Perl modules, it shouldn't be beyond the average sysadmin's abilities to add a LCD to his mod'ed system. However, the newer USB variants can present significant issues.

(Happily) knowing next to nothing about USB devices beyond plugging them in and using them, I accepted an offer to spend some time seeing if I could get a Crystalfontz USB LCD display to work with FreeBSD. I scoured the Internet for a while rummaging around to find a documented solution and turned up very little. According to rumors on the lcdproc mailing list, a few developer types had gotten it working but nobody bothered publishing HOW they did it.

I feel it's important to note that the Crystalfontz LCD family seems to have the best reputation among the developers that write software for interacting with LCD displays. I read a lot of posts while researching this project and the general consensus is that "Crystalfontz LCD's cost more but they just work". I have no affiliation with Crystalfontz beyond them contributing several LCD panels to me for testing. I have not used any other LCD panels.

My care package of LCD's arrived from Crystalfontz and I plugged the USB LCD 634 into my development server (FreeBSD 5.2, dual PIII, 2U) and it immediately registered the device:


Serial Console under FreeBSD

28.6.2. In-Depth Serial Console Configuration

Chapter 28. Serial Communications




JTAG_Debug1_usbconfig-show_ifdrv.txt: 57 lines, 3984 characters.
fred@fredTC93-pc ~/A/JTAG_FreeBSD_Debug> cat JTAG_Debug1_usbconfig-show_ifdrv.txt
fred@fredTC93-pc ~/A/JTAG_FreeBSD_Debug> usbconfig show_ifdrv
ugen2.1: <Intel EHCI root HUB> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.1.0: uhub0: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen1.1: <Intel EHCI root HUB> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.1.0: uhub1: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1>
ugen0.1: <Intel XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1.0: uhub2: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1>
ugen0.2: <Logitech USB Receiver> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (98mA)
ugen0.2.0: ukbd0: <Logitech USB Receiver, class 0/0, rev 2.00/12.11, addr 1>
ugen0.2.1: ums0: <Logitech USB Receiver, class 0/0, rev 2.00/12.11, addr 1>
ugen0.2.2: uhid0: <Logitech USB Receiver, class 0/0, rev 2.00/12.11, addr 1>
ugen1.2: <vendor 0x8087 product 0x8008> at usbus1, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen1.2.0: uhub3: <vendor 0x8087 product 0x8008, class 9/0, rev 2.00/0.04, addr 2>
ugen2.2: <vendor 0x8087 product 0x8000> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE (0mA)
ugen2.2.0: uhub4: <vendor 0x8087 product 0x8000, class 9/0, rev 2.00/0.04, addr 2>
ugen0.3: <Kingston DataTraveler 3.0> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)
ugen0.3.0: umass0: <Kingston DataTraveler 3.0, class 0/0, rev 2.10/2.00, addr 2>
ugen0.4: <PixArt Dell MS116 USB Optical Mouse> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen0.4.0: ums1: <PixArt Dell MS116 USB Optical Mouse, class 0/0, rev 2.00/1.00, addr 3>
ugen0.6: <ULT-Best Best USB Device> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (224mA)
ugen0.6.0: umass1: <ULT-Best Best USB Device, class 0/0, rev 3.10/41.03, addr 5>
ugen0.5: <vendor 0x8087 product 0x07dc> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.7: <Black Sphere Technologies Black Magic Probe> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.7.0: umodem0: <Black Magic GDB Server>
ugen0.7.2: umodem1: <Black Magic UART Port>
fred@fredTC93-pc ~/A/JTAG_FreeBSD_Debug> 

fred@fredTC93-pc ~/A/JTAG_FreeBSD_Debug> usbconfig show_ifdrv ugen0.7
ugen0.7: <Black Sphere Technologies Black Magic Probe> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
ugen0.7.0: umodem0: <Black Magic GDB Server>
ugen0.7.2: umodem1: <Black Magic UART Port>

fred@fredTC93-pc ~/A/JTAG_FreeBSD_Debug> pstat -t
      LINE   INQ  CAN  LIN  LOW  OUTQ  USE  LOW   COL  SESS  PGID STATE
     ttyu2     0    0    0    0     0    0    0     0     0     0 IC
     ttyv0  1920    0    0  192  1984    0  199 11199 19177 19177 Oicl
     ttyv1  1920  171    0  192  1984    0  199     0 23531 23531 Oi
     ttyv2  1920    0    0  192  1984    0  199     7 19179 19179 Oil
     ttyv3  1920    0    0  192  1984    0  199     7 19180 19180 Oil
     ttyv4  1920    0    0  192  1984    0  199     7 19181 19181 Oil
     ttyv5  1920    0    0  192  1984    0  199     7 19182 19182 Oil
     ttyv6  1920    0    0  192  1984    0  199     7 19183 19183 Oil
     ttyv7  1920    0    0  192  1984    0  199     7 19184 19184 Oil
     ttyv8  1920 1920    0  192  1984    0  199     0     0     0 OiHil
     ttyv9     0    0    0    0     0    0    0     0     0     0 -
     ttyva     0    0    0    0     0    0    0     0     0     0 -
     ttyvb     0    0    0    0     0    0    0     0     0     0 -
     pts/0  1920    0    0  192  1984    0  199    13 26930 17456 Oi
     pts/1  1920    0    0  192  1984    0  199     4 29881 29881 Oi
     pts/2  1920    0    0  192  1984    0  199     4 70907 70907 Oi
     ttyU0     0    0    0    0     0    0    0     0     0     0 IC
     ttyU1     0    0    0    0     0    0    0     0     0     0 IC
     pts/3  1920    1    0  192  1984    0  199     0 15991 15992 Oi
     pts/4  1920    0    0  192  1984    0  199   130 16024 16024 Oi
     pts/5  1920    0    0  192  1984    0  199     0 17659 25163 Oi


https://docs.freebsd.org/doc/6.1-RELEASE/usr/share/doc/faq/serial.html#SET-BPS  Found sh MAKEDEV in old 6.1 document faq serial.html

If there is no /dev/cuaa0 on your system, do this:

# cd /dev
# sh MAKEDEV cuaa0

cd /dev
sh MAKEDEV umodem0
sh MAKEDEV umodem1

or just use  /dev/ttyU0  for gdb debugger and use /dev/ttyU1 for the serial port 115200 bps virtual connection


#sysctl hw.usb.template
hw.usb.template: -1

#sudo sysctl hw.usb.template=3
hw.usb.template: -1 -> 3

sudo vi /boot/loader.conf
#add 3 lines for next boot to include modules
umodem_load="YES"
usb_template_load="YES"
ucom_load="YES"
hw.usb.template=3


root@fredTC93-pc:/home/fred/ARM64/JTAG_FreeBSD_Debug # kldload usb_template
root@fredTC93-pc:/home/fred/ARM64/JTAG_FreeBSD_Debug # kldstat
Id Refs Address                Size Name
 1  132 0xffffffff80200000  2938648 kernel
 2    1 0xffffffff82b39000    1ae68 geom_eli.ko
 3    1 0xffffffff82b55000   5b93a0 zfs.ko
 4    1 0xffffffff83af9000    38070 linux.ko
 5    4 0xffffffff83b32000    10ab0 linux_common.ko
 6    1 0xffffffff83b43000    32208 linux64.ko
 7    1 0xffffffff83b76000     6730 cuse.ko

 8    1 0xffffffff83b7d000    11cd8 fusefs.ko

37    1 0xffffffff83ed9000     3480 umodem.ko
38    1 0xffffffff83edd000     4d90 ucom.ko
39    1 0xffffffff83ee2000     b3a8 usb_template.ko

# sysctl hw.usb.template=3
hw.usb.template: 3 -> 3

# cu -s 115200 -l /dev/ttyU1
Connected
`Y`�`�b�CCf`�q�aa�pa`���X����sy�a�``u``

FreeBSD/arm64 (Fred_RasPi4B) (ttyu0)

login: 

There you go!  A working USB virtual serial connection to the Raspberry Pi 4B, Uart0

GDB setup and initialization for the Black Magic Probe V2.3  black-magic.org

# sudo gdb
Password:
GNU gdb (GDB) 12.1 [GDB v12.1 for FreeBSD]
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".

(gdb) set arch aarch64
The target architecture is set to "aarch64".


(gdb) target extended-remote /dev/ttyU0
Remote debugging using /dev/ttyU0

(gdb) monitor
Black Magic Probe (Firmware v1.7.1-1-g0e7e276) (Hardware Version 3)
Copyright (C) 2015  Black Sphere Technologies Ltd.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

(gdb) help monitor
Send a command to the remote monitor (remote targets only).
(gdb) monitor help
General commands:
version -- Display firmware version info
help -- Display help for monitor commands
jtag_scan -- Scan JTAG chain for devices
swdp_scan -- Scan SW-DP for devices
targets -- Display list of available targets
morse -- Display morse error message
halt_timeout -- Timeout (ms) to wait until Cortex-M is halted: (Default 2000)
connect_srst -- Configure connect under SRST: (enable|disable)
hard_srst -- Force a pulse on the hard SRST line - disconnects target
tpwr -- Supplies power to the target: (enable|disable)
traceswo -- Start trace capture, Manchester mode: (decode channel ...)
heapinfo -- Set semihosting heapinfo
(gdb) monitor version
Black Magic Probe (Firmware v1.7.1-1-g0e7e276) (Hardware Version 3)
Copyright (C) 2015  Black Sphere Technologies Ltd.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

(gdb) 


Comments

Popular posts from this blog

FreeBSD 14.0 Compiling kernel for Raspberry Pi 4B

HDMI Audio sound patches into GhostBSD source code /usr/ghost14/ghostbsd-src SOLVED Jan20 2024

How to install GhostBSD-Arm64 into a USB Flash Drive stick April 24, 2024 update edition.