TechNexion / u-boot-tn-imx

i.MX U-Boot maintained by TechNexion
GNU General Public License v2.0
13 stars 11 forks source link

Missing complete usdhc boot for pico-imx7d #6

Closed Livius90 closed 1 year ago

Livius90 commented 2 years ago

Hi,

I have a custom carrier board for pico-imx7d which is able to boot from an external SD card from usdhc1 physical port. It nicely works in u-boot-tn-imx v2018.03. Unfortunately in any newest u-boot it stopped working to boot from usdhc1, only the SoM's eMMC boot works well in u-boot-tn-imx and also in u-boot-fslc.

I found that in u-boot-tn-imx v2018.03, it was nicely implemented in pico-imx7d.c. But that adaptive booting algorithm is totally missing in the newest u-boot-tn-imx and in u-boot-fslc.

@richard-hu Can you restore that feature to newest u-boot-tn-imx to be able to boot from any sd card, from usdhc3 (SoM MicroSD/MMC) and usdhc1 (Carrier board MicroSD)?

@otavio Then, later can you merge it to u-boot-fslc and to mainline u-boot, too?

otavio commented 2 years ago

@Livius90 check 2022.07 as it works just fine. This old release isn't maintained anymore.

Livius90 commented 2 years ago

I already try u-boot-fslc v2022.07, it does not work, only the SoM's eMMC boot can work in it too.

richard-hu commented 2 years ago

@Livius90 :

Thanks for the feedback. @JoeZhang-tn Could you take a look at this problem?

BR,

Richard

Livius90 commented 2 years ago

There is a quick fix which is working in u-boot-fslc v2022.07 for me. https://gist.github.com/Livius90/6806a73dd2128e5fe66924f103515b1b

It is based on u-boot-tn-imx v2018.03 pico-imx7d.c. But my code is not complete for final fix, the original was much better in u-boot-tn-imx v2018.03, the best could be to merge v2018.03 to the mainline u-boot.

JoeZhang-tn commented 2 years ago

@Livius90

For pico-imx7d, we only support PICO-PI for our baseboard. So we remove the boot from SD of baseboard since 5.4.70(v2020.04).

But, we create the patch that can support boot from SD of baseboard. Hope it will help.

add baseboard detection of pico-imx7.zip

THAKS~~ Joe

Livius90 commented 2 years ago

@Livius90

For pico-imx7d, we only support PICO-PI for our baseboard. So we remove the boot from SD of baseboard since 5.4.70(v2020.04).

But, we create the patch that can support boot from SD of baseboard. Hope it will help.

add baseboard detection of pico-imx7.zip

THAKS~~ Joe

Can you merger it to newest u-boot-tn-imx v2021.04_5.15.5?

JoeZhang-tn commented 2 years ago

@Livius90

Our uboot code is v2021.04_5.10.72 The zip file above have its patch, named 5.10.72-0001-pico-imx7d-add-baseboard-SD-card-boot-detect.patch

Livius90 commented 2 years ago

@JoeZhang-tn I mean, it should be part of your u-boot-tn-imx GitHub repo in latest version.

JoeZhang-tn commented 2 years ago

@Livius90

Push both patches on *next branch.

Livius90 commented 2 years ago

@JoeZhang-tn In your patch board_late_mmc_env_init() function assigne an incorrect mmc blk number because mmc_get_env_dev() returns just a defined number, so /dev/mmcblkXp2 is not filled automatically with correct X blk number.

JoeZhang-tn commented 2 years ago

The check mmcdev flow is in arch/arm/mach-imx/mmc_env.c

__weak int board_mmc_get_env_dev(int devno)
{
    return devno;
}

