42
https://www.pengutronix.de RAUC Behind the Scenes of an Update Framework ELC Europe 2019 Enrico Jörns – [email protected]

RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

https://www.pengutronix.de

RAUC

Behind the Scenesof an Update Framework

ELC Europe 2019

Enrico Jörns – [email protected]

Page 2: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

2/42

About Me

Embedded software developer RAUC co-maintainer At Pengutronix since 2014

Embedded Linux consulting & support since 2001 > 5000 patches in Linux kernel

Page 3: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

https://www.pengutronix.de

Introduction

Page 4: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

4/42

Updating – Big Picture

Page 5: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

5/42

Updating – Big Picture

Page 6: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

6/42

Fail-Safe Updating – Atomicity + Redundancy

Updating device. Do not turn off!

Page 7: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

7/42

Fail-Safe Updating

A: Active (running) system

B: Inactive system

Page 8: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

8/42

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Page 9: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

9/42

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Write update(s) to disk

Critical Operation!

Page 10: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

10/42

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Write update(s) to disk

Critical Operation! Update fully completed +

verified, etc.

Page 11: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

11/42

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Write update(s) to disk

Critical Operation! Update fully completed +

verified, etc. Activate updated slot

Page 12: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

12/42

Overview Over FOSS Update Frameworks

Image-based Others

OSTree

swupdate

Page 13: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

https://www.pengutronix.de

RAUC

Page 14: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

14/42

about:rauc

Name: „Robust Auto-Update Controller“ Subject: FOSS update framework Age: Started in 2015, project-driven License: LGPL-2.0 Version: 1.2 Community: ~50 contributors (1450 commits) Recent: Ongoing development / fixes / adaptions

Page 15: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

15/42

RAUC – Design Goals

Generic declarative framework A+B, A+recovery, A+B+recovery Platforms / bootloaders Application integration

Limited complexity Security (update verification) Robust design

Error Handling, standard libaries, subprocess calls

Page 16: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

16/42

RAUC – Host + Target Tool

host tool target service / tool

compile

Page 17: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

17/42

RAUC – Code & Service Architecture

C, automake Utility library GLib →

D-Bus (optional) Subprocess calls for

robustness

Service architecture

Page 18: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

18/42

Slots – Configuring Redundancy Setup

Page 19: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

19/42

RAUC – Slot Handling

Page 20: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

20/42

RAUC – Slot Handling

Service determinestarget slots

Page 21: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

21/42

Booted Slot Detection

Preferably explicit

→ must match bootname

… console=ttyS0,115200 rauc.slot=system0 root=…

added by bootloader

Alternatively via root=

→ must be detectable in mounted file systems

… console=ttyS0,115200 root=UUID=1b77ad0b-… …

Page 22: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

22/42

Introspection

$ rauc status

[...]

=== Slot States ===

[bootloader.0] (/dev/mtd0, raw, inactive)

○ [rootfs.0] (/dev/sda1, raw, booted)

bootname: system1

boot status: good

[appfs.0] (/dev/sda3, raw, active)

⏺ [rootfs.1] (/dev/sda2, raw, inactive)

bootname: system0

boot status: good

[appfs.1] (/dev/sda4, raw, inactive)

Page 23: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

23/42

RAUC – Update Bundle Format

SquashFS Mountable! Compression

Signature (CMS) Standard X.509 PKI Verification on Target

A bundle describes theintended target stateof the system

Page 24: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

24/42

Manifest – System Configuration

Page 25: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

25/42

HOW to install – Update Handler

Page 26: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

26/42

RAUC Bootloader Interaction

Installation

(Atomic action)

Boot acknowledge

(fallback handling)

Page 27: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

27/42

RAUC – Bootloader Interface

Page 28: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

28/42

Customizing The Update

System Configuration Hooks

In update bundle

Handlers In system

Full custom handler Only use signature verification

Page 29: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

29/42

RAUC – Authentication

RAUC host tool signs Bundle Verification on target OpenSSL 1.x X.509 crypto / CMS Self-signed to full PKI Key revocation and

replacement

Page 30: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

30/42

RAUC Signing Features– X.509 PKI

Page 31: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

https://www.pengutronix.de

RAUC – Advanced Topics

Page 32: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

32/42

Build System

install

r/oext4

block devicer/w

extract

journal tagsdm-integrity

hash treeimage tar

Target

dm-verity dm-integrity

RAUC And Verified Boot

Page 33: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

33/42

Built-In Bootloader Updates

Single point of failure

→ Critical Component No Fallback, but atomicity! MBR If supported by ROM

loader / storage: eMMC NAND (i.MX6)

...

[bootloader.0]

type=boot-..

device=/dev/device

...

Page 34: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

34/42

Atomic Bootloader Updates – eMMC

built-in dual boot partitions extCSD register selects

active one

...[bootloader.0]type=boot-emmcdevice=/dev/mmcblk0...

Page 35: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

35/42

Atomic Bootloader Updates – MBR

...[bootloader.0]type=boot-mbr-switchdevice=/dev/sda1...

ROM loader boots from first MBR partition

Switch between redundant partition regions

Page 36: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

36/42

Streaming and Delta Updates – casync

Image updates over Network Too large (slow connection) Temporary storage required

→ delta updates

→ avoid reinventing the wheel

“casync (content-addressable synchronisation) is a Linux software utility designed to distribute frequently-updated file system images over the Internet.“

[Wikipedia]

Page 37: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

37/42

casync – RAUC

chunk storeupdate

.caidxmetadata

slot A

seed store

slot B

install

Page 38: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

https://www.pengutronix.de

Usage and Integration

Page 39: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

39/42

Integration – Required Components

Page 40: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

40/42

Integration & Ecosystem

Linux build system integration

Yocto (meta-rauc) PTXdist Buildroot

Into Application: D-Bus Example projects like

rauc-hawkbit

Page 41: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

https://www.pengutronix.de

Thank you!

Questions?

Page 42: RAUC - eLinux · Embedded software developer ... A bundle describes the intended target state of the system. 24/42 Manifest – System Configuration. 25/42 HOW to install – Update

42/42

References

RAUC system update documentation:

https://rauc.readthedocs.io/en/latest/

RAUC on GitHub:

https://github.com/rauc/rauc

meta-rauc:

https://github.com/rauc/meta-rauc

casync:

https://github.com/systemd/casync