cancel
Showing results for 
Search instead for 
Did you mean: 

Change U-Boot Variables for Different rootfs / bootfs Partitions

ASuar.1
Associate III

I am working with the STM32MP1-DK2 development board and am trying to use RAUC to do image updates. I am using an SD card with two bootfs and rootfs partitions with one pair being active at a time. Currently I'm in the uboot integration stage where I need to create a script to change the active bootfs and rootfs, below is an example that rauc provides.

I've looked at the uboot environment variables but can't seem to find which ones set boot and rootfs partition to use?

I see reference to a scan that is done to detect a bootfs but not sure how to modify it. For this application the partitions are going to not change so maybe it's better to remove the scan all together and hardcode the values.

uboot env:

altbootcmd=run bootcmd
android_mmc_boot=mmc dev ${devnum};run android_mmc_splash;run android_mmc_fdt;run android_mmc_kernel;bootm ${kernel_addr_r} - ${fdt_addr_r};
android_mmc_fdt=if part start mmc ${devnum} dt_${suffix} dt_start &&part size mmc ${devnum} dt_${suffix} dt_size;then mmc read ${dtimg_addr} ${dt_start} ${dt_size};dtimg getindex ${dtimg_addr} ${board_id} ${board_rev} dt_index;dtimg start ${dtimg_addr} ${dt_index} fdt_addr_r;fi
android_mmc_kernel=if part start mmc ${devnum} boot_${suffix} boot_start &&part size mmc ${devnum} boot_${suffix} boot_size;then mmc read ${kernel_addr_r} ${boot_start} ${boot_size};part nb mmc ${devnum} system_${suffix} rootpart_nb;env set bootargsroot=/dev/mmcblk${devnum}p${rootpart_nb} androidboot.serialno=${serial#} androidboot.slot_sufi
android_mmc_splash=if part start mmc ${devnum} splash splash_start && part size mmc ${devnum} splash splash_size;then mmc read ${splashimage} ${splash_start} ${splash_size};cls; bmp display ${splashimage} m m;fi
arch=arm
autoload=no
baudrate=115200
board=stm32mp1
board_name=stm32mp157c-viper-heavy-mx
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_device=mmc
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_instance=0
boot_net_usb_start=true
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 ubifs0 mmc0 mmc2 pxe 
bootcmd=run bootcmd_stm32mp
bootcmd_android=env set mmc_boot run android_mmc_boot;run bootcmd_stm32mp
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc2=devnum=2; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_stm32mp=echo "Boot over ${boot_device}${boot_instance}!";if test ${boot_device} = serial || test ${boot_device} = usb;then stm32prog ${boot_device} ${boot_instance}; else run env_check;if test ${boot_device} = mmc;then env set boot_targets "mmc${boot_instance}"; fi;if test ${boot_device} = nand || test ${boot_device} = spi-nand ;the;
bootcmd_ubifs0=devnum=0; run ubifs_boot
bootcount=2
bootdelay=1
cpu=armv7
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
dtimg_addr=0xc4500000
efi_dtb_prefixes=/ /dtb/ /dtb/current/
env_check=env exists env_ver || env set env_ver ${ver};if env info -p -d -q; then env save; fi;if test "$env_ver" != "$ver"; then echo "*** Warning: old environment ${env_ver}"; echo '* set default: env default -a; env save; reset'; echo '* update current: env set env_ver ${ver}; env save';fi;
env_ver=U-Boot 2020.01-stm32mp-r1 (Jan 06 2020 - 20:56:31 +0000)
ethaddr=00:80:e1:42:6c:b4
fdt_addr_r=0xc4000000
fdtcontroladdr=d7df08a0
fdtfile=stm32mp157c-viper-heavy-mx.dtb
kernel_addr_r=0xc2000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0xc2000000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
partitions=name=ssbl,size=2M;name=bootfs,size=64MB,bootable;name=vendorfs,size=16M;name=rootfs,size=746M;name=userfs,size=-
pxefile_addr_r=0xc4200000
ramdisk_addr_r=0xc4400000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootparte
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0xc4100000
serial#=0041003B3438510438333630
serverip=192.168.1.1
soc=stm32mp
splashimage=0xc4300000
suffix=a
ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol || env set bootubivol boot; if ubi part ${bootubipart} && ubifsmount ubi${devnum}:${bootubivol}; then devtype=ubi; run scan_dev_for_boot; fi
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=st
ver=U-Boot 2020.01-stm32mp-r1 (Jan 06 2020 - 20:56:31 +0000)
 
Environment size: 5640/8187 bytes

Sample script

test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B"
test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3
test -n "${BOOT_B_LEFT}" || setenv BOOT_B_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}" = "xA"; then
    if test ${BOOT_A_LEFT} -gt 0; then
      echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining"
      setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
      setenv load_kernel "nand read ${kernel_loadaddr} ${kernel_a_nandoffset} ${kernel_size}"
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p1 rauc.slot=A"
    fi
  elif test "x${BOOT_SLOT}" = "xB"; then
    if test ${BOOT_B_LEFT} -gt 0; then
      echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining"
      setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
      setenv load_kernel "nand read ${kernel_loadaddr} ${kernel_b_nandoffset} ${kernel_size}"
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p2 rauc.slot=B"
    fi
  fi
