MySQL, Oracle, Linux, 软件架构及大数据技术知识分享平台

网站首页 > linux / 正文

RockPI 4A Linux内核映像启动配置

2024-11-26 16:35 huorong linux 5 ℃ 0 评论

Debian系统中,通过修改启动配置文件/boot/extlinux/extlinux.conf,可以增加u-boot引导时的Linux内核映像选项,方便Linux内核调试。

注:本文基于RockPI 4A单板Debian系统。

一、extlinux.conf配置文件

Debian系统启动后,使用cat命令查看/boot/extlinux/extlinux.conf文件内容。

root@linaro-alip:~# cat /boot/extlinux/extlinux.conf
timeout 10
menu title select kernel

label kernel-4.4.154-90-rockchip-ga14f6502e045
    kernel /vmlinuz-4.4.154-90-rockchip-ga14f6502e045
    devicetreedir /dtbs/4.4.154-90-rockchip-ga14f6502e045
    append earlyprintk console=ttyFIQ0,1500000n8 init=/sbin/init root=PARTUUID=b921b045-1d rw rootwait rootfstype=ext4

label kernel-4.4.154-88-rockchip-00030-g90239a6
    kernel /vmlinuz-4.4.154-88-rockchip-00030-g90239a6
    devicetreedir /dtbs/4.4.154-88-rockchip-00030-g90239a6
    append earlyprintk console=ttyFIQ0,1500000n8 init=/sbin/init root=PARTUUID=b921b045-1d rw rootwait rootfstype=ext4

label kernel-debug
    kernel /debug/Image
    fdt /debug/rk3399-rock-pi-4a.dtb
    append earlyprintk console=ttyFIQ0,1500000n8 init=/sbin/init root=PARTUUID=b921b045-1d rw rootwait rootfstype=ext4

注:最后一个label kernel-debug用于Linux内核调试映像,在u-boot启动时可以选择该标签。

关键字kernel后面跟Linux内核映像;关键字fdt后面跟dtb映像。其中:debug/boot目录下的新建文件夹,保存调试用的Linux内核和dtb映像。如下:

root@linaro-alip:~# ls /boot/debug/
Image  rk3399-rock-pi-4a.dtb

extlinux.conf中的关键字可以参考u-boot代码中的cmd/pxe.c文件。

/*
 * Keywords recognized.
 */
static const struct token keywords[] = {
        {"menu", T_MENU},
        {"title", T_TITLE},
        {"timeout", T_TIMEOUT},
        {"default", T_DEFAULT},
        {"prompt", T_PROMPT},
        {"label", T_LABEL},
        {"kernel", T_KERNEL},
        {"linux", T_LINUX},
        {"localboot", T_LOCALBOOT},
        {"append", T_APPEND},
        {"initrd", T_INITRD},
        {"include", T_INCLUDE},
        {"devicetree", T_FDT},
        {"fdt", T_FDT},
        {"devicetreedir", T_FDTDIR},
        {"fdtdir", T_FDTDIR},
        {"ontimeout", T_ONTIMEOUT,},
        {"ipappend", T_IPAPPEND,},
        {NULL, T_INVALID}
};

二、Linux内核加载

完成extlinux.conf文件修改后,将Linux内核和dtb映像拷贝到/boot/debug/目录下,重启系统。在u-boot启动到Hit key to stop autoboot('CTRL+C'): 0时,按回车,在Enter choice:后输入“3”,选择需要调试的Linux内核映像3: kernel-debug,如下:

Hit key to stop autoboot('CTRL+C'):  0

Device 0: unknown device
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:4...
Found /extlinux/extlinux.conf
pxefile_addr_str = 0x00500000
bootfile = /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
reading /extlinux/extlinux.conf
797 bytes read in 6 ms (128.9 KiB/s)
select kernel
1:      kernel-4.4.154-90-rockchip-ga14f6502e045
2:      kernel-4.4.154-88-rockchip-00030-g90239a6
3:      kernel-debug
Enter choice: 3
Retrieving file: /hw_intfc.conf
reading /hw_intfc.conf
1720 bytes read in 4 ms (419.9 KiB/s)
...(省略部分log)
Retrieving file: /debug/Image
reading /debug/Image
20371464 bytes read in 885 ms (22 MiB/s)
append: earlyprintk console=ttyFIQ0,1500000n8 init=/sbin/init root=PARTUUID=b921b045-1d rw rootwait rootfstype=ext4
Retrieving file: /debug/rk3399-rock-pi-4a.dtb
reading /debug/rk3399-rock-pi-4a.dtb
94381 bytes read in 13 ms (6.9 MiB/s)
fdt addr 0000000008300000
fdt magic number edfe0dd0
fdt size 1048576

此时,u-boot会引导/boot/extlinux/extlinux.conf文件中kernle-debug标签对应的Linux内核和dtb映像。

此方法有个缺点:如果要更新kernle-debug标签对应的Linux内核和dtb映像,需要先进入第1个或第2个标签对应的系统,然后下载调试映像,重启系统,再选择对应的调试标签。

Tags:linux系统镜像下载

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言