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 Answers
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.

- 487
- 5
- 16
-
Thank you so much. I will try to follow your steps and let you know the result – Prudhvi Reddy Vemireddy Mar 24 '20 at 20:53
-
4Did it worked ok? I've followed the steps, flashed the .rpi-sdimg but the Raspberry keeps complaining about "wrong image format for bootm command" – Matteo Iervasi Aug 28 '20 at 16:38
-
1This answer is extremely useful, however I suggest that IMAGE_FSTYPES to wic instead of rpi-sdimg... check https://groups.google.com/g/swupdate/c/R87EdIsOujU/m/kNv0q7GoCAAJ – Bernardo Rodrigues Apr 03 '21 at 21:11
-
1there's actually a few extra issues, Stefano explains them in detail in that mail thread... I guess the safest path is to use the terminal-server and use the build vars he suggests – Bernardo Rodrigues Apr 03 '21 at 21:26
-
also the actual image to be built is terminal-server-image – Bernardo Rodrigues Apr 04 '21 at 00:25
-
Does your setup use /boot/cmdline.txt ? Im trying to figure out how to get swupdate to update that file. – uglyoldbob Aug 31 '21 at 16:11
-
I think one issue is that `core-image-full-cmdline-raspberrypi3.{wic,rpi-sdimg}` is the image upon which `update-image` is based (for generating the `.swu` file), but this image does not contain any SWUpdate functionality since it's a Poky recipes-extended image. So after flashing it to an SD card, it doesn't actually contain anything SWUpdate-related. I'm still trying to work out how to create an initial .wic image that can be flashed _and_ contains SWUpdate. – davidA Jul 05 '22 at 22:02
-
Also, looks like the "terminal-server" branch in the referenced "Homeassistant" repo has been deleted. Anyone know which remaining branch is closest to what it was? – davidA Jul 05 '22 at 22:04
-
Responding to myself earlier: I suppose the answer is to append `swupdate` and friends to `CORE_IMAGE_EXTRA_INSTALL`, but none of these instructions, nor the ones linked, mention that step. – davidA Jul 05 '22 at 22:20