移植android3.3到ZedBoard
follow doc:Android移植Guide1.3.pdf
follow website: http://elinux.org/Zedboard_Android
(1)在Ubuntu12.04LTS下安装编译所需环境:
sudo apt-get install git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libglapi-mesa:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils xsltproc zlib1g-dev:i386 uboot-mkimage gparted screen
(2)下载和安装jdk:
从以下网址下载jdk-6u45-linux-i586.bin
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html
进入编译目录
chmod u+x jdk-6u45-linux-i586.bin ./jdk-6u45-linux-i586.bin mkdir -p /usr/lib/jvm mv jdk1.6.0_45 /usr/lib/jvm/ update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_45/bin/java" 1 update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_45/bin/javac" 1 update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_45/bin/javaws" 1 update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_45/jre/lib/i386/libnpjp2.so" 1 //若是64位版,路径为/usr/lib/jvm/jdk1.6.0_45/jre/lib/amd64/libnpjp2.so
update-alternatives --config java update-alternatives --config javac update-alternatives --config javaws update-alternatives --config mozilla-javaplugin.so
复制以下段落到~/.bashrc
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_45/
JRE_HOME=${JAVA_HOME}/jre
export ANDROID_JAVA_HOME=$JAVA_HOME
export CLASSPATH=.:${JAVA_HOME}/lib:$JRE_HOME/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export JAVA_HOME;
export JRE_HOME;
export CLASSPATH;
HOME_BIN=~/bin/
export PATH=${PATH}:${JAVA_PATH}:${HOME_BIN};
(3)下载Linux 源
git clone https://github.com/Digilent/linux-digilent.git
(4)下载Android Kernel
git clone https://android.googlesource.com/kernel/common -b android-3.3
在疆目录下建立bin目录并将其添加到path环境变量,并下载REPO脚本
mkdir ~/bin export PATH=~/bin:$PATH curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
给repo加权限
chmod a+x ~/bin/repo cd YourWorkspace
新建repo疆目录,repo将安装在此目录下,然后安装最新的repo(在2M网速下可能需要1天或更久)
repo init -u https://android.googlesource.com/platform/manifest repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1 repo sync
准备BOOT.BIN(FSBL,SSBL,)。。。[Hardware Design Source folder]中有
wget http://www.digilentinc.com/Data/Products/ZedBoard/ZedBoard_Linux_Design.zip
解压后在sd_image目录下可以发现sd卡boot分区需要装载的所有文件
(5)kernel编译:
cd ~/android_for_zed
vi dev.sh
粘贴以下代码
#!/bin/bash
export CCOMPILER=arm-xilinx-linux-gnueabi-gcc
export ARCH=arm
export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
export PATH=$PATH:/root/CodeSourcery/bin/
其中CodeSourcery是交叉编译工具链,自行去xilinux,git
cd ~/android_for_zed/linux-digilent
make digilent_zed_defconfig
sudo apt-get install build-essential
sudo apt-get install libncurses5
apt-get install libncurses5-dev
make menuconfig
Linux运行情况测试:
(6)编译安卓:
打开USB OTG键盘输入功能:
cd ~/android_for_zed/frameworks/base/policy/src/com/android/internal/policy/impl
vi PhoneWindowManager.java
cd ~/android_for_zed
source build/envsetup.sh
lunch generic-eng
make
error solving:
apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib
ls /usr/bin/gcc* –l
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 50
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 50
update-alternatives --config gcc
sudo apt-get install libncurses5-dev:i386
错误找不到libGL库:
ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
编译成功:
(7)打包镜像
cd ~/android_for_zed/
vi Makefile.zynq
输入以下代码:
OUT_DIR:=out/target/product/generic
ROOT_IMG:=root.img
ROOTFS:=rootfs
ROOT_DIRS=lib/modules tmp media
.PHONY: dummy
$(ROOT_IMG): dummy
rm -rf $@
sudo rm -rf $(ROOTFS)
cp -r $(OUT_DIR)/root $(ROOTFS)
cp -r $(OUT_DIR)/system $(ROOTFS)
cd $(ROOTFS) && mkdir -p $(ROOT_DIRS)
sudo chown -R root:root $(ROOTFS)
sudo genext2fs -d $(ROOTFS) -b $$((80*1024)) -m 0 -N $$((64*1024)) $(ROOT_IMG)
sudo chown $(shell id -u):$(shell id -g) $(ROOT_IMG)
# Phony target forces the rootfs image file to be rebuilt on each make
dummy:
注意遵循Makefile语法,每行后面不能有空格,命令以Tab开头。
apt-get install genext2fs
make –f Makefile.zynq
这一步生成 root.img 文件系统镜像。
(8)准备运行
cd ~/android_for_zed/ready_to_download
gunzip ramdisk8M.image.gz
mkdir -p temp
mount ramdisk8M.image -o loop temp/
cd ~/android_for_zed/ready_to_download/temp/etc/init.d
vi rcS
echo "Mounting SD card to /mnt/sd"
mkdir -p /mnt/sd
mount /dev/mmcblk0p1 /mnt/sd
echo "++ Starting startup.sh script on SD card"
if [ -f /mnt/sd/startup.sh ]; then
./mnt/sd/startup.sh
fi
cd ~/android_for_zed/ready_to_download/
umount temp/
gzip ramdisk8M.image
vi startup.sh
粘贴下面的代码:
echo "++ Preparing for Android"
mkdir /mnt/root
mount -o loop /mnt/sd/root.img /mnt/root/
mount -t proc proc /mnt/root/proc
mount -t sysfs sys /mnt/root/sys
mount -t tmpfs tmp /mnt/root/data
mkdir -p /mnt/root/tmp/sd
mount /mnt/sd /mnt/root/tmp/sd
echo "++ Starting Android"
chroot /mnt/root /init
chmod 777 startup.sh
拷贝文件到SD卡:
BOOT.BIN | 来自硬件工程 |
devicetree.dtb | 来自硬件工程 |
ramdisk8m.image.gz | 修改自硬件工程 |
root.img | 安卓编译后产生 复制到sd卡ext分区 |
startup.sh | 刚写的 |
zImage | 来自linux内核编译 |
(9)运行问题解决方法
cp ~/android_for_zed/out/target/product/generic/obj/SHARED_LIBRARIES/gralloc.default_intermediates/LINKED/gralloc.default.so ~/android_for_zed/rootfs/system/lib/hw/
cd ~/android_for_zed/rootfs
vi vi init.rc
错误
zynq> chroot /mnt/root /init
[ 97.420000] init: cannot open '/initlogo.rle'
[ 97.480000] EXT4-fs (loop0): re-mounted. Opts: (null)
[ 97.500000] init (695): /proc/1/oom_adj is deprecated, please use /proc/1/oo.
[ 97.580000] init: cannot find '/system/bin/drmserver', disabling 'drm'
[ 97.630000] init: cannot find '/system/etc/install-recovery.sh', disabling ''
[ 97.790000] init: untracked pid 1099 exited
[ 97.790000] init: untracked pid 1100 exited
[ 97.800000] init: untracked pid 1106 exited
[ 97.800000] init: untracked pid 1107 exited
[ 102.830000] init: untracked pid 1121 exited
[ 102.840000] init: untracked pid 1131 exited
[ 102.850000] init: untracked pid 1128 exited
[ 102.850000] init: untracked pid 1129 exited
[ 107.870000] init: untracked pid 1141 exited
[ 107.870000] init: untracked pid 1142 exited
[ 107.880000] init: untracked pid 1147 exited
[ 107.880000] init: untracked pid 1149 exited
[ 112.900000] init: untracked pid 1159 exited
[ 112.910000] init: untracked pid 1160 exited
[ 112.910000] init: untracked pid 1165 exited
[ 117.940000] init: critical process 'servicemanager' exited 4 times in 4 minue
� 117.950000] Restarting system with command 'recovery'.
在回到make menuconfig步骤看看, 在common外make clean 后会覆盖前面的设置。
VGA(HDMI)
[Hardware Design Source folder]:/root/android_for_zed/ZedBoard_Linux_Design/
[Xillinux sources folder] : /root/android_for_zed/xillinux-eval-zedboard-1.2/
(5)下载 Xillinux sources :
wget http://www.xillybus.com/downloads/xillinux-eval-zedboard-1.2.zip cd ~/android_for_zed/ cp -r xillinux-eval-zedboard-1.2/system/pcores/xillyvga_v1_00_a/ ZedBoard_Linux_Design/hw/xps_proj/pcores/ cd ~/android_for_zed/ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a mkdir netlist
安装ISE14.4
用ISE打开~/android_for_zed/xillinux-eval-zedboard-1.2/runonce
regenerate core
完成后:
cd ~/android_for_zed/
cp xillinux-eval-zedboard-1.2/runonce/vga_fifo.v ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a/hdl/verilog/
cp xillinux-eval-zedboard-1.2/runonce/vga_fifo.ngc ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a/netlist/
cp xillinux-eval-zedboard-1.2/cores/xillyvga_core.ngc ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a/netlist/
cd ~/android_for_zed/ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a/data
vi xillyvga_v2_1_0.pao
加入一行lib xillyvga_v1_00_a vga_fifo verilog
cd ~/android_for_zed/ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a/hdl/verilog
vi xillyvga.v
最后加入一段
FDCE vga_iob_ff[13:0] (
.Q({vga_red, vga_green, vga_blue, vga_hsync, vga_vsync}),
.D({vga_red_app[7:4], vga_green_app[7:4], vga_blue_app[7:4], vga_hsync_app, vga_vsync_app}),
.C(vga_clk_app),
.CE(1'b1),
.CLR(1'b0)
);
在第69行修改
output [3:0] vga_blue,
output [3:0] vga_green,
output vga_hsync,
output [3:0] vga_red,
cd ~/android_for_zed/ZedBoard_Linux_Design/hw/xps_proj/pcores/xillyvga_v1_00_a/data/
vi xillyvga_v2_1_0.bbd
加入以下3行:
Files
#####
vga_fifo.ngc,xillyvga_core.ngc
vi xillyvga_v2_1_0.mpd
第90行那里,改三行:
PORT vga_red = "", DIR = O, VEC = [3:0]
PORT vga_green = "", DIR = O, VEC = [3:0]
PORT vga_blue = "", DIR = O, VEC = [3:0]
第7行后插入两行:
OPTION STYLE = MIX
OPTION RUN_NGCBUILDF = TRUE
用ISE的XPS打开~/android_for_zed/ZedBoard_Linux_Design/hw/xps_proj/system.xps如下图
点击BUS INTERFACE的TAB页
删除axi_hdmi_tx_16_b0, axi_iic_hdmi, axi_vdma_0共三项
打开system.mhs,修改152行去掉hdmi_int,
点IP Catalog ->Project local PCores ->User –> XILLYVGA
将VGA通过INTERCONNECT3链接到ZYNC,其他接线如图所示
点Ports->Xillvga_0,将如图所示几个端口MakeExernel
OK,Generate bitstream.
4 Prepare the kernel for Android
git log --pretty=oneline --format="%Cgreen%h %Creset%s" --grep="Linux 3.3." -n 20
显示20行:
7a84477 mtd: fix oops in dataflash driver
e2aa417 Merge tag 'v3.3-rc7' into gpio/next
fde7d90 Linux 3.3-rc7
192cfd5 Linux 3.3-rc6
d5a74af Merge tag 'iommu-fixes-v3.3-rc5' of git://git.kernel.org/pub/scm/linux/k
e0e5ce5 Merge branch 'imx/dt' of git://git.linaro.org/people/shawnguo/linux-2.6
a0008bf Merge branch 'lpc32xx/fixes-non-critical' of git://git.antcom.de/linux-2
f2273ec Merge branch 'lpc32xx/fixes' of git://git.antcom.de/linux-2.6 into fixes
a173fc6 Merge branch 'kirkwood/board' into next/boards
6b21d18 Linux 3.3-rc5
2daa79e Merge branch 'lpc32xx/drivers' into next/drivers
fa2c8f4 Merge tag 'v3.3-rc4' into for-3.4 in order to resolve the conflict resol
b01543d Linux 3.3-rc4
ffafe77 Merge branch 'v3.3-samsung-fixes-3' of git://git.kernel.org/pub/scm/linu
082f53c Merge branch 'for-arm-soc' of git://sources.calxeda.com/kernel/linux int
a08a499 Merge tag 'v3.3-rc3' as we've got several bugfixes in there which are co
d65b4e9 Linux 3.3-rc3
290436c Merge tag 'v3.3-rc2' into perf/core
177f72f Merge tag 'v3.3-rc2' into for-3.4
62aa2b5 Linux 3.3-rc2
以上源都含有Linux3.3.的字符
需要将patch放到Linux Kernel 顶层
git diff 192cfd5 HEAD > 3.3-rc6-to-Android.patch
有意个文件3.3-rc6-to-Android.patch出现在当前Linux根目录中了。
git apply --ignore-whitespace --ignore-space-change --check 3.3-rc6-to-Android.patch
git apply --ignore-whitespace --ignore-space-change --reject 3.3-rc6-to-Android.patch