How to customize the STM32MPU distribution for Android

This articles explain how you can customize the STM32MPU distribution for Android™. It's intent to be used by distribution package users.

1 Prerequisites[edit]

The environment used must have been installed using the Distribution Package adapted to your microprocessor device. See Distribution_Package.

To execute the following instructions, go to your distribution root directory and initialize your environment:

 source build/
 lunch aosp_<BoardId>-userdebug

2 Layout configuration[edit]

The memory layout can be configure through the android_layout.config file located in device/stm/<STM32Series>/layout. It contains all the necessary data.

When changes are complete, reload the environment:

 source build/
 lunch aosp_<BoardId>-userdebug

2.1 Memory type[edit]

To adapt your build to the required memory, change the PART_MEMORY_TYPE parameter in the android_layout.config file. PART_MEMORY_TYPE values can be:

  • sd
  • emmc

2.2 Memory size[edit]

To adapt your build to your memory size, change the PART_MEMORY_SIZE parameter in the android_layout.config file. PART_MEMORY_SIZE values can be:

  • 4GiB (4 Gbytes)
  • 8GiB (8 Gbytes)

Its value must match the parameter of name PART_<Memory size>_MEMORY_MAX_SIZE, located at the end of the file.

It might need to be changed. For example:


The 7536M must be adapted if your memory size is lower that the value defined.

To find the correct value, execute the command below:

 sgdisk -p /dev/mmcblk<x>

It displays the following information:

Disk /dev/mmcblk0: 15433728 sectors, 7.4 GiB
Logical sector size: 512 bytes
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 15433694
Partitions will be aligned on 2-sector boundaries
Total free space is 0 sectors (0 bytes)

The first line show the microSD card available size: here 15433728 sectors.

To calculate the size in MiB (Mbytes):

size = (NbSectors * SectorSize) / 1024 / 1024
In this example: (15433728 * 512) / 1024 / 1024 = 7536 MiB

Report this value in PART_8GiB_MEMORY_MAX_SIZE:


For more details, refer to the README file located in the same folder.

2.3 Partition size[edit]

To change the size of a partition, modify it in the android_layout.config file.

Adapt the following parameters:

NAME: name of the local variable (last partition MUST start with PART_LAST_)
PART_SIZE: as xxxMB or xxxKB or xxxGB
PART_NB: number of instances of partition (x1 or x2)
PART_LABEL: name of the partition label
PART_SUFFIX (optional): name of the suffix in case PART_NB equal x2 (_a/_b by default)
PART_ENABLE (optional): device for which the partition is only applicable (sd)

Then adapt every FlashLayout_*.tsv under device/stm/<STM32Series>/layout/programmer to match your changes.

To do this, use the device/stm/<STM32Series>/script/layout/ script.

3 Audio configuration[edit]

The audio.stm.xmlconfiguration file is stored in device/stm/<STM32Series>/<BoardId>/media/audio.

Refer to How to change audio device for Android for more details.

4 Light configuration[edit]

The lights.stm.xml configuration file is stored in device/stm/<STM32Series>/<BoardId>/lights.

This file allows associating the list of LEDs with the Android light IDs:

  • notifications
  • attention
  • backlight
  • keyboard
  • buttons
  • battery
  • bluetooth
  • wifi

First identify the list of available LEDS (it is recommended to stub the list of lights by adding device="stub").

Open a terminal on the device:

 adb shell

Get the list of available labels:

 ls /sys/class/leds/

In the device-tree associated to your device, you can check the list of <label> names in the <led> structure.

Then associate the following Android light IDs with the correct label.

5 Thermal configuration[edit]

The thermal.stm.xml configuration file is stored in device/stm/<STM32Series>/<BoardId>/thermal.

Thermal information can be returned for the following temperature types:

  • CPUx (one index for each CPU)
  • GPU
  • Battery
  • Skin (external part of the device)

First identify the list of available thermal zones (it is recommended to stub the list of thermal data by adding stub="1" and adding fixed values for threshold,shutdown and threshold_vr_min).

Open a terminal on the device:

 adb shell

Check the list of available zones:

 ls /sys/class/thermal/

Check each thermal zone type. Below the example corresponding to the case of two thermal zones with indexes 0 and 1:

 cat /sys/class/thermal/thermal_zone0/type
 cat /sys/class/thermal/thermal_zone1/type

For each zone, check the list of available trip points (not systematically present). Below the example corresponding to the case of two trip points with indexes 0 and 1 for thermal zone 0:

 cat /sys/class/thermal/thermal_zone0/trip_point_0_type
 cat /sys/class/thermal/thermal_zone0/trip_point_1_type

Update the configuration file according to the information returned:

  • If no information is available, you can stub the list of thermal data by adding fixed values stub="1"
  • If a thermal zone is associated to one or several temperature types: stub="0"
    • No trip point data: fix the values in the file.
    • Trip point data: put all data at 0 and add each trip index and type values in the file.

6 Bluetooth configuration[edit]

The configuration is stored in bdroid_buildcfg.h located in device/stm/<STM32Series>/<BoardId>/network/bt.

Bluetooth is enabled in device/stm/<STM32Series>/<BoardId>/


Add the path of the configuration file overlay bdroid_buildcfg.h:

BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR ?= device/stm/<STM32Series>/<BoardId>/network/bt

The Android Bluetooth stack (located in system/bt) can be configured through the device/stm/<STM32Series>/<BoardId>/network/bt/bdroid_buildcfg.h file.

It must at least contain the definition of the Class of Device (CoD) (refer to the Bluetooth Specification[1] for additional information):

#define BTA_DM_COD {0x5A, 0x01, 0x1C}

Additionally, it can contain the Bluetooth Stack profile configuration. If a variable is not set in this file, the default configuration is used in the stack.

By default, all the profiles are selected (see system/bt/include/bt_target.h). Example for the PAN profile:


To disable it, add the following line in bdroid_buildcfg.h:


Refer to Android Bluetooth[2] for more details

7 Wi-Fi configuration[edit]

The configuration is stored in device/stm/<STM32Series>/<BoardId>/network/wifi.

You can change the following parameters:

  • p2p
  • wpa supplicant
  • dhcp

Refer to How to change Wi-Fi device for Android for more details.

8 Modification of the Android distribution[edit]

The list of changes performed during the <STM32Series>setup (ex: stm32mp1setup for STM32MP1 series) can be adapted by modifying the android_patch.config available in device/stm/<STM32Series>/patch/android/ file.

First retrieve the original configuration:

 <STM32Series>clear -p

Then adapt the file (add or/and remove list of commits and patches).

Some rules must be respected for adding patches:

  • Patch files shall be added with the relative path to device/stm/<STM32Series>/patch/android/ directory.
  • Patch files shall be added without the .patch suffix.
  • Patches shall be added in the correct order.

Some rules must the respected for removing patches:

  • Test the new configuration on the targeted directory by applying the patches manually (generate them again if required).
  • Do not remove patches and commits with do not modify mention.

When this is done, apply the new configuration:


Then rebuild the distribution to take into account your changes:

 make -j

9 References[edit]