在ubuntu 14.04上使用GParted软件将SD卡分为两个区,
一个为fat32 BOOT区,用于放boot.bin, Image, system.dtb文件
另一个为ext4格式rootfs区,用于放文件系统
编译器做准备,armv8需要aarch64 toolchain,
sudo apt-get install gcc-aarch64-linux-gnu
设置环境变量
export CROSS_COMPILE=aarch64-linux-gnu-
uboot下载2017.2版本,按默认编译,生成u-boot.elf
https://github.com/Xilinx/u-boot-xlnx/releases
make xilinx_zynqmp_zcu102_config
make
建一个bootgen.bif文件,
the_ROM_image:
{
[fsbl_config] a53_x64
[pmufw_image] pmufw.elf
[bootloader] zynqmp_fsbl.elf
[destination_device=pl] design_1_wrapper.bit
[, destination_cpu=a53-0,exception_level=el-3,trustzone] bl31.elf
[, destination_cpu=a53-0,exception_level=el-2] u-boot.elf
}
其余的文件从wiki上直接下载,
http://www.wiki.xilinx.com/Zynq+Releases
建一个boot.bat文件,生成boot.bin文件
@call G:\Xilinx\SDK\2017.2\settings64.bat
bootgen -arch zynqmp -image bootgen.bif -o BOOT.BIN -w on
linux同样选择2017.2版本,建议下载tar.gz压缩格式,按默认编译,生成Image文件,
https://github.com/Xilinx/linux-xlnx/releases
make ARCH=arm64 xilinx_zynqmp_defconfig
make ARCH=arm64
system.dtb直接从wiki上下载,修改bootargs部分,这样可以从SD卡加载文件系统
bootargs = "earlycon root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait clk_ignore_unused";
至此已经有了boot.bin,Image,system.dtb,下面介绍文件系统的制作过程。
下载ubuntu的rootfs,
http://www.armhf.com/download/
ubuntu-trusty-14.04-armhf.com-20140603.tar.xz
解压,并将文件夹重命名为ubuntu-rootfs
xz -d ~/*.tar.xz | sudo tar --numeric-owner -xvf .
由于后面要chroot到此文件系统运行,而此文件系统中的可执行文件都是armhf版本的binary,所以需要安装qemu static解释器
sudo apt-get install qemu-user-static
cp /usr/bin/qemu-arm-static ubuntu-rootfs/usr/bin/
将本机的dns配置复制到目标rootfs,后面联网时会用到
cp -b /etc/resolv.conf ubuntu-rootfs/etc/resolv.conf
在chroot之前,需要做些准备工作,挂载一些文件系统
sudo bash ch-mount.sh -m ubuntu-rootfs/
ch-mount脚本内容如下,
#!/bin/bash
#
function mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
function umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or both parameters were missing"
echo ""
echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
echo ""
echo "For example: ch-mount -m /media/sdcard/"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : ${2}
fi
chroot成功后,切换到ubuntu-rootfs文件系统,
可以为root设一个密码
添加ubuntu用户
adduser ubuntu
usermod -aG adm,cdrom,sudo,plugdev ubuntu
设置主机名称:
echo "ubuntu-arm" > /etc/hostname
设置本机入口ip:
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.1.1 ubuntu-arm" >> /etc/hosts
允许自动更新dns:
dpkg-reconfigure resolvconf
设置时区:
dpkg-reconfigure tzdata
网络设置
echo "auto lo" > /etc/network/interfaces.d/lo
echo "iface lo inet loopback" >> /etc/network/interfaces.d/lo
echo "auto eth0" > /etc/network/interfaces.d/eth0
echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
默认情况下ZCU102使用的串口为ttyPS0,
echo "start on stopped rc or RUNLEVEL=[12345]" > /etc/init/ttyPS0.conf
echo "stop on runlevel [!12345]" >> /etc/init/ttyPS0.conf
echo "respawn" >> /etc/init/ttyPS0.conf
echo "exec /sbin/getty -L 115200 ttyPS0 vt102" >> /etc/init/ttyPS0.conf
安装软件包
apt-get update
apt-get -y install gcc
apt-get -y install g++
apt-get -q=2 -y install python-software-properties
apt-get -y install make
apt-get install\
language-pack-en-base \
sudo \
ssh \
net-tools \
ethtool \
wireless-tools \
ifupdown \
network-manager \
iputils-ping \
rsyslog \
bash-completion \
htop \
--no-install-recommends
然后exit退出chroot,执行sudo bash ch-mount.sh -u ubuntu-rootfs/
最后将做好的文件系统同步到SD卡的ext4分区
sudo rsync -avSH /home/telantan/ubuntu-rootfs/* /media/telantan/rootfs
SD卡启动,发现在init过程中出了问题,
解决办法是删除对应的conf文件,一共三个文件plymouth-upstart-bridge.conf, ureadahead.conf, ureadahead_other.conf
再次启动,如果网络hdcp时间过长,可考虑static IP,
修改static IP方法如下
vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
ubuntu用户登录