Tinker OS Android
Initialize the environment with the envsetup.sh
script.
source build/envsetup.sh
Run the lunch
command to choose Tinker_Board_3N-userdebug
as the target to build for Tinker Board 3N.
lunch Tinker_Board_3N-userdebug
Run the build.sh
script to build the code. Here the option U
is provided to build the u-boot, the options C
and K
are provided to build the kernel, the option A
is provided to build the Android, and the option u
is provided to pack all the images. All the images will be stored in the directory rockdev/Image-Tinker_Board_3N.
./build.sh -UCKAu
You can configure the build number with the option n
. If the option p
is provided, the build output will be moved to the directory IMAGE.
./build.sh -UCKAup -n X.Y.Z
Building OTA package
You can provide the option o
to build target files archieve and the OTA package. The target-files.zip archive and the full OTA package will be built out.
./build.sh -UCKAou
Please refer to Building OTA packages to build full updates and incremental updates.
A/B boot
To enable the A/B boot, please apply the modification under each directory.
- u-boot: In the directory u-boot, make sure the config CONFIG_ANDROID_AB is enabled.
diff --git a/configs/tinker_board_3n_defconfig b/configs/tinker_board_3n_defconfig
index a7b28f952b..6779b1a11e 100644
--- a/configs/tinker_board_3n_defconfig
+++ b/configs/tinker_board_3n_defconfig
@@ -32,6 +32,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y
# CONFIG_DISPLAY_CPUINFO is not set
CONFIG_ANDROID_BOOTLOADER=y
CONFIG_ANDROID_AVB=y
+CONFIG_ANDROID_AB=y
CONFIG_ANDROID_BOOT_IMAGE_HASH=y
CONFIG_SPL_BOARD_INIT=y
# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
- device/asus/tinker_board_3: In the directory device/asus/tinker_board_3, change the flag BOARD_USES_AB_IMAGE to true.
diff --git a/Tinker_Board_3N/BoardConfig.mk b/Tinker_Board_3N/BoardConfig.mk
index 59d3f8a..d19d66d 100644
--- a/Tinker_Board_3N/BoardConfig.mk
+++ b/Tinker_Board_3N/BoardConfig.mk
@@ -17,7 +17,7 @@ include device/asus/tinker_board_3/BoardConfig.mk
BUILD_WITH_GO_OPT := false
# AB image definition
-BOARD_USES_AB_IMAGE := false
+BOARD_USES_AB_IMAGE := true
BOARD_ROCKCHIP_VIRTUAL_AB_ENABLE := false
ifeq ($(strip $(BOARD_USES_AB_IMAGE)), true)
Please also provide the option B
when running the build.sh
script.
./build.sh -UCKABu
Creating a new partition for A/B boot
If want to creat a new partition for A/B boot, you can refer to this example. This example is to create a new partition persist
for A/B boot and the partition will be mounted on /persist
. Please apply the modification under each directory.
- device/asus/common: In the directory device/asus/common, edit the
mkimage_ab.sh
script to create the persist.img file. The initial data could also be added here.
diff --git a/mkimage_ab.sh b/mkimage_ab.sh
index 7bfcf27..2e5efe0 100755
--- a/mkimage_ab.sh
+++ b/mkimage_ab.sh
@@ -313,4 +313,14 @@ rm -rf $IMAGE_PATH/.tmp
echo "done."
fi
+echo -n "create persist.img"
+dd if=/dev/zero of=$IMAGE_PATH/persist.img count=2000 bs=8k
+mkdosfs $IMAGE_PATH/persist.img
+# You can uncomment the followings to put some initial files if needed.
+#mkdir $IMAGE_PATH/.tmp
+#sudo mount $IMAGE_PATH/persist.img $IMAGE_PATH/.tmp
+#sudo umount $IMAGE_PATH/.tmp
+#rm -rf $IMAGE_PATH/.tmp
+echo "done."
+
chmod a+r -R $IMAGE_PATH/
- device/asus/tinker_board_3: In the directory device/asus/tinker_board_3,
- Edit the
RebuildParameter.mk
file to add the partitionpersist
into the partition_list. - Edit the
Tinker_Board_3N/fstab.in
file and theTinker_Board_3N/recovery.fstab_AB
file to add the partition /dev/block/by-name/persist. - Edit the
sepolicy/dtoverlay/file_contexts
file to configure SELinux for the partition /dev/block/by-name/persist.
- Edit the
diff --git a/RebuildParameter.mk b/RebuildParameter.mk
index 95796c2..8c3e6c5 100644
--- a/RebuildParameter.mk
+++ b/RebuildParameter.mk
@@ -38,6 +38,8 @@ partition_list := $(partition_list),splash:16M
# Added by ASUS: dtoverlay partition
partition_list := $(partition_list),dtoverlay:16M
+partition_list := $(partition_list),persist:16M
+
ifeq ($(strip $(BOARD_SUPER_PARTITION_GROUPS)),rockchip_dynamic_partitions)
partition_list := $(partition_list),super:$(BOARD_SUPER_PARTITION_SIZE)
else # BOARD_USE_DYNAMIC_PARTITIONS
diff --git a/Tinker_Board_3N/fstab.in b/Tinker_Board_3N/fstab.in
index 89348c2..e8c9696 100755
--- a/Tinker_Board_3N/fstab.in
+++ b/Tinker_Board_3N/fstab.in
@@ -26,6 +26,7 @@ ${_block_prefix}odm /odm ext4 ro,barrier=1 ${_flags},first_stage_mount
# Added by ASUS
/dev/block/by-name/splash /splash emmc defaults defaults
/dev/block/by-name/dtoverlay /dtoverlay vfat defaults defaults
+/dev/block/by-name/persist /persist vfat defaults defaults
# Full disk encryption has less effect on rk3326, so default to enable this.
/dev/block/by-name/userdata /data f2fs noatime,nosuid,nodev,discard,reserve_root=32768,resgid=1065 latemount,wait,check,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,formattable,reservedsize=128M,checkpoint=fs
diff --git a/Tinker_Board_3N/recovery.fstab_AB b/Tinker_Board_3N/recovery.fstab_AB
index e4b65c6..4478d16 100644
--- a/Tinker_Board_3N/recovery.fstab_AB
+++ b/Tinker_Board_3N/recovery.fstab_AB
@@ -24,3 +24,4 @@ odm_dlkm /odm_dlkm ext4 ro,barrier=1 wait,slotselect,logical,first_stage_m
# Added by ASUS
/dev/block/by-name/splash /splash emmc defaults defaults
/dev/block/by-name/dtoverlay /dtoverlay vfat defaults defaults
+/dev/block/by-name/persist /persist vfat defaults defaults
diff --git a/sepolicy/dtoverlay/file_contexts b/sepolicy/dtoverlay/file_contexts
index fd6a17f..75c0564 100644
--- a/sepolicy/dtoverlay/file_contexts
+++ b/sepolicy/dtoverlay/file_contexts
@@ -1,3 +1,6 @@
/dtoverlay(/.*)? u:object_r:vfat:s0
/dev/block/by-name/dtoverlay u:object_r:userdata_block_device:s0
+
+/persist(/.*)? u:object_r:vfat:s0
+/dev/block/by-name/persist u:object_r:userdata_block_device:s0
- RKTools: In the directory RKTools, add the partition
persist
using the image persist.img.
diff --git a/linux/Linux_Pack_Firmware/rockdev/package-file-Tinker_Board_3N-ab b/linux/Linux_Pack_Firmware/rockdev/package-file-Tinker_Board_3N-ab
index 1cf0780..17489b5 100755
--- a/linux/Linux_Pack_Firmware/rockdev/package-file-Tinker_Board_3N-ab
+++ b/linux/Linux_Pack_Firmware/rockdev/package-file-Tinker_Board_3N-ab
@@ -13,6 +13,7 @@ dtbo_a Image/dtbo.img
dtbo_b Image/dtbo.img
splash Image/splash.img
dtoverlay Image/dtoverlay.img
+persist Image/persist.img
vbmeta_a Image/vbmeta.img
vbmeta_b Image/vbmeta.img
baseparameter Image/baseparameter.img
- system/core: In the directory system/core, edit the
rootdir/Android.mk
file to mount the partitionpersist
on/persist
.
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 63a1a484b..39cea748d 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -116,6 +116,8 @@ ifdef BOARD_USES_DTOVERLAY_PARTITION
LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/dtoverlay
endif
+LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/persist
+
# For /odm partition.
LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/odm
# For Treble Generic System Image (GSI), system-as-root GSI needs to work on