2

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?

Varyag
  • 676
  • 12
  • 29
  • Did you look at this [presentation](https://events.linuxfoundation.org/wp-content/uploads/2018/07/ALS19_AGL_RAUC_AS_SOTA_FOTA_SOLUTION_v1r01.pdf) – Nayfe Oct 01 '19 at 11:29
  • I did not! Giving it a go and returns to either edit question or give an answer, ty. – Varyag Oct 01 '19 at 12:20
  • @Nayfe It says to make an image from the uboot.sh script with mkimage, but how do i do that and what do i do with this image? – Varyag Oct 01 '19 at 12:35
  • You can look at this [u-boot script recipe](https://github.com/UpdateHub/meta-updatehub-freescale/blob/master/recipes-bsp/u-boot/u-boot-script-boundary-updatehub.bb) for example. – Nayfe Oct 01 '19 at 12:40
  • I've added uboot.sh and the u-boot-script.bb. I've just changed your linked u-boot-script to have "uboot.sh" instead of "boot.scr" and changed the part numbers in the uboot.sh file to fit mine. It's building with bitbake now, so we'll see if it works – Varyag Oct 02 '19 at 07:09
  • @Nayfe i've updated the question after trying to replicate the recipe. – Varyag Oct 02 '19 at 09:06
  • Maybe you don't have u-boot support for your board yet, see [commit](https://github.com/thierryreding/u-boot/commit/54ea3ff4ab354b3a0a15d58840f6bafe32ae920f) – Nayfe Oct 02 '19 at 09:14
  • @Nayfe I'm pretty sure it has when looking at meta-tegra layer contents. BTW after i removed `PREFERRED_PROVIDER_virtual/bootloader = "u-boot"` from my local.conf file, it didnt return any errors during `bitbake u-boot` as before, but will i even have u-boot as a bootloader if i haven't added that line? i'm not specifying anywhere else that i want to run u-boot as bootloader. Except that i have `IMAGE_INSTALL += " u-boot-fw-utils"` – Varyag Oct 02 '19 at 09:33
  • The meta-tegra layer machine conf for jetson nano does however have the lines `UBOOT_MACHINE = "p3450-porg_defconfig"` and `KERNEL_ROOTSPEC ?= "root=/dev/mmcblk0p${@uboot_var('distro_bootpart')} rw rootwait"` – Varyag Oct 02 '19 at 09:36
  • See [PREFERRED_PROVIDER_u-boot ?= "u-boot-tegra"](https://github.com/madisongh/meta-tegra/blob/warrior/conf/machine/include/tegra-common.inc#L9) – Nayfe Oct 02 '19 at 13:13
  • ah, so no need to add it myself, ty. – Varyag Oct 03 '19 at 10:31

1 Answers1

3

U boot part of the default boot sequence tries to find a file named boot.src in the first partition from where it has booted. if this file is found then it will try to run this script. The commands put in the file can be based on RAUC syntax so that when RAUC gets activated in the user space it can update the same environment variables. So RAUC handles the boot sequence via the commands put int the script file. RAUC has no way to directly alter the flow of U Boot boot up sequence

Rohit Pai
  • 89
  • 9