向linux kernel中添加cmdline的四种方式

快速链接:
.
👉👉👉 个人博客笔记导读目录(全部) 👈👈👈

在linux启动时候,串口log中会打印cmdline

[    0.000000] c0 0 (swapper) Kernel command line: earlycon androidboot.selinux=permissive uart_dma keep_dbgclk_on clk_ignore_unused initrd=0xd0000000,38711808 rw crash_page=0x8f040000 initrd=/recoveryrc boot_reason=0x2000 ota_status=0x1001

在linux启动完成后,通过 cat /proc/cmdline也是可以看到cmdline. 那么cmdline是如何添加的呢?

1、 在dts中的bootargs中添加
/ {
    model = "xxx yyyyyyy FPGA";
    compatible = "xxx ,yyyyy-fpga", "xxx ,yyyyyy";

    chosen {
        /*
         * initrd parameters not set in dts file since the ramdisk.img size
         * need to check in uboot, and the initrd load address and size will
         * set in uboot stage.
         */
        bootargs = "earlycon androidboot.selinux=permissive uart_dma keep_dbgclk_on clk_ignore_unused";
        stdout-path = "serial0:115200";
    };
......
}
2、在BoardConfig中添加

vim device/xxx/xxx_evb/BoardConfigCommon.mk

BOARD_KERNEL_CMDLINE += androidboot.selinux=enforcing androidboot.hardware=xxxxx_phone androidboot.dtbo_idx=0
3、在uboot中添加

vim u-boot/common/cmd_bootm.c

append_bootargs("recovery=1");

sprintf(dm_buf,"init=/init skip_initramfs rootwait root=/dev/dm-0 dm=\"system none ro,0 1 android-verity /dev/mmcblk0p%d\"",ret);
append_bootargs((const char *)dm_buf);
4、在android的Makefile中添加

vim build/core/Makefile

INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif

在这里插入图片描述
《ARMv8/ARMv9架构学习系列课程》全系列,共计52节课,超16h的视频课程

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码改变世界ctw

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值