File system and CompactFlash question on MCF5485EVB board

Chris Xenophontos cxenophontos at hammers.com
Fri Nov 2 03:02:29 UTC 2012


We are currently running RTEMS 4.10.2 on a Coldfire MCF5485EVB board, with
a Transcend 4GB Compact Flash Card installed in respective slot.  The
required manufacturer's firmware has been downloaded onto CPLD in order to
access Compact Flash, etc.

The Compact Flash socket is wired on the board to use 16-bit accesses,
(both enables tied together), and memory mapped mode only.

We want to use the Compact Flash card for file storage for our application,
not for bootup.

I've modified an existing ATA/IDE driver to access Compact Flash card, as
directed in RTEMS File System documentation.

The ATA driver initializes and reads Compact Flash card status correctly,
and, when Identify Drive command is sent to card, the correct expected data
is returned.  First word is 0x848A, and driver correctly interprets
cylinder/head/sector and LBA info - since these values translate into the
card's capacity of 4GB.  Logical Block Addressing is used.

The problem we have is, during register and mount process, the file system
attempts to read an MBR from the Compact Flash card - however, all zeroes
are returned, and the process fails.

When a file is written to CompactFlash card using a PC, it can be listed,
etc, so the card appears to be OK.  And because the Identify Device command
causes the card to return expected data, the HW interface from our Coldfire
board appears to be OK as well.

Relevant parts from rtems.c are included below - any help is greatly
appreciated!!

thanks
Chris Xenophontos

#include <stdlib.h>
#include <rtems.h>
#include <bsp.h>
#include <unistd.h>

#include <rtems/rtems_bsdnet.h>
#include <rtems/libio.h>
#include <rtems/shellconfig.h>     // added for shell/filesystem support
#include <rtems/ide_part_table.h>
#include "networkconfig.h"
#include <libchip/ide_ctrl_cfg.h>
#include <libchip/ide_ctrl_io.h>
#include  <libchip/ata.h>
#include <rtems/bdpart.h>
#include <rtems/dosfs.h>
#include <rtems/fsmount.h>

rtems_task Init( rtems_task_argument ignored );
extern int xmain( void );


fstab_t fs_table[] =
{
  {
    "/dev/hda","/mnt/cf", "dosfs",
    RTEMS_FILESYSTEM_READ_WRITE,
    FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
    0
  }
};



rtems_task Init( rtems_task_argument ignored )
{
    rtems_status_code sc;
    int rv;
    size_t abort_index;

   /*     * * * *   /

    abort_index = 0;

    sc = rtems_bdpart_register_from_disk( "/dev/hda" );

    rv = rtems_fsmount( fs_table, sizeof(fs_table)/sizeof(fs_table[0]),
NULL);

    printf( "\n\nrtems_bdpart_register_from_disk status: %d\n", sc );    //
returns 27 = IO_ERROR
    printf(   "\nrtems_fsmount status status:            %d\n", rv );
   // return 0

   /*     * * * *   /

    sc = rtems_shell_init ( "fstst", 60 * 1024, 150, "/dev/console", 0, 1,
0 );

   /*     * * * *   /

    printf( "\nEntering xmain....\n" );

    xmain();
};

   /*     * * * *   /

#define TASK_INTLEVEL 0
#define CONFIGURE_INIT
#define CONFIGURE_INIT_TASK_ATTRIBUTES ( RTEMS_FLOATING_POINT |
RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_ASR |
RTEMS_INTERRUPT_LEVEL(TASK_INTLEVEL))

#define CONFIGURE_MAXIMUM_TASKS               20
/*( SYS_MAX_TASKS + 7 ) */
#define CONFIGURE_MAXIMUM_TIMERS               3


#define CONFIGURE_MAXIMUM_SEMAPHORES          20 //12   // 16
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES      24   //SB_MAX_PIPES=23    //32
/* #define CONFIGURE_INIT_TASK_STACK_SIZE      2048 */

#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024)
#define CONFIGURE_INIT_TASK_PRIORITY   120
#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
                                           RTEMS_NO_TIMESLICE | \
                                           RTEMS_NO_ASR | \
                                           RTEMS_INTERRUPT_LEVEL(0))

#define ADA_TASKS  0

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER

#define CONFIGURE_MAXIMUM_DRIVERS                   10
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS    30
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
#define CONFIGURE_FILESYSTEM_DOSFS

#define CONFIGURE_APPLICATION_NEEDS_IDE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
#define CONFIGURE_ATA_DRIVER_TASK_PRIORITY           9
#define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS             512
#define CONFIGURE_MICROSECONDS_PER_TICK           10000
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS    30

#define CONFIGURE_SHELL_COMMANDS_INIT         // added for shell/filesystem
support
#define CONFIGURE_SHELL_COMMANDS_ALL     // added for shell/filesystem
support

////////////////////////////////////////////////////////////////
#include <rtems/confdefs.h>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20121101/d54f3859/attachment.html>


More information about the users mailing list