OpenCores

Advanced Debug System

Issue List
regular user parallel port access using adv_jtag_bridge #9
Closed rfajardo opened this issue about 15 years ago
rfajardo commented about 15 years ago

I needed to debug using a computer connected to a network having a server account management, thus I couldn't get superuser access.

I solved that by changing the direct memory access to the port for operating system calls on a file descriptor.

Your user account has to have read and write permissions to the "/dev/parport0". In my case "/dev/parport0" gives read and write permissions to the group lp and the user was registered to this group.

In linux it has been tested and is working. Also compatibility issues with impact have been solved.

How To? Includes: #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <linux/ppdev.h> #include <linux/ioctl.h> #include <linux/parport.h>

create a global variable called fd to carry the file descriptor pointing to the device.

int fd;

Initialize the device: int mode = IEEE1284_MODE_COMPAT; fd = open("/dev/parport0", O_RDWR | O_NONBLOCK); if (fd == -1) { perror("Not able to acquire the device desriptor\n"); return APP_ERR_INIT_FAILED; } if (ioctl(fd, PPCLAIM) == -1) { perror("Fail to claim the interface for itself.\n"); return APP_ERR_INIT_FAILED; } if (ioctl(fd, PPSETMODE, &mode) == -1) { perror("Setting compatibility mode failed.\n"); return APP_ERR_INIT_FAILED; }

Read from the device: ioctl(fd, PPRSTATUS, inval); Write to the device: ioctl(fd, PPWDATA, &value);

inval and value as shown here work with cable_parallel.c. Actually both should be pointers to "unsigned char".

rfajardo commented about 15 years ago

In order for it to work you have to include the files: sys/types.h sys/stat.h fcntl.h linux/ppdev.h linux/ioctl.h linux/parport.h

That's it :-)

rfajardo commented about 15 years ago

This solution does not work for cygwin users.

To connect to devices through parallel port using different systems and guessing the right way to do it one can use: http://cyberelk.net/tim/software/libieee1284/ or possibly: https://launchpad.net/libieee1284

Anyways this only bloats everything. The above linux solution is based on ppdev which does not exist for cygwin as far as I know.

Another option is that there is different code for linux and cygwin. Well, that's pretty much all I can say about it.

I hope it helps someone, Raul

nyawn commented almost 13 years ago

This has been implemented as of the 3.0.0 release.

nyawn closed this almost 13 years ago

Assignee
No one
Labels
Idea