本篇是记录使用NXP官方开发板环境搭建过程记录,以防备忘。这次在无原厂技术支持的环境下,
把整个流程梳理一下:
(a). 选的开发板获取该开发板资料;
(b). 搭建android8.1 源码开发环境;
©. SD 卡分区并烧写android系统镜像;
(d). 使用自己编译镜像在开发板上验证;

第一条 研发资料说明

1). android_O8.1.0_1.3.0_8M_tools.tar.gz 文件是 mfgtool 下载工具.
可以制作 sd 卡镜像、烧写镜像至 emmc 中。
2). imx-o8.1.0_1.3.0_8m.tar.gz 是 android 源码补丁和编译脚本。
3). android_O8.1.0_1.3.0_8M_docs.tar 是 imx8mq 的开发说明文档。

其他版本资料样式基本相同,可以此关系下载自己需要文档资料。

第二条 官方网站提供 android8.1 版本源码

资料汇总如下:

# Ver 2.1.0
O8.1.0_2.1.1_AUTO_PATCH_DEMO_8Q2
GZ版本 O8.1.0_2.1.1_AUTOJun 3, 2019O8.1.0_2.1.1_AUTO_PATCH_DEMO_8Q2

BSP、驱动程序和中间件
O8.1.0_2.1.0_AUTO_GA_DEMO_8Q
GZ版本 O8.1.0_2.1.0_AUTOApr 29, 2019O8.1.0_2.1.0_AUTO_GA_DEMO_8Q

BSP、驱动程序和中间件
O8.1.0_2.1.0_AUTO_GA_DEMO_8Q2
GZ版本 O8.1.0_2.1.0_AUTOApr 29, 2019O8.1.0_2.1.0_AUTO_GA_DEMO_8Q2

BSP、驱动程序和中间件
O8.1.0_2.1.0_AUTO_GA_SOURCE
GZ版本 O8.1.0_2.1.0_AUTOApr 29, 2019O8.1.0_2.1.0_AUTO_GA_SOURCE

# Ver 2.0.1
BSP、驱动程序和中间件
O8.1.0_2.0.1_PATCH_SOURCE
GZ版本 O8.1.0_2.0.1Jun 3, 2019O8.1.0_2.0.1_PATCH_SOURCE

BSP、驱动程序和中间件
O8.1.0_2.0.1_PATCH_DEMO_8Q
GZ版本 O8.1.0_2.0.1Jun 3, 2019O8.1.0_2.0.1_PATCH_DEMO_8Q

# Ver 2.0
BSP、驱动程序和中间件
O8.1.0_2.0.0_GA_DEMO_8Q
GZ版本 O8.1.0_2.0.0Apr 29, 2019O8.1.0_2.0.0_GA_DEMO_8Q

BSP、驱动程序和中间件
O8.1.0_2.0.0_GA_SOURCE
GZ版本 O8.1.0_2.0.0Apr 29, 2019O8.1.0_2.0.0_GA_SOURCE
预编译image包
android_o8.1.0_2.0.0-ga_image_8qmek.tar.gz

# Ver1.3

BSP、驱动程序和中间件
O8.1.0_1.3.0_ANDROID_SOURCE_8MQ_GA
GZ版本 O8.1.0_1.3.0_8MQ_GAApr 10, 2018O8.1.0_1.3.0_ANDROID_SOURCE_8MQ_GA

BSP、驱动程序和中间件
O8.0.0_1.3.0_ANDROID_DEMO_8MQ_BETA
GZ版本 O8.0.0_1.3.0_8MQ_BetaJan 25, 2018485475 KBO8.0.0_1.3.0_ANDROID_DEMO_8MQ_BETA

嵌入式应用软件-其他
O8.1.0_1.3.0_8MQ_GA_AACPlus
GZ版本 O8.1.0_1.3.0_8MQ_GAApr 10, 2018O8.1.0_1.3.0_8MQ_GA_AACPlus

在实际开发过程验证中,1.3.0 版本中的原厂提供给的预编译的镜像中,缺乏 dtbo.img 内容,放弃此版本,
直接使用2.0.0 版本.

imx8mq mek 开发板资料链接
https://www.nxp.com.cn/design/development-boards/i-mx-evaluation-and-development-boards/i-mx-8quadmax-multisensory-enablement-kit-mek:MCIMX8QM-CPU https://www.nxp.com.cn/design/software/embedded-software/i-mx-software:IMX-SW

第三条 关于镜像烧写说明

