All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Trevor Woerner" <twoerner@gmail.com>
To: yocto-patches@lists.yoctoproject.org
Subject: [meta-rockchip][PATCH v2 2/2] fw_env.config: use partition name/label
Date: Wed, 10 Apr 2024 21:16:38 -0400	[thread overview]
Message-ID: <20240411011638.12198-2-twoerner@gmail.com> (raw)
In-Reply-To: <20240411011638.12198-1-twoerner@gmail.com>

A filesystem label (/dev/disk/by-label) is a property of, and stored in, the
filesystem itself. Since the U-Boot environment partition is not formatted (it
is a raw copy of the generated, binary U-Boot environment) it is not possible
to assign it a label.

However, if GPT partitioning is being used, GPT supports the notion of
assigning labels/names to the partitions which are stored as part of the
GPT partition table itself (instead of being stored in the filesystem
in the partition). The naming is a bit confusing (different tools use
different names) but `wic` calls this "--part-name", `lsblk` calls this
"PARTLABEL", and `parted` calls this "name".

In Linux user-space these partition labels are referenced via
/dev/disk/by-partlabel and provide an excellent way of finding the GPT
partition containing the U-Boot environment regardless of which backing
device is actually being used (e.g. mmcblk0, mmcblk1... i.e. emmc,
sdcard...).

Tested in both systemd and sysvinit.
Tested on rock-5b (both emmc and sdcard).

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
v2 changes:
- new
---
 recipes-bsp/u-boot/u-boot_%.bbappend | 3 +--
 wic/rockchip.wks                     | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/recipes-bsp/u-boot/u-boot_%.bbappend b/recipes-bsp/u-boot/u-boot_%.bbappend
index 18702428a787..a1dc25449229 100644
--- a/recipes-bsp/u-boot/u-boot_%.bbappend
+++ b/recipes-bsp/u-boot/u-boot_%.bbappend
@@ -59,8 +59,7 @@ do_compile:append:rock2-square () {
 
 do_compile:append:rk-u-boot-env() {
 	UBOOT_ENV_SIZE="$(cat ${B}/.config | grep "^CONFIG_ENV_SIZE=" | cut -d'=' -f2)"
-	UBOOT_MMC_DEV="$(cat ${B}/.config | grep "^CONFIG_SYS_MMC_ENV_DEV=" | cut -d'=' -f2)"
-	echo "/dev/mmcblk${UBOOT_MMC_DEV}p5 0x0000 ${UBOOT_ENV_SIZE}" > ${WORKDIR}/fw_env.config
+	echo "/dev/disk/by-partlabel/uboot_env 0x0000 ${UBOOT_ENV_SIZE}" > ${WORKDIR}/fw_env.config
 }
 
 do_deploy:append:rk-u-boot-env() {
diff --git a/wic/rockchip.wks b/wic/rockchip.wks
index febb826bccc7..f7e501cbd25e 100644
--- a/wic/rockchip.wks
+++ b/wic/rockchip.wks
@@ -22,7 +22,7 @@ part loader1   --offset 64s    --fixed-size 3552K --fstype=none --source rawcopy
 part v_storage --offset 7168s  --fixed-size 256K  --fstype=none
 part reserved  --offset 7680s  --fixed-size 192K  --fstype=none
 part reserved1 --offset 8064s  --fixed-size 32K   --fstype=none
-part uboot_env --offset 8128s  --fixed-size 32K   --fstype=none ${RK_UBOOT_ENV}
+part uboot_env --offset 8128s  --fixed-size 32K   --fstype=none --part-name uboot_env ${RK_UBOOT_ENV}
 part reserved2 --offset 8192s  --fixed-size 4096K --fstype=none
 part loader2   --offset 16384s --fixed-size 4096K --fstype=none --source rawcopy --sourceparams="file=u-boot.${UBOOT_SUFFIX}"
 part atf       --offset 24576s --fixed-size 4096K --fstype=none
-- 
2.44.0.501.g19981daefd7c


  reply	other threads:[~2024-04-11  1:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  1:16 [meta-rockchip][PATCH v2 1/2] enable stored U-Boot environment Trevor Woerner
2024-04-11  1:16 ` Trevor Woerner [this message]
2024-04-17 10:49   ` [yocto-patches] [meta-rockchip][PATCH v2 2/2] fw_env.config: use partition name/label Quentin Schulz
2024-04-17 10:44 ` [yocto-patches] [meta-rockchip][PATCH v2 1/2] enable stored U-Boot environment Quentin Schulz
2024-04-17 14:19   ` Trevor Woerner
2024-04-18  8:43     ` Quentin Schulz
2024-04-24 17:43       ` Trevor Woerner
2024-04-25 12:21         ` Quentin Schulz
2024-04-26 18:35           ` Trevor Woerner

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=20240411011638.12198-2-twoerner@gmail.com \
    --to=twoerner@gmail.com \
    --cc=yocto-patches@lists.yoctoproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.