基于ZYNQ的petalinux 2018.3 DMA驱动的移植和内核编译

38 篇文章 5 订阅
34 篇文章 9 订阅

vivado硬件设计

DMA设置
在这里插入图片描述

第一步,创建项目

petalinux-create --type project --template zynq --name petalinux_Dma
john@john-virtual-machine:~/zynq/version2$ petalinux-create -t project -s dma.bsp
john@john-virtual-machine:~/peta_proj$ petalinux-package --bsp -p ./version2 --output dma
petalinux-config --get-hw-description=.
petalinux-package --boot --format BIN --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --force
john@john-virtual-machine:~/zynq/version2/images/linux$ sudo tar -zxvf rootfs.tar.gz -C //media/john/root

第二步 指定SD和CMA,检查DMA

打开SD选项。
petalinux-config -c kernel
选择Image Packaging Configuration —>Root filesystem type(SD card) —>SD card

分离设备树
修改设备树后直接替换,默认是dtb会打包在uImage中。
Subsystem AUTO Hardware Settings -> Advanced boot… -> dtb image settings ->选择primary sd

保存kernel config小技巧
如果vivado工程中含有AXI-DMA 的IP核,在petalinux-config -c kernel的时候会发现基本相关项都已经开启。
这里用一个小技巧,我们在menuconfig中选保存,自己定一个保存名(例如alinx_sgdma_linux_defconfig),保存一下,不要退出,去你petalinux工程项目文件下搜索这个文件名,将其复制出来(我们之后为了编译模块也会用到它),按照github上的要求检查以下项目是否选y了(删除线的不需要检查,这个库是17年写的,但是现在xilinx的linux代码分支已经使用到2018,这些相关配置项已经不在了)

CONFIG_CMA=y
CONFIG_DMA_CMA=y
CONFIG_DMA_SHARED_BUFFER=y

记得,在menuconfig中再选保存,将文件名命名回.config,以供petalinux正确生成linux

DMA相关设置完毕后,我们还需要配置CMA
Device Drivers -> Generic Driver Options -> Default contiguous memory area size 的 Size in Mega Bytes修改为25

或者

第三步 添加DMA设备树

先运行一下生成pl相关的设备树(这是可选项,但有必要修改dtsi时直接拷贝pl.dtsi里的节点名,不容易出错)

$ petalinux-config -c device-tree

我们需要修改设备树的主要有两个点:1.加入axidma_chardev 2.修改各个dma通道的device-id不重复。
我这里有两个dma通道(一个发到FIFO,一个从FIFO接回来),我把他们的device-id分别修改为0和1
在project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi中加入

方法一

/include/ "system-conf.dtsi"
/{
};
 
&amba_pl{
    axidma_chrdev: axidma_chrdev@0 {
            compatible = "xlnx,axidma-chrdev";
            dmas = <&axi_dma_0 0 &axi_dma_0 1>;
            dma-names = "tx_channel", "rx_channel";
    };
};

方法二

&axi_dma_0 {
		#dma-cells = <1>;
		clock-names = "s_axi_lite_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
		clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>;
		compatible = "xlnx,axi-dma-7.1", "xlnx,axi-dma-1.00.a";
		interrupt-names = "mm2s_introut", "s2mm_introut";
		interrupt-parent = <&intc>;
		interrupts = <0 29 4 0 30 4>;
		reg = <0x40400000 0x10000>;
		xlnx,addrwidth = <0x20>;
		xlnx,sg-length-width = <0xe>;
		dma-channel@40400000 {
			compatible = "xlnx,axi-dma-mm2s-channel";
			dma-channels = <0x1>;
			interrupts = <0 29 4>;
			xlnx,datawidth = <0x8>;
			xlnx,device-id = <0x0>;
		};
		dma-channel@40400030 {
			compatible = "xlnx,axi-dma-s2mm-channel";
			dma-channels = <0x1>;
			interrupts = <0 30 4>;
			xlnx,datawidth = <0x20>;
			xlnx,device-id = <0x1>;
		};

};

这里使用的设备树的引用覆盖的方法来修改device-id

第四步 添加axi_dma模块

*运行指令,创建xilinx-axidma module

john@john-virtual-machine:~/peta_proj/version2$ petalinux-create -t modules -n xilinx-axidma --enable

上面的命令可能产生两个效果,一是根文件系统中使能模块,二是添加镜像文件到下面文件petalinux-image-full.bbappend中
在这里插入图片描述
*创建完成后,可以在你的工程目录下找到如下路径/home/alinx/Downloads/peta_prj/dma_Show/project-spec/meta-user/recipes-modules/xilinx-axidma/files,进入这个路径,删除其中的xilinx-axidma.c文件。
*打开下载的模块文件包,将driver文件下的全部.c文件和.h头文件拷贝进files文件夹下,再将include文件夹下的axidma_ioctl.h文件也拷贝进来。*接下来,打开这个路径中的Makefile文件,将它的第一行替换为如下代码:

DRIVER_NAME = xilinx-axidma
$(DRIVER_NAME)-objs = axi_dma.o axidma_chrdev.o axidma_dma.o axidma_of.o
obj-m := $(DRIVER_NAME).o

*修改xilinx-axidma.bb文件中,SRC_URI右侧的赋值为:
SRC_URI = "file://Makefile
file://axi_dma.c
file://axidma_chrdev.c
file://axidma_dma.c
file://axidma_of.c
file://axidma.h
file://axidma_ioctl.h
file://COPYING
"
john@john-virtual-machine:~/peta_proj/version2$ petalinux-build -c xilinx-axidma

第五步 编译打包反向检查

petalinux-build
petalinux-package --boot --fsbl ./images/linux/zynq_fsbl.elf --fpga --u-boot --force

insmod xilinx_amidma.ko

这样在images目录下就会生成我们需要的uImage、system.dtb以及BOOT.BIN,为了确保设备树修改完好,我们这里先反编译一下设备树,生成system.dts,查看里面是否我们要修改的东西都已经修改好了(需要device-tree-compiler)。

在system.dtb文件的目录下运行
dtc -I dtb -O dts -o system.dts system.dtb

没用模块
(92条消息) ZYNQ #3 - Linux环境下在用户空间使用AXI-DMA进行传输_里先森-CSDN博客 https://blog.csdn.net/sements/article/details/90230188

用模块
(92条消息) Zynq7000学习 1.如何在Linux平台上运行DMA模块_江河湖海吾所望之的博客-CSDN博客 https://blog.csdn.net/weixin_38218267/article/details/102833570

(92条消息) 基于ZYNQ的petalinux 2017.4 DMA驱动的移植_七侠镇燕捕头的博客-CSDN博客 https://blog.csdn.net/qq_39337844/article/details/90238338

在这里插入图片描述

背景知识

Device Tree 中 address-cell 和 size-cells

