Download SDK
After downloading the sdk, transfer it to the android folder via samba
Verification
Use the md5sum command to check the MD5 value of the downloaded SDK archive (tspi_android_sdk_repo_20240202.tar.gz).
md5sum tspi_android_sdk_repo_20240202.tar.gz
# The value you check yourself
2
Compare the obtained checksum value with the one provided in the download package. To check the provided checksum value, use the following command:
cat tspi_android_sdk_repo_20240202_md5sum.txt
# Official SDK provided checksum
2
Extract
After extracting the SDK, you can delete tspi_android_sdk_repo_20240202.tar.gz to save space.
$ tar -xzf tspi_android_sdk_repo_20240202.tar.gz
# After extraction, the SDK will be in a .repo directory. Files starting with a dot are hidden, so use the `ls --all` command to view them.
2
Sync Code
After extraction, there will only be the .repo directory. You will need to sync the code using the repo command. To run the repo command, you need to have Git and Python installed on your Ubuntu system; otherwise, you will encounter an error.
sudo apt-get update
sudo apt-get install git -y
sudo apt install repo -y
sudo apt-get install python2.7
sudo apt-get install python3
$Set python2.7
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
$Set python3.6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
sudo update-alternatives --config python
#Then, switch Python versions using options 0, 1, or 2.
#Finally, start syncing
.repo/repo/repo sync -l -j88
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Switch to the development board branch
cd kernel/ && git clean -xdf && cd .. && repo forall -c
Install the compilation environment
sudo apt-get update && sudo apt-get install -y git python make openjdk-8-jdk git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libgl1-mesa-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libxml2-utils xsltproc unzip python bc imagemagick ccache schedtool libssl-dev libncursesw5-dbg libncursesw5-dev libncurses5 libncursesw5 libncursesada5-dev libncurses5-dbg libncurses5-dev libncursesada-doc libncursesada5 libncurses-dev libncurses-gst libncurses5-dev clang
Full Android 11 Compilation
This command will compile boot, kernel, and android The original command uses 16 processes which is demanding for the device; adjust it to auto-adjust processes
cd u-boot && ./make.sh rk3566 && cd ../kernel && make clean && make distclean && make ARCH=arm64 tspi_defconfig rk356x_evb.config android-11.config && make ARCH=arm64 tspi-rk3566-user-v10.img -j$(nproc) && cd .. && source build/envsetup.sh && lunch rk3566_tspi-userdebug && make installclean -j$(nproc) && make -j$(nproc) && ./mkimage.sh
If power selection is incorrect, it will cause compilation errors. Ensure that VCCIO4 and VCCIO6 are selected as 1.8V, and others as 3.3V. If the power selection dialog doesn't pop up, install whiptail and recompile.
sudo apt install whiptail
Firmware packaging
./mkimage.sh
#Check the packaging time to ensure it matches your compilation time and confirm packaging success
ls rockdev/Image-rk3566_tspi/ -l
2
3
4
Pack the Image
Package the firmware into a single image
./build.sh -u
# After packaging, you should see an additional update.img file in the directory
2
3
Compilation failure Solution:
Modify Ubuntu swap partition size
Compilation of Android 11 fails with 8GB of RAM due to insufficient swap space.
Navigate to the root directory and check the original swap file (here, I created a new partition named swap2file and disabled and deleted the original swapfile partition).
cd /
ls
2
Check swap space size (original swap partition was 2GB)
swapon --show
swapon -s
free -hm
2
3
Here is the new swap partition with 32GB size.
Add Swap Partition
#1. Enter root directory
cd /
#2. Each block is 1M, with a total of 16384 blocks, which is 16G
sudo dd if=/dev/zero of=/swap bs=1M count=16384
#3. /swap is initialized as a swap space
sudo mkswap /swap
#4. Activate swap space
sudo swapon /swap
#5. Verify if the result is OK
free -hm
2
3
4
5
6
7
8
9
10
11
12
13
14
A swap partition file named swap has been created and the swap space has been activated, with a size of 16G. However, the original file name was swapfile, with a size of 2G. So, there are now two swap partitions, and recompilation still fails. The following is the diagram for dual swap partitions:
Reconfigure New Swap Partition
#1. Enter the root directory
cd /
#2. Create a new swap partition file
sudo dd if=/dev/zero of=/swap2file bs=1M count=32768
#3. Create swap file system
sudo mkswap -f swap2file
#4. Activate new swap
sudo swapon swap2file
#5. Disable and delete the original swap file
sudo swapoff swapfile && sudo rm /swapfile
#6. Set to auto-mount at boot: change swapfile to swap2file in /etc/fstab
/swap2file none swap sw 0 0
#7. Finally, use free -hm to verify if it's OK.
free -hm
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Remove SWAP Partition
# Deactivate the original swap space and remove the original swapfile.
# To remove the SWAP partition on Ubuntu 18.04, follow these steps:
#1 First, input the following command to deactivate the SWAP space:
sudo swapoff -v /swapfile
#2 Remove the valid swap line from /etc/fstab.
#3 Finally, execute the following command to delete the swapfile:
sudo rm /swapfile
2
3
4
5
6
7
8
9
Recompilation Failure Handling: Recompilation still fails: 8G low memory compilation error “java.lang.OutOfMemoryError: Java heap space”
1. Modify Z:\android\build\soong\java\droiddoc.go File, Screenshot of Original File Below
Insert the following line of code
Flag(
2. Set the system to enable swap space when remaining memory is 1.5G
# The system will only activate Swap when virtual memory is insufficient. For example, the swap space is enabled only when the system’s default memory is 6000KB, but at this point, the system may have already frozen and cannot start swap. Therefore, settings need to be changed.
# Enter the following command in the terminal:
sudo vim /etc/sysctl.conf
# Add the following line at the end
# Approximately 1.5G
vm.min_free_kbytes=1500000
# Save and exit
# Then reboot the system
2
3
4
5
6
7
8
3. Recompilation Successful
Reference: The method provided by AI to modify the swap partition: To change swapfile to swap2file, you can follow these steps:
#1. Stop using the current swap file. Use the following command to stop using swapfile:
sudo swapoff /swapfile
#2. Create a new swap file swap2file. You can use the following command to create a 32G swap file:
sudo fallocate -l 32G /swap2file
#3. Set permissions for the swap file. Use the following command to set the permissions of the swap file so that only the root user can read and write the file:
sudo chmod 600 /swap2file
#4. Set the new swap file as the swap space. Use the following command to set the new swap file as swap space:
sudo mkswap /swap2file
#5. Enable the new swap file. Use the following command to enable the new swap file:
sudo swapon /swap2file
#6. Update the `/etc/fstab` file. Edit the `/etc/fstab` file and replace the original swapfile entry with the new swap2file entry. For example, add the following content to the `/etc/fstab` file:
/swap2file none swap sw 0 0
#7. Save and close the `/etc/fstab` file.
# After completing the above steps, the system will use the new swap file swap2file as the swap space.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21