2

Background:

What I want to do is to be able to write from my ARM processor to a BRAM, on a Zynq 7000.

To do this, I have the following components:

-M_AXI_GP0 on PS7 connects to S_AXI_LITE on axi_cdma_0 through an AXI Interconnect

-cdma_introut on axi_cdma_0 connects to IRQ_F2P on PS7 through sys_concat, input 11. This means that this maps to Interrupt 87 on PS7.

-M_AXI on axi_cdma_0 connects to S00_AXI on axi_mem_intercon

-M01_AXI on axi_mem_intercon connects to S_AXI_HP3 on PS7

-M00_AXI on axi_mem_intercon connects to S_AXI on axi_bram_ctrl_0

-BRAM_PORTA on axi_bram_ctrl_0 connects to BRAM_PORTA on blk_mem_gen0

=========================================================================

In my mind, what this setup ought to do is this:

  1. Once a transaction is submitted from the ARM DMA Engine, the Zynq will use GP0 to send a command to the CDMA controller via GP0.

  2. The CDMA controller will receive the commands on its slave AXI_LITE port, and interpret the request to access RAM via HP3.

  3. The CDMA controller will move data through axi_mem_intercon in order to take the transaction data from hp3 on M01_AXI, and send it through M00_AXI to the BRAM Controller

  4. The BRAM controller will take in the AXI-4 input and convert that to the appropriate BRAM port to write the data into the BRAM generated by blk_mem_gen_0

  5. After completing this action, the CDMA will send an interrupt through sys_concat to indicate to the DMA Engine that its work is complete.

After loading this hdl design into the PL fabric, I attempt to submit the transaction to the DMA engine via a kernel module. The result is a timeout, with the DMA engine apparently never finishing the task.

=========================================================================

In my attempts to figure out the problem, I've made these observations:

  1. After attempting a write transaction, which times out, I attempted a read transaction to the same DMA channel, but configured to read data. What I get back is all the data that I had attempted to write. This, to me, seems to indicate that the DMA engine IS writing to somewhere, but isn't recognizing the completion of the task

  2. The BRAM in question is a dual port RAM, and the other port reads the data in the BRAM and toggles LEDs to reflect the data. The LEDs are not toggling when I attempt this write transaction, so it seems as though the DMA transaction is not making it as far as the BRAM

  3. When looking at cat /proc/interrupts, I can see several interrupts, but not GIC 87. As mentioned before, the interrupt line I am using goes to Input 11 of the IRQ concat block. I can confirm that the interrupt line which goes to Input 12 does indeed correspond to GIC 88 from /proc/interrupts, so I believe my understanding of which interrupt I am looking for is correct. So for some reason it is not registering that interrupt on the processor.

=========================================================================

Based on this, I believe my devicetree entry for this CDMA is what is incorrect.

In Vivado, I can see these entries in the Address Editor(Some entries omitted for brevity):

sys_ps7
    Data(32 address bits:0x40000000 [1G])
        axi_cdma_0                S_AXI_LITE    Reg    0x43C0_0000    64K    0x43C0_FFFF


axi_cdma_0
    Data(32 address bits : 4G)
        axi_bram_ctrl_0           S_AXI         Mem0   0xC000_0000    4K    0xC000_0FFF
        sys_ps7                   S_AXI_HP3     HP3... 0x0000_0000    1G    0x3FFF_FFFF

My attempt to write a devicetree entry is as follows:

axi-cdma@43C00000{
    #dma-cells = <0x1>;
    compatible = "tst,axi-cdma-ctrl-1.00.a";
    reg = <0x10000000 0x1000>;
    interrupts = <0x0 0x37 0x4>;
    interrupt-parent = <0x1>;

    dma-channel@C0000000{
        buswidth = <0x20>;
    }

Before I added this entry in my kernel module failed to even register a transaction channel, and now it does, so I am fairly certain that the kernel is accepting this entry at least enough to assign a DMA channel. However, I don't understand much about how exactly the devicetree works, specifically with the addressing, so there is a good chance I have written this incorrectly, and that is why my transaction doesn't succeed. Can anyone help me correct my design? }

Zephyr
  • 337
  • 5
  • 23

1 Answers1

2

Declaring the IP core in device tree is not sufficient. You must also declare your DMA client, as Xilinx does in CDMA test client:

 cdmatest_1: cdmatest@1 {
              compatible ="xlnx,axi-cdma-test-1.00.a";
              dmas = <&axi_cdma_0 0>;
              dma-names = "cdma";
 } ;  

In dmas field, the axi_cdma_0 references the CDMA IP core and the 0 its first dma-channel, as defined in the devicetree:

 axi_cdma_0: dma@4e200000 {
              #dma-cells = <1>;
              clock-names = "s_axi_lite_aclk", "m_axi_aclk";
              clocks = <&clkc 15>, <&clkc 15>;
              compatible = "xlnx,axi-cdma-1.00.a";
              interrupt-parent = <&intc>;
              interrupts = <0 31 4>;
              reg = <0x4e200000 0x10000>;
              xlnx,addrwidth = <0x20>;
              xlnx,include-sg ;
              dma-channel@4e200000 {
                      compatible = "xlnx,axi-cdma-channel";
                      interrupts = <0 31 4>;
                      xlnx,datawidth = <0x20>;
                      xlnx,device-id = <0x0>;
                      xlnx,include-dre ;
                      xlnx,max-burst-len = <0x10>;
              };
 };

After that, you should register your client as a platform driver. Again, from CDMA test client source:

static const struct of_device_id xilinx_cdmatest_of_ids[] = {
    { .compatible = "xlnx,axi-cdma-test-1.00.a", },
    { }
 };

 static struct platform_driver xilinx_cdmatest_driver = {
     .driver = {
         .name = "xilinx_cdmatest",
         .owner = THIS_MODULE,
         .of_match_table = xilinx_cdmatest_of_ids,
     },
     .probe = xilinx_cdmatest_probe,
     .remove = xilinx_cdmatest_remove,
 };

 static int __init cdma_init(void)
 {
     return platform_driver_register(&xilinx_cdmatest_driver);
 }

Please note the compatible field of device tree and of platform driver definition, these strings must match. If you did not do this, the dma_request_slave_channel() cannot reserve a channel from your CDMA IP core. Moreover, ensure you do not use dma_request_channel() which is not supported in xilinx kernel >= 4.0 and will fail to reserve channels properly, the transfer will not complete and the DMA will timeout with no interrupt. I am not sure about observation 1, it might be a caching effect. Try to use dma_alloc_coherent() instead of kmalloc().

PS: In any case, try to make sure your hardware is ok by using a bare metal app if possible.

galanom
  • 46
  • 5