Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions source/android/Foundational_Components_Bootloaders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@ The toolchains are automatically downloaded by the build scripts.

**Install OPTEE-OS build dependencies**

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')

Check OPTEE-OS docs to know list of dependencies needed to be installed :
https://optee.readthedocs.io/en/latest/building/prerequisites.html
Check OPTEE-OS docs to know list of dependencies needed to be installed :
https://optee.readthedocs.io/en/latest/building/prerequisites.html


**Install additional dependencies**

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')

.. code-block:: console
.. code-block:: console

$ sudo apt install bc bison build-essential curl u-boot-tools flex git libssl-dev python3 python3-pip wget -y
$ pip3 install pycryptodome pyelftools shyaml --user
$ sudo apt install bc bison build-essential curl u-boot-tools flex git libssl-dev python3 python3-pip wget -y
$ pip3 install pycryptodome pyelftools shyaml --user


.. _android-download-bootloaders:
Expand All @@ -30,18 +26,16 @@ The toolchains are automatically downloaded by the build scripts.
Downloading sources
*******************

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
Fetch the code using ``repo``:

Fetch the code using ``repo``:

.. code-block:: console
.. code-block:: console

$ mkdir ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Bootloader.xml
$ repo sync
$ mkdir ${YOUR_PATH}/ti-bootloader-aosp/ && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Bootloader.xml
$ repo sync

For more information about ``repo``, visit `Android's official
documentation <https://source.android.com/setup/build/downloading>`__
For more information about ``repo``, visit `Android's official
documentation <https://source.android.com/setup/build/downloading>`__

.. _android-build-bootloaders:

Expand Down
122 changes: 59 additions & 63 deletions source/android/Foundational_Components_Kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,125 +2,121 @@
Android Kernel
##############

Android is built around a Linux kernel. By default, Android's
``boot.img`` is build from a binary kernel Image located in:

.. code-block:: text

${YOUR_PATH}/ti-aosp-15/device/ti/am62x-kernel/kernel/6.6

This guide describes how to rebuild and customize a Linux kernel for
Android.

.. _android-download-kernel:

*******************
Downloading sources
*******************

.. ifconfig:: CONFIG_part_variant in ('AM62X' 'AM62PX')

Fetch the code using ``repo``:
Fetch the code using ``repo``:

.. code-block:: console
.. code-block:: console

$ mkdir ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml
$ repo sync
$ mkdir ${YOUR_PATH}/ti-kernel-aosp/ && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml
$ repo sync

.. tip::
.. tip::

To save some disk space, pass the ``--depth=1`` option to ``repo init``:
To save some disk space, pass the ``--depth=1`` option to ``repo init``:

.. code-block:: console
.. code-block:: console

$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml --depth=1
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01_Kernel-6.6.xml --depth=1

.. _android-build-kernel:

******************
Build Instructions
******************

In this section, we will assume that we already have an Android source
tree which has been fully build and is located in:

.. code-block:: text

${YOUR_PATH}/ti-aosp-15/

Building everything from scratch
================================

.. ifconfig:: CONFIG_part_variant in ('AM62X')

The kernel is compatible with all AM62x boards, such as the SK EVM and the Beagle Play.

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')

.. code-block:: console
.. code-block:: console

$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export TARGET_KERNEL_USE="6.6"
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-15/device/ti/am62x-kernel/kernel/${TARGET_KERNEL_USE}
$ tools/bazel run //common:ti_dist -- --dist_dir=$DIST_DIR
$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export TARGET_KERNEL_USE="6.6"
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-15/device/ti/am62x-kernel/kernel/${TARGET_KERNEL_USE}
$ tools/bazel run //common:ti_dist -- --dist_dir=$DIST_DIR

Android uses Kleaf, a Bazel-based build system to build the kernel.
AOSP documentation can be found `here <https://source.android.com/docs/setup/build/building-kernels?hl=fr>`__ and
Kleaf documentation `here <https://android.googlesource.com/kernel/build/+/refs/heads/main/kleaf/README.md>`__
Re-running this command will rebuild incrementally.

.. attention::
Android uses Kleaf, a Bazel-based build system to build the kernel.
AOSP documentation can be found `here <https://source.android.com/docs/setup/build/building-kernels?hl=fr>`__ and
Kleaf documentation `here <https://android.googlesource.com/kernel/build/+/refs/heads/main/kleaf/README.md>`__

Kernel builds hangs when using the ``btrfs`` file system.
This is a known issue according to the `kleaf documentation <https://android.googlesource.com/kernel/build/+/refs/heads/main/kleaf/docs/errors.md#build-hangs-on-btrfs>`_
Make sure to pass the ``--workaround_btrfs_b292212788`` flag to bazel when using ``btrfs``.
.. attention::


Rebuilding faster
=================

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')

.. code-block:: console

$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ export TARGET_KERNEL_USE="6.6"
$ export DIST_DIR=${YOUR_PATH}/ti-aosp-15/device/ti/am62x-kernel/kernel/${TARGET_KERNEL_USE}
$ tools/bazel run --config=fast //common:ti_dist -- --dist_dir=$DIST_DIR
Kernel builds hangs when using the ``btrfs`` file system.
This is a known issue according to the `kleaf documentation <https://android.googlesource.com/kernel/build/+/refs/heads/main/kleaf/docs/errors.md#build-hangs-on-btrfs>`_
Make sure to pass the ``--workaround_btrfs_b292212788`` flag to bazel when using ``btrfs``.


