Android NXP Guide: Difference between revisions

From Variscite Wiki
No edit summary
 
(233 intermediate revisions by 10 users not shown)
Line 2: Line 2:
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}}} <!--
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}}} <!--
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Android {{#var:ANDROID_NAME}} {{#var:ANDROID_VERSION}} Developer Guide}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_NXP_VERSION}} Developer Guide}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__


= Introduction<br/> =
= Introduction =


This Wiki describes how to build and deploy Android {{#var:ANDROID_NAME}} on the {{#var:HARDWARE_NAME}}. It is based on NXP's {{#var:NXP_BSP_VERSION}} release
This page describes how to build and deploy {{#switch: {{#var:ANDROID_NAME}} | Android 10 = {{#var:ANDROID_NAME}} | Android 11 = {{#var:ANDROID_NAME}} | | Android 12 = {{#var:ANDROID_NAME}} | Android 13 = {{#var:ANDROID_NAME}} | Android {{#var:ANDROID_NAME}} }} on the {{#var:HARDWARE_NAME}}.<br> It is based on NXP's {{#var:NXP_BSP_VERSION}} release


= Overview =
= Overview =


The objective of this document is to guide {{#var:HARDWARE_NAME}} Android developers to obtain Android {{#var:ANDROID_NAME}} sources, setting up host environment, compilation, and deployment.
The objective of this document is to guide {{#var:HARDWARE_NAME}} Android developers to obtain {{#switch: {{#var:ANDROID_NAME}} | Android 10 = {{#var:ANDROID_NAME}} | Android 11 = {{#var:ANDROID_NAME}} | | Android 12 = {{#var:ANDROID_NAME}} | Android 13 = {{#var:ANDROID_NAME}} | Android {{#var:ANDROID_NAME}} }} sources, setting up host environment, compilation, and deployment.


This document contains instructions for:
This document contains instructions for:
Line 28: Line 28:
== Host (PC) setup requirements ==
== Host (PC) setup requirements ==


The host development environment for Android is based on Ubuntu, please install  
The host development environment for Android is based on Ubuntu, please install one of the following Ubuntu versions:
Ubuntu version 16.04/18.04 64bit LTS [http://www.ubuntu.com/download/desktop http://www.ubuntu.com/download/desktop]
* Ubuntu {{#switch: {{#var:ANDROID_NAME}} | Android 10 = 16.04/18.04 | Android 11 = 18.04/20.04/22.04 | Android 12 = 18.04/20.04/22.04 | Android 13 = 20.04/22.04 | 16.04/18.04 }} 64bit LTS [http://www.ubuntu.com/download/desktop http://www.ubuntu.com/download/desktop]


If you are running Linux in a virtual machine you need at least 16GB of RAM/swap.
If you are running Linux in a virtual machine you need at least 16GB of RAM and 32 GB of swap. <br>
The build process requires ~250GB of free storage space. Before starting a build, make sure you have adequate free space available.


<span style="color:red">Note:</span> Do not use other Ubuntu releases other than the ones recommended above.
{{Note|'''Note:''' Do not use other Ubuntu releases other than the ones recommended above. Variscite provides Docker containers that can be used for a development environment as an alternative to using a virtual machine or a dedicated computer.
 
To learn more, please see Variscite's [[Docker_Build_Environment | Docker Build Environment]] guide.
Windows with WSL/WSL2 is not supported for Android BSP}}


=== Install required packages on host PC ===
=== Install required packages on host PC ===
<pre>
<pre>
$ sudo apt-get -y install gnupg flex bison gperf build-essential zip gcc-multilib g++-multilib  
$ sudo apt-get -y install gnupg flex bison gperf build-essential zip gcc-multilib g++-multilib  
$ sudo apt-get -y install libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev
$ sudo apt-get -y install libc6-dev-i386 lib32ncurses5-dev libncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libz-dev libssl-dev
$ sudo apt-get -y install ccache libgl1-mesa-dev libxml2-utils xsltproc unzip bc
$ sudo apt-get -y install ccache libgl1-mesa-dev libxml2-utils xsltproc unzip bc
$ sudo apt-get -y install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git curl
$ sudo apt-get -y install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git curl lib32ncurses5-dev
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4 libz-dev
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4 dwarves libgnutls28-dev
$ sudo apt-get -y install libelf-dev cpio lz4
$ sudo apt-get -y install swig libdw-dev ninja-build clang liblz4-tool libncurses5 make tar rsync
</pre>
 
For Ubuntu 20.04 and above:<br>
The package '''android-tools-fsutils''' is obsolete and has been replaced by '''android-sdk-libsparse-utils'''.
<pre>
$ sudo apt-get -y install android-sdk-libsparse-utils
</pre>
</pre>


Line 53: Line 65:
  $ sudo apt-get update
  $ sudo apt-get update
  $ sudo apt-get install openjdk-8-jdk
  $ sudo apt-get install openjdk-8-jdk


If your Ubuntu version is missing the package (which shouldn't happen), add the PPA repository and run the previous commands again:
If your Ubuntu version is missing the package (which shouldn't happen), add the PPA repository and run the previous commands again:


  $ sudo add-apt-repository ppa:openjdk-r/ppa
  $ sudo add-apt-repository ppa:openjdk-r/ppa


Update the default Java version by running:
Update the default Java version by running:
Line 65: Line 75:
  $ sudo update-alternatives --config javac
  $ sudo update-alternatives --config javac


<span style="color:red">Note:</span> The build process requires about 135GB of free space.
<span style="color:red">Note:</span> The build process requires about 500GB of free space.
{{#switch: {{#var:ANDROID_NAME}} | Android 10 = {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}} | Android 11 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 12 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} |
Android 13 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}}}}
 
 
=== Check python version ===
In the next steps, we will download (from Google repositories) the command repo, used to download all the Android source repositories.
{{#switch: {{#var:ANDROID_NAME}} | Android 10 = {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}} | Android 11 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 12 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | Android 13 = {{#vardefine:HOST_OS|UBUNTU_18_04_20_04_22_04}} | {{#vardefine:HOST_OS|UBUNTU_16_04_18_04}}}}
 
{{#ifeq:{{#var:HOST_OS}}|UBUNTU_16_04_18_04 |
Recent versions of command repo, rely on python 3.6, not available in Ubuntu 16.04.
 
Ubuntu 16.04 LTS users can install it running
 
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6 python2
|
Certain tools like bpttools requires python2 which is not available default on Ubuntu 20.04 or 22.04 LTS. <br>
Ubuntu 20.04/22.04 LTS users can install it running
 
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6 python2
 
{{#switch: {{#var:ANDROID_NAME}} | Android 10 = 
Ubuntu 22.04 LTS users you need to setup python2 as default python for the bpttools if you are building Android 10 or older other build tools to work. <br>
Assuming you have installed python3.6 and python2 packages
$ cd /usr/bin
$ sudo ln -sf /usr/bin/python2 python
|
Make sure you use latest repo tool for all bug fixes
}}
}}


= Obtain source code =
= Obtain source code =
Line 73: Line 116:
<br>
<br>
Files:<br>
Files:<br>
* {{#var:ANDROID_VARFTP_BASE_PATCH_FILE}} - NXP's i.MX8M {{#var:ANDROID_NXP_VERSION}} original BSP patch files.<br>
* {{#var:ANDROID_VARFTP_BASE_PATCH_FILE}} - NXP's {{#var:ANDROID_NXP_VERSION}} original BSP patch files.<br>


== Get NXP's Android Release Package ==
== Get NXP's Android Release Package ==
Line 81: Line 124:
  $ tar xvf ~/Downloads/{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}}
  $ tar xvf ~/Downloads/{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}}


== Download Google Android {{#var:ANDROID_VERSION}} ==
== Download Google {{#var:ANDROID_VERSION}} ==
{{Note|Important update:
As of March 31, 2023, all codeaurora.org repositories have been migrated to other platforms and the project has been shut down.<br>
For more information, please visit: https://bye.codeaurora.org/<br>
<br>
In this context, errors may occur when downloading the source code running the script, such as:<br>
<code>fatal: unable to look up source.codeaurora.org (port 9418) (No address associated with hostname)</code><br>
<br>
Variscite has updated all relevant software repositories. Please re-download {{#var:ANDROID_VARFTP_PATCH_DIR}}{{#var:ANDROID_VARFTP_BASE_PATCH_FILE}} and the full Android source code from Variscite FTP <br>
|error}}
  $ mkdir -p ~/bin
  $ mkdir -p ~/bin
  $ curl -o ~/bin/repo http://commondatastorage.googleapis.com/git-repo-downloads/repo
  $ curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
  $ chmod a+x ~/bin/repo
  $ chmod a+x ~/bin/repo
  $ export PATH=~/bin:$PATH
  $ export PATH=~/bin:$PATH
  $ cd {{#var:BUILD_FOLDER}}
  $ cd {{#var:BUILD_FOLDER}}
  $ source {{#var:ANDROID_FOLDER_ID}}/imx_android_setup.sh
  $ source {{#var:ANDROID_FOLDER_ID}}/imx_android_setup.sh
* Note : Since Oreo the distribution of Android Source code is partially hosted on Linux Foundation https://source.codeaurora.org/*
* Note : Since Oreo the distribution of Android NXP Source code is partially hosted on Linux Foundation https://source.codeaurora.org/*
* Since Android 12 onwards the Android NXP source code is hosted on GitHub https://github.com/nxp-imx-android
Note:
{{#switch: {{#var:ANDROID_NAME}}
  | Android 11
  | Android 12
  | Android 13
  | Android 14 =
Wait for the script to finish running, and it should create following folders
$ {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device/variscite/
$ {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/kernel_imx and
$ {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/uboot-imx
 
== Apply Variscite's i.MX platforms patches ==
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device
$ variscite/scripts/install.sh {{#var:ANDROID_SCFW_INSTALL_ARGS}}
|
Wait for the script to finish running, and it should create a "{{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}" folder
Wait for the script to finish running, and it should create a "{{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}" folder
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}; mkdir -p vendor/variscite/
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}; mkdir -p vendor/variscite/
Line 100: Line 168:
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/device
  $ git clone {{#var:ANDROID_VARISCITE_GIT}} -b {{#var:ANDROID_VARISCITE_BRANCH}} variscite
  $ git clone {{#var:ANDROID_VARISCITE_GIT}} -b {{#var:ANDROID_VARISCITE_BRANCH}} variscite
  $ variscite/scripts/install.sh
  $ variscite/scripts/install.sh {{#var:ANDROID_SCFW_INSTALL_ARGS}}
}}


= Build Android Images =
= Build Android Images =
{{#ifeq:{{#var:ANDROID_BROKEN_FLEX}}|true |
For Ubuntu 22.04 LTS users the flex 2.5.39 needs to be re-compiled before you begin the build.
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
$ cd prebuilts/misc/linux-x86/flex
$ rm flex-2.5.39
$ tar zxf flex-2.5.39.tar.gz
$ cd flex-2.5.39
$ ./configure
$ make
$ mv flex ../
$ cd ../
$ rm -rf flex-2.5.39
$ mv flex flex-2.5.39
}}


Change to Android top level directory.
Change to Android top level directory.
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  $ source build/envsetup.sh
  $ source build/envsetup.sh
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
  {{#switch: {{#var:ANDROID_NAME}}  
  | Android 10 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | Android 11 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | Android 12 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | Android 13 = $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  | $ lunch {{#var:ANDROID_MACHINE_NAME}}-eng
  or
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  |
  }}
$ lunch {{#var:ANDROID_MACHINE_NAME}}-eng
{{#ifeq:{{#var:ANDROID_USERBUILD_SUPPORT}}|true |
  or
  or
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-user
}}
 
<span style="color:red">Note:</span> {{#switch: {{#var:ANDROID_NAME}} |Android 10 = userdebug build creates a debuggable version of Android.|Android 11 = userdebug build creates a debuggable version of Android.
  |Android 12 = userdebug build creates a debuggable version of Android.
  |Android 13 = userdebug build creates a debuggable version of Android.
  |userdebug build creates a debuggable version of Android.
eng build creates an engineering version of Android. Development mode enable and development tools are available on target.
  }}
  }}
{{#ifeq:{{#var:ANDROID_USERBUILD_SUPPORT}}|true |
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user build creates a production version of Android.
</span>
}}


<span style="color:red">Note:</span> userdebug build creates a debuggable version of Android.
eng build creates an engineering version of Android. Development mode enable and development tools are available on target.


  $ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
  $ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
Line 124: Line 223:


== Build Android ==
== Build Android ==
  $ {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |./imx-make.sh|make}} -j4 2>&1 | tee build1-1.log
  {{#switch: {{#var:ANDROID_NAME}}  
  | Android 10 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | Android 11 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | Android 12 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | Android 13 = ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
  | ./imx-make.sh -j4 2>&1 {{!}} tee build1-1.log
}}


== Images created by the Android build ==
== Images created by the Android build ==
Line 130: Line 235:


{{#lst:Android_Platform_Customization|{{#var:ANDROID_IMAGES_SECTION}}}}
{{#lst:Android_Platform_Customization|{{#var:ANDROID_IMAGES_SECTION}}}}
{{#ifeq:{{#var:ANDROID_DYNAMIC_PARTITION}}|true |
<span style="color:red">Note:</span> To create images with no dynamic support please follow [[Android_10_no_dynamic_partition]]
}}


= Boot options=
= Boot options=
Line 152: Line 260:


=== Preparing images ===
=== Preparing images ===
{{#ifeq:{{#var:ANDROID_NAME}}|Android 11 |
The default super.img, vendor_boot.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
$ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
$ simg2img super.img super_raw.img
|
{{#ifeq:{{#var:ANDROID_DYNAMIC_PARTITION}}|true |
The default super.img, format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.


All Android built images but system.img are ready for flashing out of the default build.<br>
$ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
 
$ simg2img super.img super_raw.img
|
{{#ifeq:{{#var:ANDROID_NAME}}|Android 10 |
The default system.img, vendor.img and product.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
|
The default system.img and vendor.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
The default system.img and vendor.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.
}}


  $ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
  $ cd out/target/product/{{#if: {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_PRODUCT_NAME}} | {{#var:ANDROID_MACHINE_NAME}} }}
Line 161: Line 281:
  $ simg2img vendor.img vendor_raw.img
  $ simg2img vendor.img vendor_raw.img
  {{#ifeq:{{#var:ANDROID_NAME}}|Android 10| $ simg2img product.img product_raw.img}}
  {{#ifeq:{{#var:ANDROID_NAME}}|Android 10| $ simg2img product.img product_raw.img}}
}}}}


=== Flashing Android from Linux shell (when the primary installation android) ===
=== Flashing Android from Linux shell (when the primary installation android) ===
Line 186: Line 307:
#Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
#Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
#Power up the board and hit return/space to stop the boot at U-Boot.
#Power up the board and hit return/space to stop the boot at U-Boot.
#type '''fastboot q''' in the U-Boot command line.
#type '''fastboot 0''' in the U-Boot command line.


'''On the Host PC:'''
'''On the Host PC:'''
Line 192: Line 313:
Replace ''<name>'' with the actual desired setup name according to the table in the [[#Images_created_by_the_Android_build|"Images created by the Android build" section]].
Replace ''<name>'' with the actual desired setup name according to the table in the [[#Images_created_by_the_Android_build|"Images created by the Android build" section]].


{{#ifeq: {{#var:ANDROID_NAME}} | Pie |
=== Android recovery mode ===
=== Android recovery mode ===
==== Enter board in Android Recovery mode ====
==== Enter board in Android Recovery mode ====
If you are using DT8MCustomBoard or you implemented any recovery key detection in uboot, the device can powered on in recovery mode by holding down the "back" (or any other recovery key) button until the end of the boot, showing the "Android Recovery" menu.


Turn on the device by holding down the "back" button must be held until the end of the boot and logged in "Android Recovery" mode.
Alternatively you can issue the command reboot recovery from the Android console (or using adb shell).


==== Control menu in Android Recovery Mode ====
==== Control menu in Android Recovery Mode ====


# To switch between menu items, use a short press of UP or DOWN buttons
If the board has UP, DOWN keys (like DT8MCustomBoard)
 
# To cycle between menu items, use a short press of UP or DOWN buttons
# To highlight an item, use a long press of BACK or HOME buttons or long touch the touchscreen
# To highlight an item, use a long press of BACK or HOME buttons or long touch the touchscreen
# To activate an item, use a short press of ON/OFF button
# To activate an item, use a short press of ON/OFF button
If the board has no UP and DOWN keys (like SymphonyBoard)
# To cycle between menu items, use a short press of any buttons or select the item with the touchscreen
# To activate an item, use a long press of any buttons or of the touchscreen
}}


==== Update Android firmware ====
==== Update Android firmware ====
Line 208: Line 339:
For generating "OTA" packages, use the following commands:
For generating "OTA" packages, use the following commands:
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  $ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
  {{#switch: {{#var:ANDROID_NAME}}  
| Android 10
| Android 11
| Android 12
| Android 13
| Android 14 =
  $ source build/envsetup.sh  
  $ source build/envsetup.sh  
  $ lunch PRODUCT={{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ ./imx-make.sh bootloader kernel -j4
  $ ./imx-make.sh bootloader kernel -j4
  $ make otapackage -j4  
  $ make otapackage -j4 2>&1 || tee build1-1.log
  |
  |
  $ make PRODUCT={{#var:ANDROID_MACHINE_NAME}}-userdebug otapackage -j4 2>&1 | tee build1-1.log
  $ make PRODUCT={{#var:ANDROID_MACHINE_NAME}}-eng otapackage -j4 2>&1 | tee build1-1.log
  }}
  }}


===== Install OTA package to device =====
===== Install OTA package to device =====
* extract payload.bin and payload_properties.txt from OTA zip file
* Extract payload.bin and payload_properties.txt from OTA zip file
* push file payload.bin to somewhere on the device (typically /cache folder)
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 11 |
* open payload_properties.txt on an editor to copy its content, lets suppose it's like in the NXP manual:
* Push payload.bin to board's /data/ota_package dir: adb push payload.bin /data/ota_package/ .
  |
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
* Push payload.bin to board's /sdcard dir: adb push payload.bin /sdcard/ .
  |
* Push file payload.bin to somewhere on the device (typically /cache folder)
  }}}}
* Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the NXP manual:
   FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   FILE_SIZE=379074366
   FILE_SIZE=379074366
Line 229: Line 372:
   }}
   }}
   METADATA_SIZE=46866
   METADATA_SIZE=46866
  {{#ifeq: {{#var:ANDROID_NAME}} | Android 11 | Android 12 |
* Input the following command on the board's console to update:
  su
  update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
  |
   {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
   {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
* Input the following command on the board's console to update:
* Input the following command on the board's console to update:
   update_engine_client --payload=http://192.168.1.1:10888/payload.bin --update --
  su
   update_engine_client --payload=file:///sdcard/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   |
   |
* Issue the following command on adb shell:
* Issue the following command on adb shell:
   update_engine_client --payload=file:///cache/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   update_engine_client --payload=file:///cache/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
   }}
   }}}}
   FILE_SIZE=379074366
   FILE_SIZE=379074366
   {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
   {{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
Line 244: Line 393:
   METADATA_SIZE=46866"
   METADATA_SIZE=46866"


{{#ifeq: {{#var:ANDROID_NAME}} | Android 11 |Android 12 |
Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return"
character.
|
{{#ifeq: {{#var:ANDROID_NAME}} | Android 10 |
Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return"
character.
|
Note that the command argument --headers="..." contains the exact (4-line) content of the payload_properties.txt file between quotes (you can copy and paste it), including 3 newline characters.
Note that the command argument --headers="..." contains the exact (4-line) content of the payload_properties.txt file between quotes (you can copy and paste it), including 3 newline characters.
}}}}
   
   
After issuing the command, nothing seems to happen on the device, but you can monit logcat for operation progress. After a successful update you can reboot into the updated version.
After issuing the command, nothing seems to happen on the device, but you can monit logcat for operation progress. After a successful update you can reboot into the updated version.
Line 257: Line 415:
  $ source build/envsetup.sh
  $ source build/envsetup.sh
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
  $ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
{{#switch: {{#var:ANDROID_NAME}}
| Android 11
| Android 12
| Android 13 =
$ ./imx-make.sh kernel -j4
|
  $ make bootimage
  $ make bootimage
}}


== Toolchain setup for manual build ==
== Toolchain setup for manual build ==
Setup the toolchain path to point to arm-linux-androideabi- tools in prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin
{{#if: {{#var:TOOLCHAIN_PATH}} |
$ export ARCH=arm64
$ export CROSS_COMPILE={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/{{#var:TOOLCHAIN_PATH}}
|
  $ export ARCH=arm64
  $ export ARCH=arm64
  $ export CROSS_COMPILE={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
  $ export CROSS_COMPILE={{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
}}


{{#if: {{#var:ANDROID_FASTBOOT_NEED_UNLOCK}} |
{{#if: {{#var:ANDROID_FASTBOOT_NEED_UNLOCK}} |
Line 275: Line 445:
* Settings => System => Advanced => Developer options => OEM unlocking
* Settings => System => Advanced => Developer options => OEM unlocking
* reboot to bootloader
* reboot to bootloader
* type "fastboot q" in the U-Boot command line
* type "fastboot 0" in the U-Boot command line
* run "sudo `which fastboot` oem unlock" from the Host PC
* run "sudo `which fastboot` oem unlock" from the Host PC
* wait until the unlock process is complete
* wait until the unlock process is complete
Line 281: Line 451:


}}
}}
{{#ifeq:{{#var:ANDROID_UUU_SUPPORT}}|true |
= Flashing Using NXP MFGTools - UUU (Universal Update Utility) =
To flash Android OS without using a recovery SD card, UUU (MFG Tools 3.0) can be used.<br>
Please refer to {{Varlink|Android_UUU_IMX8|{{#var:RELEASE_PARAM|RELEASE_O8.1.0_1.3.0_8M_DART-MX8M}}|Flashing Android OS using UUU - USB Boot}}.
}}
{{#ifeq:{{#var:ANDROID_UUU_LATEST}}|true |
{{Note|'''Note:'''The specific version of UUU is required to use this release, as VID/PIDs have been updated in the u-boot by NXP. <br>
Please download/build specific version of UUU on your host machine }}
}}
{{#ifeq:{{#var:ANDROID_M4_SUPPORTED}}|true |
= Running a M4 demo =
Please choose one of the below options while flashing Android from Linux shell
imx8mm-var-dart-1.x-dt8mcustomboard-m4 - Supports LVDS / SD / WiFi (DART-MX8M-MINI V1.x with M4 support on DT8MCustomBoard V2.x and above)
imx8mm-var-dart-dt8mcustomboard-m4 - Supports LVDS / SD / WiFi (DART-MX8M-MINI V2.x with M4 support on DT8MCustomBoard V2.x and above)
imx8mm-var-dart-wbe-dt8mcustomboard-m4 - Supports LVDS / SD / WiFi / (DART-MX8M-MINI V2.x with WBE and M4 support on DT8MCustomBoard V2.x and above)
imx8mm-var-som-symphony-m4 - Supports LVDS / SD / WiFi (VAR-SOM-MX8M-MINI V1.x with M4 support on Symphony-Board)
=== Running a demo from Linux ===
Boot Android to the shell
Increase kernel loglevel while debugging:
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
cat /sys/class/remoteproc/remoteproc0/state
If the state is 'running', stop the m4
echo stop > /sys/class/remoteproc/remoteproc0/state
Load new firmware (.elf file must already exist in /lib/firmware directory)
echo rpmsg_lite_pingpong_rtos_linux_remote.elf > /sys/class/remoteproc/remoteproc0/firmware
Change the state to running
echo start > /sys/class/remoteproc/remoteproc0/state
Copy and run demo module
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mm/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
=== Running a demo from U-Boot ===
{{#ifeq: {{#var:NXP_BSP_VERSION}} | i.MX android-11.0.0_2.4.0 |
Enable below node in -m4.dtsi and re-build images as per "Build Android Images" section and follow the steps described in paragraph "Flashing Android with USB Fastboot" to flash the images
  &rpmsg{
        status = "okay";
  };
}}
From U-Boot shell execute below commands
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x1FFE035D...
u-boot=> run bootcmd
Follow steps as described in "Copy and run demo module"
|
}}
{{#ifeq:{{#var:ANDROID_8MP_M7_SUPPORTED}}|true |
= Running a M7 demo =
Please choose one of the below <name> while flashing Android from Linux shell
imx8mp-var-dart-dt8mcustomboard-m7 (Variscite DART-MX8M-PLUS with LVDS and Cortex M7 on DT8MCustomBoard 2.x)
imx8mp-var-som-symphony-2nd-ov5640-m7 (Variscite VAR-SOM-MX8M-PLUS with 2nd OV5640 and Cortex M7 on Symphony-Board)
imx8mp-var-som-symphony-m7 (VAR-SOM-MX8M-PLUS with LVDS and Cortex M7 on Symphony-Board)
=== Running a demo from Linux ===
Boot Android to the shell
Increase kernel loglevel while debugging:
  sysctl kernel.printk=7;
 
Check the state of the m7, it should be running already by U-Boot
cat /sys/class/remoteproc/remoteproc0/state
If the state is 'running', stop the m7
echo stop > /sys/class/remoteproc/remoteproc0/state
Load new firmware (.elf file must already exist in /lib/firmware directory)
echo rpmsg_lite_pingpong_rtos_linux_remote.elf.dart > /sys/class/remoteproc/remoteproc0/firmware OR
echo rpmsg_lite_pingpong_rtos_linux_remote.elf.som > /sys/class/remoteproc/remoteproc0/firmware
Change the state to running
echo start > /sys/class/remoteproc/remoteproc0/state
Copy and run demo module
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mp/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
=== Running a demo from U-Boot ===
Enable below node in -m7.dtsi and re-build images as per "Build Android Images" section and follow the steps described in paragraph "Flashing Android with USB Fastboot" to flash the images
  &rpmsg{
        status = "okay";
  };
From U-Boot shell execute below commands
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x0000051D...
u-boot=> run bootcmd
Follow steps as described in "Copy and run demo module"
}}
{{#ifeq:{{#var:ANDROID_8M_M4_SUPPORTED}}|true |
= Running a M4 demo =
Please choose one of the below options while flashing Android from Linux shell
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-dp - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+DP
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-hdmi - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+HDMI
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds-dp - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+LVDS
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds-hdmi - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+LVDS+HDMI
imx8mq-var-dart-dt8mcustomboard-legacy-m4-wifi-lvds - Variscite DART-MX8M on DT8MCustomBoard 1.x M4+WIFI+LVDS
imx8mq-var-dart-dt8mcustomboard-m4-wifi-hdmi - Variscite DART-MX8M on DT8MCustomBoard 2.x M4+WIFI+HDMI
imx8mq-var-dart-dt8mcustomboard-m4-wifi-lvds-hdmi - Variscite DART-MX8M on DT8MCustomBoard 2.x M4+WIFI+LVDS+HDMI
imx8mq-var-dart-dt8mcustomboard-m4-wifi-lvds - Variscite DART-MX8M on DT8MCustomBoard 2.x M4+WIFI+LVDS
=== Running a demo from Linux ===
Boot Android to the shell
Increase kernel loglevel while debugging:
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
cat /sys/class/remoteproc/remoteproc0/state
If the state is 'running', stop the m4
echo stop > /sys/class/remoteproc/remoteproc0/state
Load new firmware (.elf file must already exist in /lib/firmware directory)
echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf > /sys/class/remoteproc/remoteproc0/firmware
Change the state to running
echo start > /sys/class/remoteproc/remoteproc0/state
Copy and run demo module
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mq/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
=== Running a demo from U-Boot ===
Enable below node in -m4.dtsi and re-build images as per "Build Android Images" section and follow the steps described in paragraph "Flashing Android with USB Fastboot" to flash the images
  &rpmsg{
        status = "okay";
  };
From U-Boot shell execute below commands
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x1FFE035D...
u-boot=> run bootcmd
Follow steps as described in "Copy and run demo module"
|
}}
{{#ifeq:{{#var:ANDROID_8X_M4_SUPPORTED}}|true |
= Running a M4 demo =
Please choose one of the below options while flashing Android from Linux shell
imx8qxp-var-som-symphony-wifi-m4 - Variscite M4 LVDS / WiFi
imx8qxp-var-som-symphony-sd-m4 - Variscite M4 LVDS / SD
=== Running a demo from Linux ===
Boot Android to the shell
Increase kernel loglevel while debugging:
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
cat /sys/class/remoteproc/remoteproc0/state
If the state is 'running', stop the m4
echo stop > /sys/class/remoteproc/remoteproc0/state
Load new firmware (.elf file must already exist in /lib/firmware directory)
echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf > /sys/class/remoteproc/remoteproc0/firmware
Change the state to running
echo start > /sys/class/remoteproc/remoteproc0/state
Copy and run demo module
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/som_mx8q/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
|
}}
{{#ifeq:{{#var:ANDROID_8Q_M4_SUPPORTED}}|true |
= Running a M4 demo =
Please choose one of the below options while flashing Android from Linux shell
imx8qm-var-som-dp-m4 - Supports VAR-SOM-MX8QM M4 with DP
imx8qm-var-som-hdmi-m4 - Supports VAR-SOM-MX8QM M4 with HDMI
imx8qm-var-som-lvds-m4 - Supports VAR-SOM-MX8QM M4 with LVDS
imx8qm-var-spear-dp-m4 - Supports VAR-SOM-MX8QM M4 with DP
imx8qm-var-spear-hdmi-m4 - Supports SPEAR-MX8QM M4 with HDMI
imx8qm-var-spear-lvds-m4 - Supports SPEAR-MX8QM M4 with LVDS
imx8qp-var-som-dp-m4 - Supports VAR-SOM-MX8QP M4 with DP
imx8qp-var-som-hdmi-m4 - Supports VAR-SOM-MX8QP M4 with HDMI
imx8qp-var-som-lvds-m4 - Supports VAR-SOM-MX8QP M4 with LVDS
imx8qp-var-spear-dp-m4 - Supports VAR-SOM-MX8QP M4 with DP
imx8qp-var-spear-hdmi-m4 - Supports SPEAR-MX8QP M4 with HDMI
imx8qp-var-spear-lvds-m4 - Supports SPEAR-MX8QP M4 with LVDS
=== Running a demo from Linux ===
Boot Android to the shell
Increase kernel loglevel while debugging:
  sysctl kernel.printk=7;
 
Check the state of the m4, it should be running already by U-Boot
cat /sys/class/remoteproc/remoteprocX/state
If the state is 'running', stop the m4
echo stop > /sys/class/remoteproc/remoteprocX/state
<span style="color:red">Note:</span> Replace 'X' with 0 or 1.
Load new firmware (.elf file must already exist in /lib/firmware directory)
echo cm_rpmsg_lite_pingpong_rtos_linux_remote_m4X.elf > /sys/class/remoteproc/remoteproc0/firmware
Change the state to running
echo start > /sys/class/remoteproc/remoteprocX/state
Copy and run demo module
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/som_mx8q/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
|
}}
{{#ifeq:{{#var:BASLER_ISP0}}|true |
= Running Camera app using Basler ISP camera =
Connect basler camera
{{#switch: {{#var:ANDROID_NAME}}
| Android 13 =
Flash any of the following dtbo and vbmeta images depending on your platform
* imx8mp-var-som-symphony-basler-isp0 - Supports Variscite VAR-SOM-MX8M-PLUS with Basler camera on Symphony-Board
* imx8mp-var-dart-dt8mcustomboard-basler-isp0 - Supports Variscite DART-MX8M-PLUS with Basler camera DT8MCustomBoard 2.x
* imx8mp-var-dart-dt8mcustomboard-legacy-basler-isp0 - Supports Variscite DART-MX8M-PLUS with Basler camera DT8MCustomBoard 1.x
<br>
* Note: This requires either device unlocked via fastboot or use UUU or recovery sdcard method to program proper images.
Please follow the steps to change the default camera configuration file to support Basler ISP Camera.
Unlock the device as per section 8.3
# boot up the system
adb root
# remount after reboot
adb remount
adb reboot
# boot up the system
adb root
# remount after reboot
adb remount
adb shell cp /vendor/etc/configs/camera_config_imx8mp-basler-isp0.json /vendor/etc/configs/camera_config_imx8mp.json
#reboot
}}
Launch Camera application using Basler ISP camera.
}}
{{#ifeq:{{#var:VAR_SOM_MX8MN_RPROC_DEMO}}|true |
= Running a M7 demo =
Please choose one of the below options while flashing Android from Linux shell
imx8mn-var-som-symphony-m7.img -  (VAR-SOM-MX8M-NANO M7 LVDS on Symphony-Board)
== Running a demo from Linux ==
Boot Android to the shell
Increase kernel loglevel while debugging:
$ sysctl kernel.printk=7;
 
Check the state of the m7, it should be running already by U-Boot
$ cat /sys/class/remoteproc/remoteproc0/state
If the state is 'running', stop the m7
$ echo stop > /sys/class/remoteproc/remoteproc0/state
Load new firmware (.elf file must already exist in /lib/firmware directory)
$ echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf.debug > /sys/class/remoteproc/remoteproc0/firmware OR
$ echo cm_rpmsg_lite_pingpong_rtos_linux_remote.elf.ddr_debug > /sys/class/remoteproc/remoteproc0/firmware
Note: elf.debug uses TCM and elf.ddr_debug uses DDR
Change the state to running
$ echo start > /sys/class/remoteproc/remoteproc0/state
Copy and run demo module
From Host PC
$ adb root
$ adb push {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/out/target/product/dart_mx8mn/obj/KERNEL_OBJ/drivers/rpmsg/imx_rpmsg_pingpong.ko /data
From device shell
$ su
$ cd /data
$ insmod imx_rpmsg_pingpong.ko
== Running a demo from U-Boot ==
You need to flash the firmware "Flashing Android with USB Fastboot" to flash the images
Android comes pre-compiled bin file for cortex-m7 for demo,
cm_rpmsg_lite_pingpong_rtos_linux_remote.bin.debug - TCM - Ping Pong Bin file
cm_rpmsg_lite_pingpong_rtos_linux_remote.bin.ddr_debug - DDR - Pingpong Demo bin file
$ fastboot flash mcu_os <bin file> from above
From U-Boot shell execute below commands after reset, hit enter at u-boot shell,
u-boot=> bootmcu
run command: 'bootaux 0x7e0000'
## Starting auxiliary core stack = 0x20020000, pc = 0x0000051D...
u-boot=> run bootcmd
Follow steps as described in "Copy and run demo module"
|
}}
{{#ifeq:{{#var:ANDROID_PCIE_MODEM_SUPPORTED}}|true |
= Setting up the PCI-E modem =
To add modem to your build follow {{Varlink|DART-MX8M_Android_Modem|{{#var:RELEASE_LINK}}|Modem Integration to Android build}}
}}
{{#ifeq:{{#var:ANDROID_TRUSTY_SUPPORTED}}|true |
{{#lst:Android_Platform_Customization|{{#var:ANDROID_TRUSTY_SECTION}}}}}}

Latest revision as of 18:34, 23 September 2024

DART-MX8M - Android O8.1.0_1.3.0 Developer Guide

Introduction

This page describes how to build and deploy Android Oreo on the DART-MX8M.
It is based on NXP's imx_8.1.0_1.3.0_8m_ANDROID release

Overview

The objective of this document is to guide DART-MX8M Android developers to obtain Android Oreo sources, setting up host environment, compilation, and deployment.

This document contains instructions for:

  • Hardware and software requirements.
  • Setup the hardware.
  • Setup the toolchain.
  • Download & build the sources.
  • Install the binaries on the DART-MX8M SOM and variants.

Supported hardware and features

Feature
Description
SOM support
DART-MX8M
Carrier Board support
VAR-DT8MCustomBoard
CPU

i.MX8M

eMMC
up to 64GB
DDR size support configuration
up to 4GB
SD card
+
Wired Network
10/100/1000 Mbps Ethernet
Wireless Network
Support for LWB5, 802.11 ac/a/b/g/n STA, AP, & Wi-Fi Direct Mode SmartConfig
Bluetooth
4.2 / BLE
SPI
+
I2C
+
USB host
+
USB OTG
Host and Device
Uarts
x4, up to 4 Mbps.
RTC
+
Display HDMI: V2.0a up to 4Kp60
LVDS Dual 1920×1080 24-bit
MIPI-DSI 1920×1080 24-bit
Audio Line IN / HP
Camera 2x MIPI-CSI2
PCIE +


Hardware Requirements

You will need the Variscite DART-MX8M based evaluation kit.

Host (PC) setup requirements

The host development environment for Android is based on Ubuntu, please install one of the following Ubuntu versions:

If you are running Linux in a virtual machine you need at least 16GB of RAM and 32 GB of swap.
The build process requires ~250GB of free storage space. Before starting a build, make sure you have adequate free space available.


Note: Do not use other Ubuntu releases other than the ones recommended above. Variscite provides Docker containers that can be used for a development environment as an alternative to using a virtual machine or a dedicated computer.

To learn more, please see Variscite's Docker Build Environment guide.

Windows with WSL/WSL2 is not supported for Android BSP

Install required packages on host PC

$ sudo apt-get -y install gnupg flex bison gperf build-essential zip gcc-multilib g++-multilib 
$ sudo apt-get -y install libc6-dev-i386 lib32ncurses5-dev libncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libz-dev libssl-dev
$ sudo apt-get -y install ccache libgl1-mesa-dev libxml2-utils xsltproc unzip bc
$ sudo apt-get -y install uuid uuid-dev zlib1g-dev liblz-dev liblzo2-2 liblzo2-dev lzop git curl lib32ncurses5-dev 
$ sudo apt-get -y install u-boot-tools mtd-utils android-tools-fsutils device-tree-compiler gdisk m4 dwarves libgnutls28-dev
$ sudo apt-get -y install libelf-dev cpio lz4
$ sudo apt-get -y install swig libdw-dev ninja-build clang liblz4-tool libncurses5 make tar rsync

For Ubuntu 20.04 and above:
The package android-tools-fsutils is obsolete and has been replaced by android-sdk-libsparse-utils.

$ sudo apt-get -y install android-sdk-libsparse-utils

Configure Git

$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"

Install the OpenJDK

To install it:

$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk

If your Ubuntu version is missing the package (which shouldn't happen), add the PPA repository and run the previous commands again:

$ sudo add-apt-repository ppa:openjdk-r/ppa

Update the default Java version by running:

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

Note: The build process requires about 500GB of free space.


Check python version

In the next steps, we will download (from Google repositories) the command repo, used to download all the Android source repositories.


Recent versions of command repo, rely on python 3.6, not available in Ubuntu 16.04.

Ubuntu 16.04 LTS users can install it running

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6 python2

Obtain source code

Variscite's Linux kernel and U-Boot are available through Github.
Required patches for the Android file system are under: https://variscite-public.nyc3.cdn.digitaloceanspaces.com/DART-MX8M/Software/Android/Android_iMX8M_O810_130/ in Variscite's FTP

Files:

  • imx-o8.1.0_1.3.0_8m.tar.gz - NXP's Android O8.1.0_1.3.0 original BSP patch files.

Get NXP's Android Release Package

$ mkdir ~/var_imx-o8.1.0_1.3.0_8m
$ cd ~/var_imx-o8.1.0_1.3.0_8m
$ curl -o ~/Downloads/imx-o8.1.0_1.3.0_8m.tar.gz https://variscite-public.nyc3.cdn.digitaloceanspaces.com/DART-MX8M/Software/Android/Android_iMX8M_O810_130/imx-o8.1.0_1.3.0_8m.tar.gz
$ tar xvf ~/Downloads/imx-o8.1.0_1.3.0_8m.tar.gz

Download Google Android O8.1.0_r14

Important update:

As of March 31, 2023, all codeaurora.org repositories have been migrated to other platforms and the project has been shut down.
For more information, please visit: https://bye.codeaurora.org/

In this context, errors may occur when downloading the source code running the script, such as:
fatal: unable to look up source.codeaurora.org (port 9418) (No address associated with hostname)

Variscite has updated all relevant software repositories. Please re-download https://variscite-public.nyc3.cdn.digitaloceanspaces.com/DART-MX8M/Software/Android/Android_iMX8M_O810_130/imx-o8.1.0_1.3.0_8m.tar.gz and the full Android source code from Variscite FTP

$ mkdir -p ~/bin
$ curl -o ~/bin/repo https://commondatastorage.googleapis.com/git-repo-downloads/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
$ cd ~/var_imx-o8.1.0_1.3.0_8m
$ source imx-o8.1.0_1.3.0_8m/imx_android_setup.sh

Note: Wait for the script to finish running, and it should create a "~/var_imx-o8.1.0_1.3.0_8m/android_build" folder

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build; mkdir -p vendor/variscite/

Clone Variscite's U-Boot and Linux kernel sources

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build/vendor/variscite/
$ git clone https://github.com/varigit/uboot-imx.git -b imx_v2017.03_4.9.51_imx8m_ga_var01
$ git clone https://github.com/varigit/linux-imx kernel_imx -b o8.1.0_1.3.0_8m-ga_var01

Apply Variscite's i.MX platforms patches

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build/device
$ git clone https://github.com/varigit/MX6x-android.git -b o8.1.0_1.3.0_8m-ga-var01 variscite
$ variscite/scripts/install.sh

Build Android Images

Change to Android top level directory.

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build
$ source build/envsetup.sh
$ lunch dart_mx8m-eng
 or
$ lunch dart_mx8m-userdebug


Note: userdebug build creates a debuggable version of Android. eng build creates an engineering version of Android. Development mode enable and development tools are available on target.


$ export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH

Switching from eMMC build to SD card build and vice versa

Unlike previous Android BSPs, the boot media is autodetected at boot time.

Build Android

./imx-make.sh -j4 2>&1 | tee build1-1.log

Images created by the Android build

The resulted images are located in out/target/product/dart_mx8m.


Image
Description
u-boot-imx8m-var-dart.imx U-Boot for eMMC/SD card boot.
SOM agnostics.
system.img Android system image file.
SOM agnostics.
vendor.img Android vendor image file.
SOM agnostics.
boot-<name>.img
vbmeta-<name>.img
configuration dependent
<name> is one of: imx8m-var-dart-emmc-wifi-dcss-lvds - Supports LVDS (via DCSS) / WiFi
imx8m-var-dart-emmc-wifi-dual-display - Supports HDMI (via DCSS) / LVDS (via LCDIF) / WiFi
imx8m-var-dart-emmc-wifi-hdmi-4k - Supports HDMI-4k / WiFi
imx8m-var-dart-emmc-wifi-hdmi - Supports HDMI / WiFi
imx8m-var-dart-emmc-wifi-lcdif-lvds - Supports LVDS (via LCDIF) / WiFi
imx8m-var-dart-sd-emmc-dcss-lvds - Supports LVDS (via DCSS) / SD
imx8m-var-dart-sd-emmc-dual-display - Supports HDMI (via DCSS) / LVDS (via LCDIF) / SD
imx8m-var-dart-sd-emmc-hdmi-4k - Supports HDMI-4k (via DCSS) / SD
imx8m-var-dart-sd-emmc-hdmi - Supports HDMI (via DCSS) / SD
imx8m-var-dart-sd-emmc-lcdif-lvds - Supports LVDS (via LCDIF) / SD


Boot options

Boot options of the Android:
1. Directly from SD card
2. U-Boot boots from on-SOM eMMC

Flash and boot Android from SD card

Create a bootable SD card

Partition and format SD card, and copy all images

$ sudo ./var-mksdcard.sh -f <name> /dev/sdX;sync

Boot From SD card

  • Power-off the board.
  • Insert the SD card into the SD card slot of the carrier board (DVK)
  • Make sure the Boot Mode is set to SD card: see Setting the Boot Mode section
  • Power up the board - it will boot into Linux from the SD card


Flash and boot Android from eMMC

Preparing images

The default system.img and vendor.img format is suitable for flashing using fastboot, and must be modified for flashing using 'dd'.

$ cd out/target/product/dart_mx8m
$ simg2img system.img system_raw.img
$ simg2img vendor.img vendor_raw.img

Flashing Android from Linux shell (when the primary installation android)

An example of flashing eMMC, can be found here.

Follow the following steps instructions above:

1. Preparing a rescue SD card;

2. Flash from command line (use the install_android.sh script)


Further, follow the steps described in paragraph "Flashing Android with USB Fastboot"


Flashing Android with USB Fastboot

Install tools on host

$ sudo apt-get install android-tools-adb android-tools-fastboot

Note: Make sure you built Android for eMMC
Connect the target with host PC at fastboot mode:

  1. Connect a USB OTG cable from the target board OTG port to a your host machine USB HOST port.
  2. Power up the board and hit return/space to stop the boot at U-Boot.
  3. type fastboot 0 in the U-Boot command line.

On the Host PC:

$ sudo `which fastboot` flash boot_a out/target/product/dart_mx8m/boot-<name>.img
$ sudo `which fastboot` flash boot_b out/target/product/dart_mx8m/boot-<name>.img
$ sudo `which fastboot` flash system_a out/target/product/dart_mx8m/system.img
$ sudo `which fastboot` flash system_b out/target/product/dart_mx8m/system.img
$ sudo `which fastboot` flash vendor_a out/target/product/dart_mx8m/vendor.img
$ sudo `which fastboot` flash vendor_b out/target/product/dart_mx8m/vendor.img
$ sudo `which fastboot` flash vbmeta_a out/target/product/dart_mx8m/vbmeta-<name>.img
$ sudo `which fastboot` flash vbmeta_b out/target/product/dart_mx8m/vbmeta-<name>.img
$ sudo `which fastboot` reboot

Replace <name> with the actual desired setup name according to the table in the "Images created by the Android build" section.


Update Android firmware

Generate OTA packages

For generating "OTA" packages, use the following commands:

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build
tee build1-1.log
Install OTA package to device
  • Extract payload.bin and payload_properties.txt from OTA zip file
  • Push file payload.bin to somewhere on the device (typically /cache folder)
  • Open payload_properties.txt on an editor to copy its content, lets suppose it's like in the NXP manual:
 FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866
 
  • Input the following command on the board's console to update:
 su
 update_engine_client --payload=file:///data/ota_package/payload.bin --update --headers="FILE_HASH=0fSBbXonyTjaAzMpwTBgM9AVtlBeyOigpCCgkoOfHKY=
 FILE_SIZE=379074366
 METADATA_HASH=Icrs3NqoglzyppyCZouWKbo5f08IPokhlUfHDmz77WQ/de8Dgp9zFXt8Fo+Hxccp465uTOvKNsteWU=
 METADATA_SIZE=46866"

Make sure that the -- header equals to the exact content of payload_properties.txt without "space" or "return" character.

After issuing the command, nothing seems to happen on the device, but you can monit logcat for operation progress. After a successful update you can reboot into the updated version.

You can check chapter 7 of official NXP "Android User Guide" for further "Over-The-Air (OTA) Update" examples.

Manual operations

Build boot.img

When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.

$ cd ~/var_imx-o8.1.0_1.3.0_8m/android_build
$ source build/envsetup.sh
$ lunch dart_mx8m-userdebug
$ make bootimage

Toolchain setup for manual build

$ export ARCH=arm64
$ export CROSS_COMPILE=~/var_imx-o8.1.0_1.3.0_8m/android_build/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

Unlock device for fastboot

Our build behaves like any other standard Android device.

To use fastboot, you should go through the following steps

  • Settings => System => About Tablet => Build number
  • keep on tapping until you see a prompt that says "You are now a developer!"
  • Settings => System => Advanced => Developer options => OEM unlocking
  • reboot to bootloader
  • type "fastboot 0" in the U-Boot command line
  • run "sudo `which fastboot` oem unlock" from the Host PC
  • wait until the unlock process is complete
  • proceed for flashing