From: Kever Yang <kever.yang@rock-chips.com>
To: Quentin Schulz <foss+uboot@0leil.net>
Cc: sjg@chromium.org, philipp.tomsich@vrull.eu,
klaus.goger@theobroma-systems.com, knaerzche@gmail.com,
u-boot@lists.denx.de,
Quentin Schulz <quentin.schulz@theobroma-systems.com>
Subject: Re: [PATCH 01/12] rockchip: puma-rk3399: fix boot_targets swap depending on U-Boot proper load medium
Date: Sun, 4 Sep 2022 19:41:17 +0800 [thread overview]
Message-ID: <663c7874-37c3-4dee-09cb-c6c27d905bbe@rock-chips.com> (raw)
In-Reply-To: <20220722160655.3904213-2-foss+uboot@0leil.net>
On 2022/7/23 00:06, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
>
> distroboot should try first on the same MMC medium as the one the SPL
> loaded U-Boot proper from. This was the case when the introducing commit
> was merged because the default order was eMMC first and then SD card.
> The check was therefore made only on whether we booted from SD card,
> because otherwise the order was the expected one.
> However, in commit b212ad24a604 ("rockchip: Fix MMC boot order"), the
> order was swapped. Meaning our simple check is now useless.
>
> Let's fix that by accounting for all scenarii: default boot_targets has
> mmc0 first but booting from SD Card, mmc1 first but booting from eMMC.
>
> Fixes: b212ad24a604 ("rockchip: Fix MMC boot order")
> Cc: Quentin Schulz <foss+uboot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
I will apply this first, but it will be better to use boot script, too
many logic to get the correct boot dev with this.
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Thanks,
- Kever
> ---
>
> Depends on
> https://lore.kernel.org/u-boot/20220715151552.953654-1-foss+uboot@0leil.net/
> https://lore.kernel.org/u-boot/20220715151552.953654-2-foss+uboot@0leil.net/
>
> .../puma_rk3399/puma-rk3399.c | 25 ++++++++++---------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
> index deeba3084a..ce3436b770 100644
> --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
> +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
> @@ -77,18 +77,16 @@ static int setup_boottargets(void)
> }
>
> /*
> - * Only run, if booting from mmc1 (i.e. /mmc@fe320000) and
> - * only consider cases where the default boot-order first
> - * tries to boot from mmc0 (eMMC) and then from mmc1
> - * (i.e. external SD).
> - *
> - * In other words: the SD card will be moved to earlier in the
> - * order, if U-Boot was also loaded from the SD-card.
> + * Make the default boot medium between SD Card and eMMC, the one that
> + * was used to load U-Boot proper. If SPI-NOR flash was used, keep
> + * original default order.
> */
> - if (!strcmp(boot_device, "/mmc@fe320000")) {
> + if (strcmp(boot_device, "/spi@ff1d0000/flash@0")) {
> + bool sd_booted = !strcmp(boot_device, "/mmc@fe320000");
> char *mmc0, *mmc1;
>
> - debug("%s: booted from SD-Card\n", __func__);
> + debug("%s: booted from %s\n", __func__,
> + sd_booted ? "SD-Card" : "eMMC");
> mmc0 = strstr(env, "mmc0");
> mmc1 = strstr(env, "mmc1");
>
> @@ -98,10 +96,13 @@ static int setup_boottargets(void)
> }
>
> /*
> - * If mmc0 comes first in the boot order, we need to change
> - * the strings to make mmc1 first.
> + * If mmc0 comes first in the boot order and U-Boot proper was
> + * loaded from mmc1, swap mmc0 and mmc1 in the list.
> + * If mmc1 comes first in the boot order and U-Boot proper was
> + * loaded from mmc0, swap mmc0 and mmc1 in the list.
> */
> - if (mmc0 < mmc1) {
> + if ((mmc0 < mmc1 && sd_booted) ||
> + (mmc0 > mmc1 && !sd_booted)) {
> mmc0[3] = '1';
> mmc1[3] = '0';
> debug("%s: set boot_targets to: %s\n", __func__, env);
next prev parent reply other threads:[~2022-09-04 11:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 16:06 [PATCH 00/12] Puma RK3399 migration to TPL and numerous fixes Quentin Schulz
2022-07-22 16:06 ` [PATCH 01/12] rockchip: puma-rk3399: fix boot_targets swap depending on U-Boot proper load medium Quentin Schulz
2022-09-04 11:41 ` Kever Yang [this message]
2022-07-22 16:06 ` [PATCH 02/12] rockchip: puma-rk3399: use gpio-hog instead of fixed-regulator for enabling eMMC/SPI-NOR Quentin Schulz
2022-09-01 13:04 ` Kever Yang
2022-07-22 16:06 ` [PATCH 03/12] rockchip: puma-rk3399: allow non-SD-Card-loaded SPL to load U-Boot proper from SD-Card Quentin Schulz
2022-09-01 13:04 ` Kever Yang
2022-07-22 16:06 ` [PATCH 04/12] rockchip: puma-rk3399: remove unused default ENV_OFFSET for SPI flashes Quentin Schulz
2022-09-01 13:04 ` Kever Yang
2022-07-22 16:06 ` [PATCH 05/12] rockchip: puma-rk3399: load environment from same MMC as used for loading U-Boot proper Quentin Schulz
2022-09-01 13:05 ` Kever Yang
2022-07-22 16:06 ` [PATCH 06/12] rockchip: puma-rk3399: allow loading environment from SPI-NOR flash Quentin Schulz
2022-09-01 13:05 ` Kever Yang
2022-07-22 16:06 ` [PATCH 07/12] rockchip: puma-rk3399: load environment from same medium as one used to load U-Boot proper Quentin Schulz
2022-09-01 13:03 ` Kever Yang
2022-09-01 13:13 ` Quentin Schulz
2022-09-04 11:49 ` Kever Yang
2022-09-06 9:22 ` Quentin Schulz
2022-09-14 9:17 ` patrick.delaunay
2022-09-20 12:28 ` Kever Yang
2022-09-20 14:02 ` Quentin Schulz
2022-07-22 16:06 ` [PATCH 08/12] rockchip: puma-rk3399: remove useless CONFIG_SYS_SPI_U_BOOT_OFFS Quentin Schulz
2022-09-01 13:05 ` Kever Yang
2022-07-22 16:06 ` [PATCH 09/12] rockchip: puma-rk3399: migrate to TPL Quentin Schulz
2022-09-01 13:05 ` Kever Yang
2022-09-04 11:52 ` Kever Yang
2022-07-22 16:06 ` [PATCH 10/12] rockchip: puma-rk3399: migrate to u-boot-rockchip.bin Quentin Schulz
2022-09-01 13:06 ` Kever Yang
2022-07-22 16:06 ` [PATCH 11/12] rockchip: lion-rk3368: " Quentin Schulz
2022-07-22 16:06 ` [PATCH 12/12] rockchip: puma-rk3399: migrate to u-boot-rockchip-spi.bin Quentin Schulz
2022-09-01 13:06 ` Kever Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=663c7874-37c3-4dee-09cb-c6c27d905bbe@rock-chips.com \
--to=kever.yang@rock-chips.com \
--cc=foss+uboot@0leil.net \
--cc=klaus.goger@theobroma-systems.com \
--cc=knaerzche@gmail.com \
--cc=philipp.tomsich@vrull.eu \
--cc=quentin.schulz@theobroma-systems.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).