done
 
if test -n "${bootargs}"; then
  saveenv
else
  echo "No valid slot found, resetting tries to 3"
  setenv BOOT_A_LEFT 3
  setenv BOOT_B_LEFT 3
  saveenv
  reset
fi
 
echo "Loading kernel"
run load_kernel
echo " Starting kernel"
bootm ${loadaddr_kernel}

1 ACCEPTED SOLUTION

Accepted Solutions
ASuar.1
Associate III

My final solution.

In the end I changed the first boot partition to just have the boot.scr.uimg since it needs to be in the first partition after u-boot. Then created another rootfs and two bootfs with all the typical bootfs stuff ie. kernel, device tree and custom extlinux file with the root partition line removed.

In my machine file:

# disable vendorfs partition
ST_BOOTFS   = "1"
ST_VENDORFS = "0"
ST_USERFS   = "1"
 
STM32MP_BOOTFS_IMAGE = "boot-script-image" # just has boot script
MY_BOOTFS_IMAGE = "my-image-bootfs" # has kernel, dtb and other boot stuff
 
# Proposed value for rootfs in kB
# Define max size for ROOTFS image being built to this value
IMAGE_ROOTFS_MAXSIZE = "1536864"
# And configure the ROOTFS_PARTITION_SIZE variable accordingly
ROOTFS_PARTITION_SIZE = "${IMAGE_ROOTFS_MAXSIZE}"
 
# add two new bootfs and rootfs partitions for updates
PARTITIONS_CONFIG += "bootfsrauca"
PARTITIONS_CONFIG += "rootfsrauc"
PARTITIONS_CONFIG += "bootfsraucb"
 
PARTITIONS_CONFIG[bootfsrauca]   ?= "${MY_BOOTFS_IMAGE},bootfsrauca,${STM32MP_BOOTFS_MOUNTPOINT},${BOOTFS_PARTITION_SIZE},System"
PARTITIONS_CONFIG[rootfsrauc]   = "${IMAGE_BASENAME},rootfsrauc,,${ROOTFS_PARTITION_SIZE},FileSystem"
PARTITIONS_CONFIG[bootfsraucb]   ?= "${MY_BOOTFS_IMAGE},bootfsraucb,${STM32MP_BOOTFS_MOUNTPOINT},${BOOTFS_PARTITION_SIZE},System"

Looks something like this:

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34             545   256.0 KiB   8301  fsbl1
   2             546            1057   256.0 KiB   8301  fsbl2
   3            1058            5153   2.0 MiB     8301  ssbl
   4            5154          136225   64.0 MiB    8300  boot
   5          136226         3209953   1.5 GiB     8300  rootfs
   6         3209954         3472097   128.0 MiB   8300  userfs
   7         3472098         3603169   64.0 MiB    8300  bootfsrauca
   8         3603170         6676897   1.5 GiB     8300  rootfsrauc
   9         6676898         8388574   835.8 MiB   8300  bootfsraucb

My system.conf file:

[system]
compatible=stm32mp1-my-machine
bootloader=uboot
mountprefix=/mnt/rauc
statusfile=/usr/local/raucstatus
 
[keyring]
path=/etc/rauc/ca.cert.pem
 
# [handlers]
# pre-install=/etc/rauc/preinstall.sh
 
[slot.rootfs.0]
device=/dev/mmcblk0p5
type=ext4
bootname=A
 
[slot.rootfs.1]
device=/dev/mmcblk0p8
type=ext4
bootname=B
 
[slot.bootfs.0]
device=/dev/mmcblk0p7
type=ext4
parent=rootfs.0
 
[slot.bootfs.1]
device=/dev/mmcblk0p9
type=ext4
parent=rootfs.1

my extlinux file:

TIMEOUT 20
LABEL openstlinux-my-distro
	KERNEL /uImage
	FDTDIR /
	INITRD /uInitrd

