UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer danewhome
Observer
1,117 Views
Registered: ‎01-18-2018

Debug Linux kernel with XSCT

The following are my debug steps:

  1. Put BOOT.BIN and image.ub in the SD card
  2. Boot from SD card
  3. Open XSCT console
  4. Connect to the target over JTAG

xsct% connect

  1. Target to “Cortex-A53 #0”

xsct% targets -set -filter {name =~ "Cortex-A53 #0"}

  1. Stop “Cortex-A53 #0”

xsct% stop

  1. Load Linux kernel symbol

xsct% dow vmlinux                                                              

Downloading Program -- /home/nelsonhuang/work/vt3571/mpsoc/petalinux/xilinx-zcu102-2018.3/images/linux/vmlinux

        section, .head.text: 0xffffff8008080000 - 0xffffff8008080fff

        section, .text: 0xffffff8008081000 - 0xffffff8008a4057f

        section, .rodata: 0xffffff8008a50000 - 0xffffff8008d0b737

        section, .eh_frame: 0xffffff8008d0b738 - 0xffffff8008d0b773

        section, .init__ksymtab_strings: 0xffffff8008d0b774 - 0xffffff8008d0b778

        section, .pci_fixup: 0xffffff8008d0b780 - 0xffffff8008d0e437

        section, __ksymtab: 0xffffff8008d0e438 - 0xffffff8008d230b7

        section, __ksymtab_gpl: 0xffffff8008d230b8 - 0xffffff8008d36fb7

        section, __ksymtab_strings: 0xffffff8008d36fb8 - 0xffffff8008d69d4c

        section, __param: 0xffffff8008d69d50 - 0xffffff8008d6d03f

        section, __modver: 0xffffff8008d6d040 - 0xffffff8008d6dfff

        section, __ex_table: 0xffffff8008d6e000 - 0xffffff8008d70daf

        section, .notes: 0xffffff8008d70db0 - 0xffffff8008d70dd3

        section, .init.text: 0xffffff8008d80000 - 0xffffff8008dbc60f

        section, .exit.text: 0xffffff8008dbc610 - 0xffffff8008dc0e77

        section, .altinstructions: 0xffffff8008dc0e78 - 0xffffff8008dd1977

        section, .altinstr_replacement: 0xffffff8008dd1978 - 0xffffff8008dd760f

        section, .init.data: 0xffffff8008dd8000 - 0xffffff8009c54667

        section, .data..percpu: 0xffffff8009c55000 - 0xffffff8009c60017

        section, .data: 0xffffff8009c70000 - 0xffffff8009cfdc9f

        section, .init___ksymtab+sort: 0xffffff8009cfdca0 - 0xffffff8009cfdcaf

        section, __bug_table: 0xffffff8009cfdcb0 - 0xffffff8009d13423

        section, .mmuoff.data.write: 0xffffff8009d13800 - 0xffffff8009d1380b

        section, .mmuoff.data.read: 0xffffff8009d14000 - 0xffffff8009d14007

        section, .pecoff_edata_padding: 0xffffff8009d14008 - 0xffffff8009d141ff

        section, .bss: 0xffffff8009d15000 - 0xffffff8009f37aaf

aborting, 1 pending requests... 

Failed to download /home/nelsonhuang/work/vt3571/mpsoc/petalinux/xilinx-zcu102-2018.3/images/linux/vmlinux

Memory write error at 0xFFFFFF8008080000. Blocked address 0xFFFFFF8008080000. Reserved address range

 

=> It will load symbol fail

 

 

We know how to debug Linux kernel with SDK, but don't know how to use XSCT.
We know how to load kernel symbol with XSCT below:
xsct% memmap –file <symbol file>

But it will show "no such file" when I exec "nxt" to trace code and running XSCT in Windows.
The cause should be "Path mapping" needs to be set.
Path mapping:
Linux kernel is built in Linux system.
Symbol file record build path, e.g. /home/nelsonhuang/work/zynqMP_190509/xlnx-4.14
In Windows, the kernel may be placed on network disk, e.g. X:\work\zynqMP_190509\xlnx-4.14
Therefore, "Path mapping" needs to set in Windows for XSCT.
How to set "Path mapping" in XSCT?

0 Kudos
18 Replies
Moderator
Moderator
1,085 Views
Registered: ‎09-12-2007

