From d731607cec6649a91d1088e6837d53fdf3518165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Fri, 10 Nov 2023 10:23:42 +0100 Subject: [PATCH 1/4] meta-lxatac-bsp: barebox: use partition labels to find root partitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change is inspired by a similar DistroKit commit [1]. It allows us to change the partition numbering without having to adjust the partition numbers in barebox. Adjusting partition numbers in barebox is dangerous because the numbering is set on the first boot after a new install from an image and does not update on subsequent RAUC installs. This means there can be TACs with different partition layouts in the wild and fixing that requires a re-install from image. Just using partition labels works around that problem. [1]: https://git.pengutronix.de/cgit/DistroKit/commit/?h=next&id=c4a597c6eed61b0c34e39727f63d17fd8b96c947 Signed-off-by: Leonard Göhrs --- .../barebox/files/lxatac/env/boot/{root0 => root-a} | 6 +++--- .../barebox/files/lxatac/env/boot/{root1 => root-b} | 6 +++--- .../barebox/files/lxatac/env/nv/bootchooser.system0.boot | 2 +- .../barebox/files/lxatac/env/nv/bootchooser.system1.boot | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/{root0 => root-a} (91%) rename meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/{root1 => root-b} (91%) diff --git a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root0 b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root-a similarity index 91% rename from meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root0 rename to meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root-a index 71bc04c3..f757adde 100644 --- a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root0 +++ b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root-a @@ -5,11 +5,11 @@ led led-status-red 0 led led-status-green 252 led led-status-blue 97 -echo -a /dev/fbconsole0 -e -n "\e[?25l\e[1;1H\e[37;1mBooting root0 ..." +echo -a /dev/fbconsole0 -e -n "\e[?25l\e[1;1H\e[37;1mBooting root-a ..." -boot -v mmc1.1 +boot -v mmc1.root-a # Show splash screen with red background on error splash -b 0xffcd0000 /env/data/splash.png -echo -a /dev/fbconsole0 -e -n "\e[17;10H\e[41mError booting root0!" +echo -a /dev/fbconsole0 -e -n "\e[17;10H\e[41mError booting root-a!" diff --git a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root1 b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root-b similarity index 91% rename from meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root1 rename to meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root-b index 0fd735fc..63f87e75 100644 --- a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root1 +++ b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/boot/root-b @@ -5,11 +5,11 @@ led led-status-red 0 led led-status-green 252 led led-status-blue 97 -echo -a /dev/fbconsole0 -e -n "\e[?25l\e[1;1H\e[37;1mBooting root1 ..." +echo -a /dev/fbconsole0 -e -n "\e[?25l\e[1;1H\e[37;1mBooting root-b ..." -boot -v mmc1.2 +boot -v mmc1.root-b # Show splash screen with red background on error splash -b 0xffcd0000 /env/data/splash.png -echo -a /dev/fbconsole0 -e -n "\e[17;10H\e[41mError booting root1!" +echo -a /dev/fbconsole0 -e -n "\e[17;10H\e[41mError booting root-b!" diff --git a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system0.boot b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system0.boot index c3c21179..aec7f517 100644 --- a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system0.boot +++ b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system0.boot @@ -1 +1 @@ -root0 \ No newline at end of file +root-a diff --git a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system1.boot b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system1.boot index bc96be9b..de581328 100644 --- a/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system1.boot +++ b/meta-lxatac-bsp/recipes-bsp/barebox/files/lxatac/env/nv/bootchooser.system1.boot @@ -1 +1 @@ -root1 \ No newline at end of file +root-b From 376b21a1160ac989360f10ace9830894a30e845b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Fri, 10 Nov 2023 10:33:32 +0100 Subject: [PATCH 2/4] meta-lxatac-bsp: emmc-image: remove "reserved" padding partition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current disk layout is: - 0k - 512k - Partition table etc. - 512k - 768k - Barebox Environment - 768k - 1M - Barebox State - 1M - 2M - "reserved" partition - 2M - … - root-a, root-b, data We can achieve basically the same (minus having the unused partition) by specifying an explicit offset for root-a and removing the "reserved" partition. Note that this changes the partition numbering. Signed-off-by: Leonard Göhrs --- .../recipes-core/images/emmc-image/lxatac/genimage.config | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config b/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config index cd7124c9..a2a4a29a 100644 --- a/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config +++ b/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config @@ -11,16 +11,11 @@ image @IMAGE@img { gpt-no-backup = true } - partition reserved { - image = "/dev/null" - size = 1M - offset = 1M - } - partition root-a { image = "lxatac-core-image-base-lxatac.ext4" partition-type-uuid = "69dad710-2ce4-4e3c-b16c-21a1d49abed3" partition-uuid = "e82e6873-62cc-46fb-90f0-3e936743fa62" + offset = 2M size = 2048M } } From 3b2daa6baad83c87dc54f16b55726210d6b15a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Fri, 3 Nov 2023 11:34:47 +0100 Subject: [PATCH 3/4] meta-lxatac-bsp: emmc-image: clear barebox state on install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the range in the emmc sparse image corresponding to the barebox state was not written and thus considered sparse. This meant that it was not re-written when writing the sparse image. Explicitly write zeros to the state partition to clear it. Note that this change removes the alignment parameter from the image because the new partitions do not align to a 1M boundary. This means we need to specify an explicit offset for each partition from now on. Signed-off-by: Leonard Göhrs --- .../recipes-core/images/emmc-image.bb | 17 ++++++++++++ .../images/emmc-image/lxatac/genimage.config | 27 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/meta-lxatac-bsp/recipes-core/images/emmc-image.bb b/meta-lxatac-bsp/recipes-core/images/emmc-image.bb index b7fd6d70..0b4baea4 100644 --- a/meta-lxatac-bsp/recipes-core/images/emmc-image.bb +++ b/meta-lxatac-bsp/recipes-core/images/emmc-image.bb @@ -13,6 +13,23 @@ COMPATIBLE_MACHINE = "lxatac" GENIMAGE_IMAGE_SUFFIX = "" +# This can be removed once we have a genimage with fill= support +GENIMAGE_VARIABLES[WORKDIR] = "${WORKDIR}" + +do_configure:append() { + # This can be removed once we have a genimage with fill= support. + # Just using /dev/zero in the genimage config does not work because ... + # + # $ python3 + # >>> import os + # >>> os.stat("/dev/zero") + # os.stat_result(st_mode=8630 ... st_size=0 ..) + # + # ... /dev/zero has 0 size and genimage only writes st_size bytes of + # the file into the image and leaves the rest sparse. + dd if=/dev/zero bs=1024 count=256 of=${WORKDIR}/state-filler.img +} + do_genimage[depends] += " \ lxatac-core-image-base:do_image_complete \ " diff --git a/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config b/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config index a2a4a29a..517ea00e 100644 --- a/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config +++ b/meta-lxatac-bsp/recipes-core/images/emmc-image/lxatac/genimage.config @@ -6,11 +6,36 @@ image @IMAGE@simg { image @IMAGE@img { hdimage { - align = 1M partition-table-type = gpt gpt-no-backup = true } + partition barebox-env { + image = "@WORKDIR@/state-filler.img" + in-partition-table = false + offset = 512K + size = 256K + } + + partition barebox-state { + image = "@WORKDIR@/state-filler.img" + # We can not have the barebox partitions in the partition table right + # now because: + # - If we add them the partition label clashes with the label of the + # fixed partitions in the barebox devicetree. + # - If we change the labels barebox still wont allow the partitions + # to overlap. + # - We have TACs in the wild that do not have the partitions, + # in the partition table so we can not just remove the fixed + # partitions in the barebox devicetree. + # We thus need e.g. a RAUC hook that creates the partitions on + # install. + in-partition-table = false + #partition-type-uuid = "4778ed65-bf42-45fa-9c5b-287a1dc4aab1" + offset = 768K + size = 256K + } + partition root-a { image = "lxatac-core-image-base-lxatac.ext4" partition-type-uuid = "69dad710-2ce4-4e3c-b16c-21a1d49abed3" From 3d9c404d522bb46c7af1e49378dfcfd0fc3bc676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Fri, 3 Nov 2023 11:48:44 +0100 Subject: [PATCH 4/4] README: remove troubleshooting section about invalid barebox state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should have become obsolte with the previous commit. Signed-off-by: Leonard Göhrs --- README.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/README.md b/README.md index d4643515..adc27e4e 100644 --- a/README.md +++ b/README.md @@ -500,24 +500,3 @@ console via the debug UART adapter / the USB console provided by barebox and execute `wd -x` on the shell. E.g.: barebox@Linux Automation Test Automation Controller (TAC):/ wd -x - -##### The installed bundle does not start - -When flashing the emmc-image only the first of two update partitions is -initialized. The second one is set up on first boot and filled for the first time -once you install a RAUC bundle on the system for the first time. -There is a 50/50 chance that barebox is currently set up to boot from this -non-existing partition, which will fail and reduce its retry counter. -If the TAC does not boot after flashing you should power cycle the device -about four times in slow succession to make sure the wrong partition is marked -as bad and the correct partition is used. - -Alternatively you can choose the correct partition using the barebox console -via a UART debug adapter: - - # state.bootstate.system1.remaining_attempts=0 - # state.bootstate.system1.priority=0 - # state.bootstate.system0.remaining_attempts=3 - # state.bootstate.system0.priority=1 - # state -s - # reset