How to build kernel for Android

Revision as of 09:30, 2 August 2019 by Registered User (Created page with "== Article purpose == This article is intended to a Distribution Package user (see Which STM32MPU Embedded Software Package for Android better suits your needs|Which Packag...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

1. Article purpose[edit source]

This article is intended to a Distribution Package user (see Which Package better suits your needs for more information).

The Android Linux Common kernel is used in the STM32MPU distribution for Android™.

The STM32MPU distribution for Android™ includes prebuilt kernel binaries used to generate the partition images (BOOT, DT and VENDOR).

The binaries are available in device/stm/stm32mp1-kernel/prebuilt directory.

This page explains how to rebuild the kernel binaries.

2. Prerequisites[edit source]

The environment must be installed using the Distribution Package adapted to your selected microprocessor device, STM32MP1 Distribution Package for Android.

To be able to execute following instruction you need to work from your ST AOSP root directory STM32MP1 Distribution Package for Android, initialise your environment and then launch:

source build/envsetup.sh

lunch aosp-eval-userdebug

3. Partition impact[edit source]

The Linux kernel binary files is part of the BOOT partition.

The Linux kernel drivers built as modules (.ko files) are part of the VENDOR partition.

The device tree binary file is part of the DT partition.

4. Load the kernel source[edit source]

By default, the kernel sources are not part of the STM32MPU distribution for Android. To load the sources, execute the following command:

load_kernel

It will load the Android™ Linux common kernel sources. They can be access from device/stm/stm32mp1-kernel/linux-stm32mp1

Info white.png Information

The load_kernel script is using configuration file available in the device/stm/stm32mp1-kernel/source/patch/<kernel version>/ directory.

5. Build the kernel[edit source]

After retriving the kernel sources you can build it using:

build_kernel

The output can be found in: out-bsp/stm32mp1/KERNEL_OBJ

Usage: build_kernel [Options] [Command]

  This script allows building the Linux kernel source

Options:
  -h/--help: print this message
  -i/--install: update prebuilt images
  -v/--version: get script version
  --verbose: enable verbosity
Command: only one command at a time supported
  dtb: build only device-tree binaries
  gpu: build only gpu module (kernel is build if not already performed)
  defaultconfig: build only .config based on default defconfig files and fragments
  menuconfig: display standard Linux kernel menuconfig interface
  modules: build only kernel modules binaries (kernel is build if not already performed)
  mrproper: execute make mrproper on targeted kernel
  vmlinux: build only kernel vmlinux binary

6. Generate AOSP without kernel prebuilt[edit source]

In order to compile and generate the AOSP with your custom kernel build you need to change the device/stm/stm32mp1/BoardConfigCommon.mk file and comment those lines:

TARGET_PREBUILT_KERNEL
TARGET_PREBUILT_MODULE_PATH
TARGET_PREBUILT_DTB_PATH

Then you need to rebuild the AOSP:

make -j

7. Creates kernel prebuilt[edit source]

When you have compile your new kernel and your change are valid, you can generate prebuilt images to simplify it's integration by doing:

build_kernel -i