-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the driver with Petalinux #24
Comments
The problem comes from the fact that PetaLinux seems to be putting all the generated build files from compiling the kernel in a separate directory. This also means that you can't run an out of tree build (at least I havne't been able to), so you can't use the driver's build system. Instead you must create a PetaLinux 'modules' project, copy the source code into the project, and then make some modifications to the Makefile. First, petalinux-create -t modules -n xilinx-axidma --enable Next, copy all of the C source files and header files under the driver directory, and the header file include/axidma_ioctl.h to the driver source directory, and remove the auto-generated file there: cp -a driver/*.c driver/*.h include/axidma_ioctl.h <path/to/PetaLinux/project>/project-spec/meta-user/recipes-modules/xilinx-axidma/files
rm <path/to/PetaLinux/project>/project-spec/meta-user/recipes-modules/xilinx-axidma/files/xilinx-axidma.c Then, replace the first line of the Makefile at <path/to/PetaLinux/project>/project-spec/meta-user/recipes-modules/xilinx-axidma/files/Makefile with the following: DRIVER_NAME = xilinx-axidma
$(DRIVER_NAME)-objs = axi_dma.o axidma_chrdev.o axidma_dma.o axidma_of.o
obj-m := $(DRIVER_NAME).o Finally, you can build the module normally with the petalinux-build -c rootfs/xilinx-axidma The module should be packaged with your filesystem image, and you can find the kernel object file under /lib/modules//extra/xilinx-axidma.ko. Alternately, you can find it in your PetaLinux project directory under <path/to/PetaLinux/project>/build/tmp/sysroots/plnx_arm/lib/modules//extra/xilinx-axidma.ko. |
This was brought about by issue #24, and the README now contains a reference to the issue to point people on how to use the driver with PetaLinux.
Did that end up working for you? |
To make it work i had to append all C and Header Files to the SRC_URI List in the xilinx-axidma.bb file.
I'm using petalinux 2016.4. Thank you a lot for make this driver compatible with Petalinux! |
No problem! Ahh got it, those steps worked for me, but we might have been using different versions of PetaLinux. Thanks for posting your solution, it should be useful to everyone else who runs into this issue, |
Hi Brandon and Jared, Thank you guys VERY much for sharing all the great work. I am very happy to find your Now my modified version of your test program (axidma_transfer.c) is also running -- RX forever, How to set up the ring of buffers/descriptors like with the bare metal? And then how to receive This way we can reduce the chance of loosing data to practically ZERO if we have a large number Thank you very much again, best regards, |
The best way to do this would be to use AXI VDMA, as it supports this continuous transfer mode. Unfortunately, the driver at the moment has the code to support VDMA, but it does not work. However, this is still possible to emulate with AXI DMA. The best way to setup the ring of buffers is to use To initiate a continuous transfer, you can use the signal support that is part of the AXI DMA library. You can use the library function With those two functions, that should be sufficient to setup a continuous RX transfer. The signal handler can advance the buffer in the ring that you're sending, and set a flag that indicates for your application to initiate the next transfer. |
Hi Brandon,
Thank you very much for the advises.
This device/driver business is rather new to me. Is it correct that the built-in "xilinx-dma" is the driver,
and you package is the device and you are using the "xilinx-dma" driver?
I have been reading the "xilinx-dma" code, and yours of course. It seems that "xilinx-dma" is already supporting the SG / ring of buffers stuff. However it is not clear to me where the buffers are allocated -- seems "xilinx-dma" is only allocating the descriptors (only 255 of them, I would like more), but not allocating any buffers.
I am planing to copy and modify the "xilinx-dma" code, so that it will:
1. allocate 4095 descriptors, and the associated buffers (each not too large)
2. make the "read" method use the oldest filled buffer, then return the descriptor back to the ring
I would not mind to copy_to_user if it makes the code simpler, will worry about the CMA later. For now
it is more important to ensure that we don't loose data.
How can I do this? Modify "xilinx-dma" to get #1, modify your chardev to get #2? Is it possible to do all
of these in just one package? Please advice if you have a little spare time.
Thank you again, best regards,
|
This was brought about by issue #24, and the README now contains a reference to the issue to point people on how to use the driver with PetaLinux.
Sorry for the late reply, I missed this notification. Ah yes, that's a good question. So you can think of my driver purely as a "bridge" between userspace and Xilinx's AXI (V)DMA driver. The Xilinx AXI (V)DMA driver can only used by other drivers or code in kernel space, and cannot be used by userspace code. The Xilinx AXI DMA handles all of what would be traditionally considered what a "driver" does, such as setting up the interrupts, handling low-level writes to MMIO registers, allocating DMA buffer descriptors, etc. My driver, on the other hand, handles setting up some basic data structures, and exposing DMA functionalities to userspace through IOCTL's. Of course, there's also a userspace library that sits between my driver and the end user application to further simplify the use of the driver. In terms of your question about the descriptors, it's probably unnecessary to increase the number of them, unless the size of data you're transferring is larger than 8 MB * 255 (8 MB is the max size for any one transfer). Your second point should work, though you'll likely need to handle that in Xilinx's driver. |
Hi Brandon, I am trying to install your driver for using with VDMA on petalinux 2017.2 and run into some problems.
(Actually, there are some more entries for my platform here, but they are not related to DMA)
So it seems the Xilinx DMA stuff is initialized correctly. But then:
According to device tree entry:
I would expect the channel IDs being 0 and 1. Do you have an idea about what is going wrong here? Thanks a lot |
Hi again, sometimes it helps to describe the problem for finding the solution. Obviously petalinux assigns device id 0 to both dma channels, no idea why. I made a copy of the petalinux-generated device tree entry into system-user.dtsi and manually set the rx channel to device id 1. After compiling, the driver loads fine. Bests, Westwood68 |
Ok, got it thanks for the heads up. Yeah that's annoying that PetaLinux does that. I'm guessing that implies that the device-id field may be deprecated soon, which may be an issue. I'll need to update my README about the different config option. I think Xilinx merged the AXI DMA and AXI VDMA drivers in the newer versions of the kernel. So no other problems then? The driver works fine with AXI VDMA? |
Yes, all DMA modes (dma, cdma, vdma) are handled by a single low level driver in the new kernels. My idea was to to start with a VDMA loopback test, same as the Xilinx vdmatest kernel module does. There is also a userspace bridge driver for VDMA from Xilinx (vdma_wrapper), which is still included in the kernel tree but seems outdated and even does not compile. So I am a bit at a loss what to do now. |
Actually, I'm literally writing that support into the driver as we speak, see issue #31. At the moment, the driver does support VDMA transactions, but only one at a time. It doesn't have a loop mode for cameras like it does for displays. Interesting, glad to see they finally tried to add a userspace bridge driver; after all, I had to write this because they lacked one. It's actually not too complicated to add, I never did simply because I didn't need it for any of my projects. |
Ok, I added support for this with c3181d8. Unfortunately, I don't have a setup right now to test my changes (and I won't for a while), so I only check that the changes compiled against the most recent version of the Xilinx kernel. Could you take the code for a spin and let me know if it works? |
Ok... does this mean, each vdma read operation must be requested explicitly by the software? This would be sufficient for the moment. How can I do this? I should read the issue #31 comments.
Well, it is in the staging tree, and it seems Xilinx forgot it there. No idea if this was ever operational. It depends on another C source file which has changed, and so compiling the kernel fails with this wrapper enabled. Btw, I tried to do loopback test from kernel space. Xilinx provides a kernel module for that (config_vdma_test=y), and it reports vdma working. So I can verify my hardware being ok. However, for this test, all f_sync options in the vdma IP must be turned off, otherwise I get a timeout. |
It doesn't need to be explicitly requested by your userspace application. In either of the library functions,
That's just classic Xilinx there.
Got it. I've never tested my driver with the The commit I just pushed enables cyclic/loop transfer for VDMA reads. It's untested, but I have verified that it successfully compiles. |
Sorry, crossover. I will test your code and let you know. |
I did just a short test, but get a read timeout, see below. Do I need to change the example code somehow?
|
Ok, seems it works now. The timeout problem is obviously caused from the "Frame Store Configuration is not enabled..." thing, see previous posting. This occurs when the number of frame buffers configured in the vdma ip core is higher than 1, which cannot be handled by the xilinx dma engine driver. According to Xilinx this should already be fixed , but maybe in newer versions of Petalinux (I am on 2017.2). So I configured the core and the device tree for a single frame buffer, and now the benchmark passes:
Next I will try to get it working with multiple buffers. |
Ok, got it. Yeah that makes sense, but a shame that they haven't backported the changes to earlier versions. Let me know if you're able to get multiple frame buffers working. |
Hi Brandon, I have upgraded to Petalinux 2017.3 and Vivado 2017.3. Now your axidma bridge benchmark works also with multiple frame buffers (tested with 3 buffers). I have tried this on a Digilent Zybo board: root@zybo_linux:~# ./axidma_benchmark -v Using transmit channel 0 and receive channel 1. DMA Timing Statistics: Thanks a lot for your support! Regards |
Awesome, great to know! And no problemo, I'm glad to hear that the issue has been resolved. |
Greetings. I am trying to replicate these steps for Petalinux 2017.4. I got to the point where I perform the command petalinux-build -c rootfs/xilinx-axidma, but this is returning an error: "ERROR: Nothing PROVIDES 'rootfs/xilinx-axidma'. Close matches: xilinx-axidma". I tried following LucasKl's additional step of modifying the SRC_URI line of xilinx-axidma.bb. I noticed in the listed procedure, it does instruct to delete the xilinx-axidma.c file, but it still exists in the SRC_URI line? |
I'm not sure. I would try deleting the file as described and also removing it from the @Westwood68 did you run into a similar issue? |
Hi Brandon,
currently I can not continue with this project, I am sorry.
Brandon Perez <notifications@github.com> wrote:
I'm not sure. I would try deleting the file as described and also removing it from the SRC_URI line.
@Westwood68 did you run into a similar issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Sent with mySecureMail.
http://www.mysecurephone.eu/
|
@Westwood68 Do you happen to remember/have the settings for the AXI VDMA IP you used to get the VDMA test to work in the kernel? I'm trying to get it up an running now, but I can't seem to find the right configuration. |
Where can I find the Bitbake recipe <xilinx-axidma.bb> for this? I am not working in Petalinux, just working in straight Yocto with meta-xilinx, and can't seem to find the recipe. Thanks! |
I haven't worked much with Yocto unfortunately, but the |
Thanks for the neat and clear set of instructions! Was a breeze to compile your module with petalinux, and use the user space library :) |
No problem, glad to hear it was a smooth process for you. |
Hi , I am testing axi-dma in zcu106 board with your driver , I have compiled the driver code with petalinux under your guidence above , and I have modified my device-tree as follows in system-user.dtsi . However , after insmod my driver.ko in zcu106 board , I cannot see anything ,it seems like that the code is stuck in this function "platform_driver_register(&axidma_driver);" in axi_dma.c , and there is nothing shown on the screen , and there is no device registered in the kernel , I cannot see the driver under "/dev/", my system-user.dtsi is as follows Any idea?Thanks. |
@18829212662 upload your dmesg log |
Hey, I wrote code to get camera pics and I did some modifications to those pics. After that, I use your driver to send pics to pl. How do I know I successfully transfered pics? |
use a fifo loop to rewrite your pics data back to ps ddr |
@suikammd or add ila to your block design. When you start your pics transfer vivado monitor interface will get the data waveform in axi bus, so you can check whether the data is well tranfered |
@suikammd If you really worry about verifying that your data transfer happened reliably, I would suggest the use of checksum like CRC32. It can be computed very efficiently both in PS and PL and you only need to send a single checksum word from PL to PS to perform your verification. |
This is required for Petalinux 2018.2 as well. Huge thanks to you and @bperez77! Edit: The steps described above in (#24 (comment)) are also required. Whilst copying the contents of pl.dtsi to system-user.dtsi, I had to get it from the amba_pl bus section, as described below:
|
hey,Thank you VERY much for sharing all the great work. |
The problem lies in the width of buffer length register , it's 14 by default ,when the buffer size was larger than 4M , it will goes wrong ,final I change it to 23,which works,thanks again :) |
I get this error too. root@xdmatest:/lib/modules/4.14.0-xilinx-v2018.2/extra# insmod xilinx-axidma.ko But one dma two channel, is it ok? |
always error: root@xdmatest:/lib/modules/4.14.0-xilinx-v2018.2/extra# insmod xilinx-axidma.ko |
help~~ |
this is the error: ./axidma_benchmark -t 0 -r 1 -b 1500 -s 1500-n 300 Using transmit channel 0 and receive channel 1. |
Instead of running Note that for 2019.2 I was required to change 2 *.c files as seen here: ISSUE-123 |
I tried compiling the driver using the Makefile you provided, however it seems to me that the KBUILD_DIR parameter is not correct.
"make CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm KBUILD_DIR=..../petalinux-test/zynq-3/build/tmp/work-shared/plnx_arm/kernel-source/ driver"
This gives me the following error:
"make: *** No rule to make target '/home/lklemmer/Documents/Studium/Bachelorarbeit/petalinux-test/zynq-3/kernel-source/Module.symvers', needed by 'driver/axidma.ko'. Stop."
I noticed that petalinux put the Module.symvers file in a seprate directory (kernel-build-artifacts/)
I tried copying the contents of this directory into the linux kernel-sources (kernel-sources/) but without success.
The text was updated successfully, but these errors were encountered: