[RTEMS Project] #3771: JFFS2 file system integration with External QSPI Flash

RTEMS trac trac at rtems.org
Wed Jul 24 10:47:09 UTC 2019


#3771: JFFS2 file system integration with External QSPI Flash
--------------------------+---------------------------------------
  Reporter:  Karthikeyan  |      Owner:  (none)
      Type:  defect       |     Status:  new
  Priority:  highest      |  Milestone:  4.11.3
 Component:  admin        |    Version:  4.11
  Severity:  normal       |   Keywords:  JFFS2 QSPI External Flash
Blocked By:               |   Blocking:
--------------------------+---------------------------------------
 Hardware Configuration Setup:
 Controller: STM32H7
 Rtems : 4.11
 External Memory: IS25LP016D (2MB flash or 16Mb 133MHZ)
 Memory interface : QSPI

 For JFFS2 Configuration , I have followed the below link,
 https://lists.rtems.org/pipermail/users/2017-October/031757.html



 #define BLOCK_SIZE (16UL * 256UL)

 #define FLASH_SIZE (256 * BLOCK_SIZE)

 typedef struct {

    rtems_jffs2_flash_control super;
    //unsigned char area[FLASH_SIZE];
 } flash_control;

 static flash_control *get_flash_control(rtems_jffs2_flash_control *super)
 {
   return (flash_control *) super;
 }

 static int flash_read(
   rtems_jffs2_flash_control *super,
   uint32_t offset,
   unsigned char *buffer,
   size_t size_of_buffer
 )
 {
   flash_control *self = get_flash_control(super);
   //unsigned char *chunk = &self->area[offset];
   qspiExtFlashRead(offset, buffer, size_of_buffer);
   //memcpy(buffer, chunk, size_of_buffer);

   return 0;
 }

 static int flash_write(
   rtems_jffs2_flash_control *super,
   uint32_t offset,
   const unsigned char *buffer,
   size_t size_of_buffer
 )
 {
   int count = 0;
   flash_control *self = get_flash_control(super);
   //unsigned char *chunk = &self->area[offset];


   qspiExtFlashWrite(offset, buffer, size_of_buffer);
   for (count = 0; count <= size_of_buffer; count++)
   {
     printf("\n\r T : %d", *buffer++);

   }
   //size_t i;

 //  for (i = 0; i < size_of_buffer; ++i) {
 //    chunk[i] &= buffer[i];
 //  }

   return 0;
 }

 static int flash_erase(
   rtems_jffs2_flash_control *super,
   uint32_t offset
 )
 {
   flash_control *self = get_flash_control(super);
   //unsigned char *chunk = &self->area[offset];
   qspiExtFlashErase(offset,BLOCK_SIZE);
  //memset(chunk, 0xff, BLOCK_SIZE);

   return 0;
 }

 static flash_control flash_instance = {
   .super = {
     .block_size = BLOCK_SIZE,
     .flash_size = FLASH_SIZE,
     .read = flash_read,
     .write = flash_write,
     .erase = flash_erase
   }
 };

 static rtems_jffs2_compressor_control compressor_instance = {
   .compress = rtems_jffs2_compressor_rtime_compress,
   .decompress = rtems_jffs2_compressor_rtime_decompress
 };

 static const rtems_jffs2_mount_data mount_data = {
   .flash_control = &flash_instance.super,
   .compressor_control = &compressor_instance
 };

 static void erase_all(void)
 {
  // memset(&flash_instance.area[0], 0xff, FLASH_SIZE);
    qspiExtFlashErase(0, FLASH_SIZE);
 }

 static rtems_resource_snapshot before_mount;

 void test_initialize_jffs2filesystem(void)
 {
   int rv;

   //erase_all();

   rv = mkdir(BASE_FOR_QSPI, S_IRWXU | S_IRWXG | S_IRWXO);
   if(rv != 0)
   {
     printf("\n\r mkdir failed : %d", rv);
   }
  // rtems_test_assert(rv == 0);

   rtems_resource_snapshot_take(&before_mount);

   rv = mount(
     NULL,
     BASE_FOR_QSPI,
     RTEMS_FILESYSTEM_TYPE_JFFS2,
     RTEMS_FILESYSTEM_READ_WRITE,
     &mount_data
   );
   if(rv != 0)
   {
     printf("\n\r mount failed : %d", rv);
   }
 }

 void test_shutdown_jffs2filesystem(void)
 {
   int rv = unmount(BASE_FOR_QSPI);
   bool snapshotStatus;
   //rtems_test_assert(rv == 0);
    if(rv != 0)
   {
     printf("\n\r  failed : %d", rv);
   }
   snapshotStatus = rtems_resource_snapshot_check(&before_mount);
   if ( snapshotStatus != true)
   {
        printf("\n\r  failed : %d", snapshotStatus);
   }
 }

 Problem facing on writing and reading flash memory data during power
 cycle. Following CRC error always coming on power up,

 Listening for connections
  QSPI Read address : 1000, 4096
  QSPI Read address : 2000, 8192
  QSPI Read address : 3000, 12288
  QSPI Read address : 4000, 16384
  QSPI Read address : 5000, 20480
  QSPI Read address : 6000, 24576
  QSPI Read address : 7000, 28672
  QSPI Read address : 8000, 32768
  QSPI Read address : 9000, 36864
  QSPI Read address : a000, 40960
  QSPI Read address : b000, 45056
  QSPI Read address : c000, 49152
  QSPI Read address : d000, 53248
  QSPI Read address : e000, 57344
  QSPI Read address : f000, 61440
  QSPI Read address : 10000, 65536
  QSPI Read address : 11000, 69632
  QSPI Read address : 12000, 73728
  QSPI Read address : 13000, 77824
  QSPI Read address : 14000, 81920
  QSPI Read address : 15000, 86016
  QSPI Read address : 16000, 90112
  QSPI Read address : 17000, 94208
  QSPI Read address : 18000, 98304
  QSPI Read address : 19000, 102400
  QSPI Read address : 1a000, 106496
  QSPI Read address : 1b000, 110592
  QSPI Read address : 1c000, 114688
  QSPI Read address : 1d000, 118784
  QSPI Read address : 1e000, 122880
  QSPI Read address : 1f000, 126976
  QSPI Read address : 20000, 131072
  QSPI Read address : 21000, 135168
  QSPI Read address : 22000, 139264
  QSPI Read address : 23000, 143360
  QSPI Read address : 24000, 147456
  QSPI Read address : 25000, 151552
  QSPI Read address : 26000, 155648
  QSPI Read address : 27000, 159744
  QSPI Read address : 28000, 163840
  QSPI Read address : 29000, 167936
  QSPI Read address : 2a000, 172032
  QSPI Read address : 2b000, 176128
  QSPI Read address : 2c000, 180224
  QSPI Read address : 2d000, 184320
  QSPI Read address : 2e000, 188416
  QSPI Read address : 2f000, 192512
  QSPI Read address : 30000, 196608
  QSPI Read address : 31000, 200704
  QSPI Read address : 32000, 204800
  QSPI Read address : 33000, 208896
  QSPI Read address : 34000, 212992
  QSPI Read address : 35000, 217088
  QSPI Read address : 36000, 221184
  QSPI Read address : 37000, 225280
  QSPI Read address : 38000, 229376
  QSPI Read address : 39000, 233472
  QSPI Read address : 3a000, 237568
  QSPI Read address : 3b000, 241664
  QSPI Read address : 3c000, 245760
  QSPI Read address : 3d000, 249856
  QSPI Read address : 3e000, 253952
  QSPI Read address : 3f000, 258048
  QSPI Read address : 40000, 262144
  QSPI Read address : 41000, 266240
  QSPI Read address : 42000, 270336
  QSPI Read address : 43000, 274432
  QSPI Read address : 44000, 278528
  QSPI Read address : 45000, 282624
  QSPI Read address : 46000, 286720
  QSPI Read address : 47000, 290816
  QSPI Read address : 48000, 294912
  QSPI Read address : 49000, 299008
  QSPI Read address : 4a000, 303104
  QSPI Read address : 4b000, 307200
  QSPI Read address : 4c000, 311296
  QSPI Read address : 4d000, 315392
  QSPI Read address : 4e000, 319488
  QSPI Read address : 4f000, 323584
  QSPI Read address : 50000, 327680
  QSPI Read address : 51000, 331776
  QSPI Read address : 52000, 335872
  QSPI Read address : 53000, 339968
  QSPI Read address : 54000, 344064
  QSPI Read address : 55000, 348160
  QSPI Read address : 56000, 352256
  QSPI Read address : 57000, 356352
  QSPI Read address : 58000, 360448
  QSPI Read address : 59000, 364544
  QSPI Read address : 5a000, 368640
  QSPI Read address : 5b000, 372736
  QSPI Read address : 5c000, 376832
  QSPI Read address : 5d000, 380928
  QSPI Read address : 5e000, 385024
  QSPI Read address : 5f000, 389120
  QSPI Read address : 60000, 393216
  QSPI Read address : 61000, 397312
  QSPI Read address : 62000, 401408
  QSPI Read address : 63000, 405504
  QSPI Read address : 64000, 409600
  QSPI Read address : 65000, 413696
  QSPI Read address : 66000, 417792
  QSPI Read address : 67000, 421888
  QSPI Read address : 68000, 425984
  QSPI Read address : 69000, 430080
  QSPI Read address : 6a000, 434176
  QSPI Read address : 6b000, 438272
  QSPI Read address : 6c000, 442368
  QSPI Read address : 6d000, 446464
  QSPI Read address : 6e000, 450560
  QSPI Read address : 6f000, 454656
  QSPI Read address : 70000, 458752
  QSPI Read address : 71000, 462848
  QSPI Read address : 72000, 466944
  QSPI Read address : 73000, 471040
  QSPI Read address : 74000, 475136
  QSPI Read address : 75000, 479232
  QSPI Read address : 76000, 483328
  QSPI Read address : 77000, 487424
  QSPI Read address : 78000, 491520
  QSPI Read address : 79000, 495616
  QSPI Read address : 7a000, 499712
  QSPI Read address : 7b000, 503808
  QSPI Read address : 7c000, 507904
  QSPI Read address : 7d000, 512000
  QSPI Read address : 7e000, 516096
  QSPI Read address : 7f000, 520192
  QSPI Read address : 80000, 524288
  QSPI Read address : 81000, 528384
  QSPI Read address : 82000, 532480
  QSPI Read address : 83000, 536576
  QSPI Read address : 84000, 540672
  QSPI Read address : 85000, 544768
  QSPI Read address : 86000, 548864
  QSPI Read address : 87000, 552960
  QSPI Read address : 88000, 557056
  QSPI Read address : 89000, 561152
  QSPI Read address : 8a000, 565248
  QSPI Read address : 8b000, 569344
  QSPI Read address : 8c000, 573440
  QSPI Read address : 8d000, 577536
  QSPI Read address : 8e000, 581632
  QSPI Read address : 8f000, 585728
  QSPI Read address : 90000, 589824
  QSPI Read address : 91000, 593920
  QSPI Read address : 92000, 598016
  QSPI Read address : 93000, 602112
  QSPI Read address : 94000, 606208
  QSPI Read address : 95000, 610304
  QSPI Read address : 96000, 614400
  QSPI Read address : 97000, 618496
  QSPI Read address : 98000, 622592
  QSPI Read address : 99000, 626688
  QSPI Read address : 9a000, 630784
  QSPI Read address : 9b000, 634880
  QSPI Read address : 9c000, 638976
  QSPI Read address : 9d000, 643072
  QSPI Read address : 9e000, 647168
  QSPI Read address : 9f000, 651264
  QSPI Read address : a0000, 655360
  QSPI Read address : a1000, 659456
  QSPI Read address : a2000, 663552
  QSPI Read address : a3000, 667648
  QSPI Read address : a4000, 671744
  QSPI Read address : a5000, 675840
  QSPI Read address : a6000, 679936
  QSPI Read address : a7000, 684032
  QSPI Read address : a8000, 688128
  QSPI Read address : a9000, 692224
  QSPI Read address : aa000, 696320
  QSPI Read address : ab000, 700416
  QSPI Read address : ac000, 704512
  QSPI Read address : ad000, 708608
  QSPI Read address : ae000, 712704
  QSPI Read address : af000, 716800
  QSPI Read address : b0000, 720896
  QSPI Read address : b1000, 724992
  QSPI Read address : b2000, 729088
  QSPI Read address : b3000, 733184
  QSPI Read address : b4000, 737280
  QSPI Read address : b5000, 741376
  QSPI Read address : b6000, 745472
  QSPI Read address : b7000, 749568
  QSPI Read address : b8000, 753664
  QSPI Read address : b9000, 757760
  QSPI Read address : ba000, 761856
  QSPI Read address : bb000, 765952
  QSPI Read address : bc000, 770048
  QSPI Read address : bd000, 774144
  QSPI Read address : be000, 778240
  QSPI Read address : bf000, 782336
  QSPI Read address : c0000, 786432
  QSPI Read address : c1000, 790528
  QSPI Read address : c2000, 794624
  QSPI Read address : c3000, 798720
  QSPI Read address : c4000, 802816
  QSPI Read address : c5000, 806912
  QSPI Read address : c6000, 811008
  QSPI Read address : c7000, 815104
  QSPI Read address : c8000, 819200
  QSPI Read address : c9000, 823296
  QSPI Read address : ca000, 827392
  QSPI Read address : cb000, 831488
  QSPI Read address : cc000, 835584
  QSPI Read address : cd000, 839680
  QSPI Read address : ce000, 843776
  QSPI Read address : cf000, 847872
  QSPI Read address : d0000, 851968
  QSPI Read address : d1000, 856064
  QSPI Read address : d2000, 860160
  QSPI Read address : d3000, 864256
  QSPI Read address : d4000, 868352
  QSPI Read address : d5000, 872448
  QSPI Read address : d6000, 876544
  QSPI Read address : d7000, 880640
  QSPI Read address : d8000, 884736
  QSPI Read address : d9000, 888832
  QSPI Read address : da000, 892928
  QSPI Read address : db000, 897024
  QSPI Read address : dc000, 901120
  QSPI Read address : dd000, 905216
  QSPI Read address : de000, 909312
  QSPI Read address : df000, 913408
  QSPI Read address : e0000, 917504
  QSPI Read address : e1000, 921600
  QSPI Read address : e2000, 925696
  QSPI Read address : e3000, 929792
  QSPI Read address : e4000, 933888
  QSPI Read address : e5000, 937984
  QSPI Read address : e6000, 942080
  QSPI Read address : e7000, 946176
  QSPI Read address : e8000, 950272
  QSPI Read address : e9000, 954368
  QSPI Read address : ea000, 958464
  QSPI Read address : eb000, 962560
  QSPI Read address : ec000, 966656
  QSPI Read address : ed000, 970752
  QSPI Read address : ee000, 974848
  QSPI Read address : ef000, 978944
  QSPI Read address : f0000, 983040
  QSPI Read address : f1000, 987136
  QSPI Read address : f2000, 991232
  QSPI Read address : f3000, 995328
  QSPI Read address : f4000, 999424
  QSPI Read address : f5000, 1003520
  QSPI Read address : f6000, 1007616
  QSPI Read address : f7000, 1011712
  QSPI Read address : f8000, 1015808
  QSPI Read address : f9000, 1019904
  QSPI Read address : fa000, 1024000
  QSPI Read address : fb000, 1028096
  QSPI Read address : fc000, 1032192
  QSPI Read address : fd000, 1036288
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE000:
 0x0185 instead
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE00C:
 0x0981 instead
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE014:
 0x8909 instead
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE02C:
 0x339C instead
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE030:
 0x779E instead
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE034:
 0x779E instead
 <5>JFFS2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at
 0x000FE04C:
 0x4343 instead
  QSPI Read address : fe000, 1040384
 <5>JFFS2: jffs2_scan_inode_node(): CRC failed on node at 0x000FE0EC: Read
 0xFFFF
 FFFF, calculated 0x2D670D7B
 <5>JFFS2: jffs2_scan_inode_node(): CRC failed on node at 0x000FE1D0: Read
 0xFFFF
 FFFF, calculated 0xBAABA5B5
  QSPI Read address : fe0ec, 1040620
  QSPI Read address : fe244, 1040964
  QSPI Read address : ff000, 1044480

 Please let me know any solution on this. Also we are not able to unmount
 jffs directory from root file system.

 [[Image()]]

--
Ticket URL: <http://devel.rtems.org/ticket/3771>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list