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