WLS2Linux subsystem compiles Android
In the previous article, I explained "WLS2Linux Subsystem Migration/Restore", migrating from C drive to D drive. It can not only prevent the C disk from becoming popular, but also free up disk space. Having a larger storage space means that there is a lot to do, such as compiling the Android system. This article takes the open source firefly Android10 code as an example to briefly explain the compilation process.
提示:
Compilation environment dependencies are missing, please refer to "WLS2Linux Subsystem (3)" .
Article directory
1. Preparation for compilation
1.1 Get the Android source code
注意:下载或解包源码时,请勿使用 root 权限操作。
You can go to the official website of firefly to pick up the SDK, download it to the local decompression, and then it will be a git mirror warehouse.
# 还原源码
git checkout .
1.2 Compile dependency package installation
a) uboot compilation dependencies
Install the uboot compilation dependency package.
sudo apt-get install gcc make device-tree-compiler gawk
If you do not install and compile, you need to rely on packages, error messages and related prompts, please refer to "WLS2Linux Subsystem (3)" .
b) kernel compilation dependencies
Install the kenrel compilation dependency package.
sudo apt install gcc make bison cpio flex openssl libssl-dev liblz4-tool -y
If there are omissions or error prompts that are not installed, please refer to "WLS2Linux Subsystem (3)" .
c) Compile the recovery dependency package
Install the recovery compilation dependency package.
sudo apt install expect g++ -y
If there are omissions or error prompts that are not installed, please refer to "WLS2Linux Subsystem (3)" .
d) Compile the Android dependency package
Install Android compilation dependencies.
sudo apt install fakeroot unbuffer expect unzip libncurses5 libncurses5-dev -y
If there are omissions or error prompts that are not installed, please refer to "WLS2Linux Subsystem (3)" .
The error message is as follows, curses5 needs to be installed.
curses.h: No such file or directory
Install curses5.
sudo apt-get install libncurses5 libncurses5-dev
e) Install python environment variables
/bin/bash: 行 1: python: 未找到命令
The compilation in the Android source code depends on the python2 environment,
sudo apt install python2
cd /usr/bin
sudo ln -s python2.7 python
2. Compile the source code
2.1 uboot
Compile uboot and MiniLoader.bin
cd ~/linux/u-boot
# 编译 rk3568
./make.sh rk3568
# 编译 rk3288
./make.sh rk3288
......
load addr is 0x8400000!
pack input bin/rk32/rk3288_tee_ta_v2.01.bin
pack file size: 734592(717 KB)
crc = 0x69d0e887
trustos version: Trust os
pack ./trust.img success!
pack trust okay! Input: /home/fish/linux/rkbin/RKTRUST/RK3288TOS.ini
/home/fish/linux/u-boot
pack loader ok.(rk3288_loader_v1.09.263.bin)(0.02)
pack loader okay! Input: /home/fish/linux/rkbin/RKBOOT/RK3288MINIALL.ini
# 编译完成后生成 uboot.img 和 rk3288_loader_v1.09.263.bin
2.2 compile kernel
cd ~/linux/kernel
# 编译 rk3568 为 64bit A55,可选用 aarch64
make ARCH=arm rockchip_linux_defconfig -j4
make ARCH=arm rk3568-evb2-lp4x-v10.img -j16
# 编译 rk3288 为 32bit A17, 须使用 arm
make ARCH=arm rockchip_linux_defconfig -j4
make ARCH=arm rk3288-evb-rk808-linux.img -j16
......
LD [M] drivers/net/wireless/marvell/mwifiex/mwifiex_sdio.ko
LD [M] drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/bcmdhd.ko
LD [M] drivers/net/wireless/marvell/mwifiex/mwifiex.ko
Image: resource.img (with rk3288-evb-rk808-linux.dtb logo.bmp logo_kernel.bmp) is ready
Image: boot.img (with Image resource.img) is ready
Image: zboot.img (with zImage resource.img) is ready
#编译完成后生成 4个镜像文件
# boot.img ---> 内核完整镜像
# kernel.img ---> 内核
# resource.img ---> logo 和 dtb
# zboot.img --> 最小内核
2.3 Compile Android
- Configure environment variables
source build/envsetup.sh
lunch rk3568_r-userdebug
- compile android
# 一键编译 uboot kernel Android
./build.sh -UKAu
# 编译完成自动生成刷机镜像,漫长等待过程,此处省略N小时
2.4 Flash
2.4.1 View image files and partition tables
ls rockdev/rk3568_r/
baseparameter.img boot.img dtbo.img MiniLoaderAll.bin parameter.txt pcba_whole_misc.img resource.img uboot.img vbmeta.img
boot-debug.img config.cfg logo.img misc.img pcba_small_misc.img recovery.img super.img update.img
2.4.2 Flashing
You can use the flashing tool to flash the upgrade package, or use the rkflash.sh script for Linux flashing
# 刷 升级包
./rkflash.sh updateimg
WSL2 子系统无法执行 mount 和 chroot 命令,故需要拷贝到 Windows 目录,使用相关工具刷机。
2.5 The previous driver could not be loaded after the upgrade
Error message:
wlan_mt7668_sdio: version magic '4.19.193 SMP mod_unload aarch64' should be '5.10.66 SMP mod_unload aarch64'
Due to the difference between the current system kernel and the version before the upgrade, the driver cannot be loaded. The solution to this problem: flash to the 4.19.193 version of the kernel.
Tips
- If the computer memory used is less than 24G, compilation errors may be reported due to insufficient memory. Please refer to "https://blog.csdn.net/weixin_35723192/article/details/132008500" .
- If the compilation tools are not fully installed, a compilation error will also be prompted.
Summarize
The WSL2 subsystem is a subsystem after all, compiling uboot kernel openwrt is also competent; if compiling Android and Linux rootfs is limited by the system and CPU, it is recommended to use Ubuntu PC or server.