pcmcia

Several questions here, but first some background:

Our software is QNX version 4.25. Our hardware is a Ampro P5e
board interfacing to PCMCIA card via Ampro MM2-PCC adaptor
board. Our system will collect data and write it to a “Sundisk SDP5/3 0.6”
card. We will then take the card and read it into NT machine for further
processing.

What we have found:

After launching Pcmcia.generic we use the “pin cis” command to
extract the configuration for the “Sundisk SDP5/3 0.6” card and
this confuguration is added it to pcmcia.cards file.
After launching Efsys.365sl server we see /dev/skt1 in /dev directory.
The program (below) will try and write then read to/from the card, but it
does not work. The open() as shown in the program is not successful
BUT if we open using “/dev/skt1” instead, then the open IS successful
BUT then after successful write, seek, read we don’t read back the
“Hello World”, even though wbytes is 11, pos is 0, and rbytes is 11.

Finally my questions:

Which driver should we be using? Currently using Efsys.365sl but is this
the correct driver for our hardware?

Can we use buffered I/O calls (fopen, fread, fwrite etc.)? These do not
seem to work.

Do the Sundisk cards need to be formatted or mounted?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>

int main (void)
{
off_t pos;
int fd;
int wbytes , rbytes;
char buf[15] = “Hello World”;
char temp[15] = “test”;

fd = open("/dev/skt1/filename", O_RDWR | O_CREAT, S_IRWXU);
if (fd == -1)
perror("\nFailed to open device.\n");
wbytes = write(fd, buf, strlen(buf));
if(wbytes == -1)
perror("\nFailed to write to the device.\n");

pos = lseek(fd, 0L, SEEK_SET);
rbytes = read(fd, temp, strlen(buf));
if (rbytes == -1)
perror("\nFailed to read from the device.\n");
printf("\ntemp is %s, buf is %s\n", temp, buf); // does not print
anything
close(fd);

return 0;
}

regards

Rob Murenbeeld
robm@optech.on.ca

rob <robm@optech.on.ca> wrote:
: Several questions here, but first some background:

: Our software is QNX version 4.25. Our hardware is a Ampro P5e
: board interfacing to PCMCIA card via Ampro MM2-PCC adaptor
: board. Our system will collect data and write it to a “Sundisk SDP5/3 0.6”
: card. We will then take the card and read it into NT machine for further
: processing.

: What we have found:

: After launching Pcmcia.generic we use the “pin cis” command to
: extract the configuration for the “Sundisk SDP5/3 0.6” card and
: this confuguration is added it to pcmcia.cards file.
: After launching Efsys.365sl server we see /dev/skt1 in /dev directory.
: The program (below) will try and write then read to/from the card, but it
: does not work. The open() as shown in the program is not successful
: BUT if we open using “/dev/skt1” instead, then the open IS successful
: BUT then after successful write, seek, read we don’t read back the
: “Hello World”, even though wbytes is 11, pos is 0, and rbytes is 11.

: Finally my questions:

: Which driver should we be using? Currently using Efsys.365sl but is this
: the correct driver for our hardware?

No, Efsys.365sl is for PCMCIA cards that use AMD or Intel flash, such as
the AMD 29Fxxx and the Intel 28Fxxx series flash. For a Sandisk (Sundisk),
you still need to run Pcmcia.generic, but they are accessed as block
oriented ATA devices. When you’ve got the pcmcia.cards file correct,
and you then slay and restart Pcmcia.generic, you should see your card
show up as an ATA device.

Here are some instructions for setting up an 8M Sandisk ATA Compact Flash card.
Note that your numbers may vary somewhat, but it should give you an idea
of how to get started.

\



Initializing the CompactFlash Card

  1. Boot the host PC into QNX, and run the Pcmcia manager (Pcmcia.generic)

  2. Insert the CompactFlash card into the PCMCIA adapter, and insert the
    adapter into the PCMCIA socket

  3. Run the QNX “pin” utility. This will show the currently detected cards in
    the PCMCIA sockets. The CompactFlash card should be detected as follows:


    Sock Win Type Flags PID Base Size IRQ Base Size DMA
    1 0 ATA C—I-±-------W None 0x320 16 7
    2 Empty ----MF---------- None

Note : the values for Base and IRQ may be different, depending on your
particular PCMCIA configuration. If so, make note of the values,
and enter the appropriate values when performing step 5.

  1. Start the QNX Fsys driver (if not already running).

Fsys &

  1. Start the QNX Fsys.eide driver as follows (substitute values for -a and -i
    as determined by pin output if necessary):

Fsys.eide -v fsys -h2,32 -NFLASH -n0=flash eide -b -l -a0x320 -i7 -S &

A device called flash0 should appear under the /dev/ directory.

  1. Run the QNX fdisk utility as follows:

fdisk -z /dev/flash0

This will zero the existing partition table.

Once in fdisk, all 4 positions should be blank, with the arrow pointing at the
first position.

Press C (change). The cursor will go to the “type” field. Type 77 and press
Enter. The cursor will go to the “Start Cylinder” field, with 0 showing. Press
Enter. The “End Cylinder” field will show 244. Press Enter. The rest of the
fields will fill in, and the size will be 7M. Press B to make the partition
bootable. A * should appear under the “Boot” field. Press S to save the
changes. Fdisk will exit, and prompt you to reboot. Reboot the machine.

  1. Start the Fsys and Fsys.eide drivers as in steps 4 and 5.

  2. mount the partition (/dev/flash0) as follows:

mount -p /dev/flash0 /dev/flash0t77 /flash

The first time you do this procedure, you’ll likely get an error message
saying that the mount of /dev/flash0t77 failed (corrupted filesystem
detected), but /dev/flash0 will be mounted.

  1. Format the partition as follows:

dinit -h /dev/flash0t77

  1. Mount the filesystem partition:

mount /dev/flash0t77 /flash

You should now have a writeable filesystem under /flash.


Dave Green (dgreen@qnx.com)

Custom Engineering Services
QNX Software Systems Ltd.
http://www.qnx.com