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:

PC $> source build/envsetup.sh
PC $> 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:

PC $> source build/envsetup.sh
PC $> 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:

PART_8GiB_MEMORY_MAX_SIZE 7432M x1 sd

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

To find the correct value, execute the command below:

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

It displays the following information:

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)

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:

PART_8GiB_MEMORY_MAX_SIZE 7536M x1 sd

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:

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)

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/build_tsv.py 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 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.

5 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:

PC $> <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.
  • 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:

PC $> <STM32Series>setup

Then rebuild the distribution to take into account your changes:

PC $> make -j

6 References[edit]