Skip to content

Instantly share code, notes, and snippets.

@Scott31393
Last active June 9, 2020 13:31
Show Gist options
  • Save Scott31393/e6c022b1e3ca1c3eea5f1e1839eb661e to your computer and use it in GitHub Desktop.
Save Scott31393/e6c022b1e3ca1c3eea5f1e1839eb661e to your computer and use it in GitHub Desktop.

Android-Embedded-Porting-Note

Compile Kernel/U-Boot inside Android source tree

#After run this script clean kernel tree using:
#make clean
#make mrproper

export ARCH=arm64
export CROSS_COMPILE=../../../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

echo "Using toolchain:"
echo ""
echo ""
echo ${CROSS_COMPILE}
echo ""
echo "---------------------------------------------------------------------------------------------------------------------------"

make android_defconfig
make -j20 dtbs 

echo ""
echo "---------------------------------------------------------------------------------------------------------------------------"
echo ""

Setup NXP Android env

export AARCH64_GCC_CROSS_COMPILE=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-elf/bin/aarch64-elf-
export MY_ANDROID=`pwd`/imx-android-10.0.0_1.0.0/
. build/envsetup.sh
lunch 

Compile Commands

Building entire Android Image

./imx-make.sh -j20 2>&1 | tee build-log.txt

Building U-Boot images

./imx-make.sh bootloader -j4

Building a kernel image

./imx-make.sh kernel -c -j4

Building boot.img

make bootimage -j4

Building dtbo.img

make dtboimage -j4

mfgtool script to Flash Android from out dir (imx8x)

# These commands will be run when use SPL and will be skipped if no spl
# SDPU will be deprecated. please use SDPV instead of SDPU
# {
SDPU: delay 1000
SDPU: write -f u-boot-imx8qxp-mek-uuu.imx -offset 0x57c00
SDPU: jump
# }

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f u-boot-imx8qxp-mek-uuu.imx -skipspl
SDPV: jump
# }

FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f u-boot-imx8qxp-mek-uuu.imx
FB: ucmd mmc write $fastboot_buffer 0x40 0x8000

FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev 0
FB: ucmd mmc dev 0
FB: ucmd mmc dev 0 0
FB: ucmd mmc erase 0x2000 0x10
FB: ucmd mmc partconf 0 1 1 1
FB: flash bootloader0 u-boot-imx8qxp.imx
FB: flash gpt partition-table.img
FB: ucmd setenv fastboot_dev sata
FB: ucmd setenv fastboot_dev mmc
FB: flash dtbo_a dtbo-imx8qxp.img
FB: flash boot_a boot.img
FB: flash system_a system.img
FB: flash vendor_a vendor.img
FB: flash product_a product.img
FB: flash vbmeta_a vbmeta-imx8qxp.img
FB[-t 600000]: erase misc
FB[-t 600000]: erase presistdata
FB[-t 600000]: erase fbmisc
FB: set_active a
FB: ucmd mmc partconf ${emmc_dev} 0 0 0
FB: Done

Reset the board and use following command (for single channel display, debug console=ttyLP0):

setenv bootargs console=ttyLP0,115200 earlycon=lpuart32,0x5a060000,115200 init=/init androidboot.console=ttyLP0 androidboot.hardware=freescale androidboot.fbTileSupport=enable cma=800M@0x960M-0xe00M androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never androidboot.wificountrycode=IT androidboot.lcd_density=213
saveenv
setenv append_bootargs androidboot.selinux=permissive
saveenv

Reset the board and use following command (for single channel display, debug console=ttyLP2):

setenv bootargs console=ttyLP2,115200 earlycon=lpuart32,0x5a080000,115200 init=/init androidboot.console=ttyLP2 androidboot.hardware=freescale androidboot.fbTileSupport=enable cma=800M@0x960M-0xe00M androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never androidboot.wificountrycode=IT androidboot.lcd_density=213
saveenv
setenv append_bootargs androidboot.selinux=permissive
saveenv

Then boot from android a partition:

boota

For dual channel display:

setenv bootargs console=ttyLP0,115200 earlycon=lpuart32,0x5a060000,115200 init=/init androidboot.console=ttyLP0 androidboot.hardware=freescale cma=800M@0x960M-0xe00M androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never androidboot.primary_display=imx-drm firmware_class.path=/vendor/firmware transparent_hugepage=never
saveenv
setenv append_bootargs androidboot.selinux=permissive
saveenv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment