0、说明

基于Vivado工程配置petalinux实现linux下控制PL端GPIO

完成对linux网卡的驱动

实验内容:

  • 完成一个vivado工程,导出硬件信息
  • 创建petalinux工程,导入硬件,修改,完成工程编译及导出
  • 烧写测试网卡

1、环境

1.1 硬件环境

Xilinx ZYNQ-7000开发板

1.2 软件环境

VM Ubuntu 18.04.5 LTS

windows 10

Vivado v2021.1 (64-bit) 系列工具

1.3 资源下载准备

ug585-Zynq-7000-TRM.pdf

ug821-zynq-7000-swdev.pdf ug1144

官方wiki-linux驱动 Linux Drivers - Xilinx Wiki - Confluence

2、实验内容

2.1 vivado工程

由于ZYNQ包含FPGA+ARM,相比于传统的单ARM开发有所不同。ZYNQ启动包含了bootrom+fsbl,两部分。其中fsbl完成了MIO、DDR等基础硬件的初始化。因此我们linux阶段使用到的硬件一定要在vivado中配置好,并导出硬件,这点与单ARM开发不同,单ARM开发一般在uboot中完成。

本实验,主要包含网卡驱动,设置网卡io配置、复位io配置,mdio配置。因此vivado中需设计好如下几个单元。

基于以上工程,导出硬件信息给petalinux使用,也可以基于SDK开发裸机进行前期验证。

2.2 petalinux工程创建

工程操作

  • petalinux-create --type project --template zynq --name net_peta
  • petalinux-config --get-hw-description ../project.sdk(petalinux-config --get-hw-description ***.xsa)
  • petalinux-config -c uboot
  • petalinux-config -c kernel
  • petalinux-config -c rootfs
  • petalinux-build
  • petalinux-package --boot --fsbl --fpga --u-boot --force
  • BOOT.BIN 和 image.ub 复制到 sd 卡

设备树修改

       petalinux在 --get-hw-description期间会根据导出的硬件情况构建设备树。但是一些板级特殊信息不会被包含。比如vivado工程中只配置了复位管脚但是PHY ID并没有配置,因此一些设备树信息是需要用户单独补充的。

petalinux 给用户转门导出给用户使用的设备树 project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi。

以上内容仅增加了对gem0 phy id的配置,其他信息由于在vivado中配置了,petalinux会自动生成所需要的设备树配置。

petalinux基于工程生成的设备树: components/plnx_workspace/device-tree/device-tree/

如果没有在vivado中使能MAC,那么设备树中就不会启用网卡,此处的设备树就不仅仅是补充phy id了。

内核修改

同样内核和设备树也一样,有些东西,并不会完全在vivado配置到。vivado中并没有办法告诉petalinux phy的厂家是什么,需要哪个驱动。因此需要在petalinux-config -c kernel中根据使用的phy配置内核,添加对指定phy的支持。

此处使用的是 Micrel KSZ9031 Gigabit PHY。因此在内核中增加对Micrel系列phy的支持。不然在启动后可能出现无法识别phy类型,甚至无法进行通信使用。

3、启动测试

