您的位置:首页 > 其它

rtems 文件系统(12)-flash jffs2

2018-01-24 12:48 495 查看
现在IMFS base file system已经建立起来了。到目前为止还是不了解怎么挂载其他的系统。因此查看rtems的wiki,看是否可以获取一些信息,并且看一下confdefs.h中关于文件系统这一部分。发现可以通过配置,增加jffs2的文件系统到rtems_filesystem_table中。

要使用jffs2需要包含一个库函数。libjffs2.a

在配置中增加#define CONFIGURE_FILESYSTEM_JFFS2。

根据现在的理解,增加到rtems_filesystem_table的文件系统,在初始化base filesystem的时候应该没有主动挂载,这个表只是在里面查询是否有该文件系统。所以还是需要自己挂载。

wiki上面说rtems也提供block device的API.也支持下面的设备,但是这种就像之前说的,是cache的方式,和jffs2相比没有优势

ATA disks supporting IDE disk drives as well as Compact Flash disks configured in IDE mode
RAM disk
Non-volatile disk
Flash disk
看完之后还是没有什么思路啊,突然想起testsuites 在其中的testsuites/fstests/jffs2_support/fs_support.c中找到一些思路。
在jffs2.h中 cpukit/libfs/src/jffs2/include/rtems/jffs2.h 定义了如下结构,这是一个很重要的结构,所有的底层驱动函数,比如read write 都会链接到该结构上面对应读写函数指针上面
/**
* @brief JFFS2 flash device control.
*/
struct rtems_jffs2_flash_control {
/**
* @brief The size in bytes of the erasable unit of the flash device.
*/
uint32_t block_size;

/**
* @brief The size in bytes of the flash device.
*
* It must be an integral multiple of the block size.  The flash device must
* have at least five blocks.
*/
uint32_t flash_size;

/**
* @brief Read from flash operation.
*/
rtems_jffs2_flash_read read;

/**
* @brief Write to flash operation.
*/
rtems_jffs2_flash_write write;

/**
* @brief Flash erase operation.
*/
rtems_jffs2_flash_erase erase;

/**
* @brief Flash destroy operation.
*
* This operation is optional and the pointer may be @c NULL.
*/
rtems_jffs2_flash_destroy destroy;

/**
* @brief The device identifier of the flash device.
*
* It is used in combination with the inode number to uniquely identify a
* file system node in the system.
*/
dev_t device_identifier;
};


比如rtems_jffs2_flash_read就是一个函数指针类型。其他的就不列举了。那么我只需要实现该结构中各个函数就可以了。这是对于底层方向的扩展。那么怎么安装jffs2到系统中呢

rv = mount(
NULL,
FLASH_MOUNT_POINT, //if this is NULL,then the root file system will be mount
RTEMS_FILESYSTEM_TYPE_JFFS2,
RTEMS_FILESYSTEM_READ_WRITE,
&mount_data
);其中target,自己选择一个挂载点即可。因为jffs2已经在rtems_filesystem_table中,所以他会自动在表中找到,并调用表中初始化函数初始化该文件系统,最后还会注册到系统中。
rtems_jffs2_initialize中会做很多工作。这部分后续如果有需要再考虑。

剩下的任务就是实现底层的驱动函数,并和该控制结构链接到一起即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rtems