#Preface
As we all know, Google often uses dessert names to label Android versions, and this tradition has been going on for a decade, with each version increasing with the addition of a new letter in the alphabet. Hence, the latest Android 14, with the letter “U,” is now dubbed as Upside Down Cake.
Upside Down Cake is a type of cake baked in a skillet, where the ingredients (usually apple or pineapple slices) are placed on the bottom of the skillet. The batter is then poured on top and placed in the oven for baking.
Now, we can enjoy the latest Upside Down Cake on VIM3/VIM3L.
Code Download and Compilation
Obtaining the Code
mkdir khadas-aosp-14 && cd $_
repo init -u https://gitlab.baylibre.com/baylibre/amlogic/atv/aosp/manifest.git -b yukawa-android-14
repo sync
Compiling the Code
- VIM3
export TARGET_VIM3=true
export TARGET_AVB_ENABLE=true
export TARGET_USE_TABLET_LAUNCHER=true
source build/envsetup.sh && lunch yukawa-user/yukawa-userdebug
time make -j50 2>&1 | tee build_vim3_14_android.log
- VIM3L
export TARGET_VIM3L=true
export TARGET_AVB_ENABLE=true
export TARGET_USE_TABLET_LAUNCHER=true
source build/envsetup.sh && lunch yukawa-user/yukawa-userdebug
time make -j50 2>&1 | tee build_vim3l_14_android.log
Supported Lunch Targets
Android Lunch | Android Version |
---|---|
yukawa-userdebug |
TV Debug (VIM3) |
yukawa-user |
TV Release (VIM3) |
We also support the following build flags to enable optional features:
TARGET_AVB_ENABLE=true
: Enable AVBTARGET_KERNEL_USE=6.1|mainline
: Choose the kernel version (default is 6.1)TARGET_VIM3=true
: Build for VIM3 boardTARGET_VIM3L=true
: Build for VIM3L board (default target)TARGET_BUILTIN_EDID=true
: This option allows to preload 1920x1080 EDID structureTARGET_USE_TABLET_LAUNCLHER=true
: Use tablet launcher instead of Android TV launcher
Extension
Building the Android Kernel
Android is built around the Linux kernel. By default, the boot.img for Android is constructed from the binary kernel image located in the following directory:
~/src/khadas-aosp-14/device/amlogic/yukawa-kernel/6.1
Below are instructions for rebuilding and customizing the Linux kernel for Android.
Obtaining Kernel Code
Use repo to get the code:
mkdir ~/src/khadas-kernel/ && cd $_
repo init -u https://gitlab.baylibre.com/baylibre/amlogic/atv/aosp/kernel/manifest.git -b yukawa-android-14-6.1
repo sync
Building the Kernel
In this section, we assume that we already have a fully built Android source code tree located at:
~/src/khadas-aosp-14/
Building Everything from Scratch
For the 6.1 kernel, use:
cd ~/src/khadas-kernel/
export DIST_DIR=~/src/khadas-aosp-14/device/amlogic/yukawa-kernel/6.1
tools/bazel run //yukawa-device:yukawa_dist -- --dist_dir=$DIST_DIR
Rerun this command for incremental rebuilding.
Defconfig/menuconfig Changes
The usual (make menuconfig) is achieved by manually editing arch/arm64/configs/amlogic_gki.fragment.
Rebuilding All Associated Android Images
To test the changes made to the kernel, we must rebuild the relevant Android images:
boot.img: Contains the kernel binary file and the main device tree
vendor.img: Contains the kernel modules
To rebuild the Android images, perform the following:
cd ~/src/khadas-aosp-14/
source build/envsetup.sh && lunch yukawa-user/yukawa-userdebug
make bootimage vendorimage
Flash the newly generated boot.img and vendor.img into the device:
fastboot flash boot boot.img
fastboot flash vendor vendor.img
Bootloader
Obtaining Code
git clone https://gitlab.baylibre.com/baylibre/amlogic/atv/u-boot.git -b u-boot/v2024.01-rc1/integ bootloaders
Building
Install build dependencies:
sudo apt install gcc-aarch64-linux-gnu bc bison build-essential curl u-boot-tools flex git libssl-dev python3 python3-pip wget -y
pip3 install pyamlboot --user
Download the FIP package and generate the script:
cd bootloaders/
wget <package_file>
wget https://gitlab.baylibre.com/baylibre/amlogic/atv/aosp/device/amlogic/yukawa/-/raw/master/bootloader/scripts/generate-bins-new.sh
Unpack the FIP package:
tar xvf <package_file>
Generate the U-Boot image with the following command:
export CROSS_COMPILE=aarch64-linux-gnu-
make khadas-vim3_android_ab_defconfig|khadas-vim3l_android_ab_defconfig
make -j"$(nproc)"
Generate the FIP binary file:
chmod +x generate-bins-new.sh
./generate-bins-new.sh <fip-directory> u-boot.bin
Flashing Bootloader
Flash the result:
fastboot flash bootloader uboot-bins/u-boot.bin
fastboot erase bootenv
fastboot reboot bootloader
If partition table update is required after reboot:
fastboot oem format
Firmware Download
For this purpose, we will provide firmware for each version. If you wish to skip the compilation, you can click the links below to download the images directly.
Version(Latest) 20240613:
Version 20240115:
Flashing Method
For optimal results, the VIM3/VIM3L should be directly connected to the host PC. Avoid using USB hubs, as they often do not provide enough power to the board. Below, I will demonstrate the flashing process using VIM3.
After downloading the firmware and extracting it, if the image file is obtained from the compiled code, it will be located in the khadas-aosp-14\out\target\product\yukawa directory. We will need the following five files: boot.img, dtbo-unsigned.img, super.img, u-boot_kvim3_ab.bin, and userdata.img.
The latest version 20240613 still needs vbmeta.img.
Initial Flashing Method:
The flashing will be done using the pre-built pyamlboot tool, which requires a Ubuntu system for flashing.
- Install pyamlboot via pip
pip3 install pyamlboot
Alternatively, refer to pyamlboot for other methods.
- Set the board to USB upgrade mode:
1- Power up the VIM3
2- Press the F button quickly 3 times within 2 seconds, then release the button
The power LED (blue) will flash for about 3 seconds. After the power LED (blue) goes out, the board will enter upgrade mode.
- Flash the Android bootloader
# For vim3
export BOOTLOADER_NAME=u-boot_kvim3_ab.bin
# For VIM3L
export BOOTLOADER_NAME=u-boot_kvim3l_ab.bin
boot-g12.py ${BOOTLOADER_NAME}
The bin file path is: khadas-aosp-14/device/amlogic/yukawa/bootloader/
- Start U-Boot and run fastboot
fastboot flash bootloader ${BOOTLOADER_NAME}
fastboot erase bootenv && fastboot oem format && fastboot reboot bootloader
Note that after executing the above command, you need to press the R (Reset) button . After this, the development board should boot into the newly refreshed u-boot and enter fastboot mode.
- Flash the Android image
fastboot devices---Check if there is a device present; if there is, continue with the flash command
If you encounter “waiting for device” and there is no device ID appearing, follow the steps below:If Waiting for Device prompts and there is no device number, please follow the following:
which fastboot ---Locate the fastboot path, mine is /usr/bin/fastboot
sudo chown root:root /usr/bin/fastboot
sudo chmod +s /usr/bin/fastboot
If you encounter the following error when executing fastboot format metadata
mke2fs 1.44.1 (24-Mar-2018)
/tmp/TemporaryFile-qiakg4: Unimplemented ext2 library function while setting up superblock
/usr/lib/android-sdk/platform-tools/mke2fs failed with status 1
mke2fs failed: 1
error: Cannot generate image for metadata
You can copy the latest version of fastboot and mke2fs to your local directory
cp mke2fs /usr/lib/android-sdk/platform-tools/mke2fs
chmod 777 /usr/lib/android-sdk/platform-tools/mke2fs
The following print message appears, indicating that the fastboot format metadata execution is successful.
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
Sending 'metadata' (52 KB) OKAY [ 0.007s]
Writing 'metadata' OKAY [ 0.036s]
Finished. Total time: 0.085s
Flash command:
fastboot flash boot_a boot.img && fastboot flash boot_b boot.img && fastboot flash super super.img && fastboot flash userdata userdata.img && fastboot flash dtbo_a dtbo-unsigned.img && fastboot flash dtbo_b dtbo-unsigned.img && fastboot erase misc && fastboot erase frp && fastboot format metadata && fastboot flash vbmeta_a vbmeta.img && fastboot flash vbmeta_b vbmeta.img && fastboot reboot
With these steps completed, the flashing should be successful. Now, simply wait for the device to boot up.
Before officially entering the system, we also need to set up avb in the uboot environment. During the boot process, connect to the serial port and keep pressing Enter to enter. Enter the following command and then restart to set up the boot
setenv force_avb 1
saveenv