3.1). 介质 eMMC 或 sd 分区

采用源码 tool 中的 分区脚本 /fsl-sdcard-partition.sh 来制作,方法如下:

$ cd ${MY_ANDROID}/
$ sudo ./device/fsl/common/tools/fsl-sdcard-partition.sh -f <soc_name> /dev/sdX
# <soc_name> can be imx8qm or imx8qxp.

NOTE
• The minimum size of the SD card is 8 GB bytes.
• If the SD card is 8 GB, use sudo ./device/fsl/common/tools/fslsdcard-partition.sh -f <soc_name> -c 7 /dev/sdX to flash images.
• If the SD card is 16 GB, use sudo ./device/fsl/common/tools/fslsdcard-partition.sh -f <soc_name> /dev/sdX to flash images.
• If the SD card is 32 GB, use sudo ./device/fsl/common/tools/fslsdcard-partition.sh -f <soc_name> -c 28 /dev/sdX to flash images.
• /dev/sdX, the X is the disk index from 'a' to 'z', which may be different on each
Linux PC.
• Unmount all the SD card partitions before running the script.
• Put related bootloader, boot image, system image, and vbmeta image in your
current directory.
• This script needs simg2img tool to be installed on your PC. The simg2img is a tool
that converts sparse system image to raw system image on the host PC running
Linux OS. The android-tools-fsutils package includes the simg2img command for
Ubuntu Linux.

NXP 原厂有预先发布镜像包中(android_o8.1.0_2.0.0-ga_image_8qmek.tar.gz)、也此分区脚本。

3.2). 镜像下载方法

3.2.1). 使用 UUU 下载镜像

参考使用说明 Android™ Quick Start Guide (AQSUG).
UUU can be used to flash the Android system image into the board, but it needs to make the board enter serial down mode
first, and make the board enter boot mode once flashing is finished.

To achieve more flexibility, two script files are provided to invoke UUU to automatically flash all Android images.
• uuu_imx_android_flash.sh for Linux OS
• uuu_imx_android_flash.bat for Windows OS
For this release, these two scripts are validated on UUU 1.2.91 version. Download corresponding version from github:
• For Linux OS, download the file named “uuu”.
• For Windows OS, download the file named “uuu.exe”.

将uuu.exe 拷贝到 C:\Windows\System32 目录,此步等同于给 uuu.exe 添加环境变量,因为 C:\Windows\System32 在环境变量PATH中有记录。

将 OTG 线插入 Windows 主机的 USB接口中。将镜像拷贝到 C 盘 uuu 目录,
在 Windows 下运行 cmd 程序,进入镜像文件所在的目录,根据自己的需要执行下面命令:
烧写 u-boot 到 emmc:

C:\uuu> uuu.exe -b emmc flash_sd_emmc.bin

烧写 u-boot、内核、 文件系统到 emmc:

C:\uuu> uuu.exe -b emmc_all flash_sd_emmc.bin rootfs.sdcard

烧写 u-boot 到 QSPI flash:

C:\uuu> uuu.exe -b qspi flash_qspi.bin

Because the two script files will direclty invoke UUU, make sure that UUU is in a path contained by the system environment
variable of “PATH”.

使用 uuu_imx_android_flash.bat 烧写镜像步骤如下1~8 步。

Perform the following steps to download the board images:

1. Download the UUU binary file from github as described before.

Install UUU into a directory contained by the system environment variable of “PATH”.

2. Make the board enter serial download mode.

• Change the board’s SW2 (boot mode) to 001000 (from 1-6 bit) to enter serial download mode for i.MX
8QuadMax.
• Change the board’s SW2 (boot mode) to 1000 (from 1-4 bit) to enter serial download mode for i.MX
8QuadXPlus.

3. Power on the board.

Use the USB cable on the board USB 3.0 Type-C port to connect your PC with the board.

4. Decompress release_package/android_8.1.0_2.0.0-ga_image_8qmek.tar.gz

which contains the image files and uuu_imx_android_flash tool.

5. Execute the uuu_imx_android_flash tool to flash images.

The uuu_imx_android_flash tool can be executed with options to get help information and specify the images to be
flashed. For Android images on the i.MX 8QuadMax/8QuadXPlus MEK board , related options are described as
follows

On Linux system, open the shell terminal. For example, you can execute a command as follows:

> sudo ./uuu_imx_android_flash.sh -f imx8qm -a -e -t sd

