All,

I am new to vxworks and bsp development, we are trying to integrat the
mdoc h3 to the on baord power pc ... i got a instruction document from
m-systems for the trueffs driver for vxworks... i made the changes
according to the document in the bootConfig.c and usrConfig.c..however
when i tried building the bootRom it compalins about undefined
reference to tffsSetup and tffsLoad...

These are the instrcutions...

3. BOOTING VXWORKS FROM mDOC
----------------------------

3.1. There are two basic VxWorks boot scenarios supported by mDOC
driver:

A. One-step boot

This scenario is used with relatively small VxWorks
applications
that can entirely fit into system's ROM.

In this case VxWorks bootimage, along with VxWorks,
includes
application and mDOC driver.

B. Two-step boot

This scenario is used with larger VxWorks applications
where
scenario 'A' cannot be used because of application's
size.

Two different bootimages are involved in this boot
scenario -
'bootrom' and 'vxWorks'.

The 'bootrom' bootimage resides in system's ROM. It
includes minimal
configuration of VxWorks (which includes dosFs2 file
system) and
mDOC driver; it does not include user application itself.
Essentially, 'bootrom' bootimage is a program loader. It
gets executed
upon reset, and uses mDOC driver for loading the second
bootimage -
'vxWorks' - from mDOC. The 'vxWorks' bootimage includes
the
full configuration of VxWorks, mDOC driver, and user's
application.

If you are using boot scenario 'A', proceed with instructions in
Section 3.2.

If you are using boot scenario 'B', proceed with instructions in
Section 3.3.

3.2. If you are using boot scenario 'B', skip this Section, and
proceed with
Section 3.3 instead.

Boot scenario 'A' does not require any changes in VxWorks boot
code.

All user has to do, is to place bootimage to board's ROM.

If at that point user boots the system, bootimage will get
executed. Once
bootimage is up and running, user should see mDOC appearing in
system's device list (produced by Shell's 'devs' command), under
the
name "/tffs0" or "/tffs0a".

You are done; skip the rest of Chapter 3.

3.3. In case if you are using boot scenario 'A', skip Section 3.3, and
proceed
with Section 3.2 instead.

3.3.1. If you are using boot scenario 'B', you will need to modify the
following
VxWorks files:

- BSP configuration .H file (/target/config//
config.h)
- /target/config/all/bootConfig.c
- /target/config/all/usrConfig.c

and build bootimage(s) in order to boot VxWorks application off
the
mDOC. Sections 3.3.2 - 3.3.17 explain how to do this.

3.3.2. Add the following line to BSP configuration file
/target/config//config.h:

#define INCLUDE_DISKONCHIP /* msystems mDOC */

3.3.3. Change DEFAULT_BOOT_LINE in BSP configuration file
/target/config//config.h to look similar to this:


#define DEFAULT_BOOT_LINE \
"tffs=0,0(0,0)host:/tffs0/VxWorks h=90.0.0.3
e=90.0.0.50 u=target"


===> NOTE. Bootline above instructs 'bootrom' bootimage to
look for file
named "VxWorks" in the root directory of device "/
tffs0/"
(which is mDOC). If you want to name your
application
differently, or place it into location other than
the root
directory, you have to change bootline accordingly.

3.3.4. Excluded.

3.3.5. Modify file /target/config/all/bootConfig.c to add the
following
code fragment under #define INCLUDE_DISKONCHIP:


#ifdef INCLUDE_PCMCIA
LOCAL STATUS pcmciaLoad (int sock, char *fileName, FUNCPTR
*pEntry);
#endif /* INCLUDE_PCMCIA */

#ifdef INCLUDE_TFFS
LOCAL STATUS tffsLoad (int drive, int removable, char
*fileName,
FUNCPTR *pEntry);
#endif /* INCLUDE_TFFS */

#ifdef INCLUDE_DISKONCHIP
LOCAL STATUS tffsLoad (int drive, int removable, char
*fileName,
FUNCPTR *pEntry);
#endif /* INCLUDE_DISKONCHIP */


