Difference between revisions of "Rockpi4/dev/rockpi-android-tv"
RadxaYuntian (Talk | contribs) |
|||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | + | __NOTOC__ | |
− | Recommend build host is Ubuntu 16.04 64bit, for other hosts, refer official Android documents [ | + | {{rockpi4_header}} |
+ | |||
+ | {{Languages|Rockpi4/dev/rockpi-android-tv}} | ||
+ | |||
+ | [[rockpi4 | ROCK Pi 4]] > [[Rockpi4/dev/rockpi-android-tv | Android7-TV]] | ||
+ | |||
+ | |||
+ | For more up-to-date Android version, please refer to '''Working With Android''' section in [[Rockpi4]]. | ||
+ | |||
+ | Recommend build host is Ubuntu 16.04 64bit, for other hosts, refer official Android documents [https://source.android.com/setup/build/initializing Establishing a Build Environment]. | ||
+ | |||
+ | ==== Repo ==== | ||
<code bash> | <code bash> | ||
− | + | radxa$ wget 'https://storage.googleapis.com/git-repo-downloads/repo' -P /tmp/ | |
− | + | radxa$ sudo cp /tmp/repo /usr/local/bin/repo | |
− | $ chmod +x | + | radxa$ sudo chmod +x /usr/local/bin/repo |
</code> | </code> | ||
In China Download Repo: | In China Download Repo: | ||
<code bash> | <code bash> | ||
− | $ | + | 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 | ||
</code> | </code> | ||
− | 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. | + | ==== 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. | ||
<code bash> | <code bash> | ||
− | $ | + | radxa$ apt-get update -y && apt-get install -y openjdk-8-jdk python git-core gnupg flex bison gperf build-essential \ |
− | + | zip curl 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 | ||
</code> | </code> | ||
Configure the JAVA environment | Configure the JAVA environment | ||
<code bash> | <code bash> | ||
− | $ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 | + | radxa$ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 |
− | $ export PATH=$JAVA_HOME/bin:$PATH | + | radxa$ export PATH=$JAVA_HOME/bin:$PATH |
− | $ export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar | + | radxa$ export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar |
</code> | </code> | ||
− | == Download source code == | + | |
+ | ==== DockerFile ==== | ||
+ | <code> | ||
+ | FROM ubuntu:xenial | ||
+ | RUN apt-get update -y && apt-get install -y openjdk-8-jdk python git-core gnupg flex bison gperf build-essential \ | ||
+ | zip curl 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 | ||
+ | |||
+ | 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=android7-docker | ||
+ | |||
+ | ARG USER_ID=0 | ||
+ | ARG GROUP_ID=0 | ||
+ | RUN groupadd -g ${GROUP_ID} jenkins-docker && useradd -m -g jenkins-docker -u ${USER_ID} android7-docker | ||
+ | |||
+ | USER android7-docker | ||
+ | |||
+ | </code> | ||
+ | Build DockerFile | ||
+ | <code> | ||
+ | radxa$ docker build -t android-builder:7.x --build-arg USER_ID=`id -u` --build-arg GROUP_ID=`id -g` $(which-dir-dockerfile-in) | ||
+ | </code> | ||
+ | |||
+ | ==== Download source code ==== | ||
<code bash> | <code bash> | ||
− | $ mkdir rockpi4- | + | radxa$ mkdir rockpi4-android7-tv |
− | $ cd rockpi4- | + | radxa$ cd rockpi4-android7-tv |
</code> | </code> | ||
Then run: | Then run: | ||
<code bash> | <code bash> | ||
− | $ | + | radxa$ repo init -u https://github.com/radxa/rockpi4-android-tv-7.1.git -m rockchip_tv_nougat_release.xml |
− | $ repo sync - | + | radxa$ 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)! | ||
− | == Build u-boot == | + | ==== Build u-boot ==== |
<code bash> | <code bash> | ||
− | $ cd u-boot | + | radxa$ cd u-boot |
− | $ make rock-pi-4b-rk3399_defconfig | + | radxa$ make rock-pi-4b-rk3399_defconfig |
− | $ ./mk-uboot.sh | + | radxa$ ./mk-uboot.sh |
− | $ cd .. | + | radxa$ 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** | ||
− | == Building kernel == | + | ==== Building kernel ==== |
+ | For HDMI 4K | ||
<code bash> | <code bash> | ||
− | $ cd kernel | + | radxa$ cd kernel |
− | $ make rockchip_defconfig | + | radxa$ make rockchip_defconfig |
− | $ make rk3399-rockpi-4b.img -j$(nproc) | + | radxa$ make rk3399-rockpi-4b.img -j$(nproc) |
− | $ cd .. | + | radxa$ cd .. |
</code> | </code> | ||
+ | |||
The generated images are **kernel.img** and **resource.img**: | The generated images are **kernel.img** and **resource.img**: | ||
Line 58: | Line 111: | ||
# resource.img, contains dtb and boot logo, Rockchip format resource package | # resource.img, contains dtb and boot logo, Rockchip format resource package | ||
− | == Building AOSP == | + | ==== Building AOSP ==== |
<code bash> | <code bash> | ||
− | $ source build/envsetup.sh | + | radxa$ source build/envsetup.sh |
− | $ lunch rk3399_box-userdebug | + | radxa$ lunch rk3399_box-userdebug |
− | $ make -j$(nproc) | + | radxa$ 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... | ||
− | == Generate images == | + | ==== Generate images ==== |
<code bash> | <code bash> | ||
− | $ ln -s RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev | + | radxa$ ln -s RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev |
− | $ ./mkimage.sh | + | radxa$ ./mkimage.sh |
</code> | </code> | ||
Line 88: | Line 141: | ||
└── uboot.img | └── uboot.img | ||
</code> | </code> | ||
+ | |||
+ | ==== Generated RkUpdate Image ==== | ||
<code bash> | <code bash> | ||
− | $ cd rockdev | + | radxa$ cd rockdev |
− | $ ./ | + | radxa$ ln -s Image-rk3399_box Image |
+ | radxa$ ./mkupdate.sh | ||
</code> | </code> | ||
+ | The images under rockdev/ are `update.img` | ||
+ | |||
+ | ==== Generated GPT Image ==== | ||
<code bash> | <code bash> | ||
+ | radxa$ cd rockdev | ||
+ | radxa$ ln -s Image-rk3399_box Image | ||
+ | radxa$ ./android-gpt.sh | ||
+ | |||
IMAGE_LENGTH:3936291 | IMAGE_LENGTH:3936291 | ||
idbloader 64 16383 8.000000 MB | idbloader 64 16383 8.000000 MB | ||
Line 111: | Line 174: | ||
</code> | </code> | ||
The images under rockdev/Image are `gpt.img` | The images under rockdev/Image are `gpt.img` | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ==== Installation ==== | |
− | + | ||
− | + | [https://wiki.radxa.com/Rockpi4/install/android-microSD GPT Image Install on microSD]<br> | |
− | [ | + | [https://wiki.radxa.com/Rockpi4/install/android-eMMC GPT Image Install on eMMC module]<br> |
+ | [https://wiki.radxa.com/Rockpi4/install/android-eMMC-rkupdate RkUpdate Image Install on eMMC module]<br> | ||
− | There may be some performance loss when using | + | '''There may be some performance loss when using microSD.''' |
Latest revision as of 06:49, 30 June 2022
ROCK Pi 4 > Android7-TV
For more up-to-date Android version, please refer to Working With Android section in Rockpi4.
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 git-core gnupg flex bison gperf build-essential \ zip curl 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
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 git-core gnupg flex bison gperf build-essential \ zip curl 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
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=android7-docker
ARG USER_ID=0 ARG GROUP_ID=0 RUN groupadd -g ${GROUP_ID} jenkins-docker && useradd -m -g jenkins-docker -u ${USER_ID} android7-docker
USER android7-docker
Build DockerFile
radxa$ docker build -t android-builder:7.x --build-arg USER_ID=`id -u` --build-arg GROUP_ID=`id -g` $(which-dir-dockerfile-in)
Download source code
radxa$ mkdir rockpi4-android7-tv radxa$ cd rockpi4-android7-tv
Then run:
radxa$ repo init -u https://github.com/radxa/rockpi4-android-tv-7.1.git -m rockchip_tv_nougat_release.xml radxa$ 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$ cd u-boot radxa$ make rock-pi-4b-rk3399_defconfig radxa$ ./mk-uboot.sh radxa$ cd ..
The generated images are **rk3399_loader_v_xxx.bin** , **idbloader.img** and **uboot.img**
Building kernel
For HDMI 4K
radxa$ cd kernel radxa$ make rockchip_defconfig radxa$ make rk3399-rockpi-4b.img -j$(nproc) radxa$ 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
radxa$ source build/envsetup.sh radxa$ lunch rk3399_box-userdebug radxa$ make -j$(nproc)
It takes a long time, take a break and wait...
Generate images
radxa$ ln -s RKTools/linux/Linux_Pack_Firmware/rockdev/ rockdev radxa$ ./mkimage.sh
The generated images under rockdev/Image are
├── boot.img ├── idbloader.img ├── kernel.img ├── MiniLoaderAll.bin ├── misc.img ├── parameter.txt ├── pcba_small_misc.img ├── pcba_whole_misc.img ├── recovery.img ├── resource.img ├── system.img ├── trust.img └── uboot.img
Generated RkUpdate Image
radxa$ cd rockdev radxa$ ln -s Image-rk3399_box Image radxa$ ./mkupdate.sh
The images under rockdev/ are `update.img`
Generated GPT Image
radxa$ cd rockdev radxa$ ln -s Image-rk3399_box Image radxa$ ./android-gpt.sh
IMAGE_LENGTH:3936291 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 122879 24.000000 MB boot 122880 188415 32.000000 MB recovery 188416 253951 32.000000 MB backup 253952 483327 112.000000 MB cache 483328 745471 128.000000 MB system 745472 3891199 1536.000000 MB metadata 3891200 3923967 16.000000 MB baseparamer 3923968 3932159 4.000000 MB userdata 3932160 3932159 0.000000 MB
The images under rockdev/Image are `gpt.img`
Installation
GPT Image Install on microSD
GPT Image Install on eMMC module
RkUpdate Image Install on eMMC module
There may be some performance loss when using microSD.