系统相关
首页 > 系统相关> > 向linux kernel中添加cmdline的四种方式

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

作者:互联网

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

标签:kernel,cmdline,xxx,CMDLINE,添加,linux,KERNEL,bootargs
来源: https://blog.51cto.com/u_15278218/2931157