Having the custom extlinux file was useful since I could run the scan_dev_for_extlinux.

My boot.sh:

echo "Executing SCRIPT on target=${target}"
echo "---------------  HELLO FROM SCRIPT !!!!!!!!!!!!! -----------------"
 
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B"
test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3
test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3
 
config_file="extlinux/stm32mp157c-my-machine_extlinux.conf"
if test "${boot_syslinux_conf}" != "${config_file}"; then
  echo "Changing extlinux file to my-machine_extlinux"
  setenv boot_syslinux_conf ${config_file}
fi
 
setenv bootargs
for BOOT_SLOT in "${BOOT_ORDER}"; do
  if test "x${bootargs}" != "x"; then
    echo "skip remaining slots"
    
  elif test "x${BOOT_SLOT}" = "xA"; then
    if test ${BOOT_A_LEFT} -gt 0; then
      echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining"
      setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
      distro_bootpart=7
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p5 rootwait rw console=ttySTM0,115200 r rauc.slot=A"
    fi
 
  elif test "x${BOOT_SLOT}" = "xB"; then
    if test ${BOOT_B_LEFT} -gt 0; then
      echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining"
      setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
      distro_bootpart=9
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p8 rootwait rw console=ttySTM0,115200 r rauc.slot=B"
    fi
  fi
done
 
 
if test -n "${bootargs}"; then
  saveenv
else
  echo "No valid slot found, resetting tries to 3"
  setenv BOOT_A_LEFT 3
  setenv BOOT_B_LEFT 3
  saveenv
  reset
fi
 
echo "Scanning for for extlinux"
run scan_dev_for_extlinux

My u-boot-rauc-script.bb:

SUMMARY = "Provide script file for U-Boot"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
DEPENDS += "u-boot-mkimage-native"
 
PACKAGE_ARCH = "${MACHINE_ARCH}"
 
SRC_URI = "file://boot.sh"
 
PV = "0.1"
 
inherit kernel-arch extlinuxconf-stm32mp
 
UBOOT_BOOTSCR = "${WORKDIR}/boot.sh"
UBOOT_BOOTSCR_IMG = "boot.scr.uimg"
 
UBOOT_INSTALL_BOOT_DIR ?= "/boot"
 
do_compile() {
    mkimage -C none -A ${UBOOT_ARCH} -T script -d ${UBOOT_BOOTSCR} ${B}/${UBOOT_BOOTSCR_IMG}
}
 
do_install() {
    install -d ${D}/${UBOOT_INSTALL_BOOT_DIR}
    # Install boot script
    install -m 755 ${B}/${UBOOT_BOOTSCR_IMG} ${D}/${UBOOT_INSTALL_BOOT_DIR}/${UBOOT_BOOTSCR_IMG}
 
}
 
FILES_${PN} = "${UBOOT_INSTALL_BOOT_DIR}"
 

Don't forget to add u-boot-fw-config-stm32mp to your image as rauc needs it to change the active partitions.

One small thing to make rauc work that needs to be done is renaming fw_env.config.mmc to fw_env.config. I created an append file to the just that in meta-my-layer/recipes-bsp/u-boot/u-boot-fw-config-stm32mp_%.bbappend:

do_install_append () {
	install -d ${D}${sysconfdir}
	install -m 0644 ${WORKDIR}/fw_env.config.mmc ${D}${sysconfdir}/fw_env.config
}

After all those changes I now have rauc working :grinning_face:

View solution in original post

7 REPLIES 7
Christophe Guibout
ST Employee

Hi @ASuar.1​ ,

The bootfs partition is dynamically found by looking at the first bootable partition (see scan_dev_for_extlinux in u-boot-env variables).

Then, rootfs is found in extlinux.conf file located in bootfs partition (root=PARTUUID=)

In your case, I would not recommand to use the automatic detected, but set ${devnum} depending on A/B state.

BR,

Christophe

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
ASuar.1
Associate III

Thanks for the reply

Hey Christophe,

Thanks for the reply I can see the scan command and will replace the scan with hard coded values based on the active partition.

