Registered User mNo edit summary Tag: 2017 source edit |
Registered User mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 4: | Line 4: | ||
}}</noinclude> | }}</noinclude> | ||
{{FlowCompatibility/Android}} | {{FlowCompatibility/Android}} | ||
This article describes how to load Android<sup>TM</sup> distribution images, built for the STM32MPU, to defined | This article describes how to load Android<sup>TM</sup> distribution images, built for the STM32MPU, to defined flash device partitions. | ||
It is intended for Distribution Package users. | It is intended for Distribution Package users. | ||
Line 16: | Line 16: | ||
* STM32CubeProgrammer tool (version >= 2.17) has been installed (refer to [[STM32CubeProgrammer]]) | * STM32CubeProgrammer tool (version >= 2.17) has been installed (refer to [[STM32CubeProgrammer]]) | ||
* OpenSTDroid distribution has been built (refer to [[How to build OpenSTDroid distribution]]) | * OpenSTDroid distribution has been built (refer to [[How to build OpenSTDroid distribution]]) | ||
Line 54: | Line 55: | ||
The board can be designed to support several flash devices, | Connect the board to the host PC through[[STM32MP257x-EV1 - hardware description#MB1936-CN15|USB]]. | ||
The board can be designed to support several flash devices. For example, microSD, eMMC and so on. This document uses the eMMC as the flash device example for this article. | |||
* Go to the distribution root directory, and run flash-device: | * Go to the distribution root directory, and run flash-device: | ||
{{PC$}}flash-device | {{PC$}}flash-device | ||
Once the DFU flashing is completed, the boot switches must be configured so that the correct | Once the DFU flashing is completed, the boot switches must be configured so that the correct flash device (for example: eMMC) is selected as the boot source. | ||
* Press the reset button and keep the '''USER 2''' button (refer to [[LEDs and buttons on STM32 MPU boards]]) pressed until the board enters fastboot. The device provisioning continues until the required images have been loaded. | * Press the reset button and keep the '''USER 2''' button (refer to [[LEDs and buttons on STM32 MPU boards]]) pressed until the board enters fastboot. The device provisioning continues until the required images have been loaded. | ||
:This operation takes several minutes. | :This operation takes several minutes. | ||
* When the download is finished, press the reset button in the board. The Android software | * When the download is finished, press the reset button in the board. The Android software starts. | ||
==Populate a microSD card (case hybrid) == | ==Populate a microSD card (case hybrid) == | ||
Line 72: | Line 74: | ||
In case of hybrid (eMMC / microSD card) configuration, you have to flash the data partitions (''metadata'' and ''userdata'') in a microSD card. | In case of hybrid (eMMC / microSD card) configuration, you have to flash the data partitions (''metadata'' and ''userdata'') in a microSD card. | ||
First you need to create the disk image: | First, you need to create the disk image: | ||
{{PC$}}create-disk --hybrid | {{PC$}}create-disk --hybrid | ||
Line 78: | Line 80: | ||
It | |||
It it then possible to copy this image on a microSD card: | |||
<u>Linux (ex: Ubuntu) host</u> | <u>Linux (ex: Ubuntu) host</u> | ||
Line 84: | Line 87: | ||
{{PC$}}sgdisk --move-second-header {{HighlightParam|''<device_path>''}} | {{PC$}}sgdisk --move-second-header {{HighlightParam|''<device_path>''}} | ||
With: | With: | ||
*{{HighlightParam|''<device_path>''}}: the device identified in the system to access the microSD card (<code>/dev/sdX</code> for microSD card connected through USB dongle or <code>/dev/mmcblkX</code> for microSD card connected through reader, <code>X</code> is the instance associated to the | *{{HighlightParam|''<device_path>''}}: the device identified in the system to access the microSD card (<code>/dev/sdX</code> for microSD card connected through USB dongle or <code>/dev/mmcblkX</code> for microSD card connected through reader, <code>X</code> is the instance associated to the flash device). | ||
<u>Windows host</u> | <u>Windows host</u> | ||
Line 95: | Line 98: | ||
== Flash a dedicated image == | == Flash a dedicated image == | ||
If an Android distribution is already installed and booted on the board, it | If an Android distribution is already installed and booted on the board, it is possible to update partitions one by one depending on the need. For example, if the kernel is rebuilt, just flash the boot (kernel), the device tree (dt), and the vendor images (modules). | ||
First, the device has to be restarted in fastboot mode: | |||
First the device has to be restarted in fastboot mode: | |||
* Keep the reset button pressed until the board enters fastboot (USER1 for Evaluation board). | * Keep the reset button pressed until the board enters fastboot (USER1 for Evaluation board). | ||
or | or | ||
* Run the command | * Run the command | ||
{{PC$}}adb reboot bootloader | {{PC$}}adb reboot bootloader | ||
Finally, execute the flashing command: | Finally, execute the flashing command: | ||
Line 114: | Line 115: | ||
If the content of the partitions dedicated to Android<sup>TM</sup> needs to be updated (<code>vendor</code>,<code>system</code>, <code>system_ext</code> or <code>product</code>) after a rebuild, use [[ADB]] tool. | If the content of the partitions dedicated to Android<sup>TM</sup> needs to be updated (<code>vendor</code>,<code>system</code>, <code>system_ext</code> or <code>product</code>) after a rebuild, use [[ADB]] tool. | ||
An overlayfs mechanism is used to allow updating files in read-only partitions | An overlayfs mechanism is used to allow updating files in read-only partitions. The first time, you have to execute the following commands: | ||
{{PC$}}adb root | {{PC$}}adb root | ||
{{PC$}}adb remount | {{PC$}}adb remount | ||
Line 124: | Line 125: | ||
{{PC$}}adb sync | {{PC$}}adb sync | ||
Finally, the device needs to be rebooted to take these changes into account | Finally, the device needs to be rebooted to take these changes into account. | ||
{{PC$}}adb reboot | {{PC$}}adb reboot | ||
If the modifications that you made concern a | If the modifications that you made concern a specific service, it might be enough to restart these services to take these modifications into account, instead of rebooting the device: | ||
adb shell stop <targeted services>; adb shell start <targeted services> | adb shell stop <targeted services>; adb shell start <targeted services> | ||
For example, if only the vendor camera code is modified, it is enough to restart the | For example, if only the vendor camera code is modified, it is enough to restart the associated service ("vendor.camera.provider.stm32mpu"): | ||
adb shell stop vendor.camera.provider.stm32mpu; adb shell start vendor.camera.provider.stm32mpu | adb shell stop vendor.camera.provider.stm32mpu; adb shell start vendor.camera.provider.stm32mpu | ||
Line 135: | Line 136: | ||
[[Category:How to Android]] | [[Category:How to Android]] | ||
[[Category:Android]] | [[Category:Android]] | ||
{{PublicationRequestId | | {{PublicationRequestId | 33635 | 2025-01-13 | }} | ||
</noinclude> | </noinclude> |
Latest revision as of 09:00, 20 March 2025
Template:FlowCompatibility/Android This article describes how to load AndroidTM distribution images, built for the STM32MPU, to defined flash device partitions. It is intended for Distribution Package users.
1. Prerequisites[edit | edit source]
The recommended host PC setup is specified in the following article: PC prerequisites.
The environment must be installed using the Distribution Package adapted to the selected microprocessor device.
It is assumed that:
- STM32CubeProgrammer tool (version >= 2.17) has been installed (refer to STM32CubeProgrammer)
- OpenSTDroid distribution has been built (refer to How to build OpenSTDroid distribution)
Additionally, Fastboot mode is useful to accelerate the device provisioning (commands sent through USB).
In Linux environments, the Android USB drivers are built-in. The only action required is to set the target device information.
![]() |
To perform this action, you need administrator rights. In addition, you may need to add sudo in front of each executed command |
To do this, open a terminal and
- Create (or update if it already exists) the 51-android.rules file in /etc/udev/rules.d/ with the following information
- idVendor = 0483 (STMicroelectronics vendor)
- idProduct = 5720 or 0afb (depends on board configuration)
- Mode = 0660 (read/write permissions)
- Group = plugdev (Unix group which owns the device node)
![]() |
Check if you belong to the plugdev group by executing the following command:
$ groups |
Example:
# Fastboot on STMicroelectronics devices
SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="0afb", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="5720", MODE="0660", GROUP="plugdev"
- Make sure that the access rights to the created file are the correct ones:
chmod a+r /etc/udev/rules.d/51-android.rules
At this stage, your USB driver is correctly installed and configured.
2. Populate a board[edit | edit source]
The out/target/product/<BoardId>
directory contains all images built for the selected board during the setup (lunch
step).
The STM32CubeProgrammer tool is used to flash the first stages of the 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 (also named DFU), selecting it through boot switches as explained in the article <your board reference - hardware description>, chapter Boot related switches (for example, Boot switches on the STM32MP257x-EV1 board for the STM32MP257F-EV1 board).
Connect the board to the host PC throughUSB.
The board can be designed to support several flash devices. For example, microSD, eMMC and so on. This document uses the eMMC as the flash device example for this article.
- Go to the distribution root directory, and run flash-device:
flash-device
Once the DFU flashing is completed, the boot switches must be configured so that the correct flash device (for example: eMMC) is selected as the boot source.
- Press the reset button and keep the USER 2 button (refer to LEDs and buttons on STM32 MPU boards) pressed until the board enters fastboot. The device provisioning continues until the required images have been loaded.
- This operation takes several minutes.
- When the download is finished, press the reset button in the board. The Android software starts.
3. Populate a microSD card (case hybrid)[edit | edit source]
In case of hybrid (eMMC / microSD card) configuration, you have to flash the data partitions (metadata and userdata) in a microSD card.
First, you need to create the disk image:
create-disk --hybrid
At this stage, the image st-android-optee-sd.raw has been created in the out subdirectory.
It it then possible to copy this image on a microSD card:
Linux (ex: Ubuntu) host
<device_path> bs=8M conv=fdatasync status=progress sgdisk --move-second-header <device_path>dd if=st-android-optee-sd.raw of=
With:
- <device_path>: the device identified in the system to access the 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 the flash device).
Windows host
Example using HDD Raw Copy Tool :
- Select the SOURCE: st-android-<boot_mode>-sd.raw
- Select the TARGET: microSD card
- Click on “START” button
4. Flash a dedicated image[edit | edit source]
If an Android distribution is already installed and booted on the board, it is possible to update partitions one by one depending on the need. For example, if the kernel is rebuilt, just flash the boot (kernel), the device tree (dt), and the vendor images (modules).
First, the device has to be restarted in fastboot mode:
- Keep the reset button pressed until the board enters fastboot (USER1 for Evaluation board).
or
- Run the command
adb reboot bootloader
Finally, execute the flashing command:
provision-device -i reboot
- -i option means that a confirmation will be needed for flashing each partition at a time (select the partitions that need to be updated)
- reboot option means that the device will reboot automatically at the end
5. Update an Android distribution[edit | edit source]
If the content of the partitions dedicated to AndroidTM needs to be updated (vendor
,system
, system_ext
or product
) after a rebuild, use ADB tool.
An overlayfs mechanism is used to allow updating files in read-only partitions. The first time, you have to execute the following commands:
adb root
adb remount
adb reboot
It is then possible to update the AndroidTM partitions.
adb root
adb remount
adb sync
Finally, the device needs to be rebooted to take these changes into account.
adb reboot
If the modifications that you made concern a specific service, it might be enough to restart these services to take these modifications into account, instead of rebooting the device:
adb shell stop <targeted services>; adb shell start <targeted services>
For example, if only the vendor camera code is modified, it is enough to restart the associated service ("vendor.camera.provider.stm32mpu"):
adb shell stop vendor.camera.provider.stm32mpu; adb shell start vendor.camera.provider.stm32mpu