Apalis imx6: remote update rootfs

Hi,

I have an Apalis imx6 module that is running the default lxde 2.4 beta image. It has kernel 3.10.
I would like to update the kernel and rootfs to the latest version.

The trouble here is that it will have to be done through ssh session. Physical access is not an option.

I have seen in one of the post regarding how to update the kernel by simply copying the image file to the dev that corresponding to the flash where the image file is stored.

What I’m struggling with is how to update the rootfs. Any help would be really appreciated.

In addition, any tools suggestion that can help making the update process power fail safe would be greatly appreciated.

Thanks,

Nam

Hello @Nanguyen and welcome to Toradex community.

In order to update the rootfs you need to be able to unmount it, so you can replace the files. You can achieve this with a tmpfs in ram.
Create a tmpfs, copy a temporary (preferrably very small) rootfs into it. chroot into that newly copied rootfs and then you can unmount the main rootfs and update it with the one stored in ram.

Please also see this article: https://developer.toradex.com/knowledge-base/initramfs-and-tmpfs

On https://github.com/toradex/meta-toradex-tezi you can find the Yocto layer for the Toradex Easy Installer. There we do the same thing.

About power fail safe updates: We offer Torizon for Apalis iMX6. This is an industrial linux platform which offers secure over-the-air updates with failsafe. Check out this link for further information: https://www.toradex.com/operating-systems/torizon

Best regards,
Philippe

Hi Philippe,

Thank you for your answer.

One thing I’m not exactly sure about, if you don’t mind, is that how to do I access the original fs after executing chroot?

As you indicated, the answer should be in the meta-toradex-tezi. If you don’t mind pointing me to the right file, that would be greatly appreciated.

Thanks,

Nam

Hey @Nanguyen !

We don’t use an Apalis module, but a Colibri module, so the procedure should be quite the same.

We deliver our product with a sd card on the carrier board, which we use to update.
So we download and extract the new linux image to the sd card and start the update on the next boot by setting the bootcmd parameter: fw_setenv bootcmd "run setupdate && run update"

To make this work, you also need to modify the flash_blk.scr script from the toradex layer to reset the bootcmd command after the update.

I updated the update_new variable in the flash_blk.scr to:

setenv update_new 'updt_fuse -n && run update_latest && env default -a && saveenv && setenv bootcmd "env default -a && saveenv && reset" && saveenv && reset; run update_v2.5b3'

This way, also all uboot environment variables are reseted to new default values in your linux image. We needed this, as we needed to change a new environment variable during the update.

BR Christian

Thanks for your suggestion.

Hello Nanguyen

I have never tried this myself. I also heard that OpenWRT is doing exactly that, what you are trying to do. I quickly tried this:

  • I built a minimal rootfs with bitbake initramfs-debug-image
  • Made a ramdisk and copied that initramfs-debug-image into it:

mkdir -p /mnt/ramdisk

mount -t tmpfs -o size=64m tmpfs /mnt/ramdisk

tar -xvf /media/sda/initramfs-debug-image-apalis-imx6.tar.xz -C /mnt/ramdisk

  • Now I am able to chroot /mnt/ramdisk
  • Create the needed filesystems:

mkdir dev sys proc

mount -t devtmpfs devtmpfs /dev/

mount -t proc proc /proc

mount -t sysfs sysfs /sys

  • Then I mounted /dev/mmcblk0p2, where the rootfs is stored, deleted everything and copied the new one in.
  • I was not able to reboot because I deleted the reboot command earlier.

I think there would be much better ways to update the rootfs but I can’t help you further here because we also do not have the details.

I think the better solution for you is the one from @cheesi to hook the run setupdate && run update command in bootcmd so it gets updated before boot.

Best regards,
Philippe

Thanks, Christian. I’ll give it a try.

Perfect. We will wait for your results.