int mmc_get_env_dev(void)
{
    struct bootrom_sw_info **p =
        (struct bootrom_sw_info **)(ulong)ROM_SW_INFO_ADDR;
    int devno = (*p)->boot_dev_instance;
    u8 boot_type = (*p)->boot_dev_type;

    /* If not boot from sd/mmc, use default value */
    if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
        return env_get_ulong("mmcdev", 10, CONFIG_SYS_MMC_ENV_DEV);

    return board_mmc_get_env_dev(devno);
}

And, it's working fine with our test.

HW : pico-imx7d with NYMPH

v5.10.72 SD boot

switch to partitions #0, OK
mmc0 is current device
flash target is MMC:0
Net:   eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0 
=> printenv
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk0p2 rootwait rw

root@pico-imx7:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  7.5G  0 disk 
|-mmcblk0p1  179:1    0 24.8M  0 part /run/media/mmcblk0p1
`-mmcblk0p2  179:2    0  7.5G  0 part /
mmcblk2      179:8    0 14.6G  0 disk 
|-mmcblk2p1  179:9    0 24.8M  0 part /run/media/mmcblk2p1
`-mmcblk2p2  179:10   0  1.1G  0 part /run/media/mmcblk2p2
mmcblk2boot0 179:16   0    4M  1 disk 
mmcblk2boot1 179:24   0    4M  1 disk

v5.10.72 emmc boot

switch to partitions #0, OK
mmc2(part 0) is current device
flash target is MMC:2
Net:   eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0 
=> printenv
mmcdev=2
mmcpart=1
mmcroot=/dev/mmcblk2p2 rootwait rw

root@pico-imx7:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  7.5G  0 disk 
|-mmcblk0p1  179:1    0 24.8M  0 part /run/media/mmcblk0p1
`-mmcblk0p2  179:2    0  7.5G  0 part /run/media/mmcblk0p2
mmcblk2      179:8    0 14.6G  0 disk 
|-mmcblk2p1  179:9    0 24.8M  0 part /run/media/mmcblk2p1
`-mmcblk2p2  179:10   0 14.6G  0 part /
mmcblk2boot0 179:16   0    4M  1 disk 
mmcblk2boot1 179:24   0    4M  1 disk

v5.4.70 SD boot

switch to partitions #0, OK
mmc0 is current device
flash target is MMC:0
Net:   
Warning: ethernet@30be0000 using MAC address from ROM
eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0 
=> printenv
mmcdev=0
mmcpart=1

root@pico-imx7:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  7.5G  0 disk 
|-mmcblk0p1  179:1    0 24.8M  0 part /run/media/mmcblk0p1
`-mmcblk0p2  179:2    0  7.5G  0 part /
mmcblk2      179:8    0 14.6G  0 disk 
|-mmcblk2p1  179:9    0 24.8M  0 part /run/media/mmcblk2p1
`-mmcblk2p2  179:10   0 14.6G  0 part /run/media/mmcblk2p2
mmcblk2boot0 179:16   0    4M  1 disk 
mmcblk2boot1 179:24   0    4M  1 disk

v5.4.70 emmc boot

switch to partitions #0, OK
mmc2(part 0) is current device
flash target is MMC:2
Net:   
Warning: ethernet@30be0000 using MAC address from ROM
eth0: ethernet@30be0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0 
=> printenv
mmcdev=2
mmcpart=1

root@pico-imx7:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  7.5G  0 disk 
|-mmcblk0p1  179:1    0 24.8M  0 part /run/media/mmcblk0p1
`-mmcblk0p2  179:2    0  7.5G  0 part /run/media/mmcblk0p2
mmcblk2      179:8    0 14.6G  0 disk 
|-mmcblk2p1  179:9    0 24.8M  0 part /run/media/mmcblk2p1
`-mmcblk2p2  179:10   0 14.6G  0 part /
mmcblk2boot0 179:16   0    4M  1 disk 
mmcblk2boot1 179:24   0    4M  1 disk 
JoeZhang-tn commented 2 years ago

Besides, in our patch, we 'REMOVE' the define number in our code. So it's now detecting the boot device. image