Difference between revisions of "Rockpi4/rockpi-android9"
(5 intermediate revisions by the same user not shown) | |||
Line 35: | Line 35: | ||
libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \ | libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \ | ||
htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \ | htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \ | ||
− | dosfstools vim-common parted udev lzop | + | dosfstools vim-common parted udev lzop rsync |
radxa$ pip install pycrypto | radxa$ pip install pycrypto | ||
</code> | </code> | ||
Line 53: | Line 53: | ||
libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \ | libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \ | ||
htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \ | htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \ | ||
− | dosfstools vim-common parted udev lzop | + | dosfstools vim-common parted udev lzop rsync |
RUN pip install pycrypto | RUN pip install pycrypto | ||
RUN curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > /usr/local/bin/repo && \ | RUN curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > /usr/local/bin/repo && \ | ||
Line 81: | Line 81: | ||
Then run: | Then run: | ||
<code bash> | <code bash> | ||
− | radxa$ repo init -u https://github.com/radxa/manifests.git -b rockpi-box-9.0 -m rockpi-release.xml | + | radxa:rockpi4-android9$ repo init -u https://github.com/radxa/manifests.git -b rockpi-box-9.0 -m rockpi-release.xml |
− | radxa$ repo sync -d --no-tags -j4 | + | radxa:rockpi4-android9$ repo sync -d --no-tags -j4 |
</code> | </code> | ||
It might take quite a bit of time to fetch the entire AOSP source code(around 86G)! | It might take quite a bit of time to fetch the entire AOSP source code(around 86G)! | ||
Line 88: | Line 88: | ||
==== Build u-boot ==== | ==== Build u-boot ==== | ||
<code bash> | <code bash> | ||
− | radxa$ cd u-boot | + | radxa:rockpi4-android9 $ cd u-boot |
− | radxa$ ./make.sh rk3399 | + | radxa:rockpi4-android9/u-boot$ ./make.sh rk3399 |
− | radxa$ cd .. | + | radxa:rockpi4-android9/u-boot$ cd .. |
</code> | </code> | ||
The generated images are **rk3399_loader_v_xxx.bin** , **idbloader.img** and **uboot.img** | The generated images are **rk3399_loader_v_xxx.bin** , **idbloader.img** and **uboot.img** | ||
Line 97: | Line 97: | ||
For HDMI 4K | For HDMI 4K | ||
<code bash> | <code bash> | ||
− | radxa$ cd kernel | + | radxa:rockpi4-android9 $cd kernel |
− | radxa$ make rockchip_defconfig | + | radxa:rockpi4-android9/kernel$ make rockchip_defconfig |
− | radxa$ make rk3399-rockpi-4b.img -j$(nproc) | + | radxa:rockpi4-android9/kernel$ make rk3399-rockpi-4b.img -j$(nproc) |
− | radxa$ cd .. | + | radxa:rockpi4-android9/kernel$ cd .. |
</code> | </code> | ||
Line 111: | Line 111: | ||
Android TV: | Android TV: | ||
<code bash> | <code bash> | ||
− | radxa$ source build/envsetup.sh | + | radxa:rockpi4-android9$ source build/envsetup.sh |
− | radxa$ lunch rk3399_box-userdebug | + | radxa:rockpi4-android9$ lunch rk3399_box-userdebug |
− | radxa$ make -j$(nproc) | + | radxa:rockpi4-android9$ make -j$(nproc) |
</code> | </code> | ||
Android Tablet: | Android Tablet: | ||
<code bash> | <code bash> | ||
− | radxa$ source build/envsetup.sh | + | radxa:rockpi4-android9$ source build/envsetup.sh |
− | radxa$ lunch rk3399-userdebug | + | radxa:rockpi4-android9$ lunch rk3399-userdebug |
− | radxa$ make -j$(nproc) | + | radxa:rockpi4-android9$ make -j$(nproc) |
</code> | </code> | ||
It takes a long time, take a break and wait... | It takes a long time, take a break and wait... | ||
Line 125: | Line 125: | ||
==== Generate images ==== | ==== Generate images ==== | ||
<code bash> | <code bash> | ||
− | radxa$ ln -s RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev | + | radxa:rockpi4-android9$ ln -s RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev |
− | radxa$ ./mkimage.sh | + | radxa:rockpi4-android9$ ./mkimage.sh |
</code> | </code> | ||
Line 152: | Line 152: | ||
Android TV | Android TV | ||
<code bash> | <code bash> | ||
− | radxa$ cd rockdev | + | radxa:rockpi4-android9 $ cd rockdev |
− | radxa$ ln -s Image-rk3399_box Image | + | radxa:rockpi4-android9/rockdev$ ln -s Image-rk3399_box Image |
</code> | </code> | ||
Android Tablet | Android Tablet | ||
<code bash> | <code bash> | ||
− | radxa$ cd rockdev | + | radxa:rockpi4-android9 $ cd rockdev |
− | radxa$ ln -s Image-rk3399 Image | + | radxa:rockpi4-android9/rockdev$ ln -s Image-rk3399 Image |
</code> | </code> | ||
1. RkUpdate Image | 1. RkUpdate Image | ||
<code> | <code> | ||
− | radxa$ ./mkupdate.sh | + | radxa:rockpi4-android9/rockdev$ ./mkupdate.sh |
</code> | </code> | ||
The images under rockdev/ are `update.img` | The images under rockdev/ are `update.img` | ||
− | 2. GPT Image | + | 2. GPT Image<br> |
+ | If you start a new terminal, the android environment is not configured, you need: | ||
<code bash> | <code bash> | ||
− | radxa$ ./android-gpt.sh | + | radxa:rockpi4-android9$ source build/envsetup.sh && setpaths |
+ | </code> | ||
+ | gen apt image: | ||
+ | <code bash> | ||
+ | radxa:rockpi4-android9/rockdev$ ./android-gpt.sh | ||
IMAGE_LENGTH:9018403 | IMAGE_LENGTH:9018403 |
Latest revision as of 09:31, 28 February 2020
ROCK Pi 4 > Android9
Recommend build host is Ubuntu 16.04 64bit, for other hosts, refer official Android documents Establishing a Build Environment.
Repo
radxa$ wget 'https://storage.googleapis.com/git-repo-downloads/repo' -P /tmp/ radxa$ sudo cp /tmp/repo /usr/local/bin/repo radxa$ sudo chmod +x /usr/local/bin/repo
In China Download Repo:
radxa$ echo "export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/'" >> ~/.bashrc radxa$ source ~/.bashrc radxa$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o /tmp/repo radxa$ sudo cp /tmp/repo /usr/local/bin/repo radxa$ sudo chmod +x /usr/local/bin/repo
Init Environment
Android's source code primarily consists of Java, C++, and XML files.
To compile the source code, you'll need to install OpenJDK 8, GNU C and C++ compilers, XML parsing libraries, ImageMagick, and several other related packages.
radxa$ apt-get update -y && apt-get install -y openjdk-8-jdk python python-pip git-core gnupg flex bison gperf build-essential \ zip curl liblz4-tool zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \ lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \ libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \ htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \ dosfstools vim-common parted udev lzop rsync radxa$ pip install pycrypto
Configure the JAVA environment
radxa$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 radxa$ export PATH=$JAVA_HOME/bin:$PATH radxa$ export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
DockerFile
FROM ubuntu:xenial RUN apt-get update -y && apt-get install -y openjdk-8-jdk python python-pip git-core gnupg flex bison gperf build-essential \ zip curl liblz4-tool zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \ lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \ libgl1-mesa-dev libxml2-utils xsltproc unzip mtools u-boot-tools \ htop iotop sysstat iftop pigz bc device-tree-compiler lunzip \ dosfstools vim-common parted udev lzop rsync RUN pip install pycrypto RUN curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > /usr/local/bin/repo && \ chmod +x /usr/local/bin/repo
RUN which repo
ENV REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/' USER=android9-docker
ARG USER_ID=0 ARG GROUP_ID=0 RUN groupadd -g ${GROUP_ID} jenkins-docker && useradd -m -g jenkins-docker -u ${USER_ID} android9-docker
USER android9-docker
Build DockerFile
radxa$ docker build -t android-builder:9.x --build-arg USER_ID=`id -u` --build-arg GROUP_ID=`id -g` $(which-dir-dockerfile-in)
Download source code
radxa$ mkdir rockpi4-android9 radxa$ cd rockpi4-android9
Then run:
radxa:rockpi4-android9$ repo init -u https://github.com/radxa/manifests.git -b rockpi-box-9.0 -m rockpi-release.xml radxa:rockpi4-android9$ repo sync -d --no-tags -j4
It might take quite a bit of time to fetch the entire AOSP source code(around 86G)!
Build u-boot
radxa:rockpi4-android9 $ cd u-boot radxa:rockpi4-android9/u-boot$ ./make.sh rk3399 radxa:rockpi4-android9/u-boot$ cd ..
The generated images are **rk3399_loader_v_xxx.bin** , **idbloader.img** and **uboot.img**
Building kernel
For HDMI 4K
radxa:rockpi4-android9 $cd kernel radxa:rockpi4-android9/kernel$ make rockchip_defconfig radxa:rockpi4-android9/kernel$ make rk3399-rockpi-4b.img -j$(nproc) radxa:rockpi4-android9/kernel$ cd ..
The generated images are **kernel.img** and **resource.img**:
- kernel.img, kernel with rkcrc checksum
- resource.img, contains dtb and boot logo, Rockchip format resource package
Building AOSP
Android TV:
radxa:rockpi4-android9$ source build/envsetup.sh radxa:rockpi4-android9$ lunch rk3399_box-userdebug radxa:rockpi4-android9$ make -j$(nproc)
Android Tablet:
radxa:rockpi4-android9$ source build/envsetup.sh radxa:rockpi4-android9$ lunch rk3399-userdebug radxa:rockpi4-android9$ make -j$(nproc)
It takes a long time, take a break and wait...
Generate images
radxa:rockpi4-android9$ ln -s RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev radxa:rockpi4-android9$ ./mkimage.sh
The generated images under rockdev/Image-* are
├── boot.img ├── dtbo.img ├── idbloader.img ├── kernel.img ├── misc.img ├── oem.img ├── parameter.txt ├── pcba_small_misc.img ├── pcba_whole_misc.img ├── recovery.img ├── resource.img ├── system.img ├── trust.img ├── uboot.img ├── vbmeta.img └── vendor.img
Generated Image
Android TV
radxa:rockpi4-android9 $ cd rockdev radxa:rockpi4-android9/rockdev$ ln -s Image-rk3399_box Image
Android Tablet
radxa:rockpi4-android9 $ cd rockdev radxa:rockpi4-android9/rockdev$ ln -s Image-rk3399 Image
1. RkUpdate Image
radxa:rockpi4-android9/rockdev$ ./mkupdate.sh
The images under rockdev/ are `update.img`
2. GPT Image
If you start a new terminal, the android environment is not configured, you need:
radxa:rockpi4-android9$ source build/envsetup.sh && setpaths
gen apt image:
radxa:rockpi4-android9/rockdev$ ./android-gpt.sh
IMAGE_LENGTH:9018403 simg2img system.img simg2img vendor.img simg2img oem.img idbloader 64 16383 8.000000 MB Warning: The resulting partition is not properly aligned for best performance. uboot 16384 24575 4.000000 MB trust 24576 32767 4.000000 MB misc 32768 40959 4.000000 MB resource 40960 73727 16.000000 MB kernel 73728 139263 32.000000 MB dtb 139264 147455 4.000000 MB dtbo 147456 155647 4.000000 MB vbmeta 155648 157695 1.000000 MB boot 157696 223231 32.000000 MB recovery 223232 354303 64.000000 MB backup 354304 583679 112.000000 MB security 583680 591871 4.000000 MB cache 591872 1640447 512.000000 MB system 1640448 6883327 2560.000000 MB metadata 6883328 6916095 16.000000 MB vendor 6916096 7964671 512.000000 MB oem 7964672 9013247 512.000000 MB frp 9013248 9014271 0.500000 MB userdata 9014272 9014271 0.000000 MB Warning: The resulting partition is not properly aligned for best performance.
The images under rockdev/Image are `gpt.img`
Installation
GPT Image Install on microSD
GPT Image Install on eMMC module
GPT Image Install on M.2 NVME SSD
RkUpdate Image Install on eMMC module
There may be some performance loss when using microSD.