• On Windows system, open the command line interface in administrator mode. The corresponding command is as
follows:

> .\uuu_imx_android_flash.bat -f imx8qm -a -e -t sd

参数说明

Options explanation:
 -h Displays this help message
 -f soc_name Flashes the Android image file with soc_name
 -a Only flashes the image to slot_a
 -b Only flashes the image to slot_b
 -c card_size Optional setting: 7 / 14 / 28
 If it is not set, use partition-table.img (default).
 If it is set to 7, use partition-table-7GB.img for 8 GB SD card.
 If it is set to 14, use partition-table-14GB.img for 16 GB SD card.
 If it is set to 28, use partition-table-28GB.img for 32 GB SD card.
 Make sure that the corresponding file exists on your platform.
 -m Flashes the Cortex-M4 image.
 -d dev Flash dtbo, vbmeta, and recovery image file with dev.
 If it is not set, use default dtbo, vbmeta, and recovery image.
 -e Erases user data after all image files are flashed.
 -l Locks the device after all image files are flashed.
 -D directory Directory of images.
 If this script is execute in the directory of the images, it does not 
need to use this option.

When the command above is executed, the default images will be flashed into eMMC slot a for 8QuadMax.
         NOTE
• To flash the SD card, execute the tool with "-t sd". To flash eMMC, it does
not need to use -t option.
• If your SD card is 16 GB or the on-board eMMC is used as the boot device, it
does not need to use -c option.
• If your SD card is 32 GB, execute the tool with "-c 28".
• If your SD card is 8 GB, execute the tool with "-c 7".
• i.MX 8QuadMax MEK:
• To test LVDS-to-HDMI/MIPI-to-HDMI display, it does not need to use
-d option.
• To test MIPI panel display, execute the tool with "-d mipi-panel".
• To test physical HDMI display, execute the tool with "-d hdmi".
• uuu_imx_android_flash.bat generates a temporary file under the current
working directory. Make sure you have Write permission under the current
working directory.
• If uuu_imx_android_flash.bat is used to flash images on a remote server
through samba, you need to map the remote resource to the local environment
first. Take the following command as an example:
> net use z: \\10.193.108.179\daily_images
"z" in the command represents an available drive letter. It can be other
available drive letter.

注意,第一次在 windows 平台烧写时由于 windows 没有安装相应的驱动程序会出现下图的失败情况:
使用 latest_usb_driver_windows.zip安装驱动,在win10烧写成功过程记录如下。
关于驱动的安装,我还安装 豌豆荚助手,具体是那个驱动有效、我有点不确认。

烧写 32GB 的 SD image 记录
C:\scrcpy-shuangjun\android_o8.1.0_2.0.0-ga_image_8qmek>uuu_imx_android_flash.bat -f imx8qm -c 28 -a -e -t sd
This script is validated with uuu 1.2.91 version, please align with this version.
dtbo is supported
dual slot is supported
generate lines to flash partition-table-28GB.img to the partition of gpt
generate lines to flash u-boot-imx8qm.imx to the partition of bootloader0
generate lines to flash dtbo-imx8qm.img to the partition of dtbo_a
generate lines to flash boot.img to the partition of boot_a
generate lines to flash system.img to the partition of system_a
generate lines to flash vendor.img to the partition of vendor_a
generate lines to flash vbmeta-imx8qm.img to the partition of vbmeta_a
uuu script generated, start to invoke uuu with the generated uuu script
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.4.193-0-ge56424c
Success 1    Failure 0
1:114    1/ 1 [=================100%=================] SDPS: boot -f u-boot-imx8qm-mek-uuu.imx.link
1:234   19/19 [Done                                  ] FB: done

C:\scrcpy-shuangjun\android_o8.1.0_2.0.0-ga_image_8qmek>

console 打印错误信息,虽然有错误信息,但是SD卡还是可以启动。

MMC write: dev # 1, block # 58707968, count 8 ... 8 blocks written: OK
Writing 'vbmeta_a' DONE!
erase target is MMC:1
Erasing blocks 7569408 to 7577600 due to alignment
........ erased 4194304 bytes from 'misc'
erase target is MMC:1
Erasing blocks 7581696 to 7583744 due to alignment
........ erased 1048576 bytes from 'presistdata'
erase target is MMC:1
Erasing blocks 58703872 to 58705920 due to alignment
........ erased 1048576 bytes from 'fbmisc'
avb_ab_flow.c:30: ERROR: Magic is incorrect.
avb_ab_flow.c:112: ERROR: Error validating A/B metadata from disk. Resetting and writing new A/B metadata to disk.
erase target is MMC:1
Erasing blocks 8634368 to 58703872 due to alignment
烧写 8GB SD 记录
C:\scrcpy-shuangjun\android_o8.1.0_2.0.0-ga_image_8qmek>uuu_imx_android_flash.bat -f imx8qm -c 7 -a -e -t sd
This script is validated with uuu 1.2.91 version, please align with this version.
dtbo is supported
dual slot is supported
generate lines to flash partition-table-7GB.img to the partition of gpt
generate lines to flash u-boot-imx8qm.imx to the partition of bootloader0
generate lines to flash dtbo-imx8qm.img to the partition of dtbo_a
generate lines to flash boot.img to the partition of boot_a
generate lines to flash system.img to the partition of system_a
generate lines to flash vendor.img to the partition of vendor_a
generate lines to flash vbmeta-imx8qm.img to the partition of vbmeta_a
uuu script generated, start to invoke uuu with the generated uuu script
uuu (Universal Update Utility) for nxp imx chips -- libuuu_1.4.193-0-ge56424c

Success 1    Failure 0

1:114    1/ 1 [=================100%=================] SDPS: boot -f u-boot-imx8qm-mek-uuu.imx.link
1:234   19/19 [Done                                  ] FB: done
C:\scrcpy-shuangjun\android_o8.1.0_2.0.0-ga_image_8qmek>

consol 打印烧写信息

MMC write: dev # 1, block # 14667776, count 8 ... 8 blocks written: OK
Writing 'vbmeta_a' DONE!
status: -104 ep 'ep1in' trans: 0
erase target is MMC:1
Erasing blocks 7569408 to 7577600 due to alignment
........ erased 4194304 bytes from 'misc'
erase target is MMC:1
Erasing blocks 7581696 to 7583744 due to alignment
........ erased 1048576 bytes from 'presistdata'
erase target is MMC:1
Erasing blocks 14663680 to 14665728 due to alignment
........ erased 1048576 bytes from 'fbmisc'
avb_ab_flow.c:30: ERROR: Magic is incorrect.
avb_ab_flow.c:112: ERROR: Error validating A/B metadata from disk. Resetting and writing new A/B metadata to disk.
erase target is MMC:1
Erasing blocks 8634368 to 14663680 due to alignment
........ erased 3087007744 bytes from 'userdata'

打印信息未报错误。

6.Wait for the uuu_imx_android_flash execution to complete.

If there is not any error, you will get information on the
command window indicating that images are already flashed.

7. Power off the board.

8. Change boot device as eMMC or SD card.

• Change SW2 to switch the board back to 000100 (from 1-6 bit) to enther eMMC boot mode for i.MX 8QuadMax.
• Change SW2 to sithch the board back to 001100 (from 1-6 bit) to enther SD boot mode for i.MX 8QuadMax.
• Change SW2 to switch the board back to 0100 (from 1-4 bit) to enter eMMC boot mode for i.MX 8QuadXPlus.
• Change SW2 to switch the board back to 1100 (from 1-4 bit) to enter SD boot mode for i.MX 8QuadXPlus.

3.2.2). 使用 脚本 下载镜像

There is another tool of fastboot_imx_flashall script, which uses fastboot to flash the Android System Image into board.
It requires the target board to be able to enter fastboot mode and the device is unlocked.
There is no need to change the boot mode with this fastboot_imx_flashall script.

fastboot_imx_flashall.sh

Linux OS

fastboot_imx_flashall.bat

Windows OS

With the help of fastboot_imx_flashall scripts, you do not need to use fastboot to flash Android images one-by-one manually.
These scripts will automatically flash all images with only one command.

fastboot can be built with Android build system. Based on Section 3, which introduces how to build android images, use the
following commands to build fastboot:

$ cd ${MY_ANDROID}
$ make -j4 fastboot

After the build process finishes building fastboot, the directory to find the fastboot is as follows:
• Linux version binary file: ${MY_ANDROID}/host/linux-x86/bin/
• Windows version binary file: ${MY_ANDROID}/host/windows-x86/bin/

The way to use these scripts is follows:
• Linux shell script usage: sudo fastboot_imx_flashall.sh
• Windows batch script usage: fastboot_imx_flashall.bat

Example:

sudo ./fastboot_imx_flashall.sh -f imx8qm -a -e -D /imx_or8.1/mek_8q/

