Ruslan Trofymenko | 68ff769 | 2019-07-05 15:37:35 +0300 | [diff] [blame] | 1 | Android A/B updates |
| 2 | =================== |
| 3 | |
| 4 | Overview |
| 5 | -------- |
| 6 | |
| 7 | A/B system updates ensures modern approach for system update. This feature |
| 8 | allows one to use two sets (or more) of partitions referred to as slots |
| 9 | (normally slot A and slot B). The system runs from the current slot while the |
| 10 | partitions in the unused slot can be updated [1]. |
| 11 | |
| 12 | A/B enablement |
| 13 | -------------- |
| 14 | |
| 15 | The A/B updates support can be activated by specifying next options in |
| 16 | your board configuration file: |
| 17 | |
| 18 | CONFIG_ANDROID_AB=y |
| 19 | CONFIG_CMD_AB_SELECT=y |
| 20 | |
| 21 | The disk space on target device must be partitioned in a way so that each |
| 22 | partition which needs to be updated has two or more instances. The name of |
| 23 | each instance must be formed by adding suffixes: _a, _b, _c, etc. |
| 24 | For example: boot_a, boot_b, system_a, system_b, vendor_a, vendor_b. |
| 25 | |
| 26 | As a result you can use 'ab_select' command to ensure A/B boot process in your |
| 27 | boot script. This command analyzes and processes A/B metadata stored on a |
| 28 | special partition (e.g. "misc") and determines which slot should be used for |
| 29 | booting up. |
| 30 | |
| 31 | Command usage |
| 32 | ------------- |
| 33 | |
| 34 | ab_select <slot_var_name> <interface> <dev[:part_number|#part_name]> |
| 35 | |
| 36 | for example: |
| 37 | |
| 38 | => ab_select slot_name mmc 1:4 |
| 39 | |
| 40 | or |
| 41 | |
| 42 | => ab_select slot_name mmc 1#misc |
| 43 | |
| 44 | Result: |
| 45 | |
| 46 | => printenv slot_name |
| 47 | slot_name=a |
| 48 | |
| 49 | Based on this slot information, the current boot partition should be defined, |
| 50 | and next kernel command line parameters should be generated: |
| 51 | |
| 52 | - androidboot.slot_suffix= |
| 53 | - root= |
| 54 | |
| 55 | For example: |
| 56 | |
| 57 | androidboot.slot_suffix=_a root=/dev/mmcblk1p12 |
| 58 | |
| 59 | A/B metadata is organized according to AOSP reference [2]. On the first system |
| 60 | start with A/B enabled, when 'misc' partition doesn't contain required data, |
| 61 | the default A/B metadata will be created and written to 'misc' partition. |
| 62 | |
| 63 | References |
| 64 | ---------- |
| 65 | |
| 66 | [1] https://source.android.com/devices/tech/ota/ab |
| 67 | [2] bootable/recovery/bootloader_message/include/bootloader_message/bootloader_message.h |