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

The environment used must have been installed using the right Distribution Package for your selected microprocessor device. See Distribution_Package.

To be able to execute following instructions you need to work from your distribution root directory and initialise your environment:

PC $> source build/envsetup.sh
PC $> lunch aosp-<BoardId>-userdebug

2 Layout configuration

It is possible to configuration the memory layout. The file android_layout.config located device/stm/<STM32Series>/layout contains all the necessary data.

When changes is done you need to reload the environment with:

PC $> source build/envsetup.sh
PC $> lunch aosp-<BoardId>-userdebug

2.1 Memory type

To adapt your build to the memory you desire, you must change in the file android_layout.config the parameter PART_MEMORY_TYPE.

For example the possible values can be:

  • sd
  • emmc

2.2 Memory size

To adapt your build to the size of your memory you can change in the file android_layout.config the parameter PART_MEMORY_SIZE.

For example the possible values can be:

  • 4GiB
  • 8GiB

This value must match the parameter at the end of the file that looks like PART_<Memory size>_MEMORY_MAX_SIZE

It may be necessary to change the value attach to this parameter. For example:

PART_8GiB_MEMORY_MAX_SIZE 7432M x1 sd

The 7536M must be adapt if your memory is less than its definition.

To find the correct value execute:

PC $> sgdisk -p /dev/mmcblk<x>

It will output something looking like:

Disk /dev/mmcblk0: 15433728 sectors, 7.4 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
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)

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

To calculate the size in MiB:

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

Report this value for the parameter PART_8GiB_MEMORY_MAX_SIZE

PART_8GiB_MEMORY_MAX_SIZE 7536M x1 sd

You can refer to the README file in the same folder for more details.

2.3 Partition size

If you decide to change the size of some partition you need to change in the file android_layout.config.

You need to adapt all parameter that looks like

PART_<NAME> <PART_SIZE> <PART_NB> <PART_LABEL> <PART_SUFFIX> <PART_ENABLE>
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)

When this is done you also need to adapt every FlashLayout_*.tsv under device/stm/<STM32Series>/layout/programmer to match your changes.

For that purpose, you can use the script device/stm/<STM32Series>/script/layout/build_tsv.py.

3 Audio configuration

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

For more details please refer to How to change audio device for Android

4 Lights configuration

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

The target of this file is to associated the list of leds with the Android light IDs:

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

First you have to identify the list of available leds (it's recommended to stubbed the list of lights adding device="stub").

Open a terminal on the device:

PC $> adb shell

Get the list of available labels:

Board $> 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 you can associate the following Android light IDs with the correct label.

5 Thermal configuration

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

Thermal information can be returned for the following list of temperature types:

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

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

Open a terminal on the device:

PC $> adb shell

Check the list of available zones:

Board $> ls /sys/class/thermal/

Check each thermal zone types (example with two thermal zones with indexes 0 and 1) :

Board $> cat /sys/class/thermal/thermal_zone0/type
Board $> cat /sys/class/thermal/thermal_zone1/type

You can check for each zone the list of trip point available (not systematically present, example with two trip points with indexes 0 and 1 for thermal zone 0):

Board $> cat /sys/class/thermal/thermal_zone0/trip_point_0_type
Board $> cat /sys/class/thermal/thermal_zone0/trip_point_1_type

From this stage, you can update in consequence the configuration file.

  • If no information is available, you can stubbed adding fixed values stub="1"
  • If a thermal zone is associated to one or several temperature types stub="0"
    • case without trip point data, you have to fixed the values in the file
    • case with trip point data, you have to put all data at 0 and add each trip index and type values in the file

6 Bluetooth configuration

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

The Bluetooth is enabled in device/stm/<STM32Series>/<BoardId>/BoardConfig.mk

BOARD_HAVE_BLUETOOTH := true
BOARD_HAVE_BLUETOOTH_LINUX := true

The path of the configuration file overlay bdroid_buildcfg.h must be also added:

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

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

It must at least contain the definition of the Class of Device (CoD) (see more information in the Bluetooth Specification[1])

#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 selected in the stack.

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

#ifndef BTA_PAN_INCLUDED
#define BTA_PAN_INCLUDED TRUE
#endif

If you want to disable it, add the following line in bdroid_buildcfg.h:

#define BTA_PAN_INCLUDED FALSE

More details in Android Bluetooth[2].

7 Wi-Fi configuration

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

You can change various configuration:

  • p2p
  • wpa supplicant
  • dhcp

For more details please refer to How to change Wi-Fi device for Android

8 Modify Android distribution

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

For that purpose, before any modification, you have to clear the current configuration:

PC $> <STM32Series>clear -p

From this stage, you can adapt the file (add or/and remove list of commits and patches).

Some rules shall be followed for added patches:

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

Some rules shall be followed for removed patches:

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

Then you can apply the new configuration:

PC $> <STM32Series>setup

From this stage, you have to rebuild the distribution to take into account your changes:

PC $> make -j

</references>

Attachments

Discussions