命令参数说明

Options explanation:
• -f imx8qm: Flashes images for i.MX 8QuadMax MEK Board.
• -a: Only flashes slot a.
• -e: Erases user data after all image files are flashed.
• -D /imx_or8.1/mek_8q/: images to be flashed are in the directory of /imx_or8.1/mek_8q/.

Options:
 -h Displays this help message
 -f soc_name Flashes the Android image file with soc_name
 -a Only flashes the image to slot_a
 -b Only flashes the image to slot_b
 -c card_size Optional setting: 7 / 14 / 28
 If it is not set, use partition-table.img (default).
 If it is set to 7, use partition-table-7GB.img for 8 GB SD card.
 If it is set to 14, use partition-table-14GB.img for 16 GB SD card.
 If it is set to 28, use partition-table-28GB.img for 32 GB SD card.
 Make sure that the corresponding file exists on your platform.
 -m Flashes the Cortex-M4 image.
 -d dev Flash dtbo, vbmeta, and recovery image file with dev.
 If it is not set, use default dtbo, vbmeta, and recovery image.
 -e Erases user data after all image files are flashed.
 -l Locks the device after all image files are flashed.
 -D directory Directory of images.
 If this script is execute in the directory of the images, it does not 
need to use this option.
 -s ser_num Serial number of the board.
 If only one board connected to computer, it does not need to use this

           NOTE
• -f option is mandatory. SoC name can be imx8qm or imx8qxp.
• Boot the device to U-Boot fastboot mode, and then execute these scripts. The
device should be unlocked first.

此方法笔者未实际使用,没有实验数据分享。

第四条 系统启动

imx8mq mek 开发板系统启动源、支持 sd 、 eMMc 、 spl-flash 方式;

4.1). Booting from eMMC/SD
Table 10. Boot device switch settings

i.MX 8QuadMax boot switch

Download mode (UUU mode)

SD boot

eMMC boot

SW2 Boot_Mode (1-6 bit)

001000

001100

000100

需要根据启动介质类型,选择对应的启动方式,本实验中使用的是 SD 卡模式,因此选择 11,给 iMX8QM mek 板上电,
本次实验使用的开发板、需要重新按板子上的复位按键、否则会有不启动的情况,具体原因不祥。再次上电后就不需要复位处理。

The default environment in boot.img is booting from eMMC. To use the default environment in boot.img, do not set bootargs
environment in U-Boot.

如果烧写错误、也可以通过U-boot命令修改启动参数,方法如下:

# 1). Booting with single LVDS-to-HDMI/MIPI-to-HDMI/MIPI panel or dual LVDS-to-HDMI display:
U-Boot > setenv bootargs console=ttyLP0,115200 earlycon=lpuart32,0x5a060000,115200 init=/init \
         androidboot.console=ttyLP0 consoleblank=0 androidboot.hardware=freescale androidboot.fbTileSupport=enable \
         cma=800M@0x960M-0xe00M androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never
U-Boot > saveenv 

# 2). Booting with physical HDMI display:
U-Boot > setenv bootargs console=ttyLP0,115200 earlycon=lpuart32,0x5a060000,115200 init=/init \
androidboot.console=ttyLP0 consoleblank=0 androidboot.hardware=freescale androidboot.fbTileSupport=enable \
cma=1184M@0x960M-0xe00M androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never 
U-Boot > saveenv


#3). With the settings above, the Android platform does not start the shell console. To disable selinux, append
"androidboot.selinux=permissive" to the U-Boot's bootargs. Boot environment variables are as follows:

U-Boot > setenv append_bootargs androidboot.selinux=permissive
U-Boot > saveenv


To clear the bootargs environment being set and saved before, use the following command:
U-Boot > setenv bootargs
U-Boot > saveenv # Save the environments

在系统启动时、在 console 工具中(如:xShell),输入任意键将进入 U-boot 命令行模式,输入上面命令。

第五条 系统编译

5.1). 编译 kernel

$ export ARCH=arm64
$ export CROSS_COMPILE=/home/robot/android_build/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
$ make android_defconfig
$ make KCFLAGS=-mno-android

5.2). 编译 u-boot

$ cd android_build
$ source build/envsetup.sh
$ lunch mek_8q-userdebug
$ make bootloader -j4

5.3). 编译 boot

$ cd android_build
$ source build/envsetup.sh
$ lunch mek_8q-userdebug
$ make bootimage -j4

