cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP1 How to Modify Partition and Flash Layout for RAUC

ASuar.1
Associate III

I am working with the STM32MP157 creating an SD card image using OpenSTLinux. I would like to use RAUC to perform updates but to do so I need to create a second rootfs partition. One active partition and the other for updates. I couldn't find in the wiki how to modify the partitions and general flash layout.

Does anyone have any recommendations on where to start looking or what to modify in OpenSTLinux to modify the generated partition layout. Also any advice with RAUC is appreciated.

https://github.com/rauc/rauc

3 REPLIES 3
ASuar.1
Associate III

So it looks like i can modify the partitions by just adding to the PARTITIONS_CONFIG variable. I also removed the other partitions to simplify updates. Most of the variables that I changed were first declared in st-machine-common-stm32mp.inc.

I add the following to my machine config file.

ST_BOOTFS   = "0"
ST_VENDORFS = "0"
ST_USERFS   = "0"
 
STM32MP_DATAFS_MOUNTPOINT ?= "/data"
 
# Proposed value for rootfs is 1GB in kB
# Define max size for ROOTFS image being built to this value
IMAGE_ROOTFS_MAXSIZE = "1048576"
# And configure the ROOTFS_PARTITION_SIZE variable accordingly
ROOTFS_PARTITION_SIZE = "${IMAGE_ROOTFS_MAXSIZE}"
# 128MB (4*32MB)
DATAFS_PARTITION_SIZE ?= "131072"
 
PARTITIONS_CONFIG += "rootfsrauc"
PARTITIONS_CONFIG += "datafs"
 
PARTITIONS_CONFIG[rootfsrauc]   = "${IMAGE_BASENAME},rootfsrauc,,${ROOTFS_PARTITION_SIZE},FileSystem"
PARTITIONS_CONFIG[datafs]       = "${STM32MP_VENDORFS_IMAGE},data,${STM32MP_DATAFS_MOUNTPOINT},${DATAFS_PARTITION_SIZE},FileSystem"

Now the issue I'm having is that there seems to be a variable that limits the since of the SD card flashlayout to 1.6GB and the create_sdcard_from_flashlayout.sh keeps giving me an error saying:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

[ERROR]: The rootfs and/or other partitions doesn't enter on a SDCARD size of 1536 MB

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I'm now trying to find where I can change this value.

ASuar.1
Associate III

It turns out the 1536 MB limit was inside the create_sdcard_from_flashlayout.sh script itself. I created a patch to increase the value.

Also I need to put back the bootfs to be able to start the device.

ASuar.1
Associate III

I've been able to get the extra partitions and created a system.conf file for rauc to use.

# disable venderfs
ST_BOOTFS   = "1"
ST_VENDORFS = "0"
ST_USERFS   = "1"
 
# Proposed value for rootfs is 1.6GB 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 additional boot and rootfs partitions 
PARTITIONS_CONFIG += "bootfsrauc"
PARTITIONS_CONFIG += "rootfsrauc"
 
PARTITIONS_CONFIG[bootfsrauc]   ?= "${STM32MP_BOOTFS_IMAGE},bootfsrauc,${STM32MP_BOOTFS_MOUNTPOINT},${BOOTFS_PARTITION_SIZE},System"
PARTITIONS_CONFIG[rootfsrauc]   = "${IMAGE_BASENAME},rootfsrauc,,${ROOTFS_PARTITION_SIZE},FileSystem"

[system]
compatible=stm32mp1-viper-heavy
bootloader=uboot
mountprefix=/mnt/rauc
max-bundle-download-size=805306368
 
[keyring]
path=/etc/rauc/ca.cert.pem
 
#handlers
#post-install=/usr/lib/rauc/post-install.sh
 
[slot.rootfs.0]
device=/dev/mmcblk1p5
type=ext4
bootname=A
 
[slot.rootfs.1]
device=/dev/mmcblk1p8
type=ext4
bootname=B
 
[slot.bootfs.0]
device=/dev/mmcblk1p4
type=ext4
parent=rootfs.0
 
[slot.bootfs.1]
device=/dev/mmcblk1p7
type=ext4
parent=rootfs.1

I've moved onto the uboot integration which requires a custom uboot script to be compiled into uboot to allow rauc to detect the active partition and change it after update. The following is the result of the printenv from my current version of uboot.

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

I'm not exactly sure which variables I should be modifying to change the boot and rootfs partitions. Does anyone have any suggestions? Or even how exactly I should add this script so it gets compiled with the rest of uboot?