Skip to content

How to build RZ AOSP from Source Code

Notice

The command in this section will be executed on the Ubuntu Host PC.

Tools & Dependency packages

Prerequisite packages for building the Android Filesystem (Note: This is with reference to Ubuntu 20.04 64-bit). Ubuntu 64-bit is required for the cross-compilation of Android Filesystem.

Setup build environment according to Google Android setup guide (follow Installing required packages): https://source.android.com/source/initializing.html#setting-up-a-linux-build-environment

$ sudo apt-get install git-core gnupg flex bison build-essential zip curl zlib1g-dev
$ sudo apt-get install libc6-dev-i386 x11proto-core-dev libx11-dev lib32z1-dev
$ sudo apt-get install libgl1-mesa-dev libxml2-utils xsltproc unzip fontconfig
In addition, it's required to install "python-is-python3", "python-crypto", "liblz4-tool", "libssl-dev" and "lzop" package. "python-is-python3" is used for "repo", "python-crypto" is used into the python scripts. "liblz4-tool" package is used into the compress tool which builds a kernel, "libssl-dev" is used for compiling kernel 4.19 and newer, "lzop" is used as a compressor similar to gzip. Below version packages were used to confirm this BSP version.
PackageVersion
python-is-python3-
python-crypto2.6.1-13ubuntu2
liblz4-tool1.9.2-2ubuntu0.20.04.1
libssl-dev1.1.1f-1ubuntu2.24
lzop1.04-1
$ sudo apt-get install python-is-python3 python-crypto liblz4-tool libssl-dev lzop

To build Mesa Graphics, the following tools and development dependencies must be installed on the build host. For more details, please visit: https://docs.mesa3d.org/install.html#compiling-and-installing

$ sudo apt-get install python3-pip
$ sudo pip3 install --upgrade meson ninja mako PyYAML

Note: meson package version should be “1.1.0” or higher for building Mesa 24.3.3

Please install the following packages when users need to set up build environment by using Ubuntu 20 Docker container. This is just for reference only and note that Renesas official test is on natively-installed Ubuntu 20

$ sudo apt-get install rsync libncurses5

Note: Recommended python3 version: 3.8.10 for Ubuntu 20.04

Please install the following package when users need to set up build environment by using Ubuntu 22.04 Docker container. This is just for reference only and note that Renesas official test is on natively-installed Ubuntu 22.04

$ sudo apt-get install pkg-config

Prepare build environment

Download "repo" command and update the environment variables "PATH".

$ bash
$ cd <your work directory>
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo
$ chmod a+x repo
$ export PATH=$(pwd):${PATH}

Get RZ AOSP source code

Clone android local package

$ cd <your working directory>
$ export ANDROID_BUILD_DIR=`pwd`
$ cd ${ANDROID_BUILD_DIR}
$ git clone https://github.com/renesas-rz/aosp_local_package.git -b android15-26q2

Checking the content of the source by listing items:

$ tree -L 1 ${ANDROID_BUILD_DIR}/aosp_local_package

The result should be:

aosp_local_package/
├── additional_patches
├── buildenv.sh
├── modified-aosp-projects.xml
├── RELFILES
├── renesas-projects.xml
└── walkthrough.sh

Jumping to aosp_local_package directory

$ cd ${ANDROID_BUILD_DIR}/aosp_local_package
$ export workspace=$(pwd)
$ chmod a+x -R *

Note: Please make sure that all scripts have “execute” permission

$ export TARGET_SOC=r9a09g057
$ ./walkthrough.sh RZV2H_EVK_VER1

Please confirm this message

Done : TARGET= RZV2H_EVK_VER1

Prepare additional components

Notice

Please download RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software.zip package that includes addtitional components.

RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software.zip

Mali Graphics module (Mandatory to boot up)

By default, Mali Graphics modules is not included in source tree. Because no license agreement is confirmed.

See How to extract additional components to add Mali Graphics modules to your RZ AOSP build environment before building Android images

Note:

  • This repo is required to boot with Mali Graphics successfully. If users skip it, users must check how to switch to use mesa Graphics.
  • Officially, All features have been tested with Mali Graphics.
  • Please run vendor/arm/gralloc/configure before building Android images

Hardware Codec module

By default, Hardware Codecs related repos are not included in source tree. Because no license agreement is confirmed.

  • Software codecs are used as default.
  • No additional repositories are required.

See How to extract additional components to add Hardware Codec modules to your RZ AOSP build environment before building Android images

Note: Please export ENABLE_HW_CODECS=true before building Android images

USB Wi-Fi module

By default, USB Wi-Fi kernel module is not included in source tree.

See How to extract additional components to add USB Wi-Fi modules to your RZ AOSP build environment before building Android images

Note: Please export USE_USB_WIFI=true before building Android images

How to extract additional components

Ensure that you have get RZ AOSP source code successfully. See Get RZ AOSP source code

Jump to your android build directory

$ cd ${ANDROID_BUILD_DIR}

Extract the RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software.zip package

$ unzip <path to proprietary software package>/RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software.zip -d .

Confirm the content of RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software

$ tree -L 1 ${ANDROID_BUILD_DIR}/RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software

The content should be:

RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software
├── apply_package.sh
├── mydroid
├── patch_OV5645
└── README.txt