Re: Debug Linux kernel with XSCT

To load the symbol file it should be memmap -file vmlinux

0 Kudos
Xilinx Employee
Xilinx Employee
1,066 Views
Registered: ‎10-21-2010

Re: Debug Linux kernel with XSCT

Hi @danewhome 

There's no path map command in XSDB. I have created a script to add path map. You can use it like this

xsdb% source pathmap.tcl
xsdb% pathmap /tmp/ws_1 /home/sadanan/ws_1
xsdb% pathmap
{Source /tmp/ws_1 Destination /home/sadanan/ws_1}
xsdb% pathmap /tmp/ws_2 /home/sadanan/ws_2
xsdb% pathmap
{Source /tmp/ws_1 Destination /home/sadanan/ws_1} {Source /tmp/ws_2 Destination /home/sadanan/ws_2}

0 Kudos
Observer danewhome
Observer
1,059 Views
Registered: ‎01-18-2018

Re: Debug Linux kernel with XSCT

What is the content of pathmap.tcl?

 

Should it be following content?

pathmap /tmp/ws_1 /home/sadanan/ws_1

pathmap {Source /tmp/ws_1 Destination /home/sadanan/ws_1}

pathmap /tmp/ws_2 /home/sadanan/ws_2

pathmap {Source /tmp/ws_1 Destination /home/sadanan/ws_1} {Source /tmp/ws_2 Destination /home/sadanan/ws_2}

0 Kudos
Xilinx Employee
Xilinx Employee
1,048 Views
Registered: ‎10-21-2010

Re: Debug Linux kernel with XSCT

I have attached it along with my previous post. It has a command named pathmap, which can be used to get/set path map

Usage:

pathmap

Return the current pathmap settings

pathmap <src-path> <dest-path>

Set path map

 

0 Kudos
Observer danewhome
Observer
1,026 Views
Registered: ‎01-18-2018

Re: Debug Linux kernel with XSCT

We want to debug Linux kernel with XSCT.
We used "pathmap" to map "Linux build source code path" and "Windows network disk source path", but XSCT still can't find source code file.
xsct% pathmap /home/work/zynqMP_190509/xlnx-4.14 X:\work\zynqMP_190509\xlnx-4.14
Linux build source code path: /home/work/zynqMP_190509/xlnx-4.14
Windows network disk source path: X:\work\zynqMP_190509\xlnx-4.14

xsct% memmap -file images/linux/vmlinux
xsct% bt
0 0xffffff8008097680 cpu_do_idle()+8: proc.S, line 54
1 0xffffff800875573c arm_enter_idle_state()+52: cpuidle-arm.c, line 45
2 0xffffff80087536c0 cpuidle_enter_state()+240: cpuidle.c, line 220
3 0xffffff8008753808 cpuidle_enter()+24: cpuidle.c, line 288
4 0xffffff80080d0384 call_cpuidle()+28: idle.c, line 121
5 0xffffff80080d05d4 do_idle()+420: idle.c, line 186
6 0xffffff80080d05d4 do_idle()+420: idle.c, line 186
7 0xffffff80080d0780 cpu_startup_entry()+32: idle.c, line 351
8 0xffffff8008a3542c rest_init()+172: main.c, line 435
9 0xffffff8008d80b7c start_kernel()+924: main.c, line 714
10 0x0
xsct% pathmap /home/work/zynqMP_190509/xlnx-4.14 X:\work\zynqMP_190509\xlnx-4.14
xsct% nxt
Info: Cortex-A53 #0 (target 9) Stopped at 0xffffff800875573c (Step)
arm_enter_idle_state() at cpuidle-arm.c: 45
45: couldn't open "/home/nelsonhuang/work/zynqMP_190509/xlnx-4.14/drivers/cpuidle/cpuidle-arm.c": no such file or directory

0 Kudos
Observer danewhome
Observer
998 Views
Registered: ‎01-18-2018

Re: Debug Linux kernel with XSCT

To 

Do you see my previous question.

 

Thank you.

0 Kudos
Xilinx Employee
Xilinx Employee
954 Views
Registered: ‎10-21-2010

Re: Debug Linux kernel with XSCT

Hi @danewhome 

Sorry, i was away last week and couldn't look into this. I have made some changes to XSDB and verified that path mapping works with these changes. I have created patches for 2018.3 and 2019.1. You can use the patch like this

