Compile Bootloader
Ubuntu open system terminal, enter Bootloader directory, to extract the U-boot source directory u-boot-xlnx
$ cd <WORK>/Bootloader
$ tar -jxvf u-boot-xlnx.tar.bz2
Virtual machine directly extracted to here, and then into the folder
$ cd u-boot-xlnx
Start compiling
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- zynq_myd_config
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-
zynq_myd_config is the core board configuration file
Take some time to compile, subsystems longer than the virtual machine build time. After compilation, in the current directory will generate "u-boot" ELF file. When you use this mirroring boot.bin needs to be renamed as "u-boot.elf":
cp u-boot ../u-boot.elf
The u-boot.elf file to <WORK> / sd_image / boot_build directory
Delete Package u-boot-xlnx.tar.bz2
Compile the Linux kernel
Kernel into the directory, extract the kernel source:
$ cd <WORK>/Kernel
$ tar -jxvf linux-xlnx.tar.bz2
Virtual machines can be directly extracted, and then into the folder
$ cd linux-xlnx
Start the compilation:
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- distclean
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- zynq_myd_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- uImage
$ make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- dtbs
I need to compile machines in a virtual machine for about seven minutes, but in a very long time Linux compiler subsystem (eventually gave compiled, estimated to be the cause of 64-bit systems with 32-bit emulator to run). After compilation, the Linux kernel image file generated uImage at arch / arm / boot directory; in arch / arm / boot / dts / file tree generation device zynq-myd.dtb, these two files are copied to <WORK> / sd_image directory and rename the file to the device tree devicetree.dtb
linux-xlnx the root directory of the drive that contains the Linux kernel and the device tree, the development process needs to be added, modified. After completing the drive, add the drive information to arch / arm / configs / zynq_myd_defconfig file, and then make again again (do not need distclean)
Delete Package linux-xlnx.tar.bz2
QT build the root file system
Buildroot use to build the root file system. First, enter the file system Filesystem directory, extract buildroot Source:
$ cd <WORKDIR>/Filesystem
$ tar -jxvf buildroot-2015.02.tar.bz2
$ cd buildroot-2015.02
Copy the files in the directory zynq_myd_config new .config file (to show hidden files):
$ cp zynq_myd_config .config
Configuration buildroot:
$ make menuconfig
Set cross compiler tool path:
Toolchain --->
() Toolchain path
进入Toolchain path 选项,填入编译器路径:
<WORK>/Toolchain/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux
修改保存后退出配置,开始编译:
$ make
编译耗时非常长,大约1小时 ,等待!编译完成之后将在“buildroot-2015.02/output/images”目录内生产rootfs.tar 文件 ,将rootfs.tar文件移动到<WORK>/sd_image目录
删除包buildroot-2015.02.tar.bz2
修改根文件系统
- 拆解rootfs包(只需要做一次),虚拟机不要直接解压提取(非root)
$ cd <WORK>/sd_image
$ mkdir -p rootfs
$ sudo tar xvf rootfs.tar -C ./rootfs/
- 修改文件夹,加入新文件。添加用户应用程序及各种功能,如vsftpd(参考其他技术文档)
- 打包tar
$ cd ./rootfs
$ sudo tar cvf ../rootfs.tar ./*
在<WORK>/sd_image目录将生成更新的rootfs.tar文件
修改 Ramdisk 文件系统
Ramdisk 主要作为烧写QSPI,eMMC 时使用。
(1) 挂载Ramdisk
新建目录tmp,并将uramdisk.image.gz 拷贝至该目录
$ cd <WORK>/Filesystem
$ mkdir tmp
$ cp uramdisk.image.gz tmp/
$ cd tmp/
去掉mkimage 生成的64 bytes 的文件头,生成新的ramdisk.image.gz
$ dd if=uramdisk.image.gz of=ramdisk.image.gz bs=64 skip=1
gunzip 解压ramdisk.image.gz 生成 ramdisk.image
$ gunzip ramdisk.image.gz
新建挂载目录“ramdiskdir”,并将ramdisk.image 挂载
$ mkdir -p ramdiskdir
$ sudo mount -o loop,rw ramdisk.image ramdiskdir
(2) 进入ramdiskdir目录,根据需要做修改。
移植vsftpd见上一篇
(3) 重新生成ramdisk
同步文件系统并卸载ramdisk
$ sync
$ sudo umount ramdiskdir
用gzip 压缩 ramdisk.image,生成 ramdisk.image.gz
$ gzip -9 ramdisk.image
用mkimage 添加文件头,生成新的 uramdisk.image.gz 供u-boot 使用
$ mkimage -A arm -T ramdisk -C gzip -n Ramdisk -d ramdisk.image.gz uramdisk.image.gz
删除临时文件 ramdisk.image.gz
$ rm ramdisk.image.gz
说明:也可以用unpackfs.sh 脚本来解压。把unpackfs.sh拷贝到uramdksi.image.gz 所在的目录下,执行命令:
$ ./unpackfs.sh uramdisk.image.gz
如提示sh文件没有权限,执行
$ chmod +x unpackfs.sh
该命令会将uramdisk.image.gz 解压并挂载到ramdiskdir 文件夹下。
如果用unpackfs.sh 脚本来解压,可以用packfs.sh脚本来打包。将packfs.sh 拷贝到uramdisk.image.gz 所在的目录下,执行命令打包:
$ ./packfs.sh
(4) 将uramdisk.image.gz文件拷贝到<WORK>/sd_image目录,删除tmp目录
本节结束。