Load files to FileX filesystem

I have been reading the documentation of FileX, analyzing the examples given for the EK-RA6M5 and I'm trying to implement a filesystem on the external QSPI flash. I do this by running the erase_qspi_flash funciton that was retrieved from the FileX_block_media_qspi_LevelX example project. I have also set the same options in the configuration of the FileX on my project. However, when the QSPI is formatted and opened, I dump the contents and try to analyze the partition with fsck in linux, but the partition has a lot of issues. 

The first issue is that the first 512 bytes, which should be the MBR according to https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/filex/chapter3.md , it has this:

0000000060000000: 00000001 00000000 00000006 00000000
0000000060000010: C0000000 C0000001 C0000002 C0000003
0000000060000020: C0000004 C0000005 C0000006 FFFFFFFF
0000000060000030: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000040: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000050: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000060: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000070: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000080: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000090: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600000A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600000B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600000C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600000D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600000E0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600000F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000100: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000110: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000120: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000130: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000140: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000150: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000160: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000170: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000180: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
0000000060000190: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600001A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600001B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600001C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600001D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600001E0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
00000000600001F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF

Which I don't even know what it is ... Then comes the MBR:

0000000060000200: 459034EB 4946204C 0058454C 00010102
0000000060000210: 00010001 000CF810 00010001 00000000
0000000060000220: 00000000 01290000 56000000 6D756C6F
0000000060000230: 20312065 00002020 00000000 00000000
0000000060000240: 00000000 00000000 00000000 00000000
0000000060000250: 00000000 00000000 00000000 00000000
0000000060000260: 00000000 00000000 00000000 00000000
0000000060000270: 00000000 00000000 00000000 00000000
0000000060000280: 00000000 00000000 00000000 00000000
0000000060000290: 00000000 00000000 00000000 00000000
00000000600002A0: 00000000 00000000 00000000 00000000
00000000600002B0: 00000000 00000000 00000000 00000000
00000000600002C0: 00000000 00000000 00000000 00000000
00000000600002D0: 00000000 00000000 00000000 00000000
00000000600002E0: 00000000 00000000 00000000 00000000
00000000600002F0: 00000000 00000000 00000000 00000000
0000000060000300: 00000000 00000000 00000000 00000000
0000000060000310: 00000000 00000000 00000000 00000000
0000000060000320: 00000000 00000000 00000000 00000000
0000000060000330: 00000000 00000000 00000000 00000000
0000000060000340: 00000000 00000000 00000000 00000000
0000000060000350: 00000000 00000000 00000000 00000000
0000000060000360: 00000000 00000000 00000000 00000000
0000000060000370: 00000000 00000000 00000000 00000000
0000000060000380: 00000000 00000000 00000000 00000000
0000000060000390: 00000000 00000000 00000000 00000000
00000000600003A0: 00000000 00000000 00000000 00000000
00000000600003B0: 00000000 00000000 00000000 00000000
00000000600003C0: 00000000 00000000 00000000 00000000
00000000600003D0: 00000000 00000000 00000000 00000000
00000000600003E0: 00000000 00000000 00000000 00000000
00000000600003F0: 00000000 00000000 00000000 AA550000

That, after analyzing, has these configurations:

Boot Sector (First 512 bytes):

  • 0x00 - 0x02: EB 34 90 (Jump Instruction)
  • 0x03 - 0x0A: 46 49 4C 45 58 20 4C 00 ("FILEX L ") (OEM Name)
  • 0x0B - 0x0C: 00 02 (512 bytes per sector) → This is correct.
  • 0x0D: 01 (Sectors Per Cluster: 1 sector)
  • 0x0E - 0x0F: 01 00 (Number of Reserved Sectors: 1 sector)
  • 0x10: 01 (Number of FATs: 1 FAT)
  • 0x11 - 0x12: 0C 00 (Root Directory Entries: 12 entries)
  • 0x13 - 0x14: 10 F8 (Total Sectors: 63504 sectors)
  • 0x15: 01 (Media Descriptor)
  • 0x16 - 0x17: 01 00 (Sectors Per FAT: 1 sector per FAT)
  • 0x18 - 0x19: 00 00 (Sectors Per Track: 0)
  • 0x1A - 0x1B: 00 00 (Number of Heads: 0)
  • 0x1C - 0x1F: 29 01 00 00 (Hidden Sectors: 297 sectors)
  • 0x20 - 0x23: 00 00 00 56 (Total Sectors for FAT-32: 56000 sectors)
  • 0x1FE - 0x1FF: 55 AA (Boot Signature, indicating a valid boot sector)

And from the Root Directory Entries part, everything is completely incorrect. Here are the defines that are used in the fx_media_format:

#define G_FX_MEDIA0_MEDIA_MEMORY_SIZE (512)
#define G_FX_MEDIA0_VOLUME_NAME ("Volume 1")
#define G_FX_MEDIA0_NUMBER_OF_FATS (1)
#define G_FX_MEDIA0_DIRECTORY_ENTRIES (256)
#define G_FX_MEDIA0_HIDDEN_SECTORS (0)
#define G_FX_MEDIA0_TOTAL_SECTORS (4096)
#define G_FX_MEDIA0_BYTES_PER_SECTOR (512)
#define G_FX_MEDIA0_SECTORS_PER_CLUSTER (1)
#define G_FX_MEDIA0_VOLUME_SERIAL_NUMBER (12345)
#define G_FX_MEDIA0_BOUNDARY_UNIT (128)

With the function being called as:

err = fx_media_format(&g_fx_media0,                              // Pointer to FileX media control block.
                          RM_FILEX_LEVELX_NOR_DeviceDriver,          // Driver entry
                          (void *) &g_rm_filex_levelx_nor0_instance,  // Pointer to LevelX NOR Driver
                          g_fx_media0_media_memory,                  // Media buffer pointer
                          G_FX_MEDIA0_MEDIA_MEMORY_SIZE,             // Media buffer size
                          (char *) G_FX_MEDIA0_VOLUME_NAME,          // Volume Name
                          G_FX_MEDIA0_NUMBER_OF_FATS,                // Number of FATs
                          G_FX_MEDIA0_DIRECTORY_ENTRIES,             // Directory Entries
                          G_FX_MEDIA0_HIDDEN_SECTORS,                // Hidden sectors
                          G_FX_MEDIA0_TOTAL_SECTORS,                 // Total sectors
                          G_FX_MEDIA0_BYTES_PER_SECTOR,              // Sector size
                          G_FX_MEDIA0_SECTORS_PER_CLUSTER,           // Sectors per cluster
                          MEDIA_SECTOR_HEADS_VALUE,                  // Heads (disk media)
                          MEDIA_SECTORS_PER_HEAD);                   // Sectors per track (disk media)

And I don't understand why this is happening. Since I have 13 files to load to this partition to be served by the webserver, I wanted to generate the FAT partition on linux, add the files, generate an image file that would actually represent the partition and files and flash that directly to the QSPI so that I could serve those files. However, the media_format is not doing what I have programmed it to do and I can't actually figure out why. Can someone please point me in the right direction ?