U-Boot 2021.01 (Jun 01 2021 - 11:54:06 +0000)CPU:   Zynq 7z020
Silicon: v3.1
Model: Zynq ALINX Development Board
DRAM:  ECC disabled 1 GiB
Flash: 0 Bytes
NAND:  0 MiB
MMC:   mmc@e0100000: 0
Loading Environment from FAT... *** Warning - bad CRC, using default environmentIn:    serial@e0001000
Out:   serial@e0001000
Err:   serial@e0001000
Net:
ZYNQ GEM: e000b000, mdio bus e000b000, phyaddr 1, interface rgmii-id
eth0: ethernet@e000b000
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
2595 bytes read in 15 ms (168.9 KiB/s)
## Executing script at 03000000
Trying to load boot images from mmc0
12999616 bytes read in 2146 ms (5.8 MiB/s)
## Loading kernel from FIT Image at 10000000 ...Using 'conf-system-top.dtb' configurationVerifying Hash Integrity ... OKTrying 'kernel-1' kernel subimageDescription:  Linux kernelType:         Kernel ImageCompression:  uncompressedData Start:   0x100000f8Data Size:    4594768 Bytes = 4.4 MiBArchitecture: ARMOS:           LinuxLoad Address: 0x00200000Entry Point:  0x00200000Hash algo:    sha256Hash value:   64748ca2202cda106096111e4cfa5c0631e3d50d5858a970cd2db5cd257cd939Verifying Hash Integrity ... sha256+ OK
## Loading ramdisk from FIT Image at 10000000 ...Using 'conf-system-top.dtb' configurationVerifying Hash Integrity ... OKTrying 'ramdisk-1' ramdisk subimageDescription:  petalinux-image-minimalType:         RAMDisk ImageCompression:  uncompressedData Start:   0x10466bd8Data Size:    8383092 Bytes = 8 MiBArchitecture: ARMOS:           LinuxLoad Address: unavailableEntry Point:  unavailableHash algo:    sha256Hash value:   65f97509758aebf4a1d07c9772bdf30bc34cc958cb0d239ba38a2d9aeaa85e4cVerifying Hash Integrity ... sha256+ OK
## Loading fdt from FIT Image at 10000000 ...Using 'conf-system-top.dtb' configurationVerifying Hash Integrity ... OKTrying 'fdt-system-top.dtb' fdt subimageDescription:  Flattened Device Tree blobType:         Flat Device TreeCompression:  uncompressedData Start:   0x10461e54Data Size:    19637 Bytes = 19.2 KiBArchitecture: ARMHash algo:    sha256Hash value:   1f394c269fb5f034ad522bab2865c727522a331c58b7e66688c178a777bce6f8Verifying Hash Integrity ... sha256+ OKBooting using the fdt blob at 0x10461e54Loading Kernel ImageLoading Ramdisk to 2f801000, end 2ffffa74 ... OKLoading Device Tree to 2f7f9000, end 2f800cb4 ... OKStarting kernel ...Booting Linux on physical CPU 0x0
Linux version 5.10.0-xilinx-v2021.1 (oe-user@oe-host) (arm-xilinx-linux-gnueabi-gcc (GCC) 10.2.0, GNU ld (GNU Binutils) 2.35.1) #1 SMP PREEMPT Fri Jun 4 15:57:16 UTC 2021
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
OF: fdt: Machine model: Zynq ALINX Development Board
earlycon: cdns0 at MMIO 0xe0001000 (options '115200n8')
printk: bootconsole [cdns0] enabled
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 rangesnode   0: [mem 0x0000000000000000-0x000000003fffffff]
Initmem setup node 0 [mem 0x0000000000000000-0x000000003fffffff]
percpu: Embedded 15 pages/cpu s32332 r8192 d20916 u61440
Built 1 zonelists, mobility grouping on.  Total pages: 260416
Kernel command line: console=ttyPS0,115200 earlycon root=/dev/ram0 rw
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: 1001600K/1048576K available (7168K kernel code, 274K rwdata, 1872K rodata, 1024K init, 160K bss, 30592K 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+0x2c0/0x4a0 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
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)
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 32, base_baud = 6249999) is a xuartps
printk: console [ttyPS0] enabled
printk: console [ttyPS0] enabled
printk: bootconsole [cdns0] disabled
printk: bootconsole [cdns0] disabled
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...
Freeing initrd memory: 8188K
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=14 max_order=18 bucket_order=4
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_master spi0: cannot find modalias for /axi/spi@e000d000/flash@0
spi_master spi0: Failed to create SPI device for /axi/spi@e000d000/flash@0
libphy: Fixed MDIO Bus: probed
CAN device driver interface
libphy: MACB_mii_bus: probed
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 34 (00:0a:35:00:1e:53)
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
i2c /dev entries driver
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=47
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
NET: Registered protocol family 10
mmc0: SDHCI controller on e0100000.mmc [e0100000.mmc] using ADMA
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
of-fpga-region fpga-full: FPGA Region probed
of_cfs_init
of_cfs_init: OK
ALSA device list:No soundcards found.
Freeing unused kernel memory: 1024K
Run /init as init process
mmc0: Problem switching card into high-speed mode!
mmc0: new SDHC card at address 0001
mmcblk0: mmc0:0001 SD16G 14.9 GiB
INIT:  mmcblk0: p1 p2
version 2.97 booting
Starting udev
udevd[71]: starting version 3.2.9
random: udevd: uninitialized urandom read (16 bytes read)
random: udevd: uninitialized urandom read (16 bytes read)
random: udevd: uninitialized urandom read (16 bytes read)
udevd[72]: starting eudev-3.2.9
random: fast init done
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
urandom_read: 2 callbacks suppressed
random: dd: uninitialized urandom read (512 bytes read)
macb e000b000.ethernet eth0: PHY [e000b000.ethernet-ffffffff:01] driver [Micrel KSZ9031 Gigabit PHY] (irq=POLL)
macb e000b000.ethernet eth0: configuring for phy/rgmii-id link mode
macb e000b000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
random: crng init done
Starting tcf-agent: OKroot@aaaa:~# uname -a
Linux aaaa 5.10.0-xilinx-v2021.1 #1 SMP PREEMPT Fri Jun 4 15:57:16 UTC 2021 armv7l GNU/Linux
root@aaaa:~# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0A:35:00:1E:53  inet addr:192.168.1.186  Bcast:192.168.1.255  Mask:255.255.255.0inet6 addr: fe80::20a:35ff:fe00:1e53/64 Scope:LinkUP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1RX packets:2 errors:0 dropped:0 overruns:0 frame:0TX packets:19 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:1152 (1.1 KiB)  TX bytes:3306 (3.2 KiB)Interrupt:34 Base address:0xb000 lo        Link encap:Local Loopback  inet addr:127.0.0.1  Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING  MTU:65536  Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)sit0      Link encap:IPv6-in-IPv4  NOARP  MTU:1480  Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)root@aaaa:~# ping 192.168.1.108
PING 192.168.1.108 (192.168.1.108): 56 data bytes
64 bytes from 192.168.1.108: seq=0 ttl=128 time=2.712 ms
64 bytes from 192.168.1.108: seq=1 ttl=128 time=1.432 ms
64 bytes from 192.168.1.108: seq=2 ttl=128 time=1.393 ms
64 bytes from 192.168.1.108: seq=3 ttl=128 time=1.406 ms
^C
--- 192.168.1.108 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 1.393/1.735/2.712 ms
root@aaaa:~# 

Vivado工程配置petalinux实现linux下网卡驱动相关推荐

  1. Linux下网卡驱动安装及故障排除

    Linux下网卡驱动安装及故障排除 赛迪网 2007-4-26 9:10:00文/forgiven 网卡是Linux服务器中最重要网络设备.据统计,Linux网络故障有35%在物理层.25%在数据链路 ...

  2. linux 网卡驱动分析,基于linux下网卡驱动分析及实现技术研究

    摘    要 Linux技术是当前计算机技术中最大的一个热点,在我国以及全世界得到了迅猛的发展,被广泛的应用于嵌入式系统.服务器.网络系统.安全等领域.从而使得掌握在 Linux环境下的开发技术,成为 ...

  3. linux端口绑定moute,Linux下网卡驱动的安装(未完结)

    这两天装一台Linux服务器,主板太另类了,在一台1u的机箱里面装了两台机器,每个都是4u的X3210,主板是X38ML,在intel首页上面都没多少介绍,找了半天才找到网卡驱动,安装debian的时 ...

  4. linux系统怎样安装驱动程序,linux下网卡驱动安装全过程

    方法一,用RPM包安装驱动程序方法: 1.将驱动程序文件bcm5700-.src.rpm复制到一个临时目录中,并在此目录中运行以下命令:rpm –ivh bcm5700-.src.rpm 2.运行以下 ...

  5. 基于linux的千兆网卡驱动程序实现及数据传输效率优化,嵌入式Linux下网卡驱动的实现与数据转发性能优化分析...

    摘要: 伴随着互联网的快速发展和后PC时代的到来,嵌入式系统已逐步成为当今IT产业的焦点之一,广阔的市场前景使嵌入式系统获得了空前的发展机遇.由于Linux操作系统具有代码开放.内核可裁减.网络功能强 ...

  6. linux网卡驱动离线安装_Linux下网卡驱动的安装

    //Linux下网卡驱动的安装 //从intel网站上下载下来的Linux驱动是e1000-5.2.52.tar.gz rpm -qa|grep kernel- //source查看是否安装了这个包, ...

  7. linux网卡驱动开发视频,Linux下网卡驱动程序的开发.doc

    Linux下网卡驱动程序的开发 论文题目:Linux下网卡驱动程序的开发 专 业: 年 级: 学生学号: 学生姓名: 指导教师: 完成时间: Linux下网卡驱动程序的开发 八年经验 专业指导毕业设计 ...

  8. 查看Linux下网卡状态或 是否连接(转)

    1) 通过mii-tool指令        [root@localhost root]# mii-tool         eth0: negotiated 100baseTx-FD, link o ...

  9. linux网卡操作命令 ,查看Linux下网卡连接状态(up还是down)?

    调整网卡工作模式 mii-tool -v //查看网卡工作模式 mii-tool -F 100baseTx-FD eth0 //将eth0改为100M,全双工工作模式 mii-tool -r eth0 ...

最新文章

  1. iphone adb android,通过ADB获取Android手机信息
  2. 优秀程序员写代码的七个优秀习惯
  3. ShardedJedis 错误使用
  4. log4j的使用 20220228
  5. 【嵌入式Linux】STM32MP157开发板上Linux启动流程
  6. ConcurrentHashMap 实现细节(转)
  7. 利用python进行数据分析——第十四章_数据分析案例
  8. php生成图形验证码的几种方法
  9. 持续交付2.0 pdf_便捷下载发布v7.2.0版本更新
  10. QQ音乐无损下载工具 Music Download Man v3.1绿色版
  11. Unrecogized font family ‘Ionicons’ 在ios上报错,android正常
  12. grldr引导iso PE img 文件
  13. 为什么拉格朗日对偶函数一定是凹函数(逐点下确界)
  14. 随机抽样的python实现
  15. 实用自动化运维Python脚本
  16. windows设置某应用开机自启
  17. 机器学习:浅谈先验概率,后验概率
  18. Android ExpandableListView 使用实例
  19. 白鹭引擎开发微信小游戏进阶教程文档
  20. 洛谷 P1719 最大加权矩形 (前缀和,动态规划)

热门文章

  1. 【每日一读】Pro-GNN:Graph Structure Learning for Robust Graph Neural Networks
  2. java 零拷贝_牛逼哄哄的零拷贝是什么?
  3. java clh_AQS基础——多图详解CLH锁的原理与实现
  4. 我已经看到了,撤回也没用了(PC微信防撤回补丁)
  5. 【Apache运维基础(5)】Apache的Rewrite攻略(2)
  6. Swarm and shipyard
  7. 【Leetcode】1512. Number of Good Pairs
  8. android数据库降级_Android之sqlite数据库版本升级和降级的处理(onUpgrade和onDowngrade)...
  9. 传奇引擎注册服务器,GeeM2引擎架设传奇不能注册账号 进不去游戏
  10. BLE service, characteristic以及CCCD概念 9