使用Buildroot编译AMD/Xilinx Zynq ZC702 单板 Linux (内核和文件系统)
Buildroot 也是一个开源的嵌入式 Linux系统自动构建框架,由 Makefile 脚本和 Kconfig 配置文件构成,小而且快。
最近测试了Buildroot,使用它编译AMD/Xilinx Zynq ZC702 单板的Linux。整个过程非常顺利。编译出来的Linux (内核和文件系统)小巧,非常适合青春版设备使用。
Buildroot 2024及其以后版本的编译命令:
git clone -b 2024.02.13 https://gitlab.com/buildroot.org/buildroot.git
cd buildroot
make zynq_zc702_defconfig
make
如果使用Buildroot 2023,由于它缺少ZC702的默认配置,需要以ZC706的默认配置文件创建ZC702的默认配置文件。过程也很简单,复制ZC706的默认配置文件“zynq_zc706_deconfig”,改名为ZC702的默认配置文件“zynq_zc702_deconfig”,使用gedit打开zynq_zc702_deconfig,替换其中的2个字符串zc706为zc702。
Buildroot 2023及其以前版本的编译命令:
git clone -b 2023.02.11 https://gitlab.com/buildroot.org/buildroot.git
cd buildroot
cp configs/zynq_zc706_deconfig configs/zynq_zc702_defconfig
gedit configs/zynq_zc702_defconfig
-> Change Line 15 to: BR2_LINUX_KERNEL_INTREE_DTS_NAME="zynq-zc702"
-> Change Line 24 to: BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS="DEVICE_TREE=zynq-zc702"
make zynq_zc702_defconfig
make
编译完成后,在目录“output/images”下,有打包完成的能从SD卡启动的映像(image)文件。可以看到,内核(uImage)和文件系统(rootfs.ext2)都很小巧。
hankf@XSZGS4:buildroot-2024.02.13$ ls -l output/images/
total 48296
-rw-r--r-- 1 hankf hankf 134792 Aug 19 21:30 boot.bin
-rw-r--r-- 1 hankf hankf 33554432 Aug 19 21:32 boot.vfat
-rw-r--r-- 1 hankf hankf 117 Aug 19 21:32 extlinux.conf
-rw-r--r-- 1 hankf hankf 62914560 Aug 19 21:32 rootfs.ext2
lrwxrwxrwx 1 hankf hankf 11 Aug 19 21:32 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 hankf hankf 7280640 Aug 19 21:32 rootfs.tar
-rw-r--r-- 1 hankf hankf 96469504 Aug 19 21:32 sdcard.img
lrwxrwxrwx 1 hankf hankf 14 Aug 19 21:32 system.dtb -> zynq-zc702.dtb
-rw-r--r-- 1 hankf hankf 1039600 Aug 19 21:30 u-boot.bin
-rw-r--r-- 1 hankf hankf 1307188 Aug 19 21:30 u-boot.img
-rw-r--r-- 1 hankf hankf 4669824 Aug 19 21:32 uImage
-rwxr-xr-x 1 hankf hankf 17111 Aug 19 21:32 zynq-zc702.dtb
建议使用rufus烧写文件“sdcard.img”到SD卡,就能启动ZC702 单板。启动后,能看到Linux的运行信息,占用的DRAM(9.9M)和SD空间(6.2M),都很少。
# uname -a
Linux buildroot 6.1.30-xilinx #1 SMP PREEMPT Tue Aug 19 21:31:45 HKT 2025 armv7l GNU/Linux
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 51.1M 6.2M 40.6M 13% /
devtmpfs 493.6M 0 493.6M 0% /dev
tmpfs 502.1M 0 502.1M 0% /dev/shm
tmpfs 502.1M 20.0K 502.1M 0% /tmp
tmpfs 502.1M 16.0K 502.1M 0% /run
# free -h
total used free shared buff/cache available
Mem: 1004.2M 9.9M 991.1M 36.0K 3.1M 978.8M
Swap: 0 0 0
测试了 buildroot-2023.02.11, buildroot-2024.02.13,buildroot.2025.02.5, buildroot.git.2025.05.1, 所有版本都编译正常,工作正常。
编译的主机是Ubuntu 18.04。由于buildroot都自己配置工具,所以编译主机的操作系统应该没有影响。
完整的log如下:
U-Boot SPL 2023.01 (Aug 19 2025 - 21:30:02 +0800)
Silicon version: 0
Trying to boot from MMC1
spl_load_image_fat: error reading image uImage, err - -22
U-Boot 2023.01 (Aug 19 2025 - 21:30:02 +0800)
CPU: Zynq 7z020
Silicon: v0.0
Model: Xilinx ZC702 board
DRAM: ECC disabled 1 GiB
Core: 32 devices, 21 uclasses, devicetree: board
Flash: 0 Bytes
NAND: 0 MiB
MMC: mmc@e0100000: 0
Loading Environment from FAT... *** Error - No Valid Environment Area found
*** Warning - bad env area, using default environment
In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Net:
ZYNQ GEM: e000b000, mdio bus e000b000, phyaddr 7, interface rgmii-id
Warning: ethernet@e000b000 (eth0) using random MAC address - 3e:44:44:83:55:27
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Zynq> boot
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
1: linux
Retrieving file: /uImage
append: console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait
Retrieving file: /system.dtb
## Booting kernel from Legacy Image at 02000000 ...
Image Name: Linux-6.1.30-xilinx
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4669760 Bytes = 4.5 MiB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
## Flattened Device Tree blob at 01f00000
Booting using the fdt blob at 0x1f00000
Working FDT set to 1f00000
Loading Kernel Image
Loading Device Tree to 2fff8000, end 2ffff2d6 ... OK
Working FDT set to 2fff8000
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 6.1.30-xilinx (hankf@XSZGS4) (arm-buildroot-linux-gnueabihf-gcc.br_real (Buildroot 2024.02.13) 12.4.0, GNU ld (GNU Binutils) 2.40) #1 SMP PREEMPT Tue Aug 19 21:31:45 HKT 2025
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: Xilinx ZC702 board
Memory policy: Data cache writealloc
cma: Reserved 16 MiB at 0x3f000000
Zone ranges:
Normal [mem 0x0000000000000000-0x000000002fffffff]
HighMem [mem 0x0000000030000000-0x000000003fffffff]
Movable zone start for each node
Early memory node ranges
node 0: [mem 0x0000000000000000-0x000000003fffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000000003fffffff]
percpu: Embedded 12 pages/cpu s16788 r8192 d24172 u49152
Built 1 zonelists, mobility grouping on. Total pages: 260608
Kernel command line: console=ttyPS0,115200 root=/dev/mmcblk0p2 rw rootwait
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
mem auto-init: stack:all(zero), heap alloc:off, heap free:off
Memory: 1010880K/1048576K available (7168K kernel code, 249K rwdata, 1944K rodata, 1024K init, 120K bss, 21312K reserved, 16384K cma-reserved, 245760K highmem)
rcu: Preemptible hierarchical RCU implementation.
rcu: RCU event tracing is enabled.
rcu: RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
efuse mapped to (ptrval)
slcr mapped to (ptrval)
GIC physical location is 0xf8f01000
L2C: platform modifies aux control register: 0x02060000 -> 0x02460000
L2C: DT/platform modifies aux control register: 0x02060000 -> 0x02460000
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46460001
rcu: srcu_init: Setting srcu_struct sizes based on contention.
zynq_clock_init: clkc starts at (ptrval)
Zynq clock init
sched_clock: 64 bits at 167MHz, resolution 6ns, wraps every 4398046511103ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x26703d7dd8, max_idle_ns: 440795208065 ns
Switching to timer-based delay loop, resolution 6ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 333.33 BogoMIPS (lpj=1666666)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
CPU: Testing write buffer coherency: ok
CPU0: Spectre v2: using BPIALL workaround
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x100000 - 0x100060
rcu: Hierarchical SRCU implementation.
rcu: Max phase no-delay instances is 1000.
smp: Bringing up secondary CPUs ...
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
CPU1: Spectre v2: using BPIALL workaround
smp: Brought up 1 node, 2 CPUs
SMP: Total of 2 processors activated (666.66 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 512 (order: 3, 32768 bytes, linear)
pinctrl core: initialized pinctrl subsystem
NET: Registered PF_NETLINK/PF_ROUTE protocol family
DMA: preallocated 256 KiB pool for atomic coherent allocations
thermal_sys: Registered thermal governor 'step_wise'
cpuidle: using governor menu
platform replicator: Fixed dependency cycle(s) with /axi/etb@f8801000
platform replicator: Fixed dependency cycle(s) with /axi/tpiu@f8803000
platform replicator: Fixed dependency cycle(s) with /axi/funnel@f8804000
amba f8804000.funnel: Fixed dependency cycle(s) with /axi/ptm@f889d000
amba f8804000.funnel: Fixed dependency cycle(s) with /axi/ptm@f889c000
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
mc: Linux media interface: v0.10
videodev: Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
FPGA manager framework
Advanced Linux Sound Architecture Driver Initialized.
vgaarb: loaded
clocksource: Switched to clocksource arm_global_timer
NET: Registered PF_INET protocol family
IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
NET: Registered PF_UNIX/PF_LOCAL protocol family
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
armv7-pmu f8891000.pmu: hw perfevents: no interrupt-affinity property, guessing.
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
workingset: timestamp_bits=30 max_order=18 bucket_order=0
jffs2: version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
bounce: pool size: 64 pages
io scheduler mq-deadline registered
io scheduler kyber registered
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
dma-pl330 f8003000.dma-controller: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dma-controller: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
brd: module loaded
loop: module loaded
spi-nor spi0.0: n25q128a11 (16384 Kbytes)
5 fixed-partitions partitions found on MTD device spi0.0
Creating 5 MTD partitions on "spi0.0":
0x000000000000-0x000000100000 : "qspi-fsbl-uboot"
0x000000100000-0x000000600000 : "qspi-linux"
0x000000600000-0x000000620000 : "qspi-device-tree"
0x000000620000-0x000000c00000 : "qspi-rootfs"
0x000000c00000-0x000001000000 : "qspi-bitstream"
CAN device driver interface
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 40 (3e:44:44:83:55:27)
e1000e: Intel(R) PRO/1000 Network Driver
e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
usbcore: registered new interface driver usb-storage
ci_hdrc ci_hdrc.0: unable to init phy: -110
ci_hdrc: probe of ci_hdrc.0 failed with error -110
i2c_dev: i2c /dev entries driver
i2c i2c-0: using pinctrl states for GPIO recovery
i2c i2c-0: using generic GPIOs for recovery
cdns-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 41
si570 1-005d: registered, current frequency 148500000 Hz
i2c i2c-0: Added multiplexed i2c bus 1
i2c i2c-0: Added multiplexed i2c bus 2
at24 3-0054: supply vcc not found, using dummy regulator
at24 3-0054: 1024 byte 24c08 EEPROM, writable, 1 bytes/write
i2c i2c-0: Added multiplexed i2c bus 3
i2c i2c-0: Added multiplexed i2c bus 4
rtc-pcf8563 5-0051: low voltage detected, date/time is not reliable.
rtc-pcf8563 5-0051: registered as rtc0
rtc-pcf8563 5-0051: low voltage detected, date/time is not reliable.
rtc-pcf8563 5-0051: hctosys: unable to read the hardware clock
i2c i2c-0: Added multiplexed i2c bus 5
i2c i2c-0: Added multiplexed i2c bus 6
i2c i2c-0: Added multiplexed i2c bus 7
i2c i2c-0: Added multiplexed i2c bus 8
pca954x 0-0074: registered 8 multiplexed busses for I2C switch pca9548
ucd9200 8-0034: Device ID UCD9248-80|5.8.0.11400|091112
ucd9200 8-0034: 4 rails configured
ucd9200 8-0035: Device ID UCD9248-80|5.8.0.11400|091112
ucd9200 8-0035: 4 rails configured
ucd9200 8-0036: Device ID UCD9248-80|5.8.0.11400|091112
ucd9200 8-0036: 2 rails configured
cdns-wdt f8005000.watchdog: Xilinx Watchdog Timer with timeout 10s
EDAC MC: ECC not enabled
Xilinx Zynq CpuIdle Driver started
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
ledtrig-cpu: registered to indicate activity on CPUs
mmc0: Invalid maximum block size, assuming 512 bytes
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
timer #0 at (ptrval), irq=44
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered PF_INET6 protocol family
Segment Routing with IPv6
In-situ OAM (IOAM) with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered PF_PACKET protocol family
can: controller area network core
NET: Registered PF_CAN protocol family
can: raw protocol
can: broadcast manager protocol
can: netlink gateway - max_hops=1
zynq_pm_remap_ocm: Can't get OCM poll
zynq_pm_suspend_init: Unable to map OCM.
Registering SWP/SWPB emulation handler
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 47, base_baud = 3125000) is a xuartps
mmc0: SDHCI controller on e0100000.mmc [e0100000.mmc] using ADMA
printk: console [ttyPS0] enabled
of-fpga-region fpga-full: FPGA Region probed
input: gpio-keys as /devices/soc0/gpio-keys/input/input0
of_cfs_init
of_cfs_init: OK
ALSA device list:
No soundcards found.
Waiting for root device /dev/mmcblk0p2...
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SS08G 7.40 GiB
mmcblk0: p1 p2
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Quota mode: disabled.
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: mounted
Freeing unused kernel image (initmem) memory: 1024K
Run /sbin/init as init process
EXT4-fs (mmcblk0p2): re-mounted. Quota mode: disabled.
Saving 256 bits of non-creditable seed for next boot
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting network: OK
Welcome to Buildroot
buildroot login: root
# ls
# pwd
/root
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 51.1M 6.2M 40.6M 13% /
devtmpfs 493.6M 0 493.6M 0% /dev
tmpfs 502.1M 0 502.1M 0% /dev/shm
tmpfs 502.1M 20.0K 502.1M 0% /tmp
tmpfs 502.1M 16.0K 502.1M 0% /run
# free -h
total used free shared buff/cache available
Mem: 1004.2M 9.9M 991.1M 36.0K 3.1M 978.8M
Swap: 0 0 0
# uname -a
Linux buildroot 6.1.30-xilinx #1 SMP PREEMPT Tue Aug 19 21:31:45 HKT 2025 armv7l GNU/Linux

浙公网安备 33010602011771号