OTA for Embedded Linux Devices: A practical introduction | Interrupt

A core belief of Memfault is that we can ship faster when we have good infrastructure in place. An essential piece of this infrastructure is tools to send firmware updates over the air. It enables the team to ship more often and spend more time building features.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/ota-for-embedded-linux-devices

Does U-Boot have any options for fallback / rollback in the case a non-bootable version of firmware get installed?

1 Like

Hi,

This is a great question. You can use the techniques shown in the article to implement a boot counter and rollback when it reaches a certain number.

Here is a quick example of addition to the boot script to automatically rollback if we boot 3 times without clearing the boot counter:

if env exists bootcount; then  
  setexpr bootcount ${bootcount} + 1
  if test ${bootcount} -ge 3; then  
    echo Bootcount limit reached - Rolling back...  
    if test ${rootpart} -eq 2; then 
      setenv rootpart 3 
    else 
      setenv rootpart 2 
    fi 
    saveenv  
  else  
    echo Bootcount is ${bootcount}
    saveenv
  fi  
else  
  echo Initializing bootcount at 1.
  setenv bootcount 1
  saveenv  
fi  

In the system, you will need to set bootcount to 0 (using fw_setenv bootcount 0 once the system has started properly).

I may cover this in another post but you have the essentials here.

best,
thomas

Hi @sarfata ,@kisielk

I used dual copy scheme for the update, my question is once update done on inactive partition but user may have some data or package installed in active partition so how to take those data to the inactive/update partition.

Best,
Kirana

Hi @kirana1996,

You should store all user data in a third partition. This way it stays there across updates. That is what most people do. We would recommend not storing anything on the system partitions. Ideally they would be read-only.

best,
thomas

Hi @sarfata ,

Ok, can you please mention how we can copy to third partition and retrieve back to updated active partition.

Hi,

You would just mount the third partition in your fstab.

We discuss this approach in the OTA webinar (Over The Air Updates for Embedded Linux Devices) and it’s implemented in our meta-memfault-example layer for Yocto (https://github.com/memfault/memfault-linux-sdk/blob/kirkstone/meta-memfault-example/recipes-core/base-files/files/qemuall/fstab.append).

best,
thomas

Ok, this i tried but I didn’t see any user data on this partition.
Is it same as rootfs partition?
And
If user install packages and libraries, it will be installed on active partition right(in /) and these data how can take backup to updating partition. Like how to take backup to/from active partition to/from /media.

Thanks,