Difference between revisions of "How to build STM32MPU distribution for Android"

[quality revision] [quality revision]
(Generating the image)
m
 

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/envsetup.sh

It sets all the several required environment variables required to execute all the scripts and work in the distribution environmentfor the build and adds several useful scripts in your path. 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 envsetup.sh:

 hmm 


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 Chip selection[edit]

The distribution is built for a default chip version (ex: STM32MP157F for STM32MP1 Series).

It's possible to change the selection, modifying the SOC_VERSION value in device/stm/<STM32Series>/<BoardId>/aosp_<BoardId>.mk file.

2.2 Memory selection[edit]

The distribution is built for a default memory type (ex: microSD card 8GiB for STM32MP1 Series).

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:

PART_MEMORY_TYPE
PART_MEMORY_SIZE

Current options are :

  • PART_MEMORY_TYPE sd and PART_MEMORY_SIZE 8GiB
  • PART_MEMORY_TYPE sd and PART_MEMORY_SIZE 4GiB
  • PART_MEMORY_TYPE emmc and PART_MEMORY_SIZE 4GiB

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

 source ./build/envsetup.sh

2.23 Setup[edit]

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

 stm32mp1setup

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

2.34 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.45 Generating the image[edit]

Warning white.png Warning

In case you selected user build, it's required to rebuild the kernel as the prebuilt images are not compatible (see How to build kernel for Android)

You are now ready to compilebuild. 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.6 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"


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

== Prerequisites ==

The environment must be installed using the Distribution Package adapted to your microprocessor device (see the list of Android [[Which_STM32MPU_Embedded_Software_Package_for_Android_better_suits_your_needs#Distribution_Package | Distribution Package]]).

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

== Build ==

First execute the following command:

 {{PC$}} source ./build/envsetup.sh

It sets all theseveral required environment variables required to execute all the scripts and work in the distribution environmentfor the build and adds several useful scripts in your path.
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 <code>envsetup.sh</code>:

 {{PC$}} hmm 

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 | Choosing a build target]].

=== Memory settings ===

The memory Chip selection ===

The distribution is built for a default chip version (ex: STM32MP157F for STM32MP1 Series).

It's possible to change the selection, modifying the <code>SOC_VERSION</code> value in <code>device/stm/<STM32Series>/<BoardId>/aosp_<BoardId>.mk</code> file.

=== Memory selection ===

The distribution is built for a default memory type (ex: microSD card 8GiB for STM32MP1 Series).

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

Edit the <code>device/stm/{{HighlightParam|''<STM32Series>''}}/layout/android_layout.config</code> file.

Locate the two lines below:<pre>

PART_MEMORY_TYPE
PART_MEMORY_SIZE</pre>


Current options are :
* PART_MEMORY_TYPE sd and PART_MEMORY_SIZE 8GiB
* PART_MEMORY_TYPE sd and PART_MEMORY_SIZE 4GiB
* PART_MEMORY_TYPE emmc and PART_MEMORY_SIZE 4GiB

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

 {{PC$}} source ./build/envsetup.sh

=== Setup ===

Execute this {{HighlightParam|<STM32Series>}} setup only once, for example for STM32MP1 Series:

 {{PC$}} stm32mp1setup

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

=== Choosing a build target ===

To choose your target device, execute the command below:

 {{PC$}} lunch aosp_{{HighlightParam|''<BoardId>''}}-{{HighlightParam|''<build_type>''}}

The available <code>build_type</code> values are the following:
*<code>user</code>: to generate an end-user production image;
*<code>userdebug</code>: similar to an <code>user</code> build but with root access and debug capabilities;
*<code>eng</code>: development configuration with additional debugging tools.

=== Generating the image ===
{{Warning|
In case you selected <code>user</code> build, it's required to rebuild the kernel as the prebuilt images are not compatible (see [[How to build kernel for Android]])
}}
You are now ready to compilebuild. To do this, just launch the command:

 {{PC$}} 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 <code>out</code> folder. The generated partition images are located in <code>out/target/product/{{HighlightParam|''<BoardId>''}}</code>.

To flash images, refer to [[STM32MP1 Distribution Package for Android#Flashing the built image | Flashing the built image]].
=== Tips ===

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):
 {{PC$}} export JAVA_TOOL_OPTIONS="-Xmx4g"
<noinclude>

[[Category:How to Android]]
[[Category:Android]]
{{PublicationRequestId |13260 | 2019-09-12}}</noinclude>
(4 intermediate revisions by 2 users not shown)
Line 13: Line 13:
 
  {{PC$}} source ./build/envsetup.sh
 
  {{PC$}} source ./build/envsetup.sh
   
It sets all the environment variables required to execute all the scripts and work in the distribution environment.
+
It sets several required environment variables for the build and adds several useful scripts in your path.
 
It is mandatory to start with this command as soon as you are using a new terminal.
 
It is mandatory to start with this command as soon as you are using a new terminal.
   
Line 23: Line 23:
 
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 | Choosing a build target]].
 
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 | Choosing a build target]].
   
=== Memory settings ===
+
=== Chip selection ===
  +
 
  +
The distribution is built for a default chip version (ex: STM32MP157F for STM32MP1 Series).
  +
 
  +
It's possible to change the selection, modifying the <code>SOC_VERSION</code> value in <code>device/stm/<STM32Series>/<BoardId>/aosp_<BoardId>.mk</code> file.
  +
 
  +
=== Memory selection ===
  +
 
  +
The distribution is built for a default memory type (ex: microSD card 8GiB for STM32MP1 Series).
   
 
The memory size and type can be changed. More information refer to [[How to customize the STM32MPU distribution for Android]].
 
The memory size and type can be changed. More information refer to [[How to customize the STM32MPU distribution for Android]].
Line 65: Line 73:
 
=== Generating the image ===
 
=== Generating the image ===
   
You are now ready to compile. To do this, just launch the command:
+
{{Warning|
  +
In case you selected <code>user</code> build, it's required to rebuild the kernel as the prebuilt images are not compatible (see [[How to build kernel for Android]])
  +
}}
  +
 
  +
You are now ready to build. To do this, just launch the command:
   
 
  {{PC$}} make -j
 
  {{PC$}} make -j
Line 74: Line 86:
   
 
To flash images, refer to [[STM32MP1 Distribution Package for Android#Flashing the built image | Flashing the built image]].
 
To flash images, refer to [[STM32MP1 Distribution Package for Android#Flashing the built image | Flashing the built image]].
  +
  +
=== Tips ===
  +
  +
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):
  +
{{PC$}} export JAVA_TOOL_OPTIONS="-Xmx4g"
   
 
<noinclude>
 
<noinclude>