Hello i'm trying to compile for LabView71 C source program (using Code external nodes) that reads data from PCIe device.
when i run "./lvmkmf pcie" - it generates Makefile and it`s ok, but after i run "make" the following error i see:
# make
gcc -shared -o pcie.tmp \
/usr/local/lv71/cintools/cin.o pcie.o /usr/local/lv71/cintools/libcin.a
/usr/local/lv71/cintools/lvsbutil -c pcie -t CIN -d "`pwd`"
/usr/local/lv71/cintools/pcie.tmp: undefined symbol: CINRun
/usr/local/lv71/cintools/lvsbutil: error building resource file: 1
make: *** [pcie.lsb] Error 2
------------------------------------------
Is there a way how to solve this problem? please help, my program source code is:
------------------------------------------
#include <extcode.h>
#include <hosttype.h>
#include <fundtypes.h>
#include <platdefines.h>
#include <stdio.h>
#include <pci/pci.h>
#include <fcntl.h>
#include "/usr/include/linux/pci.h"
#define PCITAG struct pci_filter *
#include <sys/mman.h>
#include </usr/include/stdlib.h>
#include </usr/include/locale.h>
#include <time.h>
int main (int argc, char *argv[])
{
setlocale(LC_ALL, "");
struct pci_access *pacc;
struct pci_dev *dev;
struct pci_filter ltag;
struct pci_dev *d;
struct pci_dev *config_space = NULL;
struct timeval {
long tv_sec;
long tv_usec;
};
unsigned int c;
char * itoa ( int value, char * str, int base );
if (iopl (3))
{
printf ("Cannot get I/O permissions (being root helps)\n");
return 0;
}
pacc = pci_alloc();
pci_init(pacc);
pci_scan_bus(pacc);
for (dev = pacc->devices; dev; dev = dev->next) {
pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES);
}
dev = pacc->devices;
printf("Dev = %d\n", dev);
unsigned char *ptr;
while (dev != NULL)
{
printf("[%d:%d:%d] VendorID: %04x DeviceID: %04x\n", dev->bus, dev->dev, dev->func, dev->vendor_id, dev->device_id);
printf ("Class %X Revision %X ", pci_read_word (dev, 0x0a), pci_read_word (dev, 0x08));
if ((dev->vendor_id != 0x1172) || (dev->device_id != 0x0007))
dev = dev->next;
else
{
printf("\nAltera Development kit was found\n");
printf ("Vendor %X Device %X\n ", pci_read_word (dev, 0x00), pci_read_word (dev, 0x02));
printf ("Command %X Status %X\n ", pci_read_word (dev, 0x04), pci_read_word (dev, 0x06));
int pos, len=8;
void *buf;
read(dev, pos, ptr, len);
printf("Pos=%d, Len=%d\n", pos, len);
printf("Size of buf=%d\n", sizeof(buf));
printf("Size of Cache=%d\n", sizeof(dev->cache));
printf("Size of Cache=%d\n", dev->cache_len);
printf("Cache=%d\n", dev->cache);
u32 pci_mem_addr, pci_io_addr;
unsigned char *ptr_to_pci_mem;
unsigned char *ptr_to_pci_fd;
struct timeval t0;
struct timeval t1;
double dt;
pci_mem_addr = pci_read_long(dev, 0x10) & PCI_BASE_ADDRESS_MEM_MASK;
printf("\npci_mem_addr = %x\n", pci_mem_addr);
int fd = open("/dev/mem", 2);
close(fd);
break;
}
}
#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' <<
😎 char path[128];
char buf[1024];
int fd;
FILE *fptr;
unsigned int bus, device, function, devfn;
unsigned int sbus=0, sdevfn=0, svend;
unsigned long bar, sbar =0;
unsigned int *data;
u16 ven, devv;
sprintf( path, "/proc/bus/pci/03/00.0");
printf( "\npath is :%s\n", path );
fd = open("/proc/bus/pci/03/00.0", 0);
if( fd == -1 ) perror( "Couldn't open device file" );
pread(fd, &ven, 2, PCI_VENDOR_ID);
pread(fd, &devv, 2, PCI_DEVICE_ID);
printf( "ven is :%x\n", ven);
printf( "dev is :%x\n", devv);
u32 buf2;
lseek(fd, 0x00, SEEK_SET);
read(fd, buf2, 8);
printf( "size of buf2 :%d\n", sizeof(buf2));
u16 bara;
pread(fd, &bara, 2, PCI_BASE_ADDRESS_0);
printf( "bar is :%x\n", bara);
pread(fd, &bara, 2, PCI_BASE_ADDRESS_1);
printf( "bar is :%x\n", bara);
pread(fd, &bara, 2, PCI_BASE_ADDRESS_2);
printf( "bar is :%x\n", bara);
pread(fd, &bara, 2, PCI_BASE_ADDRESS_3);
printf( "bar is :%x\n", bara);
pread(fd, &bara, 2, PCI_BASE_ADDRESS_4);
printf( "bar is :%x\n", bara);
pread(fd, &bara, 2, PCI_BASE_ADDRESS_5);
printf( "bar is :%x\n", bara);
printf ("MEMORY LIMIT %X\n ", pci_read_word (dev, PCI_MEMORY_LIMIT));
close(fd);
pci_cleanup(pacc);
return 0;
}
----------------------------------------------------
Makefile source code:
----------------------------------------------------
# This Makefile was generated automatically by lvmkmf.
#
CC=gcc
LD=gcc
LDFLAGS=-shared
XFLAGS=-fPIC -O
CINDIR=/usr/local/lv71/cintools
CFLAGS=-I$(CINDIR) $(XFLAGS)
CINLIB=$(CINDIR)/libcin.a
MAKEGLUE=$(CINDIR)/makeglueLinux.awk
AS=gcc -fPIC -c
.SUFFIXES: .lsb .lsb~ $(SUFFIXES)
# Default rule to create an lsb from a C source file
.c.lsb: ; make $*.o
$(LD) $(LDFLAGS) -o $*.tmp \
$(CINDIR)/cin.o $(XLDFLAGS) $*.o $(CINLIB)
$(CINDIR)/lvsbutil -c $* -t CIN -d "`pwd`"
@rm -f $*.tmp
pcie.lsb: pcie.o
$(LD) $(LDFLAGS) -o pcie.tmp \
$(CINDIR)/cin.o $(XLDFLAGS) pcie.o $(CINLIB)
$(CINDIR)/lvsbutil -c pcie -t CIN -d "`pwd`"
@rm -f pcie.tmp
clean:
$(RM) -f pcie.o pcie.tmp
spotless: clean
$(RM) -f pcie.lsb
==================================