3.3.6. Modify file /target/config/all/bootConfig.c to add the
following
code fragment under #define INCLUDE_DISKONCHIP:


#ifdef INCLUDE_PCMCIA
LOCAL STATUS pcmciaLoad ();
#endif /* INCLUDE_PCMCIA */

#ifdef INCLUDE_TFFS
LOCAL STATUS tffsLoad ();
#endif /* INCLUDE_TFFS */

#ifdef INCLUDE_DISKONCHIP
LOCAL STATUS tffsLoad ();
#endif /* INCLUDE_DISKONCHIP */


3.3.7. If you are not using Workbench version 2.4 skip to Section
3.3.7.1.
If you are using Workbench version 2.4, skip to Section
3.3.7.2.

3.3.7.1. If you are using Workbench 2.4, skip this Section, and follow
instructions in Section 3.3.7.2 instead.

Modify file /target/config/all/bootConfig.c to add
the following
code fragment under #define INCLUDE_DISKONCHIP, just before
routine
usrInit():


#ifdef INCLUDE_DISKONCHIP

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _ASMLANGUAGE

#include "fldrvvxw.h"

#endif /* _ASMLANGUAGE */

#ifdef __cplusplus
}
#endif

/* forward declarations */

#ifdef __STDC__
void devSplit (char *fullFileName, char *devName);
#else
void devSplit ();
#endif /* __STDC__ */


