Yeah, my code is mostly like yours.

I have a handle of flash device, which can access flash hardware directly via 
QSPI. So, this means, my flash can work with jffs2 without being registered 
into rtems?

And, I still get these error...
[1136/1145] Linking build/arm-rtems4.11-xilinx_zynq_zedboard/bkv01.elf
main.c.38.o: In function `.LANCHOR1':
main.c:(.rodata+0x2f4): undefined reference to `rtems_jffs2_initialize'
Kernel/driver_module/flash/flash_driver.c.38.o:(.data+0x58): undefined 
reference to `rtems_jffs2_compressor_zlib_compress'
Kernel/driver_module/flash/flash_driver.c.38.o:(.data+0x5c): undefined 
reference to `rtems_jffs2_compressor_zlib_decompress'
collect2: error: ld returned 1 exit status




Best wishes,
xuelin.t...@qkmtech.com
 
From: Chris Johns
Date: 2017-10-21 08:56
To: xuelin.t...@qkmtech.com; Sebastian Huber; users@rtems.org
Subject: Re: Filesystem in RTEMS
On 21/10/2017 11:17, xuelin.t...@qkmtech.com wrote:
> I followed the example (testsuites/fstests/jffs2_support/fs_support.c), and 
> some
> error came up, like 
> "undefined reference to rtems_jffs2_initialize",
> "undefined reference to rtems_jffs2_compressor_zlib_compress", and 
> "undefined reference to rtems_jffs2_compressor_zlib_decompress"
> I have no clue here. Do I have to give my own implementation of these 
> functions
> here? I can exploit the default functions for jffs2 entry table and compress, 
> I
> think. 
> 
> And I have a little confused about the model of device driver in rtems, since 
> I
> get stuck for a few days.
> First, a deivce descriptor (rtems_fdisk_device_desc) should be given, 
> including
> some handlers defined in rtems_fdisk_driver_handlers,  and device 
> configuration
> (rtems_flashdisk_config). 
> Then, I need to register (or initialize) my flash device into rtems 
> dynamically
> or statically, with my own initialize, open, close functions.
> Last, the JFFS2 should be set up based on the registered device driver. The
> block size need to be equal to the page size of flash, and the read, write,
> erase operations should invoke the corresponding functions defined
> in rtems_fdisk_driver_handlers.
> 
> Am I correct in this whoe process?
 
I have something like the following piece of code in a file in my application:
 
typedef struct
{
  rtems_jffs2_flash_control super;
  /* private data for my flash driver such as stats */
} ffs_control;
 
static ffs_control*
flash_get_control(rtems_jffs2_flash_control* super)
{
  return (ffs_control *) super;
}
 
static int
flash_read(rtems_jffs2_flash_control* super,
           uint32_t                   offset,
           unsigned char*             buffer,
           size_t                     length)
{
  ffs_control* self = flash_get_control(super);
  int          r;
  .
  .
  .
  return r;
}
 
static int
flash_write(rtems_jffs2_flash_control* super,
            uint32_t                   offset,
            const unsigned char*       buffer,
            size_t                     length)
{
  ffs_control* self = flash_get_control(super);
  int          r;
  .
  .
  .
  return r;
}
 
static int
flash_erase(rtems_jffs2_flash_control* super,
            uint32_t                   offset)
{
  ffs_control* self = flash_get_control(super);
  int          r;
  .
  .
  .
  return r;
}
 
static void
flash_destroy(rtems_jffs2_flash_control* super)
{
  ffs_control* self = flash_get_control(super);
  int          r;
  .
  .
  .
  return r;
}
 
static ffs_control ffs_data = {
    .super = {
        .read = flash_read,
        .write = flash_write,
        .erase = flash_erase,
        .destroy = flash_destroy
    }
};
 
static rtems_jffs2_compressor_zlib_control compressor_instance = {
    .super = {
        .compress = rtems_jffs2_compressor_zlib_compress,
        .decompress = rtems_jffs2_compressor_zlib_decompress
    }
};
 
static const rtems_jffs2_mount_data ffs_mount_data = {
    .flash_control = &ffs_data.super,
    .compressor_control = &compressor_instance.super
};
 
bool
ffs_mount(const char* path)
{
  int r;
 
  r = flash_open();
  if (r != 0)
  {
    /* print something */
    return false;
  }
 
ffs_data.super.block_size = HYDRA_FLASH_BLOCK_SIZE;
ffs_data.super.flash_size = HYDRA_FLASH_FILESYSTEM_SIZE;
 
r = mount_and_make_target_path(NULL,
                                path,
                                RTEMS_FILESYSTEM_TYPE_JFFS2,
                                RTEMS_FILESYSTEM_READ_WRITE,
                                &ffs_mount_data);
if (r != 0)
{
    /* print something */
    return false;
}
 
return true;
}
 
You need to provide the open, close, read, write, erase and destroy code that
accesses your flash device. This can be calls to something that directly
accesses the flash device or you can build a driver registered in the device
tree to handle the flash via ioctls.
 
Chris
_______________________________________________
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Reply via email to