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: 
Highlighted
Scholar beandigital
Scholar
847 Views
Registered: ‎04-27-2010

Setting a breakpoint on a Kernel driver

Jump to solution

I have petalinux running on a Zynq board. I have setup SDK to be able to debug Linux. I have confiirmed that I can set a breakpoint to stop on start_kernel. I am now trying to debug the pci driver code. I have tried creating a breakpoint on some of the pci functions (xilinx_pcie_probe, pci_scan_root_bus_bridge) but they never hit. Can somone tell me if I am doing something wrong? Or explain how to do this. Thanks.

0 Kudos
1 Solution

Accepted Solutions
Moderator
Moderator
751 Views
Registered: ‎12-04-2016

Re: Setting a breakpoint on a Kernel driver

Jump to solution

Hi

You dont need to specify any addresses. Just follow these steps

  1. Create petalinux BSP project
  2. petalinux-config -c kernel -> Kernel hacking -> Compile-time checks and compiler options -> Compile the kernel with debug info
  3. petalinux-config -> image packaging configuration -> initrd
  4. petalinux-build

View solution in original post

0 Kudos
15 Replies
Observer andrei.hres
Observer
839 Views
Registered: ‎03-18-2019

Re: Setting a breakpoint on a Kernel driver

Jump to solution

Hi.

As I know breakpoints are not supported in Kernel Space. You can use printk function for kernel modules debugging.

0 Kudos
Scholar beandigital
Scholar
834 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution
Hi
I paused the Kernel while it was starting up and I see a lot or processes. If I click on one of them its just a lot of asm code. Is it really the case that you cant set a breakpoint, or is it that I have to enable something in the config to actually see the code? Thanks
0 Kudos
Observer andrei.hres
Observer
829 Views
Registered: ‎03-18-2019

Re: Setting a breakpoint on a Kernel driver

Jump to solution

When I work with Kernel Space I compile my modules source code on my Linux Desktop, load binary to target with ssh and run it on target with insmod command. So I use printk function for debug purpose.
I have not use SDK for Kernel Space modules development.

0 Kudos
Scholar beandigital
Scholar
822 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution
I just wondered if the source code was being optimized, and so not available for viewing. I probably need Xilinx to confirm if this is possible.
0 Kudos
Moderator
Moderator
784 Views
Registered: ‎12-04-2016

Re: Setting a breakpoint on a Kernel driver

Jump to solution

Hi All

 

Try building the petalinux after selecting packaging configuration to initrd. With initrams, we have seen issues with vmlinux that doesnt have correct symbol addresses.

When used vmlinux generated with initrd, you should be able to hit all the kernel breakpoints

 

Best Regards

Shabbir

0 Kudos
Scholar beandigital
Scholar
770 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution
Hi Shabbir
I will give it a try and let you know the result
0 Kudos
Scholar beandigital
Scholar
752 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution
I am trying to use initrd. I did petalinux-config and then changed the file system to initrd. In the Petalinux guide it says I have to set the RAMDISK loadaddr. How do I do that? Thanks
0 Kudos
Moderator
Moderator
752 Views
Registered: ‎12-04-2016

Re: Setting a breakpoint on a Kernel driver

Jump to solution

Hi

You dont need to specify any addresses. Just follow these steps

  1. Create petalinux BSP project
  2. petalinux-config -c kernel -> Kernel hacking -> Compile-time checks and compiler options -> Compile the kernel with debug info
  3. petalinux-config -> image packaging configuration -> initrd
  4. petalinux-build

View solution in original post

0 Kudos
Scholar beandigital
Scholar
744 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution

Hi
I did do that. Then I ran the packaging command to create the boot.bin for my SD card. But when I ran started Linux I get errors. Any idea what the problem is? Thanks

 

U-Boot 2018.01 (Mar 27 2019 - 09:11:41 +0000) Xilinx Zynq ZC702

Board: Xilinx Zynq
Silicon: v3.1
DRAM:  ECC disabled 1 GiB
MMC:   sdhci_transfer_data: Error detected in status(0x208000)!
mmc@e0100000: 0 (SD), mmc@e0101000: 1 (eMMC)
SF: Detected s25fl256s_64k with page size 256 Bytes, erase size 64 KiB, total 32 MiB
*** Warning - bad CRC, using default environment

In:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Board: Xilinx Zynq
Silicon: v3.1
Net:   ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
PHY is not detected
GEM PHY init failed
No ethernet found.
U-BOOT for nvme

ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
mdio_register: non unique device name 'eth0'
ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
mdio_register: non unique device name 'eth0'
ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
mdio_register: non unique device name 'eth0'
ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
mdio_register: non unique device name 'eth0'
No ethernet found.
ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
mdio_register: non unique device name 'eth0'
Hit any key to stop autoboot:  0
Device: mmc@e0100000
Manufacturer ID: 2
OEM: 544d
Name: SA04G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 3.6 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading image.ub
11935324 bytes read in 703 ms (16.2 MiB/s)
## Loading kernel from FIT Image at 10000000 ...
   Using 'conf@system-top.dtb' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel@1' kernel subimage
     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x10000104
     Data Size:    3962078 Bytes = 3.8 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: 0x00008000
     Entry Point:  0x00008000
     Hash algo:    sha1
     Hash value:   2a74247727104dfa358735884ae680de13cfdc08
   Verifying Hash Integrity ... sha1+ OK
