用传统方式在zynq7020开发板上移植linux
不使用官方提供的petalinux工具,手动编译生成linux移植所需的各个文件,在zynq7020开发板上移植linux
·
参考博客:
-
安装vivado,建立工程,进行IP核的配置。
-
安装相应环境
#安装32位依赖库 sudo apt-get install lib32z1 lib32ncurses5 lib32stdc++6 libbz2-1.0:i386 #安装 Openssl 库,实现网络的保密性和可靠性的数据传输,在编译u-boot时会用到 sudo apt-get install libssl-dev #安装设备树编译器工具 sudo apt-get install device-tree-compiler #安装此库,否则内核编译时make menuconfig等会报错 sudo apt-get install libncurses5-dev #安装此库,否则内核编译报错 sudo apt-get install u-boot-tools
-
下载官方u-boot和kernel
从https://github.com/Xilinx,直接下载官方u-boot和kernel(linux-xlnx-master.zip、u-boot-xlnx-master.tar.gz) -
编译u-boot
-
下载交叉编译工具
sudo apt install gcc-arm-linux-gnueabi #默认安装在/usr/bin/目录下。这种安装方式会自动添加环境变量,不用手工设置。
- 定位编译环境
source /opt/Xilinx/SDK/2017.4/settings64.sh
- 进入u-boot目录
cd /home/XXX/Downloads/u-boot-xlnx-master
- 指定交叉编译工具:
export CROSS_COMPILE=arm-linux-gnueabi-
- 指定目标板CPU的体系结构:
export ARCH=arm
- 指定目标板使用的设备树:
export DEVICE_TREE=zynq-zc706
- 配置:
make zynq_zc706_defconfig
- 编译:
make
- 编译完成后会在u-boot-xlnx-master主目录下生成uboot的可执行文件——u-boot,将其重命名为uboot.elf
-
-
生成BOOT.bin
-
启动SDK,新建一个FSBL模板,并在文件中
#define FSBL_DEGUG_INFO
以便看到调试信息,然后编译生成fsbl.elf -
从SDK中将上述fsbl.elf、uboot.elf打包生成BOOT.bin
-
-
生成uImage
- 定位编译环境
source /opt/Xilinx/SDK/2017.4/settings64.sh
- 进入目录
cd /home/XXX/Downloads/linux-xlnx-master
- 指定交叉编译工具:
export CROSS_COMPILE=arm-linux-gnueabi-
- 指定目标板CPU的体系结构:
export ARCH=arm
- 配置:
make xilinx_zynq_defconfig
- 编译:
make uImage LOADADDR=0x00008000
- 编译完成后,在linux-xlnx-master/arch/arm/boot目录下可以发现uImage文件
- 定位编译环境
-
生成设备树文件
- 在linux-xlnx-master/arch/arm/boot/dts目录内找到zynq-zc706.dts文件
- 修改该dts文件,将
#include "zynq-7000.dtsi"
修改为/include/ “zynq-7000.dtsi”
- 继续在linux-xlnx-master目录下运行命令:
./scripts/dtc/dtc -I dts -O dtb -o ./arch/arm/boot/devicetree.dtb ./arch/arm/boot/dts/zynq-zc706.dts
- 然后在linux-xlnx-master/arch/arm/boot/目录下即可发现devicetree.dtb文件
-
文件系统
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842473/Build+and+Modify+a+Rootfs
-
将上述生成的fsbl.elf、u-boot.elf、devicetree.dtb、BOOT.bin、uramdisk.image.gz、uImage等,拷贝到SD卡中即可。
-
设置板子为SD启动模式,上电启动,putty串口打印如下信息,系统成功启动。
U-Boot 2016.07 (Apr 16 2021 - 21:21:29 +0800)
Model: Zynq ZC706 Development Board
Board: Xilinx Zynq
I2C: ready
DRAM: ECC disabled 1 GiB
MMC: sdhci@e0100000: 0
SF: Detected W25Q256 with page size 256 Bytes, erase size 4 KiB, total 32 MiB
In: serial@e0001000
Out: serial@e0001000
Err: serial@e0001000
Model: Zynq ZC706 Development Board
Board: Xilinx Zynq
Net: ZYNQ GEM: e000b000, phyaddr 7, interface rgmii-id
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Device: sdhci@e0100000
Manufacturer ID: 12
OEM: 3456
Name: SDTran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.5 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading uEnv.txt
** Unable to read file uEnv.txt **
Copying Linux from SD to RAM...
reading uImage
4470760 bytes read in 253 ms (16.9 MiB/s)
reading devicetree.dtb
15554 bytes read in 19 ms (798.8 KiB/s)
reading uramdisk.image.gz
5310046 bytes read in 297 ms (17 MiB/s)
##Booting kernel from Legacy Image at 02080000 ...
Image Name: Linux-5.10.0-xilinx
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4470696 Bytes = 4.3 MiB
Load Address: 00008000
Entry Point: 00008000
Verifying Checksum ... OK
##Loading init Ramdisk from Legacy Image at 04000000 ...
Image Name:
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 5309982 Bytes = 5.1 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
##Flattened Device Tree blob at 02000000
Booting using the fdt blob at 0x2000000
Loading Kernel Image ... OK
Loading Ramdisk to 1faef000, end 1ffff61e ... OK
Loading Device Tree to 1fae8000, end 1faeecc1 ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 5.10.0-xilinx (suncheng@suncheng-Lenovo-G410) (arm-linux-gnueabihf-gcc (Linaro GCC Snapshot 6.2-2016.11) 6.2.1 20161114, GNU ld (Linaro_Binutils-) 2.27) #1 SMP PREEMPT Mon May 10 11:40:24 CST 2021
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: Xilinx ZC706 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 15 pages/cpu s32204 r8192 d21044 u61440
Built 1 zonelists, mobility grouping on. Total pages: 260608
Kernel command line:
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:off, heap alloc:off, heap free:off
Memory: 1007680K/1048576K available (6144K kernel code, 248K rwdata, 1832K rodata, 1024K init, 164K bss, 24512K 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.
Trampoline variant of Tasks RCU enabled.
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: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
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 ID prefetch enabled, offset 1 lines
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 0x76760001
random: get_random_bytes called from start_kernel+0x2bc/0x480 with crng_init=0
zynq_clock_init: clkc starts at (ptrval)
Zynq clock init
sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 4398046511103ns
clocksource: arm_global_timer: mask: 0xffffffffffffffff max_cycles: 0x4ce07af025, max_idle_ns: 440795209040 ns
Switching to timer-based delay loop, resolution 3ns
Console: colour dummy device 80x30
printk: console [tty0] enabled
Calibrating delay loop (skipped), value calculated using timer frequency.. 666.66 BogoMIPS (lpj=3333333)
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.
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 (1333.33 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 protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
thermal_sys: Registered thermal governor 'step_wise'
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0x(ptrval)
vgaarb: loaded
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.
clocksource: Switched to clocksource arm_global_timer
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
TCP bind hash table entries: 8192 (order: 4, 65536 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 protocol family 1
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
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (no cpio magic); looks like an initrd
Freeing initrd memory: 5188K
hw perfevents: no interrupt-affinity property for /pmu@f8891000, 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.dmac: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac: DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
brd: module loaded
loop: module loaded
spi-nor spi0.0: found w25q256, expected n25q128a11
spi-nor spi0.0: failed to read ear reg
spi-nor spi0.0: w25q256 (65536 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"
libphy: Fixed MDIO Bus: probed
CAN device driver interface
libphy: MACB_mii_bus: probed
mdio_bus e000b000.ethernet-ffffffff: MDIO device at address 7 is missing.
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 35 (00:0a:35:00:01:22)
e1000e: Intel(R) PRO/1000 Network Driver
e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
usbcore: registered new interface driver usb-storage
ULPI transceiver vendor/product ID 0x0424/0x0007
Found SMSC USB3320 ULPI transceiver.
ULPI integrity check: passed.
ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
i2c /dev entries driver
cdns-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 30
pca954x 0-0074: probe failed
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
clocksource: ttc_clocksource: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 537538477 ns
timer #0 at (ptrval), irq=48
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered protocol family 10
Segment Routing with IPv6
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
can: controller area network core
NET: Registered protocol family 29
can: raw protocol
can: broadcast manager protocol
can: netlink gateway - max_hops=1
Registering SWP/SWPB emulation handler
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 33, base_baud = 6249999) 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
of_cfs_init
of_cfs_init: OK
ALSA device list:
No soundcards found.
RAMDISK: gzip image found at block 0
using deprecated initrd support, will be removed in 2021.
EXT4-fs (ram0): mounting ext2 file system using the ext4 subsystem
EXT4-fs (ram0): mounted filesystem without journal. Opts: (null)
VFS: Mounted root (ext2 filesystem) on device 1:0.
Starting rcS...
++ Mounting filesystem
mount: mounting /dev/mmcblk0p1 on /mnt failed: No such file or directory
mount: mounting /dev/mmcblk0 on /mnt failed: No such file or directory
++ Setting up mdev
/etc/init.d/rcS: line 12: can't create /proc/sys/kernel/hotplug: nonexistent directory
++ Starting telnet daemon
++ Starting http daemon
++ Starting ftp daemon
++ Starting ssh daemon
random: sshd: uninitialized urandom read (32 bytes read)
rcS Complete
zynq>
更多推荐
已为社区贡献2条内容
所有评论(0)