安卓镜像构建指南

本文针对GDK8硬件介绍构建安卓镜像的基本步骤。

设置环境变量

./build/envstep.sh

lunch

box -> rk3328_box
atv -> rk3328

构建安卓内核

下载内核构建脚本:https://gedu.oss-cn-beijing.aliyuncs.com/build_kernel.sh

将build_kernel.sh放在kernel目录下
chmod +x build_kernel.sh
./build_kernel.sh

编译完成后,内核所在目录会生成 kernel.img,resource.img 两个镜像文件。

报错:

gcc: error: unrecognized command line option '-mlittle-endian'; did you mean '-fconvert=little-endian'?
scripts/Makefile.build:333: recipe for target 'scripts/mod/empty.o' failed
make[2]: *** [scripts/mod/empty.o] Error 1
scripts/Makefile.build:637: recipe for target 'scripts/mod' failed
make[1]: *** [scripts/mod] Error 2
make[1]: *** 正在等待未完成的任务....
  HOSTCC  scripts/selinux/mdp/mdp
  LEX     scripts/genksyms/lex.lex.c
  YACC    scripts/genksyms/parse.tab.h
  HOSTCC  scripts/dtc/data.o
  CC      kernel/bounds.s
  HOSTCC  scripts/dtc/livetree.o
  HOSTCC  scripts/genksyms/parse.tab.o
  HOSTCC  scripts/dtc/treesource.o
gcc: error: unrecognized command line option '-mlittle-endian'; did you mean '-fconvert=little-endian'?
Kbuild:21: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:1248: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
make: *** 正在等待未完成的任务....
  HOSTCC  scripts/dtc/srcpos.o
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/genksyms/lex.lex.o
  HOSTCC  scripts/dtc/util.o
  LEX     scripts/dtc/dtc-lexer.lex.c
  YACC    scripts/dtc/dtc-parser.tab.h
  YACC    scripts/dtc/dtc-parser.tab.c
  HOSTCC  scripts/dtc/dtc-parser.tab.o
  HOSTCC  scripts/dtc/dtc-lexer.lex.o
  HOSTLD  scripts/genksyms/genksyms
  HOSTLD  scripts/dtc/dtc
Makefile:1214: recipe for target 'scripts' failed
make: *** [scripts] Error 2

解决方案:

sudo apt-get install gcc-aarch64-linux-gnu
export CROSS_COMPILE=aarch64-linux-gnu-

打包镜像

由于安卓内没有dd命令,因此把kernel.img单独烧录到GDK8内,并不是太方便;因此采取打包完整镜像后,再进行烧录的策略。
下载GDK8镜像制作包:

tar -xvf tar -xvf gdk8_image_make.tar.gz
cd gdk8_image_make
将内核中编译出来的*.img文件复制到gdk8_image_make/Image/目录下
./mkupdate_rk3328.sh
geduer@gdk:~/gdk8_image_make$ ls
afptool  Image  mkupdate_rk3328.sh  package-file-box  rkImageMaker
geduer@gdk:~/gdk8_image_make$ ./mkupdate_rk3328.sh
start to make update.img...
Android Firmware Package Tool v1.67
------ PACKAGE ------
Add file: ./package-file
package-file,Add file: ./package-file done,offset=0x800,size=0x2af,userspace=0x1
Add file: ./Image/MiniLoaderAll.bin
bootloader,Add file: ./Image/MiniLoaderAll.bin done,offset=0x1000,size=0x2e94e,userspace=0x5e
Add file: ./Image/parameter.txt
parameter,Add file: ./Image/parameter.txt done,offset=0x30000,size=0x2a2,userspace=0x1
Add file: ./Image/trust.img
trust,Add file: ./Image/trust.img done,offset=0x30800,size=0x400000,userspace=0x800
Add file: ./Image/uboot.img
uboot,Add file: ./Image/uboot.img done,offset=0x430800,size=0x400000,userspace=0x800
Add file: ./Image/misc.img
misc,Add file: ./Image/misc.img done,offset=0x830800,size=0xc000,userspace=0x18
Add file: ./Image/boot.img
boot,Add file: ./Image/boot.img done,offset=0x83c800,size=0x2379800,userspace=0x46f3
Add file: ./Image/dtbo.img
dtbo,Add file: ./Image/dtbo.img done,offset=0x2bb6000,size=0x25f,userspace=0x1
Add file: ./Image/vbmeta.img
vbmeta,Add file: ./Image/vbmeta.img done,offset=0x2bb6800,size=0x1000,userspace=0x2
Add file: ./Image/recovery.img
recovery,Add file: ./Image/recovery.img done,offset=0x2bb7800,size=0x2a98800,userspace=0x5531
Add file: ./Image/baseparameter.img
baseparameter,Add file: ./Image/baseparameter.img done,offset=0x5650000,size=0x100000,userspace=0x200
Add file: ./Image/super.img
super,Add file: ./Image/super.img done,offset=0x5750000,size=0x4c665380,userspace=0x98ccb
Add CRC...
Make firmware OK!
------ OK ------
********RKImageMaker ver 1.66********
Generating new image, please wait...
Writing head info...
Writing boot file...
Writing firmware...
Generating MD5 data...
MD5 data generated successfully!
New image generated successfully!
Making update.img OK.
geduer@gdk:~/gdk8_image_make$