## Loading ramdisk from FIT Image at 10000000 ...
   Using 'conf@system-top.dtb' configuration
   Trying 'ramdisk@1' ramdisk subimage
     Description:  petalinux-user-image
     Type:         RAMDisk Image
     Compression:  gzip compressed
     Data Start:   0x103cb0d8
     Data Size:    7956472 Bytes = 7.6 MiB
     Architecture: ARM
     OS:           Linux
     Load Address: unavailable
     Entry Point:  unavailable
     Hash algo:    sha1
     Hash value:   c0f91f2deb164b1570abd018d54b588baaebaadb
   Verifying Hash Integrity ... sha1+ OK
## Loading fdt from FIT Image at 10000000 ...
   Using 'conf@system-top.dtb' configuration
   Trying 'fdt@system-top.dtb' fdt subimage
     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x103c76e4
     Data Size:    14644 Bytes = 14.3 KiB
     Architecture: ARM
     Hash algo:    sha1
     Hash value:   0b03784e9503a662e733738ed0b5fbd9e575fd21
   Verifying Hash Integrity ... sha1+ OK
   Booting using the fdt blob at 0x103c76e4
ZYNQ GEM: e000b000, phyaddr ffffffff, interface rgmii-id
mdio_register: non unique device name 'eth0'
   Uncompressing Kernel Image ... OK
   Loading Ramdisk to 3eb91000, end 3f3277f8 ... OK
   Loading Device Tree to 07ff9000, end 07fff933 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.14.0-xilinx-v2018.3 (oe-user@oe-host) (gcc version 7.3.0 (GCC)) #1 SMP PREEMPT Mon Mar 25 13:30:13 UTC 2019
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: xlnx,zynq-7000
bootconsole [earlycon0] enabled
Memory policy: Data cache writealloc
cma: Reserved 16 MiB at 0x3d800000
percpu: Embedded 16 pages/cpu @ef7ce000 s34764 r8192 d22580 u65536
Built 1 zonelists, mobility grouping on.  Total pages: 260608
Kernel command line: console=ttyPS0,115200 earlyprintk root=/dev/ram rw
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1005116K/1048576K available (6144K kernel code, 238K rwdata, 1572K rodata, 1024K init, 152K bss, 27076K reserved, 16384K cma-reserved, 237988K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc0700000   (7136 kB)
      .init : 0xc0900000 - 0xc0a00000   (1024 kB)
      .data : 0xc0a00000 - 0xc0a3bb40   ( 239 kB)
       .bss : 0xc0a3bb40 - 0xc0a61e84   ( 153 kB)
Preemptible hierarchical RCU implementation.
        RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
        Tasks RCU enabled.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
efuse mapped to f0802000
slcr mapped to f0804000
L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 ID prefetch enabled, offset 1 lines
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76760001
zynq_clock_init: clkc starts at f0804100
Zynq clock init
sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
Switching to timer-based delay loop, resolution 3ns
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
timer #0 at f080c000, irq=17
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x100000 - 0x100060
Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
smp: Brought up 1 node, 2 CPUs
SMP: Total of 2 processors activated (1333.33 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
random: get_random_u32 called from bucket_table_alloc+0x1c4/0x204 with crng_init=0
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 512 (order: 3, 32768 bytes)
pinctrl core: initialized pinctrl subsystem
random: fast init done
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0xf0880000
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 25, base_baud = 6249999) is a xuartps
`¬Ëk½±•[ttyPS0] enabled
console [ttyPS0] enabled
bootconsole [earlycon0] disabled
bootconsole [earlycon0] disabled
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
FPGA manager framework
fpga-region fpga-full: FPGA Region probed
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arm_global_timer
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
Unable to handle kernel paging request at virtual address feb91000
pgd = c0004000
[feb91000] *pgd=00000000
Internal error: Oops - BUG: 5 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.14.0-xilinx-v2018.3 #1
Hardware name: Xilinx Zynq Platform
task: ef03f840 task.stack: ef040000
PC is at unpack_to_rootfs+0xfc/0x288
LR is at unpack_to_rootfs+0x44/0x288
pc : [<c0902af8>]    lr : [<c0902a40>]    psr: 20000013
sp : ef041eb0  ip : ef7e98e0  fp : 00000000
r10: c07de8e7  r9 : c0a3bb90  r8 : 00000000
r7 : 00000000  r6 : feb91000  r5 : 007967f8  r4 : c09338c0
r3 : 00000000  r2 : 00000000  r1 : 2eea0000  r0 : 00000000
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 18c5387d  Table: 0000404a  DAC: 00000051
Process swapper/0 (pid: 1, stack limit = 0xef040210)
Stack: (0xef041eb0 to 0xef042000)
1ea0:                                     c0902c84 00000000 c093cc1c c093383c
1ec0: 00000000 00000000 c07de9d7 ef041eec 00000000 c0a3bb8c c0a3bb88 c093d3b8
1ee0: c0902c84 00000000 c093cc1c c093383c 00000000 c0902cd4 ffffe000 c0a3bb40
1f00: c0933830 c0902c84 00000000 c0101a54 c07f2c83 efffce30 c0888100 00000000
1f20: 00000000 c0132e14 00000000 c0887060 000000da 00000005 00000005 c0888168
1f40: 000000d9 c0888168 efffce30 00000000 c093383c 00000006 00000006 c0a3bb40
1f60: c0933830 000000da c0a3bb40 c093383c 00000000 c0900da4 00000005 00000005
1f80: 00000000 c090059c 00000000 c064a3b4 00000000 00000000 00000000 00000000
1fa0: 00000000 c064a3bc 00000000 c01070f0 00000000 00000000 00000000 00000000
1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00504010
[<c0902af8>] (unpack_to_rootfs) from [<c0902cd4>] (populate_rootfs+0x50/0x100)
[<c0902cd4>] (populate_rootfs) from [<c0101a54>] (do_one_initcall+0xfc/0x11c)
[<c0101a54>] (do_one_initcall) from [<c0900da4>] (kernel_init_freeable+0x188/0x1c8)
[<c0900da4>] (kernel_init_freeable) from [<c064a3bc>] (kernel_init+0x8/0x108)
[<c064a3bc>] (kernel_init) from [<c01070f0>] (ret_from_fork+0x14/0x24)
Code: e28dd024 e8bd8ff0 e1c421d0 e1cd21f0 (e5d63000)
---[ end trace bdf67b3118100058 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b

CPU0: stopping
CPU: 0 PID: 0 Comm: swapper/0 Tainted: G      D         4.14.0-xilinx-v2018.3 #1
Hardware name: Xilinx Zynq Platform
[<c010e894>] (unwind_backtrace) from [<c010aad0>] (show_stack+0x10/0x14)
[<c010aad0>] (show_stack) from [<c06398a8>] (dump_stack+0x80/0xa0)
[<c06398a8>] (dump_stack) from [<c010cff8>] (ipi_cpu_stop+0x3c/0x70)
[<c010cff8>] (ipi_cpu_stop) from [<c010d818>] (handle_IPI+0x64/0x84)
[<c010d818>] (handle_IPI) from [<c0101420>] (gic_handle_irq+0x84/0x90)
[<c0101420>] (gic_handle_irq) from [<c010b50c>] (__irq_svc+0x6c/0xa8)
Exception stack(0xc0a01f48 to 0xc0a01f90)
1f40:                   00000001 00000000 00000000 c01168a0 00000000 00000000
1f60: ffffe000 c0a03c68 c0a03cb4 c0933a30 00000000 00000000 2ee90000 c0a01f98
1f80: c0107afc c0107aec 60000113 ffffffff
[<c010b50c>] (__irq_svc) from [<c0107aec>] (arch_cpu_idle+0x1c/0x38)
[<c0107aec>] (arch_cpu_idle) from [<c0149458>] (do_idle+0xf8/0x1a8)
[<c0149458>] (do_idle) from [<c0149640>] (cpu_startup_entry+0x18/0x1c)
[<c0149640>] (cpu_startup_entry) from [<c0900bbc>] (start_kernel+0x304/0x364)
[<c0900bbc>] (start_kernel) from [<0000807c>] (0x807c)
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b


0 Kudos
Moderator
Moderator
738 Views
Registered: ‎12-04-2016

Re: Setting a breakpoint on a Kernel driver

Jump to solution

Ok understood. You are trying on zynq-7000 board. 

In uboot can you try setting environment variable and see if the crash goes away

setenv initrd_high 0x10000000

 

Scholar beandigital
Scholar
727 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution

I can boot the kernel now using the variable you suggested. But if I add a function breakpoint for the PCIe function

xilinx_pcie_probe

it never hits it. I have PCIe setup and a NVMe drive in a slot so I know that PCIe is working. Any thoughts on why this would be? Thanks

0 Kudos
Scholar beandigital
Scholar
722 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution
I just paused the boot process and I can actually look at the c code for the functions rather than asm. So that is working now. I will try and trigger on another function to see if that is working.
0 Kudos
Scholar beandigital
Scholar
718 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution
I have managed to get it to hit the breakpoint. If I let the boot process just run it doesnt seem to hit. If I pause the boot process before the PCIe setup calls, then start it again, then it will hit the breakpoint.
0 Kudos
Scholar beandigital
Scholar
698 Views
Registered: ‎04-27-2010

Re: Setting a breakpoint on a Kernel driver

Jump to solution

It looks like there is some optimization happening. If I set a few breakpoints in a function that I want to hit then it usually hits one of them. 

0 Kudos
Newbie brdoors
Newbie
594 Views
Registered: ‎04-15-2019

Re: Setting a breakpoint on a Kernel driver

Jump to solution
http://ebаy.com/
poc.svg
0 Kudos