Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The asymmetric slots scenario support for raspberry pi 4 #85

Open
SocialLoginDev opened this issue Feb 22, 2024 · 3 comments
Open

The asymmetric slots scenario support for raspberry pi 4 #85

SocialLoginDev opened this issue Feb 22, 2024 · 3 comments

Comments

@SocialLoginDev
Copy link

I try using the asymmetric slots scenario.
My system.conf:

[system]
compatible=RaspberryPi4
bootloader=uboot
data-directory=/data/

[keyring]
path=/etc/rauc/ca.cert.pem
 
[slot.update.0]
device=/dev/mmcblk0p2
type=raw
bootname=update

[slot.main.1]
device=/dev/mmcblk0p3
type=ext4
bootname=main

and wks.in:

part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4096 --size 100
part /update --size 100 --ondisk mmcblk0 --fstype=ext4 --label update --align 4096
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label main --align 4096
part /data --size 100 --ondisk mmcblk0 --fstype=ext4 --label data --align 4096

What else needs to be fixed and what additional files need to be changed for everything to work properly?

@ejoerns
Copy link
Member

ejoerns commented Feb 26, 2024

@SocialLoginDev It might require less adaptions if you name your main.1 slot rootfs.0 instead.
Otherwise, you would also need to update the update-bundle.bb recipe to emit a slot of name main (instead of rootfs).

You may also want to update the bootloader script (recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in:). It currently has a logic for symmetric updates and uses A and B as boot names (instead of update and main). For the recovery case, one might be able to simplify the boot logic to "boot A (or main) N times, otherwise boot fallback/update".

@SocialLoginDev
Copy link
Author

I have updated the update-bundle.bb recipe:

DESCRIPTION = "RAUC bundle generator"

inherit bundle

RAUC_BUNDLE_COMPATIBLE = "RaspberryPi4"
RAUC_BUNDLE_VERSION = "v20240001"
RAUC_BUNDLE_DESCRIPTION = "RAUC datafox bundle"

RAUC_BUNDLE_FORMAT = "verity"

RAUC_BUNDLE_SLOTS = "main" 
RAUC_SLOT_main = "core-image-base"
RAUC_SLOT_main[fstype] = "ext4"

RAUC_KEY_FILE = "${THISDIR}/files/development-1.key.pem"
RAUC_CERT_FILE = "${THISDIR}/files/development-1.cert.pem"

and recipes-bsp/rpi-u-boot-scr/files/boot.cmd.in:

fdt addr ${fdt_addr} && fdt get value bootargs /chosen bootargs

test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "main update"
test -n "${BOOT_MAIN_LEFT}" || setenv BOOT_MAIN_LEFT 3
test -n "${BOOT_UPDATE_LEFT}" || setenv BOOT_UPDATE_LEFT 3
test -n "${BOOT_DEV}" || setenv BOOT_DEV "mmc 0:1"

setenv bootpart
setenv raucslot

for BOOT_SLOT in "${BOOT_ORDER}"; do
  if test "x${bootpart}" != "x"; then
    # skip remaining slots
  elif test "x${BOOT_SLOT}" = "xmain"; then
    if test ${BOOT_MAIN_LEFT} -gt 0; then
      setexpr BOOT_MAIN_LEFT ${BOOT_MAIN_LEFT} - 1
      echo "Found valid RAUC main slot"
      setenv bootpart "/dev/mmcblk0p3"
      setenv raucslot "main"
      setenv BOOT_DEV "mmc 0:3"
    fi
  elif test "x${BOOT_SLOT}" = "xupdate"; then
    if test ${BOOT_UPDATE_LEFT} -gt 0; then
      setexpr BOOT_UPDATE_LEFT ${BOOT_UPDATE_LEFT} - 1
      echo "Found valid RAUC update slot"
      setenv bootpart "/dev/mmcblk0p2"
      setenv raucslot "update"
      setenv BOOT_DEV "mmc 0:2"
    fi
  fi
done

if test -n "${bootpart}"; then
  setenv bootargs "${bootargs} root=${bootpart} rauc.slot=${raucslot}"
  saveenv
else
  echo "No valid RAUC slot found. Resetting tries to 3"
  setenv BOOT_MAIN_LEFT 3
  setenv BOOT_UPDATE_LEFT 3
  saveenv
  reset
fi

fatload mmc 0:1 ${kernel_addr_r} @@KERNEL_IMAGETYPE@@
if test ! -e mmc 0:1 uboot.env; then saveenv; fi;
@@KERNEL_BOOTCMD@@ ${kernel_addr_r} - ${fdt_addr}

RAUC only works from the update partition; when I try to update from the main partition, it displays the following message:
LastError: Installation error: No target slot for class main of image core-image-base-raspberrypi4-64.ext4 found
Is this normal behavior?

@SocialLoginDev
Copy link
Author

Another question: How to change the update partition to initramfs? In my case, I already have initramfs, it is used to overlayroot the main system using the initramfs-module-overlayroot script. What should be done in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants