How to build STM32MPU distribution for Android

Revision as of 12:34, 22 June 2020 by Nathalie Sangouard (talk | contribs) (Merge articles)

This article explains how to build the STM32MPU distribution for Android™. It is intended for Distribution Package users.

1 Prerequisites[edit]

The environment must be installed using the Distribution Package adapted to your microprocessor device (see the list of Android Distribution Package).

In addition follow the PC prerequisites dedicated to Android to make sure all the packages required to use the environment are present.

2 Build[edit]

First execute the following command:

 source ./build/

It sets all the environment variables required to execute all the scripts and work in the distribution environment. It is mandatory to start with this command as soon as you are using a new terminal.

Use the command below to list some interested aliases created by


If this is the first time you set up an environment to build Android, continue to read this article. Otherwise directly go to Choosing a build target.

2.1 Memory settings[edit]

The memory size and type can be changed. More information refer to How to customize the STM32MPU distribution for Android.

Edit the device/stm/<STM32Series>/layout/android_layout.config file.

Locate the two lines below:


Current options are :


When the file has been modified, relaunch the previous command:

 source ./build/

2.2 Setup[edit]

Execute this <STM32Series> setup only once, for example for STM32MP1 Series:


It applies specific patches related to your <STM32Series> to customize Android and load the necessary libraries and modules.

2.3 Choosing a build target[edit]

To choose your target device, execute the command below:

 lunch aosp_<BoardId>-<build_type>

The available build_type values are the following:

  • user: to generate an end-user production image;
  • userdebug: similar to an user build but with root access and debug capabilities;
  • eng: development configuration with additional debugging tools.

2.4 Generating the image[edit]

You are now ready to build. To do this, just launch the command:

 make -j

Depending on your computer settings, several hours might be required to execute this command on the first build.

The result can be found in the out folder. The generated partition images are located in out/target/product/<BoardId>.

To flash images, refer to Flashing the built image.

2.5 Tips[edit]

If you encountered the following error during the build:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

It's possible to increase the maximum heap space, executing the following command (can be added in your ~/.bashrc file):

 export JAVA_TOOL_OPTIONS="-Xmx4g"