4.7. Android OTA
This application note contains steps to test the OTA (Over The Air) feature on Android.
There are 2 ways of applying an OTA update:
4.7.1. OTA via adb sideload
Build and flash android images following Build Instructions instructions.
Build OTA package
$ cd ${YOUR_PATH}/ti-aosp-14
$ source build/envsetup.sh
$ lunch <BUILD_TARGET>
$ export DIST_DIR=./dist_output
$ m dist
Reboot to recovery and apply OTA
$ adb reboot sideload
$ adb wait-for-sideload
$ adb sideload $DIST_DIR/am62p-ota-eng.${USER}.zip
$ adb reboot
4.7.2. OTA via Update Engine
Build the OTA package
$ source build/envsetup.sh $ lunch <BUILD_TARGET> $ export DIST_DIR=./dist_output $ m $ m dist
Set your
PYTHONPATH
.Some dependent python modules for
gen_update_config.py
are part of AOSP tree or part of the build output.$ cd $ANDROID_BUILD_TOP $ apex_manifest_pb2_path=$(find out -name 'apex_manifest_pb2.py' -print -quit) $ PYTHONPATH=$ANDROID_BUILD_TOP/$(dirname ${apex_manifest_pb2_path}):$PYTHONPATH $ PYTHONPATH=$ANDROID_BUILD_TOP/build/make/tools/releasetools:$PYTHONPATH $ PYTHONPATH=$ANDROID_BUILD_TOP/system/apex/apexer/:$PYTHONPATH $ export PYTHONPATH
Patch the
gen_update_config.py
script to be compatible with Android 14. Inbootable/recovery
, apply the following change:https://android-review.googlesource.com/c/platform/bootable/recovery/+/2837717
This can be done with:
$ cd $ANDROID_BUILD_TOP/bootable/recovery $ git fetch https://android.googlesource.com/platform/bootable/recovery refs/changes/17/2837717/1 $ git cherry-pick FETCH_HEAD
Update the ota config file. Feel free to change
$DIST_DIR
to match your developer environment.$ source build/envsetup.sh $ lunch <BUILD_TARGET> $ DIST_DIR=dist_output $ BOARD=am62p $ bootable/recovery/updater_sample/tools/gen_update_config.py --ab_install NON_STREAMING $DIST_DIR/$BOARD-ota-eng.${USER}.zip $DIST_DIR/$BOARD-ota-eng.${USER}.json file:///data/user/0/com.example.android.systemupdatersample/files/packages/$BOARD-ota-eng.${USER}.zip
Warning
Be careful, last line is one single very long line.
Run the SystemUpdaterSample app once:
$ adb root $ adb shell setenforce 0 $ adb shell am start com.example.android.systemupdatersample/com.example.android.systemupdatersample.ui.MainActivity
Push the files on the board:
$ adb root $ adb shell mkdir /data/user/0/com.example.android.systemupdatersample/files/configs $ adb shell mkdir /data/user/0/com.example.android.systemupdatersample/files/packages $ adb push $DIST_DIR/$BOARD-ota-eng.${USER}.json /data/user/0/com.example.android.systemupdatersample/files/configs/ $ adb push $DIST_DIR/$BOARD-ota-eng.${USER}.zip /data/user/0/com.example.android.systemupdatersample/files/packages/
Change SELinux label:
$ adb shell chcon -R u:object_r:ota_package_file:s0 /data/user/0/com.example.android.systemupdatersample/
Change Unix permisssions:
$ adb shell chmod -R 777 /data/user/0/com.example.android.systemupdatersample/
Run the update on the UI:
Tap on
RELOAD
to load the configTap on
APPLY
to apply the OTATap
OK
to confirm applicationWait for progress bar to complete
Tap on
SWITCH SLOT
to finish update (scroll downwards to see the button)Wait for verification
Reboot the device with:
$ adb shell svc power reboot
Confirm that booting on slot b
$ adb root $ adb shell grep -o 'androidboot.slot_suffix=[_ab]*' /proc/cmdline androidboot.slot_suffix=_b
4.7.2.1. Troubleshooting
Python 3.12 is not supported, because it removed the imp
module and also comes with a
too recent version of protobuf
.
To install and older version, use virtualenv
:
$ pip install virtualenv # make sure python3.11 is installed on your system
$ virtualenv --py 3.11 venv_ota_build
$ source venv_ota_build/bin/activate
$ pip install protobuf==3.20
From here, you should be able to invoke gen_update_config.py
.