5.4). 编译 dtbo

$ cd android_build
$ source build/envsetup.sh
$ lunch mek_8q-userdebug
$ make dtboimage -j4

5.5). 编译 android

$ cd android_build
$ source build/envsetup.sh
$ lunch mek_8q-userdebug
$ make -j4

错误1

./security/selinux/include/classmap.h:245:2: error: #error New address family defined, please update secclass_map.
#error New address family defined, please update secclass_map.

解决错误方法:

1.找到错误中提示的.c文件,genheader.c文件和mdp.c文件
编辑,去掉两个文件的头部引用中的
#include <sys/socket.h>

2.找到错误提示中的classmap.h文件
a/security/selinux/include/classmap.h b/security/selinux/include/classmap.h
编辑classmap.h,在头文件中添加
#include <linux/socket.h>

错误2

orks/av/media/libstagefright/FslExtractor.o frameworks/av/media/libstagefright/FslExtractor.cpp
frameworks/av/media/libstagefright/FslExtractor.cpp:839:6: error: use of undeclared identifier 'AUDIO_DSD'; did you mean 'AUDIO_DTS'?
    {AUDIO_DSD,0,MEDIA_MIMETYPE_AUDIO_DSD},
     ^~~~~~~~~
     AUDIO_DTS
vendor/nxp/fsl-codec/ghdr/common/fsl_media_types.h:85:5: note: 'AUDIO_DTS' declared here
    AUDIO_DTS,
    ^
