Step by Step walk through on how to use swupdate on Raspberry Pi or any Embedded board for system update

11.6k Views Asked by At

Stackoverflow community. I am trying to design an OTA update system and would like to use swupdate for raspberry pi to update. I have found very limited to none information regarding on how to implement that. It would be great if anybody can let me know how it is done. Thank you

1

There are 1 best solutions below

9
Danish Shrestha On BEST ANSWER

Here's a good example of OTA using SWUpdate on raspberry pi. https://mkrak.org/2018/01/26/updating-embedded-linux-devices-part2/

I had to make a few changes to use the latest zeus release. Below is step by step commands on ubuntu 18.04. (This alway worked with master branch as of Mar-22-2020)

Install all required dependencies. (installation script below from https://medium.com/@shantanoodesai/run-docker-on-a-raspberry-pi-4-with-yocto-project-551d6b615c0b)

sudo apt-get update
sudo apt-get install \
     gawk wget git-core diffstat unzip texinfo gcc-multilib \
     build-essential chrpath socat cpio \
     python python3 python3-pip python3-pexpect \
     xz-utils debianutils iputils-ping \
     python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev

Clone all meta-layers

mkdir yocto && cd yocto
mkdir layers && cd layers
git clone git://git.yoctoproject.org/poky -b zeus
git clone git://github.com/openembedded/meta-openembedded.git -b zeus
git clone https://github.com/agherzan/meta-raspberrypi.git -b zeus
git clone https://github.com/sbabic/meta-swupdate -b zeus

git clone https://github.com/sbabic/meta-swupdate-boards.git -b master

cd ..
. layers/poky/oe-init-build-env build

Add layers. If this fails modify build/conf/bblayers.conf manually to include all the layers specified below

bitbake-layers add-layer ../layers/meta-openembedded/meta-oe
bitbake-layers add-layer ../layers/meta-openembedded/meta-python
bitbake-layers add-layer ../layers/meta-openembedded/meta-networking
bitbake-layers add-layer ../layers/meta-openembedded/meta-multimedia
bitbake-layers add-layer ../layers/meta-raspberrypi
bitbake-layers add-layer ../layers/meta-swupdate
bitbake-layers add-layer ../layers/meta-swupdate-boards

Add the following to build/conf/local.conf (Raspberry pi doesn't use uboot bootloader by default. swupdate requires ext4.gz image.)

RPI_USE_U_BOOT = "1"
IMAGE_FSTYPES = "rpi-sdimg ext4.gz"
PREFERRED_PROVIDER_u-boot-fw-utils = "libubootenv"

Now finally bake it. meta-swupdate-boards contains example for a few hardware. I was able to copy raspberrypi3 board implementation to support raspberrypi2 easily.

MACHINE=raspberrypi3 bitbake update-image

This should create core-image-full-cmdline-raspberrypi3.rpi-sdimg and update-image-raspberrypi3.swu files under build/tmp/deploy/image/raspberrypi3/.

Lets burn core-image-full-cmdline-raspberrypi3.rpi-sdimg image to sd card and use update-image-raspberrypi3.swu to update it.

Update to your flash using UI tool like Balena Etcher or via command line. Please note the target file system /dev/disk2 may be different.

sudo dd if=core-image-full-cmdline-raspberrypi3.rpi-sdimg of=/dev/disk2 bs=1m

Once the pi starts up, goto pi_ipaddress:8080. Drag and drop update-image-raspberrypi3.swu to update the firmware.