I am now trying to get uboot to run the boot.scr.uimg script as recommended by rauc. I've created a recipe called u-boot-rauc-script.bb

    SUMMARY = "Provide script file for U-Boot"
    LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
     
    DEPENDS += "u-boot-mkimage-native"
     
    PACKAGE_ARCH = "${MACHINE_ARCH}"
     
    SRC_URI = "file://boot.sh"
     
    PV = "0.1"
     
    inherit kernel-arch extlinuxconf-stm32mp
     
    UBOOT_BOOTSCR = "${WORKDIR}/boot.sh"
    UBOOT_BOOTSCR_IMG = "boot.scr.uimg"
     
    UBOOT_INSTALL_DIR ?= "/boot"
     
    do_compile() {
        mkimage -C none -A ${UBOOT_ARCH} -O linux -T script -d ${UBOOT_BOOTSCR} ${B}/${UBOOT_BOOTSCR_IMG}
    }
     
    do_install() {
        install -d ${D}/${UBOOT_INSTALL_DIR}
        # Install boot script
        install -m 755 ${B}/${UBOOT_BOOTSCR_IMG} ${D}/${UBOOT_INSTALL_DIR}/${UBOOT_BOOTSCR_IMG}
    }
     
    FILES_${PN} = "${UBOOT_INSTALL_DIR}"

and a st-image-bootfs.bbappend to include the recipe in the bootfs that gets generated.

    PACKAGE_INSTALL += " \
        u-boot-rauc-script \
    "

 I can see the boot.scr.uimg in the first bootfs partition but when I boot the device I never see the script being run and when I run it myself I get an error.

    STM32MP> load mmc 0:4 0xc4100000 /boot/boot.scr.uimg
    STM32MP> source 0xc4100000
    ## Executing script at c4100000
    Wrong image format for "source" command

Do you know if I am missing a step or incorrectly compiled the boot script?

I see now it's because boot.scr.uimg' U-Boot script is executed only if 'extlinux/extlinux.conf' is not found.

https://wiki.st.com/stm32mpu/wiki/How_to_start_the_coprocessor_from_the_bootloader

A follow up question though? Is there recipe I can extend or method of rewriting the uboot variables?

In the end I actually did not have to rewrite any of the u-boot variables. I removed the extlinux/extlinux.conf file from my bootfs and had the boot.scr.uimg script change the variables i needed.

Eldam
Senior

Asuar, your post help me a lot,

As a precision, I would say that

load mmc 0:4 0xc4100000 /boot/boot.scr.uimg

points to a file in {bootfspartition}/boot{dir}/boot.scr.uimg{file}

It may be obvious for you but not for me!

a good way to check is to load the file with load mmc and check its content using

md 0xc4100000, you should see the hex content of the file instead of FFFF

Seeya!

ASuar.1
Associate III

My final solution.

In the end I changed the first boot partition to just have the boot.scr.uimg since it needs to be in the first partition after u-boot. Then created another rootfs and two bootfs with all the typical bootfs stuff ie. kernel, device tree and custom extlinux file with the root partition line removed.

In my machine file:

# disable vendorfs partition
ST_BOOTFS   = "1"
ST_VENDORFS = "0"
ST_USERFS   = "1"
 
STM32MP_BOOTFS_IMAGE = "boot-script-image" # just has boot script
MY_BOOTFS_IMAGE = "my-image-bootfs" # has kernel, dtb and other boot stuff
 
# Proposed value for rootfs in kB
# Define max size for ROOTFS image being built to this value
IMAGE_ROOTFS_MAXSIZE = "1536864"
# And configure the ROOTFS_PARTITION_SIZE variable accordingly
ROOTFS_PARTITION_SIZE = "${IMAGE_ROOTFS_MAXSIZE}"
 
# add two new bootfs and rootfs partitions for updates
PARTITIONS_CONFIG += "bootfsrauca"
PARTITIONS_CONFIG += "rootfsrauc"
PARTITIONS_CONFIG += "bootfsraucb"
 
PARTITIONS_CONFIG[bootfsrauca]   ?= "${MY_BOOTFS_IMAGE},bootfsrauca,${STM32MP_BOOTFS_MOUNTPOINT},${BOOTFS_PARTITION_SIZE},System"
PARTITIONS_CONFIG[rootfsrauc]   = "${IMAGE_BASENAME},rootfsrauc,,${ROOTFS_PARTITION_SIZE},FileSystem"
PARTITIONS_CONFIG[bootfsraucb]   ?= "${MY_BOOTFS_IMAGE},bootfsraucb,${STM32MP_BOOTFS_MOUNTPOINT},${BOOTFS_PARTITION_SIZE},System"

Looks something like this:

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34             545   256.0 KiB   8301  fsbl1
   2             546            1057   256.0 KiB   8301  fsbl2
   3            1058            5153   2.0 MiB     8301  ssbl
   4            5154          136225   64.0 MiB    8300  boot
   5          136226         3209953   1.5 GiB     8300  rootfs
   6         3209954         3472097   128.0 MiB   8300  userfs
   7         3472098         3603169   64.0 MiB    8300  bootfsrauca
   8         3603170         6676897   1.5 GiB     8300  rootfsrauc
   9         6676898         8388574   835.8 MiB   8300  bootfsraucb