m25p80@0 {
#address-cells=<1>
#size-cells=<1>;

partition@0 {
label = “u-boot”;
reg=<0x0 0x3000>
read-only;
}
我们可以看到m25p80这个父节点中的address-cells中填写了1,也就是,挂载在这个父节点下的子节点的起始地址只有1个;
size-cells中也填写了1,也就是挂载在这个父节点下的子节点的占用长度也只需要一个描述。

最后,我们看到就是
reg = <0 0x3000>;
0就是子节点绝对起始地址,个数1.
0x3000就是子节点占用长度,个数1.

(92条消息) 设备树中address-cells和size-cells的含义_violet089的专栏-CSDN博客 https://blog.csdn.net/violet089/article/details/53670758

#address-cells = <1>;
#size-cells = <1>;

...

serial@101f0000 {
    compatible = "arm,pl011";
    reg = <0x101f0000 0x1000 >;
};

serial@101f2000 {
    compatible = "arm,pl011";
    reg = <0x101f2000 0x1000 >;
};

gpio@101f3000 {
    compatible = "arm,pl061";
    reg = <0x101f3000 0x1000
           0x101f4000 0x0010>;
};

每个设备都被分配了一个基址以及该区域的大小。这个例子中为 GPIO 分配了两个地址范围:0x101f3000…0x101f3fff 和 0x101f4000…0x101f400f。
————————————————
版权声明:本文为CSDN博主「躺着的树懒」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/violet089/article/details/53670758

#address-cells = <2>
#size-cells = <1>;

    ethernet@0,0 {
        compatible = "smc,smc91c111";
        reg = <0 0 0x1000>;
    };

外部总线的地址值使用了两个 cell,一个用于片选号;另一个则用于片选基址的偏移量。而长度字段则还是单个 cell,这是因为只有地址的偏移部分才需要一个范围量。所以,在这个例子中,每个 reg 项都有三个 cell:片选号、偏移量和长度。
————————————————
版权声明:本文为CSDN博主「躺着的树懒」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/violet089/article/details/53670758

#address-cells = <1>;

#size-cells = <1>;

ranges = <0x0 0xfec00000 0x180000>;

子地址空间的cell为1,因此0x0 0xfec00000 0x180000的第一个cell表示的是片选地址为0,第二个cell表示片选地址0的地址空间映射到CPU的地址空间为0xfec00000,第三个cell表示的是地址空间的大小。

#address-cells = <2>

#size-cells = <1>;

ranges = <0 0 0x10100000 0x10000 // Chipselect 1, Ethernet

1 0 0x10160000 0x10000 // Chipselect 2, i2c controller

2 0 0x30000000 0x1000000>; // Chipselect 3, NOR Flash

子地址空间的#address-cells为2,父地址空间的#address-cells值为1,因此0 0 0x10100000 0x10000的前2个cell为设备节点后片选0上偏移0,第3个cell表示设备节点后片选0上偏移0的地址空间被映射到CPU的0x10100000位置,第4个cell表示映射的大小为0x10000。ranges的后面2个项目的含义可以类推。

Android驱动之设备树简介 - 夜尽天明00 - 博客园 https://www.cnblogs.com/yejintianming00/p/9339754.html

(92条消息) 设备树的interrupts属性_a3121772305的博客-CSDN博客_interrupts https://blog.csdn.net/a3121772305/article/details/89500617

硬件配置
petalinux-config --get-hw-description=…/vivado

Device Drivers > Generic Driver Options > DMA Contiguous Memory Allocator > Size in Mega Bytes change the size from 16 to 256MB
Device Drivers -> Staging drivers -> Xilinx APF Accelerator driver
Device Drivers -> Staging drivers -> Xilinx APF Accelerator driver -> Xilinx APF DMA engines support

不是config, 为什么是conf
/project-spec/meta-user add in the following to the conf file.

CONFIG_xrt
CONFIG_xrt-dev
CONFIG_zocl
CONFIG_opencl-clhpp-dev
CONFIG_opencl-headers-dev
CONFIG_packagegroup-petalinux-opencv

/project-spec/meta-user/system-user.dsti.

&amba {
zyxclmm_drm {
compatible = “xlnx,zocl”;
status = “okay”;
};
};

大咖投稿 | Vitis培训课后感附详细技术解析(下) | 电子创新网赛灵思社区 http://xilinx.eetrend.com/content/2020/100049392.html

Once these have been implemented, we can configure the rootfs to include the user packages we have just defined.

petalinux-config -c rootfs
enabling the user packages
在这里插入图片描述
petalinux-package --boot --format BIN --fsbl images/linux/zynqmp_fsbl.elf --u-boot images/linux/u-boot.elf --pmufw images/linux/pmufw.elf --fpga images/linux/*.bit–force
$ petalinux-package --boot --fsbl --fpga --uboot
For detailed

2021。3。20再次记录
/project-spec/configs Configuration files of top level config and RootFS config
/project-spec/configs/config Configuration file used to store user settings
/project-spec/configs/rootfs_config Configuration file used for root file system.

/project-spec/meta-user/recipes-bsp/devicetree/files/system-user.dtsi is not modified by any PetaLinux tools.

/project-spec/meta-plnx-generated/recipesbsp/u-boot/configs U-Boot PetaLinux configuration files. The following files are auto generated by petalinux-config:
platform-auto.h config.cfg
platform-top.h will not be modified by any PetaLinux tools. When U-Boot builds, these files are copied into U-Boot build directory build/linux/u-boot/src/<U_BOOT_SRC>/ as follows:
config is the U-Boot kconfig file.
/components/ Directory for embedded software workspace and place to hold external sources while packing BSP. You can also
manually copy components into this directory. Here is the rule to place a external component: /components/ext_source/
/project-spec/meta-user/conf/petalinuxbsp.conf This configuration file contains all the local user configurations for your build environment. It is a substitute for “local.conf” in the Yocto meta layers.

kernel The following files are in /project-spec/meta-plnxgenerated/
recipes-kernel/linux/configs/
plnx_kernel.cfg
bsp.cfg
U-Boot The following files are in /project-spec/meta-plnxgenerated/
recipes-bsp/u-boot/configs/
config.cfg
platform-auto.h
/project-spec/meta-user/recipes-core/images/petalinux-user-image.bbappend
To remove any default feature, add the following code in the petalinuxbsp.conf:
IMAGE_FEATURES_remove = “ssh-server-dropbear”
To add any new feature, add the following command in the petalinuxbsp.conf:
IMAGE_FEATURES_append = " myfeature"

zynq plnx-zynq7
加bb

  1. The location of the recipe is /opt/pkg/petalinux/components/yocto/source/
    aarch64/layers/meta-openembedded/meta-oe/recipes-benchmark/iperf3/
    iperf3_3.2.bb.
    加bb,还要加image,所以要加入petalinux-image-full.bbappend
  2. Add the following line in /project-spec/meta-user/recipescore/
    images/petalinux-image-full.bbappend.
    IMAGE_INSTALL_append = " iperf3"
    IMPORTANT! Whenever “_append” is used, there should be a space after = “.
    加入petalinux-image-full.bbappend,不一定入根文件系统进行编译
  3. Run petalinux-config -c rootfs.
    入了根文件系统
  4. Select user packages → iperf3. Enable it, save and exit.
    编译文件
  5. Run petalinux-build.

创建模块
petalinux-create -t modules --name mymodule --enable
recipes-core/images/petalinux-image-full.bbappend

直接编译放到根文件里
petalinux-build -c rootfs
petalinux-build -x package
这显然把module归入root

Original: earlycon clk_ignore_unused root=/dev/mmcblk0p2 rw rootwait
Updated: earlycon earlyprintk clk_ignore_unused root=/dev/mmcblk1p2 rw rootwait console=ttyPS0,115200

Edit the file “./project-spec/meta-user/conf/user-rootfsconfig” and add the following lines

CONFIG_xrt
CONFIG_xrt-dev
CONFIG_zocl
CONFIG_opencl-clhpp-dev
CONFIG_opencl-headers-dev
CONFIG_packagegroup-petalinux-opencv

&amba {
zyxclmm_drm {
compatible = “xlnx,zocl”;
status = “okay”;
reg = <0x0 0xA0000000 0x0 0x10000>;
};

petalinux-config -c rootfs

选择保存上面选项后的配置文件放在哪里

This includes changing the boot image, u-boot env partition, kernel image, and dtb image to ‘primary sd’ under Subsystem AUTO Hardware Settings > Advanced bootable images storage settings.

The root filesystem type needs to be changed to EXT (SD/eMMC/QSPI/SATA/USB)

petalinuxbsp.conf
在这里插入图片描述
在这里插入图片描述

  1. Copy or create a layer in <proj_root>/project-spec/meta-mylayer.
  2. Run petalinux-config → Yocto Settings → User Layers.
  3. Enter the following command:
    ${proot}/project-spec/meta-mylayer
  4. Save and exit.
  5. Verify by viewing the file in <proj_root>/build/conf/bblayers.conf.

This can be added to /meta-user/recipes-core/packagegroups/
packagegroup-petalinux-alsa.bb.
To add this package group in RootFS menuconfig, add IMAGE_INSTALL_append = "
packagegroup-petalinux-alsa" in /project-spec/meta-user/
recipes-core/petalinux-image.bbappend to reflect in menuconfig.
Then launch petalinux-config -c rootfs, select user packages → packagegrouppetalinux-
alsa, save and exit. Then run petalinux-build.

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

原版本
CONFIG_CMA=y
CONFIG_DMA_CMA=y
CONFIG_XILINX_DMAENGINES=y
CONFIG_XILINX_AXIDMA=y
CONFIG_XILINX_AXIVDMA=y
CONFIG_DMA_SHARED_BUFFER=y

实际准备加
CONFIG_CMA=y
CONFIG_CMA_SIZE_MBYTES=25
CONFIG_CMA_SIZE_SEL_MBYTES=y
CONFIG_DMA_CMA=y
CONFIG_DMA_SHARED_BUFFER=y

│ Symbol: CMA_SIZE_MBYTES [=16] │
│ Type : integer │
│ Prompt: Size in Mega Bytes │
│ Location: │
│ -> Device Drivers │
│ -> Generic Driver Options
在这里插入图片描述
The kernel command line can be updated by changing the device tree or from the U-Boot console. For example, to set the CMA’s pool size to 25 MB from the U-Boot console:

setenv bootargs “${bootargs} cma=25M”

在这里插入图片描述
xilinx_axidma: loading out-of-tree module taints kernel.
axidma: axidma_of.c: axidma_parse_compatible_property: 50: Device tree node dma-channel: DMA channel lacks ‘compatible’ property.
axidma: axidma_dma.c: axidma_request_channels: 651: Unable to get slave channel 1: rx_channel.
axidma: probe of amba_pl:axidma_chrdev@0 failed with error -38
random: crng init done

A device tree entry for VDMA is generated automatically by the petalinux tools in
components/plnx_workspace/device-tree-generation/pl.dtsi, in my case:

/ {
amba_pl: amba_pl {
#address-cells = <1>;
#size-cells = <1>;
compatible = “simple-bus”;
ranges ;
axi_vdma_0: dma@43000000 {
#dma-cells = <1>;
clock-names = “s_axi_lite_aclk”, “m_axi_mm2s_aclk”, “m_axi_mm2s_aclk”, “m_axi_s2mm_aclk”, “m_axi_s2mm_aclk”;
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = “xlnx,axi-vdma-1.00.a”;
interrupt-parent = <&intc>;
interrupts = <0 29 4 0 30 4>;
reg = <0x43000000 0x10000>;
xlnx,addrwidth = <0x20>;
xlnx,flush-fsync = <0x1>;
xlnx,num-fstores = <0x3>;
dma-channel@43000000 {
compatible = “xlnx,axi-vdma-mm2s-channel”;
interrupts = <0 29 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
xlnx,genlock-mode ;
};
dma-channel@43000030 {
compatible = “xlnx,axi-vdma-s2mm-channel”;
interrupts = <0 30 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
xlnx,genlock-mode ;
};
};
};
};

The additonal manual device tree entry in project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
must contain only the chrdev device:
axidma_chrdev: axidma_chrdev@0 {
compatible = “xlnx,axidma-chrdev”;
dmas = <&axi_vdma_0 0 &axi_vdma_0 1>;
dma-names = “tx_channel”, “rx_channel”;
};
(Actually, there are some more entries for my platform here, but they are not related to DMA)

I followed the Instructions given above for creating the kernel module. I also have to include all
source files in xilinx-axidma.bb as described above, except for xilinx-axidma.c which is
deleted.

After building and booting the new system, I get the following on the target platform:

#dmesg |grep dma
[…]
xilinx-vdma 43000000.dma: Xilinx AXI VDMA Engine Driver Probed!!

使用"&“来引用“label”,即是引用phandle。property"cpu"通过”&cpu0"来对node"cpu@0":

Example 1: Build Device tree Only
The below example shows the steps to generate device-tree from PetaLinux project. The devicetree
recipe depends on HDF, native tools (dtc, python-yaml…), and kernel headers.
The setup commands are:

  1. Import HDF into work space:
    petalinux-config --get-hw-description=<PATH-to-HDF/DSA-DIRECTORY>
    Chapter 4: Configuring and Building
    The above command will only copy hardware design from external location into the
    petalinux project /project-spec/hw-description/. The
    external-hdf is a recipe in Yocto which imports HDF from this location into Yocto work space.
    All the HDF dependent recipes uses hardware design from Yocto workspace. By default, this
    dependency is handled internal to recipes. You have to run the following command for every
    update in hardware design if you are building without dependencies.
    petalinux-build -c external-hdf
  2. Prepare all the prerequisites (native utilities).
    This command has to run only for the first time; re-run is needed only after cleaning
    petalinux-build -c device-tree -x do_prepare_recipe_sysroot
    Note: In future release, this feature is deprecated. Using petalinux-build -c <app/package/
    component> -x for building individual task for a component as part of a petalinuxbuild
    command will be deprecated.
  3. Build the device tree ignoring dependency tasks using the following command:
    petalinux-build -b device-tree
    This command builds device tree ignoring all dependencies and deploys it in the images/
    linux/ directory. If there is any dependency that is not met, it will error out. The above
    command can be used for incremental builds as well.
    Note: The above individual commands need to run with -b option. You can get all above functionality in
    one run: petalinux-build -c device-tree. It will

&axi_dma_0 {
#dma-cells = <1>;
clock-names = “s_axi_lite_aclk”, “m_axi_mm2s_aclk”, “m_axi_s2mm_aclk”;
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = “xlnx,axi-dma-7.1”, “xlnx,axi-dma-1.00.a”;
interrupt-names = “mm2s_introut”, “s2mm_introut”;
interrupt-parent = <&intc>;
interrupts = <0 29 4 0 30 4>;
reg = <0x40400000 0x10000>;
xlnx,addrwidth = <0x20>;
xlnx,sg-length-width = <0xe>;
dma-channel@40400000 {
compatible = “xlnx,axi-dma-mm2s-channel”;
dma-channels = <0x1>;
interrupts = <0 29 4>;
xlnx,datawidth = <0x8>;
xlnx,device-id = <0x0>;
};
dma-channel@40400030 {
compatible = “xlnx,axi-dma-s2mm-channel”;
dma-channels = <0x1>;
interrupts = <0 30 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x1>;
};

};

必须去掉dma@40400000,否则重复定义
axi_dma_0: dma@40400000 {
#dma-cells = <1>;
clock-names = “s_axi_lite_aclk”, “m_axi_mm2s_aclk”, “m_axi_s2mm_aclk”;
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = “xlnx,axi-dma-7.1”, “xlnx,axi-dma-1.00.a”;
interrupt-names = “mm2s_introut”, “s2mm_introut”;
interrupt-parent = <&intc>;
interrupts = <0 29 4 0 30 4>;
reg = <0x40400000 0x10000>;
xlnx,addrwidth = <0x20>;
xlnx,sg-length-width = <0xe>;
dma-channel@40400000 {
compatible = “xlnx,axi-dma-mm2s-channel”;
dma-channels = <0x1>;
interrupts = <0 29 4>;
xlnx,datawidth = <0x8>;
xlnx,device-id = <0x0>;
};
dma-channel@40400030 {
compatible = “xlnx,axi-dma-s2mm-channel”;
dma-channels = <0x1>;
interrupts = <0 30 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
};
};

成功调入DMA模块
在这里插入图片描述
makefile文件加入下面语句,一是忽略文件夹中可能含有clean文件,二是有错误继续删
.PHONY : clean
clean :
-rm -f *.o axidma_transfer axidma_transfer_twoway

将example文件拷入linux

在这里插入图片描述
执行make, 获取执行文件

在这里插入图片描述

内核编译

内核下载:
https://github.com/search?q=org%3AXilinx+linux-xlnx&type=
xilinx-v2018.3 内核下载:
GitHub - Xilinx/linux-xlnx at xilinx-v2018.3
https://github.com.cnpmjs.org/Xilinx/linux-xlnx/tree/xilinx-v2018.3
安装可能需要的依赖库
sudo apt-get install u-boot-tools
sudo apt-get install u-boot-tools:i386
网上所说的这个库已经废弃 sudo apt-get install uboot-mkimage

john@john-virtual-machine:~/setup/linux-xlnx-xilinx-v2018.3$ export ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
john@john-virtual-machine:~/setup/linux-xlnx-xilinx-v2018.3$ make clean
john@john-virtual-machine:~/setup/linux-xlnx-xilinx-v2018.3$ make xilinx_zynq_defconfig
john@john-virtual-machine:~/setup/linux-xlnx-xilinx-v2018.3$ make uImage LOADADDR=0x00008000

在这里插入图片描述
交叉编译测试样例
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm KBUILD_DIR=</path/to/kernel/tree> driver
make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm examples
在这里插入图片描述
root@myd-7015:~# insmod /lib/modules/4.14.0-xilinx-v2018.3/extra/xilinx-axidma.ko
root@myd-7015:~# cp /libaxidma.so /usr/lib
root@myd-7015:~# ./axidma_benchmark

AXI DMA Benchmark Parameters:
Transmit Buffer Size: 7.91 MiB
Receive Buffer Size: 7.91 MiB
Number of DMA Transfers: 1000 transfers

Using transmit channel 0 and receive channel 1.
Failed to perform the AXI DMA read-write transfer: Device or resource busy
在这里插入图片描述
root@myd-7015:~# dmesg
在这里插入图片描述
[ 552.652994] axidma: axidma_dma.c: axidma_prep_transfer: 236: Unable to prepare the dma engine for the DMA transmit buffer.
[ 587.913973] axidma: axidma_dma.c: axidma_prep_transfer: 236: Unable to prepare the dma engine for the DMA transmit buffer.

运行例程里的axidma_transfer
在SD卡中新建两个文本,在其中一个文本文件1.txt中写入内容,另一个2.txt为空
运行应用程序,将文件1的内容通过DMA环路写入文件2,因为文件太小了,所以显示的是0.00Mb
再次多加内容,可看到传输容量,运行结束后打开文件2,会发现和文件1里的内容完全一致tranfer
在这里插入图片描述
DMA w Petalinux say : Unable to prepare the dma en… - Community Forums https://forums.xilinx.com/t5/Embedded-Linux/DMA-w-Petalinux-say-Unable-to-prepare-the-dma-engine-for-the-DMA/td-p/938258
Unable to prepare the dma engine for the DMA transmit buffer. · Issue #85 · bperez77/xilinx_axidma · GitHub https://github.com.cnpmjs.org/bperez77/xilinx_axidma/issues/85

瞬间传输2.5M, 满足设计要求:
在这里插入图片描述
在定制板上的DMA传输实物照片
在这里插入图片描述

  • 6
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
### 回答1: PetaLinux是一款基于开源Linux发行版的嵌入式开发工具,用于构建、定制和部署嵌入式Linux系统。2018.3PetaLinux的版本号,代表其发布的时间和更新内容。 PetaLinux2018.3在之前版本的基础上进行了一些改进和优化。首先,该版本加入了对新的硬件平台的支持,包括新的处理器架构和外设。这意味着开发者可以在更多的硬件平台上使用PetaLinux进行嵌入式系统开发,提高了平台的可扩展性和灵活性。 其次,PetaLinux2018.3在功能上也有所增强。它提供了更多的开发工具和工程模板,使开发者在构建嵌入式系统时更加方便和高效。此外,该版本还改进了系统的性能和稳定性,增加了对多线程和多核处理的支持,提升了系统的并行处理能力。 此外,PetaLinux2018.3还新增了一些软件包和驱动程序,使开发者能够更好地支持各种外设和功能。它还引入了更多的编译器和调试工具,方便开发者进行代码编译和调试,并提供了更多的文档和示例代码,帮助开发者更好地了解和使用PetaLinux。 总之,PetaLinux2018.3是一个经过改进和优化的嵌入式开发工具,提供了更多的硬件支持和功能增强。它可以帮助开发者更方便、高效地构建和定制嵌入式Linux系统,为嵌入式开发提供了更多的选择和可能性。 ### 回答2: PetaLinux是Xilinx公司推出的一款基于Yocto Project构建的嵌入式Linux开发工具。旨在为Xilinx的Zynq和UltraScale系列FPGA提供一个高度优化的Linux发行版。PetaLinux 2018.3PetaLinux的一个版本,它包含了一些新的功能和改进。 PetaLinux 2018.3版本主要的更新包括对Yocto Project 2.6和Linux内核4.14的支持。这意味着开发人员可以使用最新版本的软件和驱动程序来构建他们的嵌入式Linux系统。该版本还提供了对新硬件平台的支持,包括Zynq UltraScale+ MPSoC ZCU102和ZCU104评估板。 PetaLinux 2018.3还加强了与Xilinx Vivado工具的集成,简化了从硬件设计到软件开发的流程。开发人员可以使用Vivado工具生成硬件设计文件,并直接从PetaLinux中进行导入和配置。这样可以提高整体开发效率,减少开发时间和风险。 此外,PetaLinux 2018.3还增强了对容器化应用程序的支持。开发人员可以使用Docker等容器技术在嵌入式Linux系统中运行和管理应用程序。这为开发人员提供了更大的灵活性和便利性,可以轻松构建和管理复杂的嵌入式应用。 总体而言,PetaLinux 2018.3为开发人员提供了更多的选择和工具来构建高度定制的嵌入式Linux系统。通过与Xilinx Vivado工具集成,支持最新版本的软件和驱动程序,以及对容器化应用程序的增强支持,开发人员可以更加轻松地进行嵌入式系统开发,并在不同的硬件平台上实现高性能和可靠性。 ### 回答3: Petalinux 2018.3是Xilinx公司开发的嵌入式Linux解决方案的一个版本。它是基于开源项目Yocto Project的,旨在帮助开发者构建用于Xilinx器件的定制化Linux操作系统。 Petalinux 2018.3提供了一套完整的工具链,使开发者可以轻松地构建、配置和定制嵌入式Linux系统。它支持多种开发板和处理器架构,包括Zynq-7000和Zynq UltraScale+等。通过使用Petalinux,开发者可以轻松地将Linux操作系统和Xilinx硬件平台结合起来,提供强大的嵌入式计算和图像处理能力。 Petalinux 2018.3具有许多强大的功能。首先,它提供了一个易于使用的界面,使开发者可以快速设置和配置嵌入式Linux系统。其次,它支持全面的嵌入式硬件和软件开发,包括设备驱动程序、文件系统、应用程序等。此外,Petalinux 2018.3还提供了丰富的软件开发工具,如交叉编译器、调试器和性能分析工具,以帮助开发者更好地进行嵌入式软件开发。 总的来说,Petalinux 2018.3是一个强大而灵活的嵌入式Linux解决方案,使开发者能够快速构建和定制嵌入式系统。无论是在工业自动化、智能交通、网络通信等领域,Petalinux 2018.3都能为开发者提供强大的工具和支持,并为他们带来更高效的开发体验。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值