Copy the RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software package to your workspace

$ cp -rf ${ANDROID_BUILD_DIR}/RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software ${workspace}/

Jumping to RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software directory

$ cd ${workspace}/RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software

Run below script to apply additional components to your RZ AOSP environment

$ ./apply_package.sh

MIPI Camera module

By default, the MIPI Camera is not enabled in the kernel. Because the CMOS sensor (OV5645) in the MIPI camera is no longer available and should not be used for mass production. Any software support provided is for evaluation purposes only.

Ensure that you have downloaded RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software.zip package from renesas.com

Jumping to kernel

$ cd ${workspace}/mydroid/device/renesas/kernel

Apply the MIPI Camera support patches to kernel

$ git am ${workspace}/RTK0EF0188Z76001ZJ_v15.3.0_proprietary-software/patch_OV5645/android15_6.1-cip28-base-update1/*.patch

Note: Please build new Android image after applying MIPI Camera support patches

Building Android, IPL, U-Boot, and Kernel sources

CAUTION: It's required to download and extract additional components to build RZ AOSP. Please refer Prepare additional components

Jumping to mydroid directory

$ cd ${workspace}/mydroid

Please set Android build environment

$ export NUM_JOBS=$(($(nproc)*2))
$ source build/envsetup.sh

Please see more lunch build options at Android build options

$ lunch rzv2h_evk_ver1-ap4a-userdebug

Please set this variable to true for building Android bootloader

$ export BUILD_BOOTLOADERS=true

(Mandatory to boot up) Configure Mali graphics (See Mali Graphics module)

$ vendor/arm/gralloc/configure

(Mandatory if users want to use hardware codecs) Enable hardware codecs (See Hardware Codec module)

$ export ENABLE_HW_CODECS=true

(Optional) Support Encryption (See Enable File-Based Encryption)

$ export ENABLE_FBE=true

(Optional) Enable optional features (See Enable optional features)

  • Support USB Bluetooth
    $ export ENABLE_BT_SUPPORT=true
    
  • Support USB Wi-Fi (See USB Wi-Fi module)
    $ export USE_USB_WIFI=true
    

(Optional) Enable fastbootd for fastboot UDP (See Fastboot UDP)

$ export USE_FASTBOOTD_FOR_UDP=true

(Optional) Enable MIPI Camera module support (See MIPI Camera module)

Start building RZ AOSP

$ make -j${NUM_JOBS}
CAUTION: If the host PC is not powerful enough, please replace ${NUM_JOBS} by smaller build threads. For example: make -j4

Build finished. Please confirm this message

#### Build completed successfully (02:14:01 (hh:mm:ss)) ####

Please set board name build. See more android build options at Android build options. Default build option is ”Base”

$ export board_name=rzv2h_evk_ver1

# Please copy output files to <your_images_dir>
$ export images_dir=<your_images_dir>
$ cp out/target/product/${board_name}/init_boot.img                   ${images_dir}
$ cp out/target/product/${board_name}/boot.img                        ${images_dir}
$ cp out/target/product/${board_name}/vendor_boot.img                 ${images_dir}
$ cp out/target/product/${board_name}/dtb.img                         ${images_dir}
$ cp out/target/product/${board_name}/dtbo.img                        ${images_dir}
$ cp out/target/product/${board_name}/vbmeta.img                      ${images_dir}
$ cp out/target/product/${board_name}/super.img	                      ${images_dir}
$ cp out/target/product/${board_name}/codec_bin.img                   ${images_dir}
$ cp out/target/product/${board_name}/bl2_bp_rzv2h_evk_ver1_esd.srec  ${images_dir}
$ cp out/target/product/${board_name}/bl2_bp_rzv2h_evk_ver1_spi.srec  ${images_dir}
$ cp out/target/product/${board_name}/fip_rzv2h_evk_ver1_sdhi.srec    ${images_dir}
$ cp out/target/product/${board_name}/fip_rzv2h_evk_ver1_spi.srec     ${images_dir}
$ cp out/target/product/${board_name}/bl2_bp_rzv2h_evk_ver1_esd.bin   ${images_dir}
$ cp out/target/product/${board_name}/bl2_bp_rzv2h_evk_ver1_spi.bin   ${images_dir}
$ cp out/target/product/${board_name}/fip_rzv2h_evk_ver1_sdhi.bin     ${images_dir}
$ cp out/target/product/${board_name}/fip_rzv2h_evk_ver1_spi.bin      ${images_dir}
$ cp vendor/renesas/utils/fastboot/fastboot.sh                        ${images_dir}
$ cp vendor/renesas/utils/fastboot/fastboot_functions.sh              ${images_dir}
$ cp out/host/linux-x86/bin/adb                                       ${images_dir}
$ cp out/host/linux-x86/bin/mke2fs                                    ${images_dir}
$ cp out/host/linux-x86/bin/fastboot                                  ${images_dir}
$ chmod a+x -R ${images_dir}
	 Please read Note.

All *.srec, *.bin files are used for section Flashing bootloader. All *.img files, fastboot.sh, and fastboot are used for section Flashing images using fastboot.

Note: Please use “fastboot” (out/host/linux-x86/bin/) command that you built in this procedure. If you use old “fastboot” command which is included in old Android SDK, you might fail to flash an image.