Kernel panic when entering KGDB

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Kernel panic when entering KGDB

675 Views
972931182
Contributor I

Hi,

I'm trying to enable KGDB in linux-imx kernel for debugging. I did the following steps:

  1. git clone the source code from here: https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm/configs?h=imx_5.4.3_2.0.0 
  2. checkout branch to imx_4.1.14_2.0.0_ga
  3. run make imx_v7_defconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  4. run make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- and enable these:
    --- KGDB: kernel debugger
        <*> KGDB: use kgdb over the serial console
        [ ] KGDB: internal test suite
        [*] KGDB_KDB: include kdb frontend for kgdb
        (0x1) KDB: Select kdb command functions to be enabled by default
        [ ] KGDB_KDB: keyboard as input device
        (0) KDB: continue after catastrophic errors
  5. run make zImage ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  6. download zImage to my board
  7. restart board and enter in system
  8. run echo ttymxc1,9600 > /sys/module/kgdboc/parameters/kgdboc to register KGDBOC serial
  9. run echo g > /proc/sysrq-trigger to enter KGDB
  10. kernel panic shows 

The panic info is blew:

 

[   74.652531] sysrq: SysRq : DEBUG
[   74.655892] Unhandled fault: imprecise external abort (0x1c06) at 0x76ee328c
[   74.662958] pgd = 8866c000
[   74.665676] [76ee328c] *pgd=88644831, *pte=830f259f, *ppte=830f2e7e
[   74.672018] Internal error: : 1c06 [#1] PREEMPT SMP ARM
[   74.677294] KGDB: re-enter exception: ALL breakpoints killed
[   74.682969] ---[ end trace d61e9a1fd52b50df ]---
[   74.687606] Unhandled fault: imprecise external abort (0x1c06) at 0x76ee328c
[   74.694664] pgd = 8866c000
[   74.697382] [76ee328c] *pgd=88644831, *pte=830f259f, *ppte=830f2e7e
[   74.703711] Internal error: : 1c06 [#2] PREEMPT SMP ARM
[   74.708992] CPU: 0 PID: 152 Comm: sh Tainted: G      D         4.1.15-00158-g30278abfe097-dirty #1
[   74.717959] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[   74.724191] [<800161e0>] (unwind_backtrace) from [<80012748>] (show_stack+0x10/0x14)
[   74.731967] [<80012748>] (show_stack) from [<80809434>] (dump_stack+0x84/0xc4)
[   74.739220] [<80809434>] (dump_stack) from [<8009d8fc>] (kgdb_handle_exception+0x1fc/0x20c)
[   74.747600] [<8009d8fc>] (kgdb_handle_exception) from [<800157dc>] (kgdb_notify+0x24/0x3c)
[   74.755891] [<800157dc>] (kgdb_notify) from [<8004fe04>] (notifier_call_chain+0x44/0x84)
[   74.764010] [<8004fe04>] (notifier_call_chain) from [<80050088>] (atomic_notifier_call_chain+0x34/0x48)
[   74.773429] [<80050088>] (atomic_notifier_call_chain) from [<80050608>] (notify_die+0x38/0x40)
[   74.782066] [<80050608>] (notify_die) from [<80012848>] (die+0xfc/0x3f0)
[   74.788789] [<80012848>] (die) from [<80009304>] (do_DataAbort+0xb4/0xb8)
[   74.795600] [<80009304>] (do_DataAbort) from [<800131d8>] (__dabt_svc+0x38/0x60)
[   74.803009] Exception stack(0x88799be0 to 0x88799c28)
[   74.808082] 9be0: 8829c410 0000000a 00005008 a0950000 80c57f19 80c57f18 80c57f18 0000002b
[   74.816279] 9c00: 80c589d8 80c58ae8 80c53aac 00000000 881bd000 88799c28 8009f838 803618d0
[   74.824467] 9c20: 000d0093 ffffffff
[   74.827987] [<800131d8>] (__dabt_svc) from [<803618d0>] (imx_poll_put_char+0x20/0x2c)
[   74.835844] [<803618d0>] (imx_poll_put_char) from [<8009f838>] (vkdb_printf+0x1d4/0xa30)
[   74.843961] [<8009f838>] (vkdb_printf) from [<800a00b8>] (kdb_printf+0x24/0x34)
[   74.851296] [<800a00b8>] (kdb_printf) from [<800a41b0>] (kdb_main_loop+0x100/0x7d0)
[   74.858974] [<800a41b0>] (kdb_main_loop) from [<800a7080>] (kdb_stub+0x2ac/0x508)
[   74.866480] [<800a7080>] (kdb_stub) from [<8009d2e0>] (kgdb_cpu_enter+0x414/0x710)
[   74.874073] [<8009d2e0>] (kgdb_cpu_enter) from [<8009d7f8>] (kgdb_handle_exception+0xf8/0x20c)
[   74.882707] [<8009d7f8>] (kgdb_handle_exception) from [<80015790>] (kgdb_compiled_brk_fn+0x28/0x30)
[   74.891774] [<80015790>] (kgdb_compiled_brk_fn) from [<800090f8>] (do_undefinstr+0xe4/0x190)
[   74.900231] [<800090f8>] (do_undefinstr) from [<800132ec>] (__und_svc_finish+0x0/0x34)
[   74.908159] Exception stack(0x88799e70 to 0x88799eb8)
[   74.913226] 9e60:                                     00000067 80a485c4 00000000 00000000
[   74.921422] 9e80: 80c53aa0 80c53aa4 80b9a504 00000067 00000000 88798000 00000000 013f7008
[   74.929614] 9ea0: 00000000 88799eb8 8034fa1c 8009c884 600d0013 ffffffff
[   74.936251] [<800132ec>] (__und_svc_finish) from [<8009c884>] (kgdb_breakpoint+0x44/0x78)
[   74.944454] [<8009c884>] (kgdb_breakpoint) from [<8034fa1c>] (__handle_sysrq+0xac/0x178)
[   74.952570] [<8034fa1c>] (__handle_sysrq) from [<8034ff14>] (write_sysrq_trigger+0x38/0x48)
[   74.960951] [<8034ff14>] (write_sysrq_trigger) from [<80146c64>] (proc_reg_write+0x5c/0x84)
[   74.969330] [<80146c64>] (proc_reg_write) from [<800f4e10>] (__vfs_write+0x20/0xdc)
[   74.977011] [<800f4e10>] (__vfs_write) from [<800f55ec>] (vfs_write+0x90/0x164)
[   74.984345] [<800f55ec>] (vfs_write) from [<800f5e10>] (SyS_write+0x44/0x9c)
[   74.991419] [<800f5e10>] (SyS_write) from [<8000f480>] (ret_fast_syscall+0x0/0x3c)
[   74.999003] Kernel panic - not syncing: Recursive entry to debugger

 

----------------------------------------------------------------------------------------------------------------

Probably solution

 

It seems that there may be some errors in the functionimx_poll_putchar.After several nights of debugging, I have found that this panic is caused because the TXEN bit in UCR2 register for uart2(ttymxc1) is not enable. 

And I think which should be enable in imx_poll_init:

 

static int imx_poll_init(struct uart_port *port)
{
	struct imx_port *sport = (struct imx_port *)port;
	unsigned long flags;
	unsigned long temp;
	int retval;

	retval = clk_prepare_enable(sport->clk_ipg);
	if (retval)
		return retval;
	retval = clk_prepare_enable(sport->clk_per);
	if (retval)
		clk_disable_unprepare(sport->clk_ipg);

	imx_setup_ufcr(sport, 0);

	spin_lock_irqsave(&sport->port.lock, flags);

	temp = readl(sport->port.membase + UCR1);
	if (is_imx1_uart(sport))
		temp |= IMX1_UCR1_UARTCLKEN;
	temp |= UCR1_UARTEN | UCR1_RRDYEN;
	temp &= ~(UCR1_TXMPTYEN | UCR1_RTSDEN);
	writel(temp, sport->port.membase + UCR1);

	temp = readl(sport->port.membase + UCR2);
	temp |= UCR2_RXEN;
	writel(temp, sport->port.membase + UCR2);

	spin_unlock_irqrestore(&sport->port.lock, flags);

	return 0;
}

 

At the fourth to last line, maybe should aslo enable UCR2_TXEN . like this:

 

temp |= (UCR2_RXEN | UCR2_TXEN);

 

After modify that line, my problem has been solved . I'm not sure if this is a bug, I hope someone could check about this. And if this is a bug, I'd like to submit a patch or pull request to this.

Thanks.

Labels (2)
0 Kudos
1 Reply

648 Views
972931182
Contributor I

Seems like nobody notice this post... could anybody help please . Any help will be appreciated.

0 Kudos