From 02334e4f252955c42eeb675dbeb0cf4b195e5c2d Mon Sep 17 00:00:00 2001 From: surenyi Date: Tue, 30 Jul 2024 09:59:24 +0800 Subject: [PATCH] fix sysboot's dtb Signed-off-by: surenyi --- arch/arm/mach-rockchip/boot_rkimg.c | 32 +++++++++++++++++++++++++---- configs/sytc_defconfig | 2 ++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-rockchip/boot_rkimg.c b/arch/arm/mach-rockchip/boot_rkimg.c index 097d976..0c66fbb 100644 --- a/arch/arm/mach-rockchip/boot_rkimg.c +++ b/arch/arm/mach-rockchip/boot_rkimg.c @@ -462,6 +462,23 @@ static int fdt_check_hash(void *fdt_addr, u32 fdt_size, #endif /* CONFIG_ROCKCHIP_DTB_VERIFY */ #if defined(CONFIG_ROCKCHIP_EARLY_DISTRO_DTB) +/* {{{ get bootpart */ +static int get_boot_part_num(void) +{ + int part_id; + disk_partition_t part; + struct blk_desc *blkdev; + + blkdev = rockchip_get_bootdev(); + if (blkdev) { + if ((part_id = part_get_info_by_name(blkdev, PART_BOOT, &part)) > 0) { + return part_id; + } + } + return -ENODEV; +} +/* }}} */ + static int rockchip_read_distro_dtb(void *fdt_addr) { const char *cmd = "part list ${devtype} ${devnum} -bootable devplist"; @@ -469,6 +486,7 @@ static int rockchip_read_distro_dtb(void *fdt_addr) char devnum_part[12]; char fdt_hex_str[19]; char *fs_argv[5]; + int part_id; if (!rockchip_get_bootdev() || !fdt_addr) return -ENODEV; @@ -478,13 +496,19 @@ static int rockchip_read_distro_dtb(void *fdt_addr) return -EINVAL; } - devplist = env_get("devplist"); - if (!devplist) - devplist = "1"; + part_id = get_boot_part_num(); + if (part_id <= 0) { + devplist = env_get("devplist"); + if (!devplist) { + part_id = 1; + } else { + part_id = strtoul(devplist, NULL, 16); + } + } devtype = env_get("devtype"); devnum = env_get("devnum"); - sprintf(devnum_part, "%s:%s", devnum, devplist); + sprintf(devnum_part, "%s:%d", devnum, part_id); sprintf(fdt_hex_str, "0x%lx", (ulong)fdt_addr); fs_argv[0] = "load"; diff --git a/configs/sytc_defconfig b/configs/sytc_defconfig index 80b44b0..f845224 100644 --- a/configs/sytc_defconfig +++ b/configs/sytc_defconfig @@ -235,3 +235,5 @@ CONFIG_ENV_IS_IN_MMC=y CONFIG_ENV_OFFSET=0x400000 CONFIG_ENV_SIZE=0x100000 CONFIG_CMD_ENV_FLAGS=y +CONFIG_ROCKCHIP_EARLY_DISTRO_DTB=y +CONFIG_ROCKCHIP_EARLY_DISTRO_DTB_PATH="/rk3588-sytc.dtb"