<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>Yeah, my code is mostly like yours.</div><div><br></div><div>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?</div><div><br></div><div>And, I still get these error...</div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">[1136/1145] Linking build/arm-rtems4.11-xilinx_zynq_zedboard/bkv01.elf</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">main.c.38.o: In function `.LANCHOR1':<br>main.c:(.rodata+0x2f4): undefined reference to `rtems_jffs2_initialize'<br>Kernel/driver_module/flash/flash_driver.c.38.o:(.data+0x58): undefined reference to `rtems_jffs2_compressor_zlib_compress'<br>Kernel/driver_module/flash/flash_driver.c.38.o:(.data+0x5c): undefined reference to `rtems_jffs2_compressor_zlib_decompress'<br>collect2: error: ld returned 1 exit status</span></div><div><br></div>
<div><br></div><hr style="width: 210px; height: 1px;" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><div>Best wishes,</div><div>xuelin.tian@qkmtech.com</div></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:chrisj@rtems.org">Chris Johns</a></div><div><b>Date:</b> 2017-10-21 08:56</div><div><b>To:</b> <a href="mailto:xuelin.tian@qkmtech.com">xuelin.tian@qkmtech.com</a>; <a href="mailto:sebastian.huber@embedded-brains.de">Sebastian Huber</a>; <a href="mailto:users@rtems.org">users@rtems.org</a></div><div><b>Subject:</b> Re: Filesystem in RTEMS</div></div></div><div><div>On 21/10/2017 11:17, xuelin.tian@qkmtech.com wrote:</div>
<div>> I followed the example (testsuites/fstests/jffs2_support/fs_support.c), and some</div>
<div>> error came up, like </div>
<div>> "undefined reference to rtems_jffs2_initialize",</div>
<div>> "undefined reference to rtems_jffs2_compressor_zlib_compress", and </div>
<div>> "undefined reference to rtems_jffs2_compressor_zlib_decompress"</div>
<div>> I have no clue here. Do I have to give my own implementation of these functions</div>
<div>> here? I can exploit the default functions for jffs2 entry table and compress, I</div>
<div>> think. </div>
<div>> </div>
<div>> And I have a little confused about the model of device driver in rtems, since I</div>
<div>> get stuck for a few days.</div>
<div>> First, a deivce descriptor (rtems_fdisk_device_desc) should be given, including</div>
<div>> some handlers defined in rtems_fdisk_driver_handlers,  and device configuration</div>
<div>> (rtems_flashdisk_config). </div>
<div>> Then, I need to register (or initialize) my flash device into rtems dynamically</div>
<div>> or statically, with my own initialize, open, close functions.</div>
<div>> Last, the JFFS2 should be set up based on the registered device driver. The</div>
<div>> block size need to be equal to the page size of flash, and the read, write,</div>
<div>> erase operations should invoke the corresponding functions defined</div>
<div>> in rtems_fdisk_driver_handlers.</div>
<div>> </div>
<div>> Am I correct in this whoe process?</div>
<div> </div>
<div>I have something like the following piece of code in a file in my application:</div>
<div> </div>
<div>typedef struct</div>
<div>{</div>
<div>  rtems_jffs2_flash_control super;</div>
<div>  /* private data for my flash driver such as stats */</div>
<div>} ffs_control;</div>
<div> </div>
<div>static ffs_control*</div>
<div>flash_get_control(rtems_jffs2_flash_control* super)</div>
<div>{</div>
<div>  return (ffs_control *) super;</div>
<div>}</div>
<div> </div>
<div>static int</div>
<div>flash_read(rtems_jffs2_flash_control* super,</div>
<div>           uint32_t                   offset,</div>
<div>           unsigned char*             buffer,</div>
<div>           size_t                     length)</div>
<div>{</div>
<div>  ffs_control* self = flash_get_control(super);</div>
<div>  int          r;</div>
<div>  .</div>
<div>  .</div>
<div>  .</div>
<div>  return r;</div>
<div>}</div>
<div> </div>
<div>static int</div>
<div>flash_write(rtems_jffs2_flash_control* super,</div>
<div>            uint32_t                   offset,</div>
<div>            const unsigned char*       buffer,</div>
<div>            size_t                     length)</div>
<div>{</div>
<div>  ffs_control* self = flash_get_control(super);</div>
<div>  int          r;</div>
<div>  .</div>
<div>  .</div>
<div>  .</div>
<div>  return r;</div>
<div>}</div>
<div> </div>
<div>static int</div>
<div>flash_erase(rtems_jffs2_flash_control* super,</div>
<div>            uint32_t                   offset)</div>
<div>{</div>
<div>  ffs_control* self = flash_get_control(super);</div>
<div>  int          r;</div>
<div>  .</div>
<div>  .</div>
<div>  .</div>
<div>  return r;</div>
<div>}</div>
<div> </div>
<div>static void</div>
<div>flash_destroy(rtems_jffs2_flash_control* super)</div>
<div>{</div>
<div>  ffs_control* self = flash_get_control(super);</div>
<div>  int          r;</div>
<div>  .</div>
<div>  .</div>
<div>  .</div>
<div>  return r;</div>
<div>}</div>
<div> </div>
<div>static ffs_control ffs_data = {</div>
<div>    .super = {</div>
<div>        .read = flash_read,</div>
<div>        .write = flash_write,</div>
<div>        .erase = flash_erase,</div>
<div>        .destroy = flash_destroy</div>
<div>    }</div>
<div>};</div>
<div> </div>
<div>static rtems_jffs2_compressor_zlib_control compressor_instance = {</div>
<div>    .super = {</div>
<div>        .compress = rtems_jffs2_compressor_zlib_compress,</div>
<div>        .decompress = rtems_jffs2_compressor_zlib_decompress</div>
<div>    }</div>
<div>};</div>
<div> </div>
<div>static const rtems_jffs2_mount_data ffs_mount_data = {</div>
<div>    .flash_control = &ffs_data.super,</div>
<div>    .compressor_control = &compressor_instance.super</div>
<div>};</div>
<div> </div>
<div>bool</div>
<div>ffs_mount(const char* path)</div>
<div>{</div>
<div>  int r;</div>
<div> </div>
<div>  r = flash_open();</div>
<div>  if (r != 0)</div>
<div>  {</div>
<div>    /* print something */</div>
<div>    return false;</div>
<div>  }</div>
<div> </div>
<div> ffs_data.super.block_size = HYDRA_FLASH_BLOCK_SIZE;</div>
<div> ffs_data.super.flash_size = HYDRA_FLASH_FILESYSTEM_SIZE;</div>
<div> </div>
<div> r = mount_and_make_target_path(NULL,</div>
<div>                                path,</div>
<div>                                RTEMS_FILESYSTEM_TYPE_JFFS2,</div>
<div>                                RTEMS_FILESYSTEM_READ_WRITE,</div>
<div>                                &ffs_mount_data);</div>
<div> if (r != 0)</div>
<div> {</div>
<div>    /* print something */</div>
<div>    return false;</div>
<div> }</div>
<div> </div>
<div> return true;</div>
<div>}</div>
<div> </div>
<div>You need to provide the open, close, read, write, erase and destroy code that</div>
<div>accesses your flash device. This can be calls to something that directly</div>
<div>accesses the flash device or you can build a driver registered in the device</div>
<div>tree to handle the flash via ioctls.</div>
<div> </div>
<div>Chris</div>
</div></blockquote>
</body></html>