Porting Linux for Zynq
U-Boot on Zynq
References
[1] - Build U-Boot - xilinx-wiki.atlassian.net
Build U-Boot for Zedboard
Tiến hành build u-boot cho chip Zynq7000 trên Zedboard theo hướng dẫn từ xilinx-wiki.atlassian.net - Build U-Boot.
Quá trình build U-Boot cho một thiết bị Zynq7000 có thể tiến hành bằng cách sử dụng bộ công cụ Petalinux của Xilinx. Thử nghiệm này sẽ trực tiếp build U-Boot từ mã nguồn cung cấp bởi Xilinx từ Github bằng compiler cung cấp bởi Xilinx SDK.
make
U-Boot
Tiến hành theo các bước hướng dẫn trong [1], tiến hành fetch source code, cấu hình và make U-Boot.
> git clone https://github.com/Xilinx/u-boot-xlnx.git
> cd u-boot-xlnx
> export CROSS_COMPILE=arm-linux-gnueabihf-
> export ARCH=arm
> source <SDK setting.sh file> // khai báo arm-linux-gnueabihf compiler
> make distclean
> make zynq_zed_defconfig
> make
Kết quả build là file u-boot.elf
. File này có thể tiến hành chạy thử nghiệm bằng phương pháp sử dụng XSCT được mô tả ở phần Zedboard
.
Nhận xét
- Compiler sử dụng cho build U-Boot là họ chương trình: arm-linux-gnueabihf-*. Ví dụ gcc được định nghĩa tại [SDX Installation Dir]/SDK/2018.2/gnu/aarch32/lin/gcc-arm-linux-gnueabi/bin/arm-linux-gnueabihf-gcc.
zynq_zed_defconfig
là bộ cấu hình dành riêng cho board zed. Các phần cứng khác sẽ có bộ cấu hình tương tự, ví dụzynq_zc706_defconfig
cho ZC706.
Linux Kernel
Quá trình thực hiện được tham khảo từ hướng dẫn chi tiết Build kernel của Xilinx.
Xilinx duy trì một github repository chứa source code Linux kernel. Quá trình build Linux kernel từ mã nguồn này tương đối đơn giản. Cần lưu ý một số điểm quan trọng như sau:
- Quá trình build kernel sử dụng họ compiler arm-linux-gnueabihf, do đó cần cấu hình
export CROSS_COMPILE=arm-linux-gnueabihf-
- Tại source code của Linux kernel thực hiện những bước sau:
> make ARCH=arm xilinx_zynq_defconfig
> make ARCH=arm menuconfig
> make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage
- Kết quả build kernel được lưu tại: [Linux source]/arch/arm/boot/ bao gồm các nội dung như dưới đây. Trong đó quan trọng nhất là Image, uImage, zImage.
drwxrwxr-x 2 vutt6 vutt6 4096 Feb 15 00:53 bootp
drwxrwxr-x 2 vutt6 vutt6 4096 Mar 4 15:21 compressed
-rwxr-xr-x 1 vutt6 vutt6 1805 Feb 15 00:53 deflate_xip_data.sh
drwxrwxr-x 2 vutt6 vutt6 73728 Feb 15 00:53 dts
-rwxrwxr-x 1 vutt6 vutt6 10662592 Mar 4 15:21 Image
-rw-rw-r-- 1 vutt6 vutt6 1648 Feb 15 00:53 install.sh
-rw-rw-r-- 1 vutt6 vutt6 3128 Feb 15 00:53 Makefile
-rw-rw-r-- 1 vutt6 vutt6 4160040 Mar 4 15:21 uImage
-rwxrwxr-x 1 vutt6 vutt6 4159976 Mar 4 15:21 zImage
uImage sẽ được sử dụng cho quá trình đóng gói boot.bin.
Device Tree
Build Device Tree Blob - Xilinx.
Trong hướng dẫn của Xilinx hướng dẫn nhiều cách để build device tree cho một thiết bị Zynq.
Generate Device Tree bằng HSM/HSI
Khởi động HSM bằng command hsm
, trong đó HSM là một công cụ tích hợp trong SDK của Xilinx. Quá trình generate bằng HSM được thực hiện tuần tự trong hướng dẫn của Xilinx (tại đây).
Tổng hợp DTB bằng công cụ dtc
Device tree được generate dưới dạng các file dts/dtsi. Công cụ dtc
(Device tree compiler) hỗ trợ compiling từ dạng dtsi/dts sang dtb. Cú pháp compile như sau:
dtc -I dts -O dts -o system.dtb system.dts
Lưu ý rằng dtc
cũng hỗ trợ quá trình dịch ngược từ dtb -> dts.
Build rootfs
http://xilinx.wikidot.com/zynq-rootfs
Create boot image
Sử dụng công cụ bootgen tích hợp trong Xilinx SDK.
Tool for package images
mkimage - Generate image for U-Boot
The mkimage command is used to create images for use with the U-Boot boot loader. Thes eimages can contain the linux kernel, device tree blob, root file system image, firmware images etc., either separate or combined.
mkimage is used in Petalinux 2017.4 at do_xilinx_fitimage:
uboot-mkimage -f fit-image.its fitImage
In do_image_cpio
, mkimage is used to packaged ramdisk file petalinux-user-image-plnx_arm-20190301083938.
cpio - copy files to and from archives
mke2fs - create an ext2/ext3/ext4 filesystem