Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Problem with jssf2

Could someone help me to start working with jffs2 file system?.

I use following code: # include <cyg/hal/io.h># include <cyg/kernel/kapi.h># include <cyg/io/io.h># include <cyg/fileio/fileio.h># include "stdio.h"

void cyg_user_start(void)

{

int err;

# ifdef CYGPKG_IO_FILEIO

err=mount ("/dev/flash", "/", "jffs2");

printf("%d\n",err);

if(err == 0)

{

printf("success");

chdir ("/");

}

# endif

}

but when I start my app i receive:

-1

so there is some error and I dont know what kind of error and how to fix it.

My flash memory is filled with 0xFF patterns.

7 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Mell,

    Have you configured ecos to use your flash memory, and set aside a block of memory for JFFS2? You need to set the "Instantiate in I/O block device API" property in the flash drivers section.

    I had a problem with JFFS2 on my Altera Cyclone II 2C35 based Dev Board because the flash memory is connected as 8-bit and the ecos driver expects it to be in 16-bit mode. I can send you code to fix this if you need it.

    I found JFFS2 quite tricky to get started with, but once it starts working it&#39;s great!

    Mike
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Mike,

    I&#39;ve configured eCos Library using NiosII config tool. I imported all required packages: JFFS2 Filesystem, Generic FLASH memory support, CRC support, Linux compatibility. I configured base of flash device block to 0x0000 and length of 16Mbytes(as we have in our system).

    I use the same evaluation board as you.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello mike,

    I&#39;ve read contens of link you sent, but I wasn&#39;t able to find any of files mentioned in neither in project path nor in installation of eCos.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Mell,

    On my system the two files you need to edit are in these locations:

    C:\altera\kits\nios2_60\components\ecos\ecos-current\packages\devs\flash\sopc\altera_avalon_am29lv065d_flash\current\src\altera_avalon_am29lv065d_flash.c

    C:\altera\kits\nios2_60\components\ecos\ecos-current\packages\devs\flash\amd\am29xxxxx\current\include\flash_am29xxxxx_parts.inl

    The file called altera_avalon_am29lv065d_flash.c contains a definition of the flash geometry that is being used. Near the top of the file you will find some code like this:

       # define CYGNUM_FLASH_INTERLEAVE  (1)
       # define CYGNUM_FLASH_SERIES         (1)
       # define CYGNUM_FLASH_WIDTH          (8)
       # define CYGNUM_FLASH_BASE       altera_avalon_am29lv065d_base

    You need to add a line to this to specify that the flash is being used in 8-bit mode, like so:

    #define CYGNUM_FLASH_INTERLEAVE (1)# define CYGNUM_FLASH_SERIES     (1)# define CYGNUM_FLASH_WIDTH      (8)# define CYGNUM_FLASH_16AS8    (1)# define CYGNUM_FLASH_BASE    altera_avalon_am29lv065d_base

    The second file called flash_am29xxxxx_parts.inl contains the settings required to drive the flash. It consists of a long list of flash settings. The defines in the previous file cause parts of the second file to be enabled. We need to add a new section to flash_am29xxxxx_parts.inl to describe the flash being used in 8-bit mode.

    Search for this code in the file (Somewhere around line 560):

    #else // 16 bit devices
    # ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV128
        {   // AM29LV128
            device_id  : FLASHWORD(0x227e),  
            block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE,
            block_count: 256,
            device_size: 0x1000000 * CYGNUM_FLASH_INTERLEAVE,
            base_mask  : ~(0x1000000 * CYGNUM_FLASH_INTERLEAVE - 1),
            bootblock  : false,
            banked     : false,
            bufsiz     : 16
        },# endif

    This is the existing code for 16-bit access to the flash. You need to add an 8-bit section before the# else statement like so:

    #ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV128
        { // AM29LV128
      long_device_id: true,
      device_id : FLASHWORD(0x7e),
      device_id2 : FLASHWORD(0x12),
      device_id3 : FLASHWORD(0x00),
      block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE,
      block_count: 256,
      device_size: 0x1000000 * CYGNUM_FLASH_INTERLEAVE,
      base_mask : ~(0x1000000 * CYGNUM_FLASH_INTERLEAVE - 1),
      bootblock : false,
      banked : false,
      bufsiz : 16
        },# endif
    # else // 16 bit devices
    # ifdef CYGHWR_DEVS_FLASH_AMD_AM29LV128
        {   // AM29LV128
            device_id  : FLASHWORD(0x227e),  
            block_size : 0x10000 * CYGNUM_FLASH_INTERLEAVE,
            block_count: 256,
            device_size: 0x1000000 * CYGNUM_FLASH_INTERLEAVE,
            base_mask  : ~(0x1000000 * CYGNUM_FLASH_INTERLEAVE - 1),
            bootblock  : false,
            banked     : false,
            bufsiz     : 16
        },# endif

    The tabs have been messed up by pasting into this message. If I knew how to send attachments through this forum then I would send these files to you. You could send me a "personal message" through the forum with your email address and I could then send the files directly to you.

    Mike
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    My problem now seems to be solved. It was caused by bad description of board and missing device drivers for my flash.