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 22.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", "python3-cryptography", "liblz4-tool", "libssl-dev" and "lzop" package. "python-is-python3" is used for "repo". "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-python33.9.2-2
python3-cryptography3.4.8-1ubuntu2.4
liblz4-tool1.9.3-2build2
libssl-dev3.0.2-0ubuntu1.26
lzop1.04-2build2

sudo apt-get install python-is-python3 python3-cryptography liblz4-tool libssl-dev lzop

To build IPL, U-boot by script, the following tools must be installed on the build host.

sudo apt-get install srecord

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

Please install the following packages 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 rsync libncurses5 pkg-config

Note

Recommended python3 version: 3.10.12 for Ubuntu 22.04

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 android17-26q3

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/
├── 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

Optional

To achieve fetch reliability and build stability, user can refer AOSP mirror from Q5. Using AOSP mirror for offline fetch

export TARGET_SOC=r9a08g046
./walkthrough.sh SMARC_RZG3L

Please confirm this message

Done : TARGET= SMARC_RZG3L

Prepare additional components

Notice

Please download RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software.zip package that includes addtitional components.

RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software.zip

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

Extract Wi-Fi firmware

By default, Wi-Fi firmware is not included in source tree.

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

Note

  • Please export ENABLE_WIFI_SUPPORT=true before building Android images
  • For enabling Wi-Fi support, please see Wi-Fi usage

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 RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software.zip package

unzip <path to proprietary software package>/RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software.zip -d .

Confirm the content of RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software

tree -L 1 ${ANDROID_BUILD_DIR}/RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software

The content should be:

RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software
├── apply_package.sh
├── mydroid
└── README.txt

Copy the RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software package to your workspace

cp -rf ${ANDROID_BUILD_DIR}/RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software ${workspace}/

Jumping to RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software directory

cd ${workspace}/RTK0EF0188Z78001ZJ_v17.0.0_proprietary-software

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

./apply_package.sh

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

How to build IPL, U-boot by script

Jumping to mydroid directory

cd ${workspace}/mydroid

Please use below command for building Android bootloader

./vendor/renesas/utils/bootloaders/build_bootloader.sh SMARC_RZG3L

Build finished. Please confirm this message

====================================================
Artifacts for device SMARC_RZG3L
   ... Bootloader Binary List

Please confirm the output

tree -L 1 vendor/renesas/utils/bootloaders/smarc_rzg3l_out/

vendor/renesas/utils/bootloaders/smarc_rzg3l_out/
├── bl2_bp_emmc.bin
├── bl2_bp_emmc.srec
├── bl2_bp_esd.bin
├── bl2_bp_esd.srec
├── bl2_bp_smarc_rzg3l_emmc.bin
├── bl2_bp_smarc_rzg3l_emmc.srec
├── bl2_bp_smarc_rzg3l_esd.bin
├── bl2_bp_smarc_rzg3l_esd.srec
├── bl2_bp_smarc_rzg3l_spi.bin
├── bl2_bp_smarc_rzg3l_spi.srec
├── bl2_bp_spi.bin
├── bl2_bp_spi.srec
├── bp_emmc.bin
├── bp_esd.bin
├── bp_spi.bin
├── fip.bin
├── fip_smarc_rzg3l.bin
├── fip_smarc_rzg3l.srec
├── fip.srec
├── host_tools.log
├── ipl.log
├── obj
├── u-boot.bin
└── u-boot.log

Building Android and Kernel sources

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 smarc_rzg3l-cp2a-userdebug

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

export ENABLE_HW_CODECS=true

(Optional) Enable Wi-Fi support (See Extract Wi-Fi firmware)

export ENABLE_WIFI_SUPPORT=true

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=smarc_rzg3l

# 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 vendor/renesas/utils/bootloaders/${board_name}_out/bl2_bp_smarc_rzg3l_emmc.srec  ${images_dir}
cp vendor/renesas/utils/bootloaders/${board_name}_out/bl2_bp_smarc_rzg3l_emmc.bin   ${images_dir}
cp vendor/renesas/utils/bootloaders/${board_name}_out/bl2_bp_smarc_rzg3l_esd.srec   ${images_dir}
cp vendor/renesas/utils/bootloaders/${board_name}_out/bl2_bp_smarc_rzg3l_esd.bin    ${images_dir}
cp vendor/renesas/utils/bootloaders/${board_name}_out/fip_smarc_rzg3l.srec          ${images_dir}
cp vendor/renesas/utils/bootloaders/${board_name}_out/fip_smarc_rzg3l.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.