frameworks/av/media/libstagefright/FslExtractor.cpp:1999:21: error: use of undeclared identifier 'AUDIO_DSD'; did you mean 'AUDIO_DTS'?
    else if(type == AUDIO_DSD){
                    ^~~~~~~~~
                    AUDIO_DTS
vendor/nxp/fsl-codec/ghdr/common/fsl_media_types.h:85:5: note: 'AUDIO_DTS' declared here
    AUDIO_DTS,
    ^
2 errors generated.
[ 80% 54581/68084] //external/sqlite/dist:libsqlite clang sqlite3.c
ninja: build stopped: subcommand failed.
17:26:46 ninja failed with: exit status 1

#### failed to build some targets (01:20:21 (hh:mm:ss)) ####

解决办法:
直接修改libstagefright/FslExtractor.cpp 文件中,AUDIO_DSD 的宏定义为 AUDIO_DTS .

错误3

Server is already running
[ 12% 1679/13505] target  C++: libsurfaceflinger <= frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
FAILED: out/target/product/hikey960/obj/SHARED_LIBRARIES/libsurfaceflinger_intermediates/SurfaceFlinger_hwc1.o 
/bin/bash -c "PWD=/proc/self/cwd  prebuilts/clang/host/linux-x86/clang-4053586/bin/clang++   -I frameworks/native/vulkan/include -I external/vulkan-validation-layers/libs/vkjson -I system/libhwbinder/fast_msgq/include -I frameworks/native/services/surfaceflinger -I out/target/product/hikey960/obj/SHARED_LIBRARIES/libsurfaceflinger_intermediates -I out/target/product/hikey960/gen/SHARED_LIBRARIES/libsurfaceflinger_intermediates -I libnativehelper/include_deprecated \$(cat out/target/product/hikey960/obj/SHARED_LIBRARIES/libsurfaceflinger_intermediates/import_includes)  -I system/core/include -I system/media/audio/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I libnativehelper/include -I frameworks/native/include -I frameworks/native/opengl/include -I frameworks/av/include -isystem out/target/product/hikey960/obj/include -isystem bionic/libc/arch-arm64/include -isystem bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem bionic/libc/kernel/uapi/asm-arm64 -isystem bionic/libc/kernel/android/scsi -isystem bionic/libc/kernel/android/uapi -c  -fno-exceptions -Wno-multichar -fno-strict-aliasing -fstack-protector-strong -ffunction-sections -fdata-sections -funwind-tables -Wa,--noexecstack -Werror=format-security -D_FORTIFY_SOURCE=2 -fno-short-enums -no-canonical-prefixes -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast -Werror=implicit-function-declaration -DNDEBUG -O2 -g -Wstrict-aliasing=2 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -DNDEBUG -UDEBUG -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-expansion-to-defined -fdebug-prefix-map=\$PWD/= -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time -nostdlibinc -mcpu=cortex-a53 -target aarch64-linux-android -Bprebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/aarch64-linux-android/bin  -Wsign-promo -Wno-inconsistent-missing-override -Wno-null-dereference -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-thread-safety-negative -fvisibility-inlines-hidden -std=gnu++14   -fno-rtti -DLOG_TAG=\\\"SurfaceFlinger\\\" -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -fvisibility=hidden -Werror=format -Wall -Werror -Wunused -Wunreachable-code -std=c++1z -fPIC -D_USING_LIBCXX -DANDROID_STRICT   -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type   -MD -MF out/target/product/hikey960/obj/SHARED_LIBRARIES/libsurfaceflinger_intermediates/SurfaceFlinger_hwc1.d -o out/target/product/hikey960/obj/SHARED_LIBRARIES/libsurfaceflinger_intermediates/SurfaceFlinger_hwc1.o frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp"
frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp:2590:42: error: too few arguments to function call, expected 2, have 1
            if (layer->setMatrix(s.matrix))
                ~~~~~~~~~~~~~~~~         ^
frameworks/native/services/surfaceflinger/Layer.h:205:5: note: 'setMatrix' declared here
    bool setMatrix(const layer_state_t::matrix22_t& matrix, bool allowNonRectPreservingTransforms);
    ^
1 error generated.
[ 12% 1694/13505] target thumb C++: libsurfaceflinger_32 <= frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
FAILED: out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libsurfaceflinger_intermediates/SurfaceFlinger_hwc1.o 
/bin/bash -c "PWD=/proc/self/cwd  prebuilts/clang/host/linux-x86/clang-4053586/bin/clang++   -I frameworks/native/vulkan/include -I external/vulkan-validation-layers/libs/vkjson -I system/libhwbinder/fast_msgq/include -I frameworks/native/services/surfaceflinger -I out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libsurfaceflinger_intermediates -I out/target/product/hikey960/gen/SHARED_LIBRARIES/libsurfaceflinger_intermediates -I libnativehelper/include_deprecated \$(cat out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libsurfaceflinger_intermediates/import_includes)  -I system/core/include -I system/media/audio/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I libnativehelper/include -I frameworks/native/include -I frameworks/native/opengl/include -I frameworks/av/include -isystem out/target/product/hikey960/obj/include -isystem bionic/libc/arch-arm/include -isystem bionic/libc/include -isystem bionic/libc/kernel/uapi -isystem bionic/libc/kernel/uapi/asm-arm -isystem bionic/libc/kernel/android/scsi -isystem bionic/libc/kernel/android/uapi -c  -fno-exceptions -Wno-multichar -ffunction-sections -fdata-sections -funwind-tables -fstack-protector-strong -Wa,--noexecstack -Werror=format-security -D_FORTIFY_SOURCE=2 -fno-short-enums -no-canonical-prefixes -DNDEBUG -g -Wstrict-aliasing=2 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -DNDEBUG -UDEBUG -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-expansion-to-defined -fdebug-prefix-map=\$PWD/= -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time -nostdlibinc -msoft-float -mfloat-abi=softfp -mfpu=neon -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -D__ARM_FEATURE_LPAE=1 -target arm-linux-androideabi -Bprebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/arm-linux-androideabi/bin  -Wsign-promo -Wno-inconsistent-missing-override -Wno-null-dereference -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -Wno-thread-safety-negative -fvisibility-inlines-hidden -std=gnu++14 -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing  -fno-rtti -DLOG_TAG=\\\"SurfaceFlinger\\\" -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES -fvisibility=hidden -Werror=format -Wall -Werror -Wunused -Wunreachable-code -std=c++1z -fPIC -D_USING_LIBCXX -DANDROID_STRICT   -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type   -MD -MF out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libsurfaceflinger_intermediates/SurfaceFlinger_hwc1.d -o out/target/product/hikey960/obj_arm/SHARED_LIBRARIES/libsurfaceflinger_intermediates/SurfaceFlinger_hwc1.o frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp"
frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp:2590:42: error: too few arguments to function call, expected 2, have 1
            if (layer->setMatrix(s.matrix))
                ~~~~~~~~~~~~~~~~         ^
frameworks/native/services/surfaceflinger/Layer.h:205:5: note: 'setMatrix' declared here
    bool setMatrix(const layer_state_t::matrix22_t& matrix, bool allowNonRectPreservingTransforms);
    ^
1 error generated.
ninja: build stopped: subcommand failed.
17:37:46 ninja failed with: exit status 1
#### failed to build some targets (02:03 (mm:ss)) ####

修改方法:

frameworks/native/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
修改文件 2590 行,把入口参数 bool allowNonRectPreservingTransforms 设置为有效。
if (layer->setMatrix(s.matrix,true))  //> if (layer->setMatrix(s.matrix))

这篇文章记录的时候,没有记录驱动程序是具体哪个程序,我只记得安装过豌豆荚、不能确定了,尴尬-
另外需要注意的事、nxp网站需要个人注册账户,就可以下载资料。

下载文件报错

Fetching:  0% (0/603) warming up
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/connectivity/wificond/': The requested URL returned error: 502

platform/system/connectivity/wificond:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/connectivity/wificond/': The requested URL returned error: 502
platform/system/connectivity/wificond: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/connectivity/wificond/': The requested URL returned error: 502

platform/system/connectivity/wificond:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/connectivity/wificond/': The requested URL returned error: 502
error: Cannot fetch platform/system/connectivity/wificond from https://source.codeaurora.org/external/imx/aosp/platform/system/connectivity/wificond

fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/frameworks/base/': The requested URL returned error: 502

platform/frameworks/base:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/frameworks/base/': The requested URL returned error: 502
platform/frameworks/base: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/frameworks/base/': The requested URL returned error: 502

platform/frameworks/base:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/frameworks/base/': The requested URL returned error: 502
error: Cannot fetch platform/frameworks/base from https://source.codeaurora.org/external/imx/aosp/platform/frameworks/base

fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/external/tinyalsa/': The requested URL returned error: 502

platform/external/tinyalsa:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/external/tinyalsa/': The requested URL returned error: 502
platform/external/tinyalsa: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/external/tinyalsa/': The requested URL returned error: 502

platform/external/tinyalsa:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/external/tinyalsa/': The requested URL returned error: 502
error: Cannot fetch platform/external/tinyalsa from https://source.codeaurora.org/external/imx/aosp/platform/external/tinyalsa
Fetching:  1% (12/603) platform/packages/inputmethods/LatinIME
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/libvintf/': The requested URL returned error: 502

platform/system/libvintf:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/libvintf/': The requested URL returned error: 502
platform/system/libvintf: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/libvintf/': The requested URL returned error: 502

platform/system/libvintf:
fatal: unable to access 'https://source.codeaurora.org/external/imx/aosp/platform/system/libvintf/': The requested URL returned error: 502
error: Cannot fetch platform/system/libvintf from https://source.codeaurora.org/external/imx/aosp/platform/system/libvintf
Fetching:  4% (28/603) platform/art
fatal: unable to access 'https://source.codeaurora.org/external/imx/imx-lib/': The requested URL returned error: 502

imx-lib:
fatal: unable to access 'https://source.codeaurora.org/external/imx/imx-lib/': The requested URL returned error: 502
imx-lib: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://source.codeaurora.org/external/imx/imx-lib/': The requested URL returned error: 502

imx-lib:
fatal: unable to access 'https://source.codeaurora.org/external/imx/imx-lib/': The requested URL returned error: 502
error: Cannot fetch imx-lib from https://source.codeaurora.org/external/imx/imx-lib

fatal: unable to access 'https://source.codeaurora.org/external/imx/android-imx/platform/hardware/imx/': The requested URL returned error: 502

platform/hardware/imx:
fatal: unable to access 'https://source.codeaurora.org/external/imx/android-imx/platform/hardware/imx/': The requested URL returned error: 502
platform/hardware/imx: sleeping 4.0 seconds before retrying
fatal: unable to access 'https://source.codeaurora.org/external/imx/android-imx/platform/hardware/imx/': The requested URL returned error: 502

platform/hardware/imx:
fatal: unable to access 'https://source.codeaurora.org/external/imx/android-imx/platform/hardware/imx/': The requested URL returned error: 502
error: Cannot fetch platform/hardware/imx from https://source.codeaurora.org/external/imx/android-imx/platform/hardware/imx

```cpp
### 解决办法:
<1>. 配置git下载压缩
```cpp
git config --global core.compression -1

<2>. 增加git 下载缓存

git config --global http.postBuffer 10485760    //> 10GB

<3>. 配置git的最低速和最低速时间

git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 120         单位 秒

以上配置后,只有十分钟(120秒)传输速率都低于 0KB/s 的话才会 timeout,即时慢,也可以慢慢等啦。

参考链接: https://pingwuu.github.io/2021/05/10/android-on-imx8qxp-mek-board/