How to populate boards for Android

Revision as of 11:36, 2 September 2019 by Registered User (→‎Update an Android distribution)

This article describes how to populate completely or partially a board with a built STM32MPU distribution for Android™. It is intended for Distribution Package users.

1. Prerequisites[edit source]

The recommended setup for the development PC (host) is specified in the following article: PC prerequisites.

The environment must be installed using the Distribution Package adapted to your selected microprocessor device. See the list of Android Distribution Package.

It is assumed that:

2. Populate a board[edit source]

The out/target/product/<BoardId> directory contains all images built for board selected during the setup (lunch step).


The STM32CubeProgrammer tool is used to flash the first stages of images to the board. Then fastboot is used to flash the remaining images.


The board shall be started in "Forced USB boot for flashing" mode (named also DFU), selecting it through boot switches as explained in the document <you board reference - hardware description, chapter Boot related switches (for example, Boot switches on the STM32MP157x-EV1 board for the STM32MP157C-EV1 board).

The board shall be connected through USB to your computer.


Depending on the board, several flash devices (microSD, eMMC and so on) might be available. The microSD card is considered as the Flash device in the rest of this article.

  • Go to the distribution root directory, and run flash-device:
 flash-device
  • Select the flashlayout you want to use (ex: FlashLayout_sd_optee.tsv to flash OP-TEE build for microSD card)
1) FlashLayout_emmc_optee.tsv	 3) FlashLayout_sd_optee.tsv
2) FlashLayout_sd_trusted.tsv	 4) FlashLayout_emmc_trusted.tsv
Which layout do you want to flash ?

Once the DFU flashing is terminated, the boot switches must be configured so that the Flash device (e.g. microSD card), on which the image has been flashed, is selected as the boot source.

This operation takes several minutes.
  • When the download is finished, press the reset button to reset the board. The Android software then starts.

3. Populate a microSD card[edit source]

You can flash images directly to a microSD card connected to your machine.

Before starting, you need to be sure that microSD card settings match yours. Please refer to the Memory settings page.

3.1. Format the microSD card[edit source]

The first time you use your microSD card or if the partition layout changes, you need to format it. The goal is to prepare it with appropriate partition size to accept images.

 format-device <device_path>

With:

  • <device_path>: the device identified in your system to access your microSD card (/dev/sdX for microSD card connected through USB dongle or /dev/mmcblkX for microSD card connected through reader, X is the instance associated to your Flash device).

This command will automatically use the partition configuration from device/stm/<STM32Series>/layout/android_layout.config.

For more information please see the usage option:

Usage: format-device [Options] <device_path>

  This script allows formatting memory device to create required partition before provisioning

Options:
  -h/--help: print this message
  -v/--version: get script version
  -s/--size <disk-size>: set requested disk size [4GiB or 8GiB] (default: PART_MEMORY_SIZE value set in <path_to>/android_layout.config)
  -c/--config <config-file-path>: set used partition configuration file (default: <path_to>/android_layout.config)

<device_path>: /dev/sdX (sd connected through usb), /dev/mmcblkX (sd connected through reader)
Info white.png Information
You need to disconnect and reconnect the microSD card before going further

3.2. Provision the microSD card[edit source]

To push the built images, you need to execute:

 provision-device <device_path>

With:

  • <device_path>: the device identify in your system to access your microSD card (/dev/sdX for microSD card connected through USB dongle or /dev/mmcblkX for microSD card connected through reader, X is the instance associated to your Flash device).

Then all images are flashed on the Flash device.


From this stage, you can plug your microSD card on your board and reboot it.

4. Flash a dedicated image[edit source]

If you already have an Android distribution installed and booted on your board, it's possible to update partitions one by one depending on your needs. For example, if you rebuild the kernel you can just flash the boot (kernel), the dt (device tree) and the vendor images (modules).


First you need to restart your device in fastboot mode:

  • Press the reset button, and a long press on the button associated with fastboot (USER PA13 for Evaluation board, USER2 for Discovery kits).

or

  • Run the command
 adb reboot-bootloader


Then execute the flashing command:

 provision-device -i reboot
  • -i option means that you will have to confirm the flash partition per partition (select the partitions you want to update)
  • reboot option means that the device will reboot automatically at the end

5. Update an Android distribution[edit source]

If you want to update the content of partitions dedicated to Android (vendor,system or userdata) after a rebuild, it's possible to use ADB tool.

You have first to switch read-only partitions to read-write:

 adb root
 adb remount

You can then update the Android partitions.

 adb sync

Finally, you have to reboot your device to take these changes into account

 adb reboot