My system.conf file:

[system]
compatible=stm32mp1-my-machine
bootloader=uboot
mountprefix=/mnt/rauc
statusfile=/usr/local/raucstatus
 
[keyring]
path=/etc/rauc/ca.cert.pem
 
# [handlers]
# pre-install=/etc/rauc/preinstall.sh
 
[slot.rootfs.0]
device=/dev/mmcblk0p5
type=ext4
bootname=A
 
[slot.rootfs.1]
device=/dev/mmcblk0p8
type=ext4
bootname=B
 
[slot.bootfs.0]
device=/dev/mmcblk0p7
type=ext4
parent=rootfs.0
 
[slot.bootfs.1]
device=/dev/mmcblk0p9
type=ext4
parent=rootfs.1

my extlinux file:

TIMEOUT 20
LABEL openstlinux-my-distro
	KERNEL /uImage
	FDTDIR /
	INITRD /uInitrd

Having the custom extlinux file was useful since I could run the scan_dev_for_extlinux.

My boot.sh:

echo "Executing SCRIPT on target=${target}"
echo "---------------  HELLO FROM SCRIPT !!!!!!!!!!!!! -----------------"
 
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B"
test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3
test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3
 
config_file="extlinux/stm32mp157c-my-machine_extlinux.conf"
if test "${boot_syslinux_conf}" != "${config_file}"; then
  echo "Changing extlinux file to my-machine_extlinux"
  setenv boot_syslinux_conf ${config_file}
fi
 
setenv bootargs
for BOOT_SLOT in "${BOOT_ORDER}"; do
  if test "x${bootargs}" != "x"; then
    echo "skip remaining slots"
    
  elif test "x${BOOT_SLOT}" = "xA"; then
    if test ${BOOT_A_LEFT} -gt 0; then
      echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining"
      setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
      distro_bootpart=7
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p5 rootwait rw console=ttySTM0,115200 r rauc.slot=A"
    fi
 
  elif test "x${BOOT_SLOT}" = "xB"; then
    if test ${BOOT_B_LEFT} -gt 0; then
      echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining"
      setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
      distro_bootpart=9
      setenv bootargs "${default_bootargs} root=/dev/mmcblk0p8 rootwait rw console=ttySTM0,115200 r rauc.slot=B"
    fi
  fi
done
 
 
if test -n "${bootargs}"; then
  saveenv
else
  echo "No valid slot found, resetting tries to 3"
  setenv BOOT_A_LEFT 3
  setenv BOOT_B_LEFT 3
  saveenv
  reset
fi
 
echo "Scanning for for extlinux"
run scan_dev_for_extlinux

My u-boot-rauc-script.bb:

SUMMARY = "Provide script file for U-Boot"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
DEPENDS += "u-boot-mkimage-native"
 
PACKAGE_ARCH = "${MACHINE_ARCH}"
 
SRC_URI = "file://boot.sh"
 
PV = "0.1"
 
inherit kernel-arch extlinuxconf-stm32mp
 
UBOOT_BOOTSCR = "${WORKDIR}/boot.sh"
UBOOT_BOOTSCR_IMG = "boot.scr.uimg"
 
UBOOT_INSTALL_BOOT_DIR ?= "/boot"
 
do_compile() {
    mkimage -C none -A ${UBOOT_ARCH} -T script -d ${UBOOT_BOOTSCR} ${B}/${UBOOT_BOOTSCR_IMG}
}
 
do_install() {
    install -d ${D}/${UBOOT_INSTALL_BOOT_DIR}
    # Install boot script
    install -m 755 ${B}/${UBOOT_BOOTSCR_IMG} ${D}/${UBOOT_INSTALL_BOOT_DIR}/${UBOOT_BOOTSCR_IMG}
 
}
 
FILES_${PN} = "${UBOOT_INSTALL_BOOT_DIR}"
 

Don't forget to add u-boot-fw-config-stm32mp to your image as rauc needs it to change the active partitions.

One small thing to make rauc work that needs to be done is renaming fw_env.config.mmc to fw_env.config. I created an append file to the just that in meta-my-layer/recipes-bsp/u-boot/u-boot-fw-config-stm32mp_%.bbappend:

do_install_append () {
	install -d ${D}${sysconfdir}
	install -m 0644 ${WORKDIR}/fw_env.config.mmc ${D}${sysconfdir}/fw_env.config
}

After all those changes I now have rauc working :grinning_face: