Debug the Host Code and Kernel Source Code using the Vitis IDE - 2023.2 English

Vitis Tutorials: AI Engine

Document ID
XD100
Release Date
2023-11-29
Version
2023.2 English

This section uses the system project built using the Vitis IDE and launch the IDE debugger to debug the host code and AI Engine kernel source code. Unlike debugging at simulation level, this topic walks you through connecting the harware to the IDE debugger, placing breakpoints in the host code and kernel source code, and observing intermittent values in the Varibale view, register view, and memory inspector.

  1. Download the Vitis IDE project from Download the Vitis IDE project and import in Vitis IDE.

  2. Invoke the Vitis IDE, and select File -> Import -> Vitis project exported zip file.

  3. Browse to the PeakDetect.ide.zip, enable the System Projects checkbox , and click Finish.

  4. Click the arrow button next to the Manage configurations to the current project icon in the taskbar, and select Hardware.

  5. Right-click the PeakDetect_system, and select the Build Project. It takes 20-25 minutes to completely build for the hardware target.

  6. Prepare the target hardware by flashing the sd_card.img on to the VCK190. (Refer to the following note).

    NOTE: The sd_card.img at the {Project}/Hardware/package directory is for regular use, and the sd_card.img at the {Project}/Hardware/package_aie_debug directory is for the debug run on the board.

  7. Plug in the sd_card into the SD card slot, and power up the board.

  8. Once the boot completes, type ifconfig in the hardware console. This is required to set up the Linux TCF agent to connect with the host.

    versal-rootfs-common-20231:/run/media/mmcblk0p1# ifconfig
    eth0      Link encap:Ethernet  HWaddr 72:5D:6F:74:88:C9
             UP BROADCAST MULTICAST  MTU:1500  Metric:1
             RX packets:0 errors:0 dropped:0 overruns:0 frame:0
             TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:1000
             RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
             Interrupt:34
    
    eth1      Link encap:Ethernet  HWaddr F6:94:91:C7:19:B0
             inet addr:10.140.179.228  Bcast:10.140.179.255  Mask:255.255.252.0
             inet6 addr: fe80::f494:91ff:fec7:19b0/64 Scope:Link
             UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
             RX packets:1325 errors:0 dropped:6 overruns:0 frame:0
             TX packets:565 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:1000
             RX bytes:103454 (101.0 KiB)  TX bytes:94168 (91.9 KiB)
             Interrupt:35
    
    lo        Link encap:Local Loopback
             inet addr:127.0.0.1  Mask:255.0.0.0
             inet6 addr: ::1/128 Scope:Host
             UP LOOPBACK RUNNING  MTU:65536  Metric:1
             RX packets:2 errors:0 dropped:0 overruns:0 frame:0
             TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
             collisions:0 txqueuelen:1000
             RX bytes:140 (140.0 B)  TX bytes:140 (140.0 B)
    

    NOTE: It is required to connect the VCK190 board to the Ethernet cable to get the ethernet address.

  9. Set up the connnection to the target hardware board.

    • Run the hardware server from the computer that connects to the target board. To do so, launch the hw_server from the computer that has the JTAG connection to the VCK190 board. launch hardware server

    • Create the debug target connection from the Vitis IDE by right-clicking the PeakDetect_system, and select the Debug -> Debug configuraions.

    • Under the Main tab -> Target section -> Hardware server option -> Local target -> New as follows. target hardware setup

    • In the Target Connection Details window, enter the Target name and Host. The Host name should match with what you see in the launch hardware server window, and hit Test Connection.

    • You should see the following Connection Successful! message: connection successful

    • You can also click the >>Advanced button to view the details of the VCK190 as follows. advanced options

  10. Similarly, set up the Linux TCF Agent. Under the Main tab -> Target section -> Linux TCF Agent option, select New and enter the Target and Host details. Enter the inet addr address you see after issuing the ifconfig command in the hardware Linux console in the Host field. Click Test Connection. You see Connection Successful message as shown above.

  11. Now, in the Vitis IDE, right-click the PeakDetect_system, and select the Debug As -> Launch Hardware.

  12. The Vitis IDE switches automatically to the debug mode, and the debugger suspends the host application at an automatic breakpoint in the host.cpp as follows.