Bring up Android A/B system (Part 2)

trouble shooting

With A/B system, previous mkdir/symlink may not work, in such case we need to create such folders/links at build time.

BOARD_ROOT_EXTRA_FOLDERS := customer_data
BOARD_ROOT_EXTRA_SYMLINKS := /customer_data:/customer

if you can not find the boot device

printk_all_partitions() from $linux/block/genhd.c can print a full list of all partitions, intended for places where the root filesystem can’t be mounted and thus to give the victim some idea of what went wrong.

[    1.993936] List of all partitions:
[    1.997553] 0100            8192 ram0  (driver?)
[    2.002335] b300         7471104 mmcblk0  driver: mmcblk
[    2.007837]   b301            1024 mmcblk0p1 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.015581]   b302            1024 mmcblk0p2 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.023317]   b303            7168 mmcblk0p3 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.031061]   b304            7168 mmcblk0p4 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.038804]   b305            8192 mmcblk0p5 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.054833]   b306            8192 mmcblk0p6 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.062570]   b307           16384 mmcblk0p7 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.070310]   b308           16384 mmcblk0p8 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.078052]   b309           16384 mmcblk0p9 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.085793]   b30a           16384 mmcblk0p10 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.093618]   b30b           16384 mmcblk0p11 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.101450]   b30c           16384 mmcblk0p12 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.109278]   b30d           16384 mmcblk0p13 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.117110]   b30e           16384 mmcblk0p14 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.124939]   b30f           16384 mmcblk0p15 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.132765]   b310           16384 mmcblk0p16 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.140596]   b311           16384 mmcblk0p17 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.148426]   b312           16384 mmcblk0p18 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.156256]   b313           32768 mmcblk0p19 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.164081]   103:00000      32768 mmcblk0p20 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.171911]   103:00001     950272 mmcblk0p21 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.179742]   103:00002     950272 mmcblk0p22 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.187573]   103:00003      16384 mmcblk0p23 b2285256-164b-4ab5-dcb9-699f7b7bb600
[    2.195404]   103:00004      16384 mmcblk0p24 b2285256-164b-4ab5-dcb9-699f7b7bb600

Supposing your /system partition resides on p21 of mmcblk0, your bootloader should set root=/dev/mmcblk0p21.

if you can start shell, but Android didn’t start, WTF?

You may need to parse your init.xx.rc, and check which stage you are at.
Android will be started in class “main” of init.

if you find BCB data is cleared unexpectedly, please blame Google …

There is “bootable/recovery/uncrypt/uncrypt.rc”, which will be put at “/system/etc/init/uncrypt.rc”, it will clear BCB on start up, which clears ‘active_slot’ too.

service clear-bcb /system/bin/uncrypt --clear-bcb
    class main
    socket uncrypt stream 600 system system
    disabled
    oneshot

But sadly, Android N 7.0 doesn’t have the right code to handle such cases. To fix this issue, you can either do some hacks to disable this BCB clear actions, or upgrade latest AOSP, which has defined “bootloader_message_ab” to match newer A/B styled Android.

bootloader_message struct

bootloader_message (1088 bytes)

char command[32]
char status[32]
char recovery[768]
char stage[32]
char slot_suffix[32]
char reserved[192]

BrilloSlotInfo (4 bytes)

uint8_t bootable : 1;
uint8_t reserved[3];

BrilloBootInfo (32 bytes)

char bootctrl_suffix[4];
uint8_t magic[3]; //"BCc"
uint8_t version;
uint8_t active_slot;
BrilloSlotInfo slot_info[2];
uint8_t reserved[15];

bootloader_message_ab struct

(2 KB) bootloader_message

char command[32]
char status[32]
char recovery[768]
char stage[32]
char reserved[1184]

(2 KB)

char slot_suffix[32]
char reserved[2016]