ILD

rk3562 panic 无打印的问题
作者:Yuan Jianpeng 邮箱:yuanjp89@163.com
发布时间:2025-5-25 站点:Inside Linux Development

最近在移植一个rk3562的板子,发现内核启动会卡住,无输入输出。


在正常的rootfs中,在串口手动触发panic后,也无输入输出。

# echo c > /proc/sysrq-trigger

仔细查看内核日志,有一个:

[    0.409106] ramoops: dmesg-0 0x18000@0x0000000000110000
[    0.414754] ramoops: dmesg-1 0x18000@0x0000000000128000
[    0.420809] ramoops: console 0x80000@0x0000000000140000
[    0.426426] ramoops: pmsg    0x30000@0x00000000001c0000
[    0.431769] printk: console [ramoops-1] enabled


怀疑是panic被打印到其它地方去了。搜内核,发现了:Documentation/admin-guide/ramoops.rst



尝试关掉pstore,仍然不解决问题。


drivers/tty/sysrq.c 加调试:

static void sysrq_handle_crash(int key)
{
        /* release the RCU read lock before crashing */
        rcu_read_unlock();

        printk("---------------- sysrq triggerred crash\n");

        panic("sysrq triggered crash\n");
}


printk都没打出来,注释掉panic后,可以打出来。怀疑是panic()的问题。


查看内核启动日志,有:

[    0.756071] printk: console [ttyFIQ0]: printing thread started

然后搜到了一篇文章。内核为printk启动了一个线程。


然后panic函数里面有:


pr_flush是等待print thread完成,再后面加一个 while(1); 结果panic日志打出来。然后怀疑是时间太短了。改成30s。就ok了。


[    1.145480] Run /sbin/init as init process
[    1.145483]   with arguments:
[    1.145487]     /sbin/init
[    1.145489]     #t-10/08/2024
[    1.145492]   with environment:
[    1.145495]     HOME=/
[    1.145497]     TERM=linux
[    1.145499]     storagemedia=emmc
[    1.150147] run /sbin/init return -2
[    1.150157] Run /etc/init as init process
[    1.150160]   with arguments:
[    1.150164]     /etc/init
[    1.150167]     #t-10/08/2024
[    1.150169]   with environment:
[    1.150172]     HOME=/
[    1.150174]     TERM=linux
[    1.150176]     storagemedia=emmc
[    1.150394] run /etc/init return -2
[    1.150398] Run /bin/init as init process
[    1.150400]   with arguments:
[    1.150403]     /bin/init
[    1.150405]     #t-10/08/2024
[    1.150407]   with environment:
[    1.150410]     HOME=/
[    1.150412]     TERM=linux
[    1.150414]     storagemedia=emmc
[    1.150461] run /bin/init return -2
[    1.150464] Run /bin/sh as init process
[    1.150466]   with arguments:
[    1.150468]     /bin/sh
[    1.150471]     #t-10/08/2024
[    1.150473]   with environment:
[    1.150475]     HOME=/
[    1.150477]     TERM=linux
[    1.150480]     storagemedia=emmc
[    1.150551] run /bin/sh return -2
[    1.150555] Kernel panic - not syncing:
[    1.150557] No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[    1.150560] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.209-rt89-g17a4e1a-dirty #12
[    1.150566] Hardware name: TL3562-MiniEVM (DT)
[    1.150570] Call trace:
[    1.150571]  dump_backtrace+0x0/0x1f0
[    1.150585]  show_stack+0x1c/0x24
[    1.150591]  dump_stack_lvl+0xe0/0x104
[    1.150599]  dump_stack+0x14/0x30
[    1.150605]  panic+0xf8/0x374
[    1.150611]  kernel_init+0x1d4/0x1ec
[    1.150618]  ret_from_fork+0x10/0x20
[    1.399234] dw-mipi-dsi-rockchip ffb10000.dsi: [drm:dw_mipi_dsi_bridge_atomic_enable] final DSI-Link bandwidth: 996 x 4 Mbps


参考:

printk: introduce printing kernel thread

https://lwn.net/Articles/716319/


Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.