Skip to content
Snippets Groups Projects
Commit e942978e authored by Michael Walle's avatar Michael Walle Committed by Frieder Schrempf
Browse files

meta-ked-imx: Use fitImageA/B instead of active/inactive

This is supposed to fix a problem where you can end up with two
non-working images.

This can be triggered by the following actions:

  * Starting with rootfs A and fitImage_active
  * Doing an update via swupdate using a corrupted kernel image
  * fitImage_active gets renamed to fitImage_inactive.
  * The corrupted kernel now in fitImage_active fails to boot
  * A fallback to rootfs A occurs: rootfs A is started together
    with the working fitImage_inactive
  * On the next update via swupdate the corrupted fitImage_active is
    renamed to fitImage_inactive ending up with two corrupted kernel
    images
  * The now corrupted fitImage_inactive is copied to fitImage_active
    and the boot is bricked

To remedy this flaw, simply swap the fitImage in sync with the rootfs.
Instead of the active/inactive image we now use A/B for the kernel image
and the currently used image is selected by the sys_active file.
parent 061d5db0
No related branches found
No related tags found
1 merge request!35meta-ked-imx: Use fitImageA/B instead of active/inactive
Pipeline #18514 passed
......@@ -8,8 +8,8 @@ do_bootfs() {
mkdir ${IMAGE_BOOTFS}
fi
cp -L ${DEPLOY_DIR_IMAGE}/fitImage ${IMAGE_BOOTFS}/fitImage_active
cp -L ${DEPLOY_DIR_IMAGE}/fitImage ${IMAGE_BOOTFS}/fitImage_inactive
cp -L ${DEPLOY_DIR_IMAGE}/fitImage ${IMAGE_BOOTFS}/fitImage_A
cp -L ${DEPLOY_DIR_IMAGE}/fitImage ${IMAGE_BOOTFS}/fitImage_B
echo "AB" > ${IMAGE_BOOTFS}/sys_active
if [ -e ${IMGDEPLOYDIR}/${IMAGE_BOOTFS_NAME}.tar.gz ];then
......
......@@ -80,7 +80,6 @@ vendor_bootm=
vendor_set_ab_bootargs=
if test $fallback_active = 0; then
echo Normal boot to active system;
setenv image ${image_base}_active;
if itest.b *${loadaddr} == 41; then
setenv active_part a;
else
......@@ -88,7 +87,6 @@ vendor_set_ab_bootargs=
fi;
else
echo Fallback boot to inactive system;
setenv image ${image_base}_inactive;
if itest.w *${loadaddr} == 0x4242 || itest.w *${loadaddr} == 0x4241; then
setenv active_part b;
elif itest.w *${loadaddr} == 0x4141 || itest.w *${loadaddr} == 0x4142; then
......@@ -96,9 +94,11 @@ vendor_set_ab_bootargs=
fi;
fi;
if test $active_part = a; then
setenv image ${image_base}_A;
setenv bootargs ubi.mtd=0 rootfstype=ubifs root=ubi0:root_A ${bootargs_base};
echo Using rootfs partition A: ubi0:root_A;
elif test $active_part = b; then
setenv image ${image_base}_B;
setenv bootargs ubi.mtd=0 rootfstype=ubifs root=ubi0:root_B ${bootargs_base};
echo Using rootfs partition B: ubi0:root_B;
fi;
......@@ -104,7 +104,6 @@ vendor_boot=
vendor_set_ab_bootargs=
if test $fallback_active = 0; then
echo Normal boot to active system;
setenv image ${image_base}_active;
if itest.b *${loadaddr} == 41; then
setenv active_part a;
else
......@@ -112,7 +111,6 @@ vendor_set_ab_bootargs=
fi;
else
echo Fallback boot to inactive system;
setenv image ${image_base}_inactive;
if itest.w *${loadaddr} == 0x4242 || itest.w *${loadaddr} == 0x4241; then
setenv active_part b;
elif itest.w *${loadaddr} == 0x4141 || itest.w *${loadaddr} == 0x4142; then
......@@ -120,9 +118,11 @@ vendor_set_ab_bootargs=
fi;
fi;
if test $active_part = a; then
setenv image ${image_base}_A;
setenv bootargs root=/dev/mmcblk${devnum}p2 ${bootargs_base};
echo Using rootfs partition A: /dev/mmcblk${devnum}p2;
elif test $active_part = b; then
setenv image ${image_base}_B;
setenv bootargs root=/dev/mmcblk${devnum}p3 ${bootargs_base};
echo Using rootfs partition B: /dev/mmcblk${devnum}p3;
fi;
......@@ -83,12 +83,6 @@ do_switch_fitImage() {
set_sys_active "BB"
fi
#move active kernel to inactive
if [ -e ${mnt_dir}/fitImage_active ]; then
echo "Moving fitImage_active to inactive"
mv ${mnt_dir}/fitImage_active ${mnt_dir}/fitImage_inactive
fi
#set active partition
if test "${cur_par}" == "ubi0:root_A" ;then
echo "Set active root partition to B with Fallback on A"
......
......@@ -20,7 +20,7 @@ software =
{
filename = "fitImage";
device = "/dev/ubi0_0";
path = "/fitImage_active";
path = "/fitImage_A";
filesystem = "ubifs";
}
);
......@@ -40,7 +40,7 @@ software =
{
filename = "fitImage";
device = "/dev/ubi0_0";
path = "/fitImage_active" ;
path = "/fitImage_B" ;
filesystem = "ubifs";
}
);
......
......@@ -78,12 +78,6 @@ do_switch_fitImage() {
set_sys_active "BB"
fi
#move active kernel to inactive
if [ -e ${mnt_dir}/fitImage_active ]; then
echo "Moving fitImage_active to inactive"
mv ${mnt_dir}/fitImage_active ${mnt_dir}/fitImage_inactive
fi
#set active partition
if test "${cur_par}" == ${rootfs_a};then
echo "Set active root partition to B with Fallback on A"
......
......@@ -19,7 +19,7 @@ software =
{
filename = "fitImage";
device = "/dev/mmcblk0p1";
path = "/fitImage_active" ;
path = "/fitImage_A" ;
filesystem = "ext4";
}
);
......@@ -39,7 +39,7 @@ software =
{
filename = "fitImage";
device = "/dev/mmcblk0p1";
path = "/fitImage_active" ;
path = "/fitImage_B" ;
filesystem = "ext4";
}
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment