File system, RTEMS, RTOS, Software

Setting up YAFFS2 and JFFS2 on RTEMS with flash simulated on a RAM-disk

Hi all, In this post we’ll look forward towards setting up flash file systems namely JFFS2 and YAFFS2 on RTEMS with flash simulated on a RAM-disk. For file system benchmarking purpose, we didn’t actually use them on a real flash(as to eliminate the effect of flash driver’s performance) but implementing them on a real flash won’t be very different from the process given in the later sections of this post. So, let’s begin with JFFS2 first:


First reference you will see is of testsuites/fstests/jffs2_support/fs_support.c . Configuration here works upto a large extent unless the size of FLASH(configured via #define FLASH_SIZE (8UL * BLOCK_SIZE) ) increases beyond certain limit.

Notice that in the above structure, size of array statistically increases as FLASH_SIZE increases. Due to this, the final size of the binary also increases and thus when loading it via u-boot one can have the following error:

In order to avoid it we can dynamically allocate the area array like with :

Here, 1k extra space is allocated to compensate for the start alignment issues. So, below is my jffs2_support/fs_support.c file after modification:

Here, notice that flash_write(), flash_read and flash_erase routines, which can be altered in case of reading/writing on an actual flash.

Setting up YAFFS2 on RTEMS

YAFFS configuration for RTEMS is a bit involved as it’s source files are kept in a separate repository

In order to use this port with RTEMS, we have to first build and install this library using RTEMS tool chain. So, the first step will be:

  1. Setup a RTEMS toolchain along with the target BSP package:  This step is pretty straight forward for anyone familiar with RTEMS. You just have to use RSB and RTEMS to have the BSP(let’s say BeagleBone Black).
  2. Clone the YAFFS port, build, install it: Grab the port and then setup the RTEMS_MAKEFILE_PATH variable like:

    where $sandbox/5 is your toolchain install path. then build the port using Makefile.rtems

After this step, we have the YAFFS library ready to be used. This can be used by using -lyaffs2 flag in the linker call.

Next step is to write a RTEMS configuration to use YAFFS2. Here’s the configuration( Christian Mauderer’s work) that can be used:

and few supporting file:

Please notice that in yaffs.c file: there are two things Chunks and Blocks. Block is made up of smaller chunks. A Blocks is the smallest unit that can be erased while chunks are smallest units that can be read/written at a time. Also, one block is divided into two sections one for flag and other for data.

About Udit kumar agarwal

1 thought on “Setting up YAFFS2 and JFFS2 on RTEMS with flash simulated on a RAM-disk

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.