STATUS usrTffsConfig
(
int drive, /* TFFS handle (usually zero) */
int removable, /* 0 - nonremovable flash media */
char * fileName /* mount point */
)
{
BLK_DEV * pBootDev;
char bootDir [BOOT_FILE_LEN];
CBIO_DEV_ID cbio, rawdisk;
char name[32];

/* create block device spanning entire disk (non-
destructive!) */

if ((pBootDev = tffsDevCreate (drive, 0)) == NULL)
{
printErr ("tffsDevCreate(%d,0) failed.\n", drive);
return (ERROR);
}

/* split off boot device from boot file */

devSplit (fileName, bootDir);

sprintf(name, "tffsCache0");
cbio = dcacheDevCreate ((CBIO_DEV_ID) pBootDev, NULL,
(128 * 1024), name);

if (NULL == cbio)
{
/* insufficient memory, will avoid the cache */
printErr ("WARNING: Failed to create disk cache.
Disk configured without cache\n");
cbio = cbioWrapBlkDev (pBootDev);
/* as cbioWrapBlkDev function does not exist in
VxWorks 5.4 it is possible to use instead
cbio = cbioDevVerify( (void *) pBootDev, FALSE );
*/
}

rawdisk = dpartDevCreate((CBIO_DEV_ID) cbio, 1,
usrFdiskPartRead);

if (NULL == rawdisk)
{
printErr ("usrTffsConfig: dpartDevCreate returned
NULL.\n");
return (ERROR);
}

if (ERROR == dosFsDevCreate(bootDir,
dpartPartGet(rawdisk, 0), 20, NONE))
{
printErr ("usrTffsConfig: dosFsDevCreate returned
ERROR.\n");
return (ERROR);
}

return (OK);
}


LOCAL STATUS tffsLoad
(
int drive, /* TFFS handle (normally zero) */
int removable, /* 0 - nonremovable flash media */
char * fileName, /* file name to download */
FUNCPTR * pEntry
)
{
int fd;

/*
* Call tffsSetup() as appropriate for your
application. See
* Section 2.6 above for details.
*/

/*
* If you want to change mDOC driver' configuration as
* as explained in Chapters 5 and 8, do it here.
*/

if (tffsDrv () != OK)
{
printErr ("Could not initialize.\n");
return (ERROR);
}

printf ("Attaching to TFFS... ");

dosFsInit (NUM_DOSFS_FILES); /* initialize DOS-
FS */

if (usrTffsConfig (drive, 0, fileName) == ERROR)
{
printErr ("usrTffsConfig failed.\n");
return (ERROR);
}

printErr ("done.\n");

/* load the boot file */

printErr ("Loading %s...", fileName);

if ((fd = open (fileName, O_RDONLY, 0)) == ERROR)
{
printErr ("\nCannot open \"%s\".\n", fileName);
return (ERROR);
}

if (bootLoadModule (fd, pEntry) != OK)
goto tffsLoadErr;

close (fd);
return (OK);

tffsLoadErr:

printErr ("\nerror loading file: status = 0x%x.\n",
errnoGet ());
close (fd);
return (ERROR);
}

#endif /* INCLUDE_DISKONCHIP */


3.3.7.2. If you are not using Workbench 2.4, skip this Section, and
follow instructions
in Section 3.3.7.1 instead.

Modify file /target/config/all/bootConfig.c to add
the following
code fragment under #define INCLUDE_DISKONCHIP, just before
routine
usrInit():


#ifdef INCLUDE_DISKONCHIP

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _ASMLANGUAGE

#include
#include
#include "fldrvvxw.h"

#endif /* _ASMLANGUAGE */

#ifdef __cplusplus
}
#endif

/* forward declarations */

#ifdef __STDC__
void devSplit (char *fullFileName, char *devName);
#else
void devSplit ();
#endif /* __STDC__ */


STATUS usrTffsConfig
(
int drive, /* TFFS handle (usually zero) */
int removable, /* 0 - nonremovable flash media */
char * fileName /* mount point */
)
{
BLK_DEV * pBootDev;
char bootDir [BOOT_FILE_LEN];
char tffsName[16];

/* split off boot device from boot file */
devSplit (fileName, bootDir);

/* Create a name for the name mapping */
sprintf(tffsName, "tffs%d:1", drive);

/* Install name mapping */
fsmNameInstall (tffsName, bootDir);

/* create block device spanning entire disk (non-
destructive!) */
if ((pBootDev = tffsDevCreate (drive, 0)) == NULL)
{
printErr ("tffsDevCreate(%d,0) failed.\n", drive);
return (ERROR);
}

sprintf(tffsName, "tffs%d", drive);

/* Create an XBD wrapper */
xbdBlkDevCreateSync (pBootDev, tffsName);

return (OK);
}


LOCAL STATUS tffsLoad
(
int drive, /* TFFS handle (normally zero) */
int removable, /* 0 - nonremovable flash media */
char * fileName, /* file name to download */
FUNCPTR * pEntry
)
{
int fd;

/*
* Call tffsSetup() as appropriate for your
application. See
* Section 2.6 above for details.
*/

/*
* If you want to change mDOC driver' configuration as
* as explained in Chapters 5 and 8, do it here.
*/

if (tffsDrv () != OK)
{
printErr ("Could not initialize.\n");
return (ERROR);
}

printf ("Attaching to TFFS... ");

if (usrTffsConfig (drive, 0, fileName) == ERROR)
{
printErr ("usrTffsConfig failed.\n");
return (ERROR);
}

printErr ("done.\n");

/* load the boot file */

printErr ("Loading %s...", fileName);

if ((fd = open (fileName, O_RDONLY, 0)) == ERROR)
{
printErr ("\nCannot open \"%s\".\n", fileName);
return (ERROR);
}

if (bootLoadModule (fd, pEntry) != OK)
goto tffsLoadErr;

close (fd);
return (OK);

tffsLoadErr:

printErr ("\nerror loading file: status = 0x%x.\n",
errnoGet ());
close (fd);
return (ERROR);
}

#endif /* INCLUDE_DISKONCHIP */


3.3.8. Modify file /target/config/all/bootConfig.c to add the
following
code fragment under #define INCLUDE_DISKONCHIP to helpMsg[] in
routine
bootHelp():


#ifdef INCLUDE_ATA
"boot device: ata=ctrl,drive file name: /ata0/
VxWorks","",
#endif /* INCLUDE_ATA */

#ifdef INCLUDE_DISKONCHIP
"boot device: tffs=drive,removable file name: /tffs0/
VxWorks","",
#endif /* INCLUDE_DISKONCHIP */

#ifdef INCLUDE_PCMCIA
"boot device: pcmcia=sock file name: /
pcmcia0/VxWorks","",
#endif /* INCLUDE_PCMCIA */


3.3.9. Modify file /target/config/all/bootConfig.c to add the
following
code fragment under #define INCLUDE_DISKONCHIP to routine
bootHelp():


#ifdef INCLUDE_ATA
printf (" ata");
#endif /* INCLUDE_ATA */

#ifdef INCLUDE_DISKONCHIP
printf (" tffs");
#endif /* INCLUDE_DISKONCHIP */

#ifdef INCLUDE_TFFS
printf (" tffs");
#endif /* INCLUDE_TFFS */

printf ("\n");
}


3.3.10. If you are using Tornado versions 2.0x, 2.1, 2.2 or higher
skip to
Section 3.3.10.1. If you are using Workbench version 2.x, skip
to
Section 3.3.10.2.

3.3.10.1. If you are using Workbench 2.x, skip this Section, and
follow
instructions in Section 3.3.10.2 instead.

Modify file /target/config/all/bootConfig.c to add
the following
code fragment under #define INCLUDE_DISKONCHIP to routine
bootLoad():


#ifdef INCLUDE_ATA

if (strncmp (params.bootDev, "ata", 3) == 0)
{
int ctrl = 0;
int drive = 0;

if (strlen (params.bootDev) == 3)
return (ERROR);
else
sscanf (params.bootDev, "%*3s%*c%d%*c%d",
&ctrl, &drive);

if (ataLoad (ctrl, drive, params.bootFile, pEntry) !
= OK)
{
printErr ("\nError loading file: errno = 0x%x.
\n", errno);
return (ERROR);
}

return (OK);
}

#endif /* INCLUDE_ATA */

#ifdef INCLUDE_DISKONCHIP

if (strncmp (params.bootDev, "tffs", 4) == 0)
{
int drive = 0;
int removable = 0;

if (strlen (params.bootDev) == 4)
return (ERROR);
else
sscanf (params.bootDev, "%*4s%*c%d%*c%d",
&drive, &removable);

if (tffsLoad (drive, 0, params.bootFile, pEntry) !=
OK)
{
printErr ("\nError loading file: errno = 0x%x.
\n", errno);
return (ERROR);
}

return (OK);
}

#endif /* INCLUDE_DISKONCHIP */

#ifdef INCLUDE_PCMCIA

pcmciaInit (); /* init PCMCIA Lib */

if (strncmp (params.bootDev, "pcmcia", 6) == 0)
{
int sock = NONE;

if (strlen (params.bootDev) == 6)
return (ERROR);
else
sscanf (params.bootDev, "%*6s%*c%d", &sock);

if (pcmciaLoad (sock, params.bootFile, pEntry) ==
OK)
return (OK);

/* fall through if the PC card is not a block
device.
* let's try to boot it from an ethernet device.
*/
}

#endif /* INCLUDE_PCMCIA */


3.3.10.2. If you are using Tornado versions 2.0x, 2.1, 2.2 or higher,
skip
this Section, and follow instructions in Section 3.3.10.1
instead.

Modify file /target/config/all/bootConfig.c to add
the following
code fragment under #define INCLUDE_DISKONCHIP to routine
bootLoad():


#ifdef INCLUDE_ATA

if (strncmp (sysBootParams.bootDev, "ata", 3) == 0)
{
int ctrl = 0;
int drive = 0;

if (strlen (sysBootParams.bootDev) == 3)
return (ERROR);
else
sscanf (sysBootParams.bootDev, "%*3s%*c%d%*c
%d", &ctrl, &drive);

if (ataLoad (ctrl, drive, sysBootParams.bootFile,
pEntry) != OK)
{
printErr ("\nError loading file: errno = 0x%x.
\n", errno);
return (ERROR);
}

return (OK);
}

#endif /* INCLUDE_ATA */

#ifdef INCLUDE_DISKONCHIP

if (strncmp (sysBootParams.bootDev, "tffs", 4) == 0)
{
int drive = 0;
int removable = 0;

if (strlen (sysBootParams.bootDev) == 4)
return (ERROR);
else
sscanf (sysBootParams.bootDev, "%*4s%*c%d%*c
%d", &drive, &removable);

if (tffsLoad (drive, 0, sysBootParams.bootFile,
pEntry) != OK)
{
printErr ("\nError loading file: errno = 0x%x.
\n", errno);
return (ERROR);
}

return (OK);
}

#endif /* INCLUDE_DISKONCHIP */

#ifdef INCLUDE_PCMCIA

pcmciaInit (); /* init PCMCIA Lib */

if (strncmp (sysBootParams.bootDev, "pcmcia", 6) == 0)
{
int sock = NONE;

if (strlen (sysBootParams.bootDev) == 6)
return (ERROR);
else
sscanf (sysBootParams.bootDev, "%*6s%*c%d",
&sock);

if (pcmciaLoad (sock, sysBootParams.bootFile,
pEntry) == OK)
return (OK);

/* fall through if the PC card is not a block
device.
* let's try to boot it from an ethernet device.
*/
}

#endif /* INCLUDE_PCMCIA */


3.3.11. Modify file /target/config/all/bootConfig.c to add
term

defined(INCLUDE_DISKONCHIP)

to the directive below:

#if (defined (INCLUDE_SCSI_BOOT) || defined
(INCLUDE_FD) || \
defined (INCLUDE_IDE) || defined
(INCLUDE_ATA) || \
defined (INCLUDE_DISKONCHIP) || defined
(INCLUDE_TFFS))


3.3.12. Modify file /target/config/all/usrConfig.c to add the
following
code fragment under #define INCLUDE_DISKONCHIP, just before
routine
usrRoot():


#ifdef INCLUDE_DISKONCHIP

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _ASMLANGUAGE

#include "fldrvvxw.h"

#endif /* _ASMLANGUAGE */

#ifdef __cplusplus
}
#endif

#endif /* INCLUDE_DISKONCHIP */


3.3.13. Modify file /target/config/all/usrConfig.c to add the
following
code fragment under #define INCLUDE_DISKONCHIP to routine
usrRoot():


#ifdef INCLUDE_ATA
{ /* initialize hard disk
driver */
IMPORT ATA_RESOURCE ataResources[];
ATA_RESOURCE *pAtaResource;

for (ix = 0; ix < ATA_MAX_CTRLS; ix++)
{
pAtaResource = &ataResources[ix];
if (pAtaResource->ctrlType == IDE_LOCAL)
ataDrv (ix, pAtaResource->drives, pAtaResource-
>intVector,

pAtaResource->intLevel, pAtaResource-
>configType,

pAtaResource->semTimeout, pAtaResource-
>wdgTimeout);

}
}
#ifdef INCLUDE_SHOW_ROUTINES
ataShowInit (); /* install ATA/IDE show
routine */
#endif /* INCLUDE_SHOW_ROUTINES */
#endif /* INCLUDE_ATA */

#ifdef INCLUDE_LPT
{
IMPORT LPT_RESOURCE lptResources[];
lptDrv (LPT_CHANNELS, &lptResources[0]); /* init LPT
parallel driver */
}
#endif /* INCLUDE_LPT */

#ifdef INCLUDE_DISKONCHIP
/*
* Call tffsSetup() as appropriate for your
application. See
* Section 2.6 above for details.
*/

/*
* If you want to change mDOC driver' configuration as
* as explained in Chapters 5 and 8, do it here.
*/

tffsDrv ();
#endif /* INCLUDE_DISKONCHIP */

#ifdef INCLUDE_PCMCIA
#ifdef INCLUDE_SHOW_ROUTINES
pcmciaShowInit (); /* install PCMCIA show routines */
#endif /* INCLUDE_SHOW_ROUTINES */
pcmciaInit (); /* init PCMCIA Lib */
#endif /* INCLUDE_PCMCIA */


3.3.14. Re-build your bootimage (normally 'bootrom') and VxWorks
application to
put all code modifications in effect.


Let me know if you guys think I am missing something

Cheers

Manju