[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

External RAM filesystem



Based on the example i made (see bellow) i got questions.

Basically this example allows to read/write information in the RAMDISK 
area (which is an array in the example) by means of the filesystem API but 
does not allow to create files because the open/f_open routine shall open 
the "/dev/ramdisk0" device.
Is it possible to "mount" somehow the /dev/ramdisk0 and then, using the 
open/f_open, etc. calls to create file inside this RAMDISK?

Cheers,

Sitor


Here is the example I made.

rtems-config.h file --------------->

#ifndef RTEMSCONFIG_H_
#define RTEMSCONFIG_H_

/* configuration information */

rtems_task Init( rtems_task_argument argument);
extern char ramdisk[];

#define CONFIGURE_NEEDS_CONSOLE_DRIVER

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_MAXIMUM_TASKS 10
#define CONFIGURE_MAXIMUM_SEMAPHORES 10
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4

rtems_bdbuf_config rtems_bdbuf_configuration[] = {
  { 512, 40, (void *) ramdisk }
};
int rtems_bdbuf_configuration_size = 1;

rtems_ramdisk_config rtems_ramdisk_configuration[] = {
  {
     512, 40, (void *) ramdisk
  }
};

// The sparc-rtems-gcc version 4 changes the location of the confdefs.h 
file.
#if (__GNUC__ > 3)
size_t rtems_ramdisk_configuration_size = 1;
rtems_task_priority swapout_task_priority = 100;
#else
int rtems_ramdisk_configuration_size = 1;
#endif


#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
rtems_driver_address_table Device_drivers[] = {
  CONSOLE_DRIVER_TABLE_ENTRY,
  CLOCK_DRIVER_TABLE_ENTRY,
  RAMDISK_DRIVER_TABLE_ENTRY
};
#define CONFIGURE_NUMBER_OF_DRIVERS \
  ((sizeof(Device_drivers) / sizeof(rtems_driver_address_table)))
#define CONFIGURE_MAXIMUM_DRIVERS 10



#define CONFIGURE_INIT

// The sparc-rtems-gcc version 4 changes the location of the confdefs.h 
file.
#if (__GNUC__ > 3)
#include <rtems/confdefs.h>
#else
#include <confdefs.h>
#endif

#endif /*RTEMSCONFIG_H_*/

<---------------------------------

test.c ----------------->

/*
 *  Simple test program -- simplified version of sample test hello.
 */

#include <bsp.h>

#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>

#include <rtems/ramdisk.h>
#include <rtems/bdbuf.h>

char ramdisk[30*1024];

#include "rtems-config.h"

rtems_task Init(
  rtems_task_argument ignored
)
{
        FILE *fp;
        unsigned char buffer[512];
        unsigned char aux[512];
        int i;
        size_t bw;
 
        // Open the RAMDISKK
        fp = fopen( "/dev/ramdisk0", "r+" );
        assert( fp );

        for ( i=0 ; i< 512 ; i++  )
                buffer[i] = (unsigned char) (i + 1);

        for (i=0; i < 30 ; i++ ) 
        {
                bw = fwrite( buffer, 512, 1, fp );
                assert(bw);
        }

        assert(fseek(fp, 0, SEEK_SET) == 0);

        for (i=0; i < 20 ; i++ ) 
        {
                memset( aux, 0, 512 );
                bw = fread( aux, 512, 1, fp );
                assert( bw == 1 );
                printf("%d ", i);

                assert( !memcmp( buffer, aux, 512 ) );
                assert( !memcmp( (ramdisk + (i*512)), aux, 512 ) );
        }

  exit( 0 );
}

/* end of file */

-----------------------------
Aitor Viana S?nchez

ESA - European Space Technology Centre (ESTEC)
TEC-EDD - Computer and Data Systems Section
ESA/ESTEC P.O. Box 299 / 2200AG Noordwijk ZH, The Netherlands
Tel (+31) 71 565 6727
Email: aitor.viana.sanchez at esa.int

Joel Sherrill <joel.sherrill at oarcorp.com> wrote on 11/14/2007 03:15:07 PM:

> I don't remember if there is an example in the source
> tree anywhere of doing this.  If you can put together
> something, it would be appreciated.  Just declared
> some large byte array and use it as the RAM for the
> purposes of an example.

> --joel

> Aitor.Viana.Sanchez at esa.int wrote:
> >
> > Hi Thomas,
> >
> > I managed to configure the RAMDISK, and also accessing it but i got
> > couple of questions.
> >
> >         - I didn't use the msdos_initialize function at all and I
> > don't know what this function does exactly and why it is needed.
> >         - I had also to initialize the rtems_bdbuf_configuration
> > structure and the rtems_bdbuf_configuration_size variable, but i don't
> > know what is this structure/variable is for.
> >         - I can access to the RAMDISK by means of
> > fopen("/dev/ramdisk0") for instance. But this allows me to write/read
> > in the RAMDISK area using the file API. But apparently does not allow
> > me to create files in the RAMDISK area (which is my intention). Lets
> > say, I want to allocate a RAMDISK area, mount it, and then access it
> > like a filesystem.
> >
> > Here is my configuration file:
> >
> > #ifndef RTEMSCONFIG_H_
> > #define RTEMSCONFIG_H_
> >
> > /* configuration information */
> >
> > rtems_task Init( rtems_task_argument argument);
> >
> > #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
> >
> > #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> >
> > #define CONFIGURE_MAXIMUM_TASKS 10
> > #define CONFIGURE_MAXIMUM_SEMAPHORES 10
> > #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
> >
> > rtems_bdbuf_config rtems_bdbuf_configuration[] = {
> >   { 512, 20, (void *) 0 }
> > };
> > int rtems_bdbuf_configuration_size = 1;
> >
> > rtems_ramdisk_config rtems_ramdisk_configuration[] = {
> >   {
> >      512, 20, (void *) 0
> >   }
> > };
> >
> > int rtems_ramdisk_configuration_size = 1;
> >
> > #define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
> > rtems_driver_address_table Device_drivers[] = {
> >   CONSOLE_DRIVER_TABLE_ENTRY,
> >   CLOCK_DRIVER_TABLE_ENTRY,
> >   RAMDISK_DRIVER_TABLE_ENTRY
> > };
> > #define CONFIGURE_NUMBER_OF_DRIVERS \
> >   ((sizeof(Device_drivers) / sizeof(rtems_driver_address_table)))
> > #define CONFIGURE_MAXIMUM_DRIVERS 10
> >
> > #define CONFIGURE_INIT
> >
> > #include <confdefs.h>
> >
> > #endif /*RTEMSCONFIG_H_*/
> >
> >
> > Cheers,
> >
> > Aitor
> >
> >
> > -----------------------------
> > Aitor Viana S?nchez
> >
> > ESA - European Space Technology Centre (ESTEC)
> > TEC-EDD - Computer and Data Systems Section
> > ESA/ESTEC P.O. Box 299 / 2200AG Noordwijk ZH, The Netherlands
> > Tel (+31) 71 565 6727
> > Email: aitor.viana.sanchez at esa.int
> >
> >
> > *Thomas Doerfler <Thomas.Doerfler at embedded-brains.de>*
> >
> > 11/13/2007 05:47 PM
> >
> >
> > To
> >  Aitor.Viana.Sanchez at esa.int
> > cc
> >  rtems-users at rtems.org
> > Subject
> >  Re: External RAM filesystem
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > yes, it should be possible. There still exists a ram disk driver, 
which
> > performs this function, see:
> >
> > cpukit/libblock/src/ramdisk.c
> >
> > We used it for our very first tests of the FATFS. If I recall 
correctly,
> > these are the steps to work with it:
> >
> > - define a rtems_ramdisk_config data structure (e.g. in the init 
module)
> > with the fixed name "rtems_ramdisk_configuration".
> >
> > - you can/must define the block size, the number of blocks and 
location
> > in this structure
> >
> > - If you add the RAMDISK_DRIVER_TABLE_ENTRY to your device driver 
table,
> > it will initialize automatically when your system comes up
> >
> > - Or, you can initialize the ramdisk with "ramdisk_initialize".
> >
> > - Next, you must format the ramdisk (use msdos_format function in
> > cpukit/libfs/src/dosfs/msdos_format.c).
> >
> > - Then you can mount the ramdisk as a (unpartitioned) volume with
> > msdos_initialze().
> >
> > I hope I am rather acurate on these steps.
> >
> > It would be nice if you could give us feedback, when things work.
> >
> > And it would be even nicer, if you could write a wiki entry on this
> > under www.rtems.com/wiki
> >
> > wkr,
> > Thomas.
> >
> >
> >
> >
> >
> > Aitor.Viana.Sanchez at esa.int schrieb:
> > >
> > > Hi all,
> > >
> > >
> > > is it possible to configure RTEMS somehow to access and external RAM
> > > memory address where a FAT32 (for instance) file system is placed? 
Is it
> > > possible to configure the address and size?
> > >
> > > Thanks in advance.
> > >
> > >
> > > Aitor
> > >
> > >
> > > 
------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > rtems-users mailing list
> > > rtems-users at rtems.com
> > > http://rtems.rtems.org/mailman/listinfo/rtems-users
> >
> >
> > --
> > --------------------------------------------
> > embedded brains GmbH
> > Thomas Doerfler           Obere Lagerstr. 30
> > D-82178 Puchheim          Germany
> > Tel. : +49-89-18 90 80 79-2
> > Fax  : +49-89-18 90 80 79-9
> > email: Thomas.Doerfler at embedded-brains.de
> > PGP public key available on request
> >
> > Diese Nachricht ist keine gesch?ftliche Mitteilung im Sinne des EHUG.
> > 
------------------------------------------------------------------------
> >
> > _______________________________________________
> > rtems-users mailing list
> > rtems-users at rtems.com
> > http://rtems.rtems.org/mailman/listinfo/rtems-users
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rtems.rtems.org/pipermail/rtems-users/attachments/20071114/6fda82c5/attachment-0001.html