RK356x 修改uboot和kernel,让固件支持多个设备树DTB选择

步骤如下

    • 1、开发环境
      • 1.1 实验环境
      • 1.2 目标
    • 2、 Uboot修改
      • 2.1 uboot默认配置文件.config
      • 2.2 uboot从resource.img获取DTB和kernel顺序过程
      • 2.3 修改boot_mode模式
      • 2.4 进入到uboot中的cmdline模式选择配置
    • 3、Kernel修改
      • 3.1 打包resource.img
    • 4 、重新编译即可

1、开发环境

1.1 实验环境

虚拟机版本:ubuntu18.04
芯片:RK356X
linux版本:4.19

1.2 目标

将一个烧写固件img变成可以兼容多个不同显示(HDMI,MIPI,LVDS)或者不同功能的固件。并通过uboot启动时进入cmdline模式时菜单栏选择支持的选项。

2、 Uboot修改

2.1 uboot默认配置文件.config

由于瑞芯微默认把uboot的环境变量设置成了CONFIG_ENV_IS_NOWHERE ,意思是环境变量将不会存储在任何地方,因此无法使用和修改环境变量。如何需要维持上一次上电前选择的配置的话,我们需要改成CONFIG_ENV_IS_IN_MMC。

#
# Environment
#
- # CONFIG_ENV_IS_NOWHERE is not set
# CONFIG_ENV_IS_IN_EEPROM is not set
# CONFIG_ENV_IS_IN_FAT is not set
# CONFIG_ENV_IS_IN_FLASH is not set
+ CONFIG_ENV_IS_IN_MMC=y
# CONFIG_ENV_IS_IN_NAND is not set
# CONFIG_ENV_IS_IN_NVRAM is not set
# CONFIG_ENV_IS_IN_ONENAND is not set
# CONFIG_ENV_IS_IN_REMOTE is not set
# CONFIG_ENV_IS_IN_SPI_FLASH is not set
# CONFIG_ENV_IS_IN_UBI is not set
# CONFIG_ENV_IS_IN_BLK_DEV is not set
# CONFIG_ENV_AES is not set```

2.2 uboot从resource.img获取DTB和kernel顺序过程

sdk/u-boot/common/board_r.c

static init_fnc_t init_sequence_r[] = {
   
	......省略
	#ifdef CONFIG_USING_KERNEL_DTB
	initr_env_nowhere,
#endif
#if defined(CONFIG_BOARD_EARLY_INIT_R)
	board_early_init_r,
#endif
	


#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
	//设备配置
	board_init,	/* Setup chipselects */
#endif
#if defined(CONFIG_USING_KERNEL_DTB) && !defined(CONFIG_ENV_IS_NOWHERE)
	
#endif
	initr_env_switch,
		......省略
}

sdk/u-boot/arch/arm/mach-rockchip/board.c

int board_init(void)
{
   
	
	board_debug_init();
	
#ifdef DEBUG
	soc_clk_dump();
#endif
#ifdef CONFIG_USING_KERNEL_DTB
#ifdef CONFIG_MTD_BLK
	board_mtd_blk_map_partitions();
#endif
	
	init_kernel_dtb();
+	env_set("reboot_mode","");
#endif

	early_download();
	
	/*
	 * pmucru isn't referenced on some platforms, so pmucru driver can't
	 * probe that the "assigned-clocks" is unused.
	 */
	
	clks_probe();
#ifdef CONFIG_DM_REGULATOR
	if (regulators_enable_boot_on(is_hotkey(HK_REGULATOR)))
		debug("%s: Can't enable boot on regulator

你可能感兴趣的:(瑞芯微RK驱动调试,linux,运维,服务器)