iMX8M Mini with AOSP Beginner Part 1

I recently got an NXP i.MX 8M Mini EVK board. It has rather powerful Arm Cortex-A53, Cortex-M4, Audio, Voice and Video processors. As a total newbie with no previous experiences on Android Operation System Project (AOSP) or NXP iMX series, this post records my first hands-on.

1. Quick Start with i.MX 8M Mini EVK

There’s a very good official tutorial that takes step-by-step approach on how to setup the kit.

Minicom

I had a little bit trouble to get the Minicom work. First

$ ls /dev/ttyUSB*

returns two USBs: ttyUSB0 and ttyUSB1, and it later turns out to be the ttyUSB1. Second, after change of Hardware Flow Control from Yes to No, Save setup to the default dfl and then restart Minicom for the settings to take effect.

Now when the board boots up, the output is shown on the console. Notice after the Android is on, any event message could be continoususly pushed to the console. One way to limit it is using dmesg

$ dmesg -n 1

Burn the NXP Linux BSP image to the board

Flashing the demo image is very straight forward, remember to put the uuu file in the same folder as images.

$ chmod a+x uuu
$ sudo ./uuu uuu-android-mx8mm-evk-sd.lst

2. Build from Source

Next I start to build from source. The Source code for a specific AOSP version can be found here. I am using imx-p9.0.0_2.3.0 for the rest of the post. Follow the README file come with the zip:

Repo

To build AOSP requires Repo, this is the same step as for the general asop build:

$: mkdir ~/bin
$: curl https://storage.googleapis.com/git-repo-downloads/repo  > ~/bin/repo
$: chmod a+x ~/bin/repo
$: export PATH=${PATH}:~/bin

Download and Setup Source:

This step is a bit different from general aosp build, but rather specific for the embedded iMX board. The setup script imx_android_setup.sh will download both general AOSP and iMX parts, as well as copy the proprietary to source folders.

$ cd ~
$ mkdir aosp
$ cd aosp
$ mv ~/Downloads/imx-p9.0.0_2.3.0 .
$ source ./imx-p9.0.0_2.3.0/imx_android_setup.sh

This is going to take a lot longer to finish, a few hours at least. If you happen to have a router without throttle ability to limit the bandwidth (e.g. Google Nest WiFi), this may render your internet unavailable for other devices. This can become even more frustrated if you needs to build for different version of AOSP. The solution is to make local mirror and sync from there.

Compile

  • Set up the environment for building. This only configures the current terminal.
$ source build/envsetup.sh
  • Execute the Android lunch command. lunch command can be issued with an argument or can be issued without the argument presenting a menu of selection.
$ lunch mek_8q-userdebug

Check Android User’s Guide for more details

  • Execute the make command to generate the image.
$ make 2>&1 | tee build-log.txt

add -j4 to speed up.

Burn

The generated .sh file does two things: 1) prepare all the images, copy them to the /tmp folder (that’s why need sudo) and generate the uuu.lst file; 2) execute UUU on the uuu.lst file to flash the image. However since my uuu is not in the path and also require sudo to execute, the 2nd step will fail and requires manual flash.

sudo ./uuu_imx_android_flash.sh -f imx8mm -a -t sd
sudo ~/UUU/uuu_1.3.191/uuu /tmp/uuu.lst

Here I also use the -t to choose set the target as SD card.