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 source]
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:
source build/envsetup.sh
lunch aosp-<BoardId>-userdebug
2. Layout configuration[edit source]
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:
source build/envsetup.sh
lunch aosp-<BoardId>-userdebug
2.1. Memory type[edit source]
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[edit source]
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:
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[edit source]
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 build_tsv_.py
.
3. Bluetooth configuration[edit source]
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/<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].
4. Audio configuration[edit source]
The configuration is stored in device/stm/<STM32Series>/<BoardId>/media/audio
For more details please refer to How to change audio device for Android
5. Wi-Fi configuration[edit source]
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
6. Patch Android distribution[edit source]
It may be necessary to patch some files from the Android distribution.
To do so make the changes you need in the Android distribution repository and create a patch file containing your changes.
Then copy this file to device/stm/<STM32Series>/patch/android/<repoName>
.
You need to add you file name in the configuration file android_patch.config
at the appropriate section.
For example if you need to change a file in the repository framework/base
, do your changes, then:
git commit -m "Some comment" git format-patch -1 #Where 1 is the number to commit to include.
The output result of a file name 0001-commitName
.
Then copy it to device/stm/<STM32Series>/patch/android/framework_base
.
In the configuration file it would result of:
PATCH_PATH frameworks/base PATCH_X frameworks_base/0001-commitName #Where X is the patch order
To apply this change you need to execute:
<STM32Series>clear -p <STM32Series>setup make -j