概述
一:车机系统框架
MCU 功能
电源控制
Radio 控制(RDS)
按键检测(Panel/Remote/SW)
常见信号检查(倒车/大灯/刹车)
CAN 模块通讯
ARM-MCU 通讯
进出碟控制
翻转马达系统
屏驱(此种情况倒车一般用 mcu 控制)
AMR 功能
wifi 、BT、 gps、3/4G
显示、触摸
多媒体播放(SD 卡、U 盘)
倒车显示
语音
AUX
胎压、DVR、CMMB
CVBS 输出(后排输出)
二:安卓启动流程
第一阶段:Android 设备上电后,首先会从处理器片上 ROM 的启动引导代码开始执行,片上 ROM 会寻找 Bootloader
代码,并加载到内存。(这一步由“芯片厂商”负责设计和实现)
第二阶段:Bootloader 开始执行,首先负责完成硬件的初始化,然后找到 Linux 内核代码,并加载到内存。(这一
步由“设备厂商”负责设计和实现)
第三阶段:Linux 内核开始启动,初始化各种软硬件环境,加载驱动程序,挂载根文件系统,并执行 init 程序,
由此开启 Android 的世界。(这一步则是 Android 内核开发过程中需要涉及的地方)
init 程序最核心的工作主要有 3 点:
(1) 创建和挂载一些系统目录/设备节点,设置权限,如:/dev, /proc, and /sys
(2) 解析 init.rc 和 init..rc,并启动属性服务,以及一系列的服务和进程。
(3) 显示 boot logo,默认是“Android”字样
第四阶段:Zygote 进程、SystemServer 进程创建 Zygote 进程由 init 进程创建,SystemServer 进程由 Zygote 创建
第五阶段:订制的service 启动:例举包括以下服务( 添加的所有关键服务)
CBMService;
CanbusService;
McuService;
RadioService;
SettingService;
McuCBMService;
PandoraService;
SWCService;
第六阶段:启动完成阶段。当所有的服务都启动完毕后,SystemServer 会打印出“Making services ready”,然后
通过 ActivityManager 启动 Home 界面,并发送“ACTION_BOOT_COMPLETED”广播消息(到此真正看到了主界面)
三:代码结构
核心服务路径:autochipsframeworksbaseservicesjavacom…
APP 路径:autochipspackages
四:编译说明(AC8217平台代码而论)
全编译
1 . mbldenv.sh 导出编译需要的编译工具相关环境变量
2 . selfenv 拷贝 autochips 到相关目录主要拷贝以下目录:
3 . selfbuild
实际上 selfbuild 仅是 autochipsbuildbuild.all 脚本的符号链接。在没有参数的情况下,selfbuild 会依次执行 build.env,
build.uboot,build.kernel,build.driver,build.arm2,build.android,build.otapackage,build.makeimage 这 7 个 sh 脚本。
相当分步执行以下:(当要单独编译部分时可以单独以下某句命令方法)
1.source./build.env设置编译环境2../selfbuild uboot 编译 uboot
3../selfbuilddriver编译ATC的driver4../selfbuild kernel 编译 linux kernel
5../selfbuildarm2编译arm26../selfbuild android 编译 android
7.$./selfbuild makeimage 生成最后需要烧写到板子上的 Image( 把多余的 apk 删除同时打包镜像)
模块编译
1 : 用 mm 或 mmm 编译相应模块
2: . selfbuild makeimage 生产镜像
附上编译脚本片段代码:
**
mbldenv.sh脚本文件
**
!/bin/bash
#
ALPS(Android4.1 based) build environment profile setting
#
Overwrite JAVA_HOME environment variable setting if already exists
PATH=/mtktools/mtk-toolchain/gnuarm-4.2.1/image-tools:PATHPATH=/mtktools/mtk−toolchain/gnuarm−4.4.1/cross−tools/usr/local/bin:PATH
PATH=/mtktools/mtk-toolchain/vfp_4.5.1_2.6.27_cortex-a9-rhel4_002/i686/bin:PATHANTHOME=/usr/local/antexportANTHOMEexportMTKJAVAHOME=”/usr/local/jdk1.6.032”exportPATH=MTK_JAVA_HOME/bin:ANTHOME/bin:PATH
export ANDROID_JAVA_HOME=MTKJAVAHOMEexportANDROIDJAVATOOLCHAIN=MTK_JAVA_HOME/bin/
export JAVA_HOME=MTKJAVAHOMEexportJREHOME={JAVA_HOME}/jre
export CLASSPATH=.:JAVAHOME/lib:{JRE_HOME}/lib
export PATH
unset USERNAME
SKIN1: SKIN2:
export SKIN=Skin2
selfenv脚本文件:
!/bin/sh
export ANDROID4=pwd
export ANDROID_SRC=ANDROID4exportKERNELSRC=ANDROID4/kernel
export KERNELDIR=KERNELSRC/exportAUTOCHIPSDIR=ANDROID4/autochips
export DRIVERS_DIR=AUTOCHIPSDIR/protect/platform/kernel/driversexportPUBLICDRIVERSDIR=AUTOCHIPS_DIR/platform/kernel/drivers
export DRIVERS_INC=AUTOCHIPSDIR/platform/kernel/drivers/incexportARM2SRC=AUTOCHIPS_DIR/platform/arm2
export DISPLAY_HARDWARE_INC=AUTOCHIPSDIR/hardware/atc/displayexportUBOOTSRC=AUTOCHIPS_DIR/platform/uboot
export SCRIPT_DIR=AUTOCHIPSDIR/buildexportANDROIDOUTPUT=ANDROID_SRC/out
export DRIVERS_OUTPUT=AUTOCHIPSDIR/platform/kernel/drivers/outputexportDRIVERSLIB=AUTOCHIPS_DIR/platform/kernel/drivers/lib
export AUTOCHIPS_TOOL=AUTOCHIPSDIR/toolsexportRELEASEFOLDERNAME=ANDROID4/image_release
export BOARD_CFG_FILE=$AUTOCHIPS_DIR/device/atc/ac8317/BoardConfig.mk
export PATH=ANDROIDSRC/autochips/external/gstreameraggregate/bin/:AUTOCHIPS_TOOL:$PATH
export JOB_NUM=grep processor /proc/cpuinfo |wc -l
export CHIP_VER=8317
find AUTOCHIPSDIR/device/atc/ac8317/.overlay/build/−typef|xargstouchcp−ruafAUTOCHIPS_DIR/device/atc/ac8317/.overlay/build/* $ANDROID_SRC/build/
copy /autochips/kernel/includeto/kernel/include
find AUTOCHIPSDIR/kernel/include−typef|xargstouchcp−ruafAUTOCHIPS_DIR/kernel/include/* $ANDROID_SRC/kernel/include/
INPUT_PARAM=$*
function check_parameter()
{
if [ ! -z “echo "$INPUT_PARAM" | grep eng
” ];then
echo “eng”
elif [ ! -z “echo "$INPUT_PARAM" | grep userdebug
” ];then
echo “userdebug”
elif [ ! -z “echo "$INPUT_PARAM" | grep user
” ];then
echo “user”
else
echo “eng”
fi
}
retval=check_parameter $*
source ANDROIDSRC/build/envsetup.shretval
INPUT_PARAM=INPUTPARAM/eng/INPUTPARAM={INPUT_PARAM/userdebug/}
INPUT_PARAM=INPUTPARAM/user/INPUTPARAM=(echo $INPUT_PARAM)
lunch
if [ ! -z “echo "$INPUT_PARAM" | grep ?
” ];then
lunch
else
lunch 5
fi
echo “env [$retval] setup completed!!!”
selfbuild脚本文件:
!/bin/sh
{
if [ -z which androidq
];then
#echo "no androidq, source bash_profile"
- 1
- 2
source ~/.bash_profile
source ~/.bashrc
fi
if [ ! -z which androidq
];then
echo “androidq ok, build with it”
ANDROIDQ=androidq
else
echo “no androidq, build without it”
ANDROIDQ=
fi
INPUT_PARA=$*
Copy Overlay folder to original
if [ ! -z “echo "$INPUT_PARA" | grep cpoverlay
” ];then
SCRIPTDIR/build.INPUT_PARA
exit 0
fi
process android version: user, userdebug, eng
if [ ! -z “echo "$INPUT_PARA" | grep eng
” ];then
export ANDROID_VER=eng
elif [ ! -z “echo "$INPUT_PARA" | grep userdebug
” ];then
export ANDROID_VER=userdebug
elif [ ! -z “echo "$INPUT_PARA" | grep user
” ];then
export ANDROID_VER=user
else
export ANDROID_VER=eng
fi
INPUT_PARA=INPUTPARA/eng/INPUTPARA={INPUT_PARA/userdebug/}
INPUT_PARA=INPUTPARA/user/INPUTPARA=(echo $INPUT_PARA)
source autochips/build/build.env $ANDROID_VER
echo “export env: ANDROID4=ANDROID4”if[!−dAUTOCHIPS_DIR -o -z $AUTOCHIPS_DIR ];then
echo “export some env var error, exit”
exit 1
fi
ALLIMAGES=”uboot kernel driver arm2 android otapackage makeimage clean cts”
check if para is nand
if [ ! -z “echo "$INPUT_PARA" | grep nand
” ];then
export AC83XX_BOOT_DEVICE=nand
elif [ ! -z “echo "$INPUT_PARA" | grep sd2
” ];then
export AC83XX_BOOT_DEVICE=sd2
else
export AC83XX_BOOT_DEVICE=mmc
fi
remove mmc para
INPUT_PARA=INPUTPARA/nand/INPUTPARA={INPUT_PARA/sd2/}
INPUT_PARA=(echoINPUT_PARA)
echo “AC83XX_BOOT_DEVICE :$AC83XX_BOOT_DEVICE”
check if it is release build, debug build by default
if [ ! -z “echo "$INPUT_PARA" | grep debug
” ];then
export RELEASE_BUILD=false
echo “build for debug”
else
export RELEASE_BUILD=true
echo “build for release”
fi
remove release or debug if it has
INPUT_PARA={INPUT_PARA%release}
INPUT_PARA={INPUT_PARA%debug}
INPUT_PARA=(echoINPUT_PARA)
if [ -z “INPUTPARA”];thenIMAGELIST=”ubootkerneldriverarm2androidotapackagemakeimage”exportBUILDALL=trueecho“noparam,default:IMAGE_LIST”
echo -e “ 33[31m delete out(ANDROIDOUTPUT)folder?(y/n)