Reading and writing from/to VME device

Martin, Tim tim.martin at viasat.com
Tue Mar 27 04:31:56 EST 2007


> I'm using the MVME6100 board with the Motorola driver for linux v3.5
(kernel 2.6.15).

I'm not sure what a "Linux v3.5" is - Montavista?  There are patches
available from Motorola to the vanila kernel if you're interested in
using something newer than 2.6.15.

> I try to access the CSR registers of an ADC board, in order to
configure it as to be
> able to access its memory, on the VME bus using one of the outbound
windows defined by
> the driver. As I am new to the whole VME stuff, I'm getting into
trouble to find out when
> I'm actually reading something on the VME, i.e. which addresses
respond.
> 1. open() and ioctl() one of the /dev/vme_m* devices, which I assume
is corresponding to
> an outbound window (at least I try to > configure it as one), 
> 2. then mmap() a memory area to hold the contents of the /dev/vme_m*
device file
> 3. and finally doing incrementation of the pointer returned by mmap()
and dereferencing it in the hope that I'll read something, which in most
cases is 0xFF 

This sounds like the right steps.  You don't appear to have the ioctl()
configuration structure set correctly.
	
> memset(&outWinCfgADC, 0, sizeof(vmeOutWindowCfg_t));
>     perror("memset");
>	    outWinCfgADC.windowNbr           = 0;
>	    outWinCfgADC.windowEnable     = 1;
>	    outWinCfgADC.wrPostEnable      = 0;
>	    outWinCfgADC.userAccessType  = VME_SUPER;
>	    outWinCfgADC.dataAccessType  = VME_DATA;
>	    outWinCfgADC.windowSizeL        = 0x200000;
>	    outWinCfgADC.xferProtocol         = VME_SCT;
>	    outWinCfgADC.addrSpace           = VME_A24;
>	    outWinCfgADC.maxDataWidth     = VME_D16;
	
This will setup a window of size 0x200000, type SingleCycleTransfer (vs.
BLT, 2eSST, etc), 24-bit addressing, 16-bit data.	
The target VME address will be 0x00000000, since you didn't configure
the .xlatedAddrU or .xlatedAddrL portions of outWinCfgADC.  Typically,
the VME address space is partitioned by VME chassis slot number or some
other application-specific scheme.  I'm guessing that 0 is not an
address that any VME board in your chassis is configured to respond to,
hence your errors.

Also, since you're doing 16-bit SCT reads, you probably want to
dereference your mmap'ed pointer as a 16-bit (unsigned short *) instead
of a (u_char *).

Tim



More information about the Linuxppc-embedded mailing list