From 9f5695b99ded1f35ab4807963a5f6002419d6e7d Mon Sep 17 00:00:00 2001 From: Banana Pi -BPI Date: Mon, 16 Feb 2026 09:17:44 -0500 Subject: [PATCH] MBR support Signed-off-by: Banana Pi -BPI --- board/spacemit/k1-x/k1x.c | 10 +++++++++- common/spl/spl_mmc.c | 22 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/board/spacemit/k1-x/k1x.c b/board/spacemit/k1-x/k1x.c index 662d334a..309bbb09 100644 --- a/board/spacemit/k1-x/k1x.c +++ b/board/spacemit/k1-x/k1x.c @@ -520,6 +520,7 @@ void _load_env_from_blk(struct blk_desc *dev_desc, const char *dev_name, int dev char cmd[128]; struct disk_partition info; + printf("BPI: :%s\n", "_load_env_from_blk"); for (part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { err = part_get_info(dev_desc, part, &info); if (err) @@ -529,8 +530,13 @@ void _load_env_from_blk(struct blk_desc *dev_desc, const char *dev_name, int dev break; } } - if (part > MAX_SEARCH_PARTITIONS) + if (part > MAX_SEARCH_PARTITIONS) { +#ifdef BPI return; +#else + part = 1; +#endif + } env_set("bootfs_part", simple_itoa(part)); env_set("bootfs_devname", dev_name); @@ -540,12 +546,14 @@ void _load_env_from_blk(struct blk_desc *dev_desc, const char *dev_name, int dev sprintf(cmd, "load %s %d:%d 0x%x env_%s.txt", dev_name, dev, part, CONFIG_SPL_LOAD_FIT_ADDRESS, CONFIG_SYS_CONFIG_NAME); pr_debug("cmd:%s\n", cmd); + printf("BPI: cmd:%s\n", cmd); if (run_command(cmd, 0)) return; memset(cmd, '\0', 128); sprintf(cmd, "env import -t 0x%x", CONFIG_SPL_LOAD_FIT_ADDRESS); pr_debug("cmd:%s\n", cmd); + printf("BPI: cmd:%s\n", cmd); if (!run_command(cmd, 0)){ pr_info("load env_%s.txt from bootfs successful\n", CONFIG_SYS_CONFIG_NAME); } diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index acf2b278..581958bb 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -91,6 +91,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, /* read image header to find the image size & load address */ count = blk_dread(bd, sector, 1, header); + printf("BPI:hdr read sector %lx, count=%lu\n", sector, count); debug("hdr read sector %lx, count=%lu\n", sector, count); if (count == 0) { ret = -EIO; @@ -222,11 +223,27 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, } } #endif + printf("BPI: partition=%d part_name[%s]\n",partition ,part_name); for (int p = 1; p <= MAX_SEARCH_PARTITIONS; p++) { err = part_get_info(mmc_get_blk_desc(mmc), p, &info); - if (err) - continue; + if (err) { +#ifdef BPI +#else + if (!strcmp(part_name, "opensbi")){ + info.start = 0x500; + strcpy(info.name,"opensbi"); + } + else + if (!strcmp(part_name, "uboot")){ + info.start = 0x800; + strcpy(info.name,"uboot"); + } + else +#endif + continue; + } + printf("BPI: p=%d info.name=[%s] info.start[%lx]\n",p ,info.name,info.start); if (!strcmp(part_name, info.name)){ if (mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start) == 0) return 0; @@ -245,6 +262,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start + sector); #else + printf("BPI2: info.name=[%s] info.start[%lx]\n" ,info.name,info.start); return mmc_load_image_raw_sector(spl_image, bootdev, mmc, info.start); #endif } -- 2.51.0