u-boot script to allow choosing between which rootfs part to boot (RAUC)

青春壹個敷衍的年華 提交于 2019-12-11 14:30:16

问题


I've managed to create an image with two rootfs partitions to run on my jetson nano with yocto/poky. I've followed the meta-rauc layer README and rauc user manual, to create the system.conf file and rauc_%.bbappend file and I am able to create bundles successfully.

As I understand, I need some sort of u-boot script:

In order to enable RAUC to switch the correct slot, its system configuration must specify the name of the respective slot from the bootloader’s perspective. You also have to set up an appropriate boot selection logic in the bootloader itself, either by scripting (as for GRUB, U-Boot) or by using dedicated boot selection infrastructure (such as bootchooser in Barebox).

The bootloader must also provide a set of variables the Linux userspace can modify in order to change boot order or priority.

Having this interface ready, RAUC will care for setting the boot logic appropriately. It will, for example, deactivate the slot to update before writing to it and reactivate it after having completed the installation successfully.

Do I make a script somewhere in the yocto layer or build folder or is it a script i need to put on the jetson nano after making the image? - and what would the contents of this script be?

**************************************************EDIT********************************************************

I've made this script:

test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "system0 system1"
test -n "${BOOT_system0_LEFT}" || setenv BOOT_system0_LEFT 3
test -n "${BOOT_system1_LEFT}" || setenv BOOT_system1_LEFT 3

setenv bootargs
for BOOT_SLOT in "${BOOT_ORDER}"; do
  if test "x${bootargs}" != "x"; then
    # skip remaining slots
  elif test "x${BOOT_SLOT}" = "xsystem0"; then
    if test ${BOOT_system0_LEFT} -gt 0; then
      setexpr BOOT_system0_LEFT ${BOOT_system0_LEFT} - 1
      echo "Found valid slot system0, ${BOOT_system0_LEFT} attempts remaining"
      setenv distro_bootpart "1"
      setenv boot_line "mmc 1:1 any ${scriptaddr} /boot/extlinux/extlinux.conf"
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p1 rauc.slot=system0"
    fi
  elif test "x${BOOT_SLOT}" = "xsystem1"; then
    if test ${BOOT_system1_LEFT} -gt 0; then
      setexpr BOOT_system1_LEFT ${BOOT_system1_LEFT} - 1
      echo "Found valid slot system1, ${BOOT_system1_LEFT} attempts remaining"
      setenv distro_bootpart "13"
      setenv boot_line "mmc 1:D any ${scriptaddr} /boot/extlinux/extlinux.conf"
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p13 rauc.slot=system1"
    fi
  fi
done

if test -n "${bootargs}"; then
  saveenv
else
  echo "No valid slot found, resetting tries to 3"
  setenv BOOT_system0_LEFT 3
  setenv BOOT_system1_LEFT 3
  saveenv
  reset
fi

sysboot ${boot_line}

And I i got this recipe recipes-bsp/u-boot/u-boot-script.bb in my meta-layer:

LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e"

S = "${WORKDIR}/git"

PACKAGE_ARCH = "${MACHINE_ARCH}"

DEPENDS = "u-boot-mkimage-native"

inherit deploy

BOOTSCRIPT ??= "${THISDIR}/uboot.sh"

do_mkimage () {
    uboot-mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
                  -n "boot script" -d ${BOOTSCRIPT} ${S}/boot.scr
}

addtask mkimage after do_compile before do_install

do_compile[noexec] = "1"

do_install () {
    install -D -m 644 ${S}/boot.scr ${D}/boot.scr
}

do_deploy () {
    install -D -m 644 ${D}/boot.scr \
                      ${DEPLOYDIR}/boot.scr-${MACHINE}-${PV}-${PR}

    cd ${DEPLOYDIR}
    rm -f boot.scr-${MACHINE}
    ln -sf boot.scr-${MACHINE}-${PV}-${PR} boot.scr-${MACHINE}
}

addtask deploy after do_install before do_build

FILES_${PN} += "/"

COMPATIBLE_MACHINE = "jetson-nano"

I can see that the script image is getting into work/jetson_nano_poky-linux/u-boot-tegra/2016.07.../git/ folder.

But how do I use it in u-boot? - How do i make sure this script is run automatically every boot?

来源:https://stackoverflow.com/questions/58183097/u-boot-script-to-allow-choosing-between-which-rootfs-part-to-boot-rauc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!