u-boot脚本,允许在哪个rootfs部件之间进行引导(RAUC) [英] u-boot script to allow choosing between which rootfs part to boot (RAUC)

查看:344
本文介绍了u-boot脚本,允许在哪个rootfs部件之间进行引导(RAUC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地创建了一个带有两个rootfs分区的图像,以便使用yocto/poky在我的jetson nano上运行.我已经按照meta-rauc层的README和rauc用户手册创建了system.conf文件和rauc _%.bbappend文件,并且能够成功创建捆绑包.

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.

据我了解,我需要某种 u-启动脚本:

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

为了使RAUC能够切换正确的插槽,其系统配置必须从引导加载程序的角度指定相应插槽的名称.您还必须通过脚本编写(例如GRUB,U-Boot)或使用专用的引导选择基础结构(例如Barebox中的bootchooser)在引导加载程序本身中设置适当的引导选择逻辑.

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).

引导加载程序还必须提供Linux用户空间可以修改的一组变量,以更改引导顺序或优先级.

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

准备好该接口后,RAUC会注意适当地设置启动逻辑.例如,它将在写入之前停用该插槽以进行更新,并在成功完成安装后将其重新激活.

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.

我是在yocto图层或构建文件夹中的某个位置制作脚本吗,还是在制作图像后需要将其放置在jetson nano上的脚本? -该脚本的内容是什么?

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}

我在我的meta层中得到了这个食谱recipes-bsp/u-boot/u-boot-script.bb:

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"

我可以看到脚本图像正在进入work/jetson_nano_poky-linux/u-boot-tegra/2016.07.../git/文件夹.

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

但是如何在u-boot中使用它? -如何确保此脚本在每次启动时自动运行?

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

推荐答案

默认引导顺序的U引导部分尝试在引导所在的第一个分区中找到名为boot.src的文件. 如果找到此文件,则它将尝试运行此脚本. 放置在文件中的命令可以基于RAUC语法,因此在用户空间中激活RAUC时,它可以更新相同的环境变量. 因此RAUC通过放置在脚本文件中的命令来处理启动顺序. RAUC无法直接更改U Boot启动顺序的流程

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

这篇关于u-boot脚本,允许在哪个rootfs部件之间进行引导(RAUC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