UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
1,481 Views
Registered: ‎02-12-2018

XAPP1251 - UIO mmap() fails

Jump to solution


- IP, Version: AXI JTAG, 1.0
- Vivado, SDK, Petalinux: 2017.4
- Device:      Zynq-7000

hello,

I am trying to recreate XAPP1251. It is made with Vivado design tools 2014.3.1. It is a reference design for XVCServer using JTAG over ethernet.

Following chapter "Connect Hardware", step 4 I am running the application on the target with the following message:

xvcmod login: root
Password:
root@xvcmod:~# xvcServer &
[1] 1276
MMAP Failed



Test case

(1) the periferal is listed as /dev/ui0
(2) the contents of /sys/class/uio/ui0/maps/map0/ are correct (address, size, offset)
(3) stepping through the code in SDK:

   fd_uio = open("/dev/uio0", O_RDWR );
   if (fd_uio < 1) {
      fprintf(stderr,"Failed to Open UIO Device\n");
      return -1;
   }

   s = socket(AF_INET, SOCK_STREAM, 0);

   if (s < 0) {
      perror("socket");
      return 1;
   }

   volatile jtag_t* ptr = (volatile jtag_t*) mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
                    fd_uio, 0);
   if (ptr == MAP_FAILED)
                fprintf(stderr, "MMAP Failed\n");

   close(fd_uio);



I am able to open uio0 successfully and creating a socket. It fails to mmap fd_uio.
jtag_t is defined as:

typedef struct {
  uint32_t  length_offset;
  uint32_t  tms_offset;
  uint32_t  tdi_offset;
  uint32_t  tdo_offset;
  uint32_t  ctrl_offset;
} jtag_t;

It's fields are not getting assigned any values after calling mmap().



Can someone give me further hints on solving this issue, thank you.

0 Kudos
1 Solution

Accepted Solutions
Moderator
Moderator
1,556 Views
Registered: ‎09-12-2007

Re: XAPP1251 - UIO mmap() fails

Jump to solution
Can you manually set the MAP_SIZE here to 4096:

mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
fd_uio, 0);

For example:
mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED,
fd_uio, 0);

View solution in original post

0 Kudos
4 Replies
Visitor wittich
Visitor
1,457 Views
Registered: ‎11-10-2017

Re: XAPP1251 - UIO mmap() fails

Jump to solution

Hi, your message from your first printout suggests that the open call is failing, not the mmap?

0 Kudos
Highlighted
1,454 Views
Registered: ‎02-12-2018

Re: XAPP1251 - UIO mmap() fails

Jump to solution

Uh, yes, I am sorry,

 

That first printout is outdated, I solved that problem (copy and pasted the wrong text from my document). I edited my question.

 

 

0 Kudos
Visitor wittich
Visitor
1,435 Views
Registered: ‎11-10-2017

Re: XAPP1251 - UIO mmap() fails

Jump to solution

Hmmm, I don't have any additional ideas. Have you looked at errno?

 

Edit: as a (probably not very useful) piece of information: 

Using Vivado/Petalinux 2017.2 I was able to get a virtual cable server to work in a system that sounds very similar to what you have, except for the problem discussed and solved here: socket problem

 

I am showing below the kernel configuration and the contents of the sysfs entries, in case that is useful to you.

 

root@yugevu2:~# zcat /proc/config.gz  | grep -i UIO
CONFIG_UIO=y
# CONFIG_UIO_CIF is not set
CONFIG_UIO_PDRV_GENIRQ=y
CONFIG_UIO_DMEM_GENIRQ=y
# CONFIG_UIO_AEC is not set
# CONFIG_UIO_SERCOS3 is not set
# CONFIG_UIO_PCI_GENERIC is not set
# CONFIG_UIO_NETX is not set
# CONFIG_UIO_PRUSS is not set
# CONFIG_UIO_MF624 is not set
CONFIG_UIO_XILINX_APM=y

root@yugevu2:~# ls /sys/class/uio/uio0/maps/map0/
addr    name    offset  size
root@yugevu2:~# cat /sys/class/uio/uio0/maps/map0/*
0x40050000
/amba_pl/axi_jtag_v1_0@40050000
0x0
0x00010000

 

In my notes from that I found that the following two things were needed beyond what's in the XAPP1251, both in the device tree, due to kernel changes in the UIO driver. The first passes a choice to the UIO driver, the second is needed for mapping the AXI jtag to the kernel. However, I think in my case these were needed to get /dev/uio0 to be created _at all_ so this is probably not of use to you.

/{
  chosen {
          bootargs = "console=ttyPS0,115200 earlyprintk root=/dev/mmcblk0p2 rw rootwait uio_pdrv_genirq.of_id=\"generic-uio\"";
  };
};

// virtual cable
&axi_jtag {
    compatible = "generic-uio";
};
Moderator
Moderator
1,557 Views
Registered: ‎09-12-2007

Re: XAPP1251 - UIO mmap() fails

Jump to solution
Can you manually set the MAP_SIZE here to 4096:

mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
fd_uio, 0);

For example:
mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED,
fd_uio, 0);

View solution in original post

0 Kudos