Defconfig/menuconfig changes
============================

The usual (``make menuconfig``) is done via ``bazel`` command :

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
.. code-block:: console

.. code-block:: console

$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ tools/bazel run //common:ti_config -- menuconfig
$ cd ${YOUR_PATH}/ti-kernel-aosp/
$ tools/bazel run //common:ti_config -- menuconfig

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
This will automatically update the :file:`arch/arm64/configs/ti_gki.fragment`.

.. note::
.. note::

Users must have built the android kernel image prior to building the Android file system.
Otherwise pre-built kernel images present in :file:`device/ti/am62x-kernel`
will be used to create :file:`boot.img`
Users must have built the android kernel image prior to building the Android file system.
Otherwise pre-built kernel images present in :file:`device/ti/am62x-kernel`
will be used to create :file:`boot.img`


Rebuild Android images
======================

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')

We should re-generate the Android images to include the newly build kernel.
Follow the Android :ref:`android-build-aosp` to do so.
We should re-generate the Android images to include the newly build kernel.
Follow the Android :ref:`android-build-aosp` to do so.

*********************
Flashing instructions
*********************

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
In order to flash a new kernel, several images should be flashed:

In order to flash a new kernel, several images should be flashed:

.. code-block:: console
.. code-block:: console

$ adb reboot fastboot
< Wait for fastbootd reboot >
$ adb reboot fastboot
< Wait for fastbootd reboot >

$ cd <PATH/TO/IMAGES>
$ fastboot flash boot boot.img
$ fastboot flash vendor_boot vendor_boot.img
$ fastboot flash vendor_dlkm vendor_dlkm.img
$ fastboot reboot
$ cd <PATH/TO/IMAGES>
$ fastboot flash boot boot.img
$ fastboot flash vendor_boot vendor_boot.img
$ fastboot flash vendor_dlkm vendor_dlkm.img
$ fastboot reboot

The board should boot with the new kernel.
The board should boot with the new kernel.

********************
Enabling new drivers
Expand Down
60 changes: 26 additions & 34 deletions source/android/Overview_Building_the_SDK.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,20 @@ To install it, please refer to this webpage : https://source.android.com/setup/d
Downloading sources
*******************

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
Create a folder for downloading all sources

Create a folder for downloading all sources

.. code-block:: console

$ mkdir ~/10_01_00 && cd $_
$ export YOUR_PATH=$PWD
.. code-block:: console

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
$ mkdir ~/10_01_00 && cd $_
$ export YOUR_PATH=$PWD

Fetch the code using ``repo``:
Fetch the code using ``repo``:

.. code-block:: console
.. code-block:: console

$ mkdir ${YOUR_PATH}/ti-aosp-15 && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01.xml
$ repo sync
$ mkdir ${YOUR_PATH}/ti-aosp-15 && cd $_
$ repo init -u https://git.ti.com/git/android/manifest.git -b android15-release -m releases/RLS_10_01.xml
$ repo sync

.. tip::

Expand All @@ -65,16 +61,14 @@ Downloading sources
Build Instructions
******************

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')

.. code-block:: console
.. code-block:: console

$ cd ${YOUR_PATH}/ti-aosp-15
$ source build/envsetup.sh
$ lunch <BUILD_TARGET>
$ m
[...]
#### build completed successfully (49:14 (mm:ss)) ####
$ cd ${YOUR_PATH}/ti-aosp-15
$ source build/envsetup.sh
$ lunch <BUILD_TARGET>
$ m
[...]
#### build completed successfully (49:14 (mm:ss)) ####

Where ``<BUILD_TARGET>`` is listed in the table below :

Expand Down Expand Up @@ -129,22 +123,20 @@ The following build flags are available. **Default** values are **highlighted**.
- **false**/true
- Boot from SD card instead of eMMC

.. ifconfig:: CONFIG_part_variant in ('AM62X', 'AM62PX')
After building is complete, the necessary images will be available in
:file:`${YOUR_PATH}/ti-aosp-15/out/target/product/am62*/`.

After building is complete, the necessary images will be available in
:file:`${YOUR_PATH}/ti-aosp-15/out/target/product/am62*/`.
To proceed to flash Android, see :ref:`android-flashing`.

To proceed to flash Android, see :ref:`android-flashing`.

.. tip::
.. tip::

As stated previously, Android build contains **pre-built binaries**
for both the kernel and the bootloaders.
These are ready to be used as-is with the EVM boards.
For customization, it's possible to rebuild them.
As stated previously, Android build contains **pre-built binaries**
for both the kernel and the bootloaders.
These are ready to be used as-is with the EVM boards.
For customization, it's possible to rebuild them.

- See :ref:`android-build-kernel` for the kernel
- See :ref:`android-build-bootloaders` for the bootloaders
- See :ref:`android-build-kernel` for the kernel
- See :ref:`android-build-bootloaders` for the bootloaders

.. ifconfig:: CONFIG_part_variant in ('AM62X')

Expand Down