Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Under what condition I can "write" but cannot "read" from a location?

$
0
0

The purpose is to do DMA transfer betwee Processing System (PS) and Programmable Logic (PL) for a ZYNQ 7000 board. I am trying to use Userspace Input Outut (UIO) framework. I have a UIO device in my ZYNQ board. I am using mmap to access the UIO device. From my application I can write to the device but cannot read, what can cause such behaviour?

I am given below only the lines that is relavant, ommiting all other lines. I am not sure the other lines are relavant or not. Other lines are unchanged. In the first case, the write command return err=4 which is correct but in the second case, "read", nothing is returned?

fd_uio = open("/dev/uio0",O_RDWR);mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_uio, (off_t) 0);err=write(fd_uio, (void *)&pending, sizeof(int));
fd_uio = open("/dev/uio0",O_RDWR);mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_uio, (off_t) 0);err=read(fd_uio, (void *)&pending, sizeof(int))

The below is edited code in case we can use memcpy() instead of read?

fd_uio = open("/dev/uio0",O_RDWR);fd_mem = open("/dev/mem",O_RDWR);fromPtr=mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_uio, (off_t) 0);destPtr=mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_mem, (off_t) 0);memcpy( destPtr, fromPtr, size);

EDIT:

uint32_t Val       =89;void *regs =   mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_uio, (off_t) 0);    *((volatile uint32_t *)(regs))=Val;    uint32_t dma_status=*((volatile uint32_t *)(regs+4));    printf("Value of errno: %d\n", errno);    printf("dma_status %" PRIu32 "\n\r",dma_status);

In the above code I was expecting the dma_status to be 89 but I do not get 89. I get 0 if (regs+4) or I get 65563 if I do regs.

The following may help. I have tried to use reserve memory by adding the following lines in system-user.dtsi file:

    reserved-memory{        #address-cells=<1>;        #size-cells =<1>;        ranges;        dma_reserved:buffer@0{            compatible="shared-dma-pool";            no-map;            reg=<0x30000000 0x1000000>;        };    };    dma_proxy@0 {        compatible ="xlnx,dma_proxy";        dmas = <&axi_dma_0 1>;        dma-names = "dma0";        memory-region = <&dma_reserved>;    };

But when I try to check if the reserved memory is there or not in the board, I get the following.

two:/home/petalinux# dmesg | grep eserveOF: fdt: Reserved memory: failed to reserve memory for node 'buffer@0': base 0x00000005, size 0 MiBOF: fdt: Reserved memory: failed to reserve memory for node 'buffer@0': base 0x00000000, size 512 MiBcma: Reserved 16 MiB at 0x3f000000Memory: 998020K/1048576K available (7168K kernel code, 243K rwdata, 1904K rodata, 1024K init, 118K bss, 34172K reserved, 16384K cma-reserved, 245760K highmem)hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.

Further edit:

The problem may be that when I type dmesg | grep eserve I get
0F: fdt: Reserved memory: failed to reserve memory for node 'buffer@0': base 0x00000005, size 0 Mib
and

0F: fdt: Reserved memory: failed to reserve memory for node 'buffer@0: base 0x00000000, size 512 Mib and

cma:Reserved 16 MiB at 0x3f000000The output of cat /proc/iomem is below

three:~$ sudo cat /proc/iomem                                                                                       00000000-2fffffff : System RAM  00008000-00afffff : Kernel code  00c00000-00c5c727 : Kernel data31000000-3fffffff : System RAMe0001000-e0001fff : xuartpse000a000-e000afff : e000a000.gpio gpio@e000a000e000b000-e000bfff : e000b000.ethernet ethernet@e000b000e000d000-e000dfff : e000d000.spi spi@e000d000e0100000-e0100fff : e0100000.mmc mmc@e0100000f8003000-f8003fff : dma-controller@f8003000  f8003000-f8003fff : f8003000.dma-controller dma-controller@f8003000f8005000-f8005fff : f8005000.watchdog watchdog@f8005000f8007000-f80070ff : f8007000.devcfg devcfg@f8007000f8007100-f800711f : f8007100.adc adc@f8007100f8801000-f8801fff : etb@f8801000f8803000-f8803fff : tpiu@f8803000f8804000-f8804fff : funnel@f8804000f889c000-f889cfff : ptm@f889c000f889d000-f889dfff : ptm@f889d000fffc0000-fffcffff : fffc0000.sram sram@fffc0000

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>