1. Extract the zip to a known location (ex. C:\temp\myvivado\2018.3). This directory should now have scripts directory from the zip

2. Set the environment variable MYVIVADO to point to the directory created in previous step (ex. set MYVIVADO=C:\temp\myvivado\2018.3)

3. Start XSDB from the same shell where you have set MYVIVADO. XSDB should use the local patch

4. Follow the steps from my previous post to set the path mapping (source pathmap.tcl; pathmap <src> <dest>). XSDB will now use the local source path

0 Kudos
Observer danewhome
Observer
910 Views
Registered: ‎01-18-2018

Re: Debug Linux kernel with XSCT

 

We have used xsdb_2018.3_patch.zip to patch our Vivado v2018.3.

But path still didn’t succeed.

Our test environment:

  1. Linux kernel is built in Ubuntu.

Ubuntu kernel path is /home/nelsonhuang/work/zynqMP_190509/xlnx-4.14

  1. We used XSDB to debugged Linux kernel in Windows.

Windows kernel path is X:/work/zynqMP_190509/xlnx-4.14

 

pathmap usage:

pathmap <src-path> <dest-path>

 

We don’t know which one is <src-path> and which one is <dest-path>.

Therefore, we have tried to test 2 cases:

 

Case1:

src-path: X:/work/zynqMP_190509/xlnx-4.14

dest-path: /home/nelsonhuang/work/zynqMP_190509/xlnx-4.14

 

xsdb% source pathmap.tcl

xsdb% pathmap X:/work/zynqMP_190509/xlnx-4.14 /home/nelsonhuang/work/zynqMP_1905

09/xlnx-4.14

xsdb% nxt

xsdb% Info: Cortex-A53 #0 (target 10) Running

xsdb% Info: Cortex-A53 #0 (target 10) Stopped at 0xffffff8008d9ac70 (Step)

do_xor_speed() at xor.c: 88

88: couldn't open "X:/home/nelsonhuang/work/zynqMP_190509/xlnx-4.14/crypto/xor.c

": no such file or directory

 

Case2:

src-path: /home/nelsonhuang/work/zynqMP_190509/xlnx-4.14

dest-path: X:/work/zynqMP_190509/xlnx-4.14

 

xsdb% source pathmap.tcl

xsdb% pathmap /home/nelsonhuang/work/zynqMP_190509/xlnx-4.14 X:/work/zynqMP_1905

09/xlnx-4.14

xsdb% nxt

Info: Cortex-A53 #0 (target 10) Stopped at 0xffffff8008085388 (Step)

arch_cpu_idle() at process.c: 89

89: couldn't open "X:/home/nelsonhuang/work/zynqMP_190509/xlnx-4.14/arch/arm64/k

ernel/process.c": no such file or directory

 

These 2 cases can’t find the kernel path in windows.

Do you kwon what is the reason?

Is it wrong for us use pathmap?

0 Kudos
Xilinx Employee
Xilinx Employee
833 Views
Registered: ‎10-21-2010

Re: Debug Linux kernel with XSCT

Hi @danewhome 

src-path is the compilation path. In your case, it should be the Linux path

dest-path is the current path where the sources exist. It the Windows path in your case

After you set the path-map, can you please run pathmap command and check if source and destination paths are returned correctly

0 Kudos
Visitor john.kading
Visitor
581 Views
Registered: ‎10-25-2019

Re: Debug Linux kernel with XSCT

Sadanan & all,

 

Thank you for the thread. I appreciate the pathmap script. I am attempting to do the same thing, but I am using xsdb 2016.4. Do I need a xsdb patch to make this work? I am finding that the commands I type in xsdb do not work in xsdb but apply to the xsdk when I attach.

 

My sequence

 

connect -host localhost -port 3121

target 3

memmap -file app-04.00-debug.elf

pathmap /home/user/release-builds/04.00/sw    /localhome/user/xilinx-workspaces/sw7

bpadd -addr Update_Status

Info: MicroBlaze #0 (target 3) Running

xsct% Info: MicroBlaze #0 (target 3) Stopped at 0x1b7e8 (Breakpoint)

333: couldn't open "/home/user/release-builds/04.00/sw/...../libsrc/services.c": permission denied

 

pathmap

{Source /home/user/release-builds/04.00/sw Destination /localhome/user/xilinx-workspaces/sw7}

 

I have verified pathmap returns the correct source and destination. So, xsdb is not working for me.

 

When I open up the SDK and attach to the same target, it properly uses the PathMap configured by my xsdb commands. So, I know the pathmap is working, but it doesn’t seem to apply to xsdb.

 

Thoughts?

Thanks,

John

0 Kudos
Xilinx Employee
Xilinx Employee
513 Views
Registered: ‎10-21-2010

Re: Debug Linux kernel with XSCT

Hi John,

Yes, you would need the XSDB patch. It does the pathmap translation

You can use the same patch with 2016.4. Some new features which are not part of 2016.4 will not work with this patch, existing features, along with pathmap should work

0 Kudos
Visitor elilabs
Visitor
504 Views
Registered: ‎10-30-2019

Re: Debug Linux kernel with XSCT

I have been writing scripts to run tests on our modified fsbl for zinq.  Initially, I loaded the software via jtag, and everything worked fine, but ultimately, we need to be able to run the test scripts on the software out of flash over qspi.  I am running the scripts from xsct.  I also tried xsdb, but I had the same problems.

It seems that I can see most(?) global symbols, as they are present in the fsbl.elf file that it presented via "memmap -file <path>/fsbl.elf", but local symbols are not being resolved and some global symbols appear to be missing.

I am now thinking that I need this pathmap thing, which I never heard of until this morning.  I am using xsct v2018.2 Jun 14 2018-20:18:43; do I need an update to implement pathmap?

The fsbl.elf was built on a jenkins server, but I am running on a pc in the lab, so I suspect pathmap might be needed to reconcile the path differences.  I had tried to start xsct from a relative path such that everything would be the same from there down the directory tree, but alas, no joy.

Thanks!

 

0 Kudos
Visitor john.kading
Visitor
475 Views
Registered: ‎10-25-2019

Re: Debug Linux kernel with XSCT

Thank you @sadanan. I decided to download the sdk for 2019.1 and apply your patch. That works. I set the pathmap and when I break it uses my source code.

Thanks,

John

0 Kudos
Visitor elilabs
Visitor
465 Views
Registered: ‎10-30-2019

Re: Debug Linux kernel with XSCT

Unfortunately, because of configuration management concerns, we are not able to upgrade anyof the tools, as the entire vm environment has been placed under configuration control, and to change is it a big fracas of change requests, CRB approval, etc. We can, however, addd adeditional cource files to the test itself, so if there are tcl source file to get pathmap working on 2018.2 xsct, I could use that approach.
0 Kudos
Highlighted
Visitor elilabs
Visitor
452 Views
Registered: ‎10-30-2019

Re: Debug Linux kernel with XSCT

I looked at the pathmap.tcl file that was attached to an earlier post on this thread, and I see that it is sending a message to xsdb:

tcf::send_command $::xsdb::curchan PathMap set blah_blah_blah...

So I tried the following bash command:

$ strings /opt/petalinux/tools/hsm/bin/sxdb | grep -i pathmap

and got nothing.  So does this mean that my xsdb does not have what it takes?

 

0 Kudos
Xilinx Employee
Xilinx Employee
391 Views
Registered: ‎10-21-2010

Re: Debug Linux kernel with XSCT

hi @elilabs,

No, you can still use pathmap. The steps would be same as my old post. You need a apply the patch, source pathmap.tcl, and run pathmap command. Do you need a 2018.2 patch?

In case you are interested how this whole thing works, pathmap command will send the path-map to hw_server, and then during debug, clients like XSDB/SDK are responsible for retreiving path-map from server, and apply it while looking for the source files

0 Kudos
Visitor elilabs
Visitor
384 Views
Registered: ‎10-30-2019

Re: Debug Linux kernel with XSCT

Yes, I do need the 2018.2 patch.  Was this patch ever issued with a petalinux release?  Or is it a a retrofit?

0 Kudos
Visitor elilabs
Visitor
383 Views
Registered: ‎10-30-2019

Re: Debug Linux kernel with XSCT

So it is really the hw-server that does the work!  I am currently using one of your blue jtag boxes that has the symbol server in the box.  I am connecting over usb.  We had previously used one of the red boxes, where the symbol server runs on the pc.  Since this using a message passing technique, then I see it should work with either of these boxes.

0 Kudos