A/B and abctl Verification
abctl is a diagnostic and factory test tool for OTA A/B metadata. It can operate on regular files or /dev/block/by-name/misc on devices.
Metadata Convention
- A/B metadata is located at
miscpartition byte offset2048. - Data structure is 32 bytes, compatible with Android AVB A/B layout version
1.0. - CRC32 uses big-endian IEEE, covering metadata bytes
0..27. - Reserved bytes remain reserved. Application OTA state is saved on the dedicated partition mounted at
/userdata/ota, not written tomiscreserved bytes. - Factory
misc.imginitial state: slot A priority 15, successful; slot B disabled.
Host Image Check
Use regular files for safe testing:
build/bin/abctl init /tmp/misc.img --size 4M
build/bin/abctl read /tmp/misc.img
Expected output includes slot A successful, slot B priority 0, last_boot=A.
Manual state switching:
build/bin/abctl set-active /tmp/misc.img b --tries 3
build/bin/abctl read /tmp/misc.img
build/bin/abctl mark-successful /tmp/misc.img b
build/bin/abctl read /tmp/misc.img
Explicitly write test state:
build/bin/abctl write /tmp/misc.img \
--a-priority 14 --a-tries 0 --a-successful 1 \
--b-priority 15 --b-tries 3 --b-successful 0
build/bin/abctl read /tmp/misc.img
abctl write will reject illegal states, such as a successful slot with non-zero tries.
Device Check
Read real misc on device:
/oem/usr/bin/abctl read /dev/block/by-name/misc
Manually switch slot:
/oem/usr/bin/abctl set-active /dev/block/by-name/misc b --tries 3
sync
reboot
After boot, confirm active slot:
cat /proc/cmdline
mount | grep ' /oem '
/oem/usr/bin/abctl read /dev/block/by-name/misc
After confirming device health, commit slot:
/oem/usr/bin/abctl mark-successful /dev/block/by-name/misc b
sync
Rollback Test
Set up a trial boot and do not mark successful:
/oem/usr/bin/abctl set-active /dev/block/by-name/misc b --tries 1
sync
reboot
Do not commit B. Continue rebooting until SPL exhausts tries and returns to the previous successful slot. Confirm with cat /proc/cmdline, mount | grep ' /oem ', and abctl read.
Expected Diagnostic Signals
/proc/cmdlinecontainsaiden.slot_suffix=_aor_b.root=PARTLABEL=rootfs_a|rootfs_bin/proc/cmdlinematches slot suffix./oemis mounted from/dev/block/by-name/oem_aoroem_b, matching slot suffix.abctl readcan parse AVB A/B metadata without CRC or layout errors.ota statuscan display OTA state, active slot, pending boot, and raw A/B data.