uboot : boot.Scr for multi boot

Discussion about U-Boot and the kernel.

uboot : boot.Scr for multi boot

Postby doudootiana » Sun Nov 29, 2020 10:54 pm

HY ladies and gentlemen :)

I use u-boot since a few time and i am lost :)

In the first time, i used one Partition where there were the "boot folder" with Kernel (image), the dtb and the files boot.scr.

Now i would like to developp my project.

I need three Partitions :
-the 1st : boot with kernel, boot.scr and dtb
-the 2nd : a rootfs alpha
-the 3rd : the rootf beta.

In the boot's Partition there are two kernels, one for each rootfs.

I build the boot.scr from the files boot.cmd and using bkimage.

the code of boot.cmd is :

$this->bbcode_second_pass_code('', 'if part uuid ${devtype} ${devnum}:${distro_bootpart} partuuid; then
if test "${bootfstype}" = "btrfs"; then
rootflags="commit=5,subvol=@"
subvol="/@"
else
rootflags="commit=5"
subvol=""
fi

if load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${subvol}/boot/armada-3720-turris-mox.dtb; then
has_dtb=1
else
setenv has_dtb 0
echo "Cannot find device tree binary!"
fi

if test $has_dtb -eq 1; then
if load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${subvol}/boot/Image; then
setenv bootargs "earlyprintk console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000 rootfstype=${bootfstype} root=PARTUUID=${partuuid} rootflags=${rootflags} rootwait ${contract} rw cfg80211.freg=${regdomain}"
booti ${kernel_addr_r} - ${fdt_addr_r}
echo "Booting Image failed"
else
echo "Cannot load kernel binary"
fi
fi

env delete partuuid
fi')

When i used one parition, it worked very well.

Now i know that i have to modify the boot's Files.
My Idea is to do two backups of boot.scr : one to boot in rootfs alpha and another for rootfs beta.
and when i wanted to boot in arootfs alpha, i do a cp boot.scr.alpha boot.scr

i have collect some informations :
Part uuid of all partitions,
and this part of the code $this->bbcode_second_pass_code('', '${devtype} ${devnum}:${distro_bootpart}') : for example the boot partition is mmc 0:1

i don't manage to do a static boot.scr for each rootfs.

i have tried a lot of combinations but none works :(

can somebody help me please :)

thanks by advance

Doudoo tiana
doudootiana
 
Posts: 2
Joined: Sun Nov 29, 2020 10:34 pm

Re: uboot : boot.Scr for multi boot

Postby summers » Mon Nov 30, 2020 9:57 am

Havn't looked at this in detail. and you boot file is very different to mine, but some thoughts.

Its more usual to edit the boot.txt file, and then compile that into a boot.scr image. Its booting via uboot distro method, so you can look up more on that. Important bit:

$this->bbcode_second_pass_code('', 'setenv bootargs "earlyprintk console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000 rootfstype=${bootfstype} root=PARTUUID=${partuuid} rootflags=${rootflags} rootwait ${contract} rw cfg80211.freg=${regdomain}"
env delete partuuid')
The important bit is the partuuid env variable, it points to the partition to use as the root partition. Note its deleted at the end of the script, so the script has some method of recreating it. So what I'd do is at the beginning of each script set the partuuid env variable, and point to where you want, e.g. the id of the two partitions you want to boot.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: uboot : boot.Scr for multi boot

Postby doudootiana » Fri Dec 04, 2020 4:40 pm

Hy,
First thank you to answer me :)

i have found the solution for my problem.
I don't know if it's clean :) but it works .

I put it here if it can help someone :

$this->bbcode_second_pass_code('', 'if part uuid mmc 0:1; then
if load mmc 0:1 ${fdt_addr_r} armada-3720-turris-mox-alpha.dtb; then
has_dtb=1
else
setenv has_dtb 0
echo "Cannot find device tree binary!"
fi

if test $has_dtb -eq 1; then
if load mmc 0:1 ${kernel_addr_r} /Image-alpha; then
setenv bootargs "earlyprintk console=ttyMV0,115200 earlycon=ar3700_uart,0xd0012000 root=/dev/mmcblk1p2 rootwait rw cfg80211.freg=${regdomain}"
booti ${kernel_addr_r} - ${fdt_addr_r}
echo "Booting Image failed"
else
echo "Cannot load kernel binary"
fi
fi

fi')
doudootiana
 
Posts: 2
Joined: Sun Nov 29, 2020 10:34 pm

Re: uboot : boot.Scr for multi boot

Postby summers » Sat Dec 05, 2020 9:51 am

Yes you can use the device name rather than PARTUUID, its what we all used to do.

Reason we flipped to PARTUUID, is the device numbering scheme depends on the order that devices come up in. So what is mmcblk1 this time, may well become mmcblk0 on next boot - and that would mean it doesn't get used.

PARTUUID though is set on the device, on on that machine should be a unique number. It means even if devices get renumbered, still the right device will be mounted.

Back in desktop days and hard disks, there didn't seem to be any problems with device name; but with flash which is what arm uses most of the time, its less clear. My laptop, if booted with a usb stick in, and typically that gets the device name of the SD card that in the machine permanently. Still if you never change what hardware is plugged into the machine, it shouldn't cause a problem.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm


Return to U-Boot/Kernel

Who is online

Users browsing this forum: No registered users and 4 guests