Placing rootfs in S25FL512S QSPI NOR

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Placing rootfs in S25FL512S QSPI NOR

2,871 Views
avanluijpen
NXP Employee
NXP Employee

Hi all,

I am working on a custom board, which uses iMX6SoloX and Spansion S25FL512S QSPI flash device (active kernel is 3.14.28). There are a number of hurdles I have allready taken:

First off in uBoot, I have:

  1. adjusted QSPI headerf for this board/flash. The default qspi-nor-slow-config had DQS=1, which is not valid for the s25fl512s device (no DQS line support). I could not manage to rework qspi-spansion-s25fl128s-config to correctly setup our 1x s25fl512s in Quad mode. I can share my attempts at this if you're interested.
  2. have enabled CONFIG_SF_CMD and can do SF probe & SF read / erase / write just fine. Have not been able to (succesfully) write rootfs.ubi using sf write though. Use this to program uboot & kernel.
  3. have enabled CONFIG_MTD_DEVICE and CONFIG_CMD_MTDPARTS, defined partitions in CONFIG_MTD_PARTITIONS, but have been unable to define an acceptable MTDIDS_DEFAULT (tried mtdids=nor0=21e4000.qspi). uBoot seems to only understand dev-id nand0 nor0, but not sf0.
  4. have also added the device partitions to by device tree.
  5. I have tried to enable CONFIG_CMD_UBI, but cannot get uboot to build. This is annoying as I cannot perform ubi functions from uboot command line. Anyway skipped this for the moment, since I have a running kernel with root=/dev/ram (Ideally, I would like to be able to write my rootfs.ubi image, made using ubinize, directly at this point .. either using sf write or using ubiformat)

Then, in the kernel i have enable mtd and ubi in the config and made the following patched to the code

  1. in drivers/mtd/spi-nor/fsl-quadspi.c I have adjusted fsl_qspi_get_seqid (), to also support additional SPINOR_OP_READ4 and BE_4B and SE_4B. This is required since the flash device is 64MiB and requires 4-byte addressing. For some reason not all SPINOR_OP commands are mapped in this kernel version
  2. in drivers/mtd/spi-nor/spi-nor.c I have noticed that the spi_nor_ids[] table uses #define INFO  () macro to fill in s25fl512s device with a fixed page_size of 256. I have patched this file, adjust the page_size to 512 bytes for this device.

With these changes, my kernel boots with the following message:

[    2.602850] UBI: attached mtd5 (name "Root Filesystem", size 56 MiB) to ubi0

[    2.609914] UBI: PEB size: 262144 bytes (256 KiB), LEB size: 262016 bytes

[    2.616752] UBI: min./max. I/O unit sizes: 1/512, sub-page size 1

[    2.622869] UBI: VID header offset: 64 (aligned 64), data offset: 128

[    2.629318] UBI: good PEBs: 224, bad PEBs: 0, corrupted PEBs: 0

[    2.635254] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128

[    2.642410] UBI: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 4284725391

[    2.651474] UBI: available PEBs: 220, total reserved PEBs: 4, PEBs reserved for bad PEB handling: 0

[    2.660532] UBI: background thread "ubi_bgt0d" started, PID 71

I can now succesfully ubiformat the /dev/mtd5 device, and then ubiattach it, and create a volume using ubimkvol

# ubimkvol /dev/ubi0 -m -N rootfs

Set volume size to 57643520

Volume ID 0, size 220 LEBs (57643520 bytes, 55.0 MiB), LEB size 262016 bytes (255.9 KiB), dynamic, name "rootfs", alignment

# ubinfo -a
UBI version:                    1
Count of UBI devices:           1
UBI control device major/minor: 10:60
Present UBI devices:            ubi0

ubi0
Volumes count:                           0
Logical eraseblock size:                 262016 bytes, 255.9 KiB
Total amount of logical eraseblocks:     224 (58691584 bytes, 56.0 MiB)
Amount of available logical eraseblocks: 220 (57643520 bytes, 55.0 MiB)
Maximum count of volumes                 128
Count of bad physical eraseblocks:       0
Count of reserved physical eraseblocks:  0
Current maximum erase counter value:     1
Minimum input/output unit size:          1 byte
Character device major/minor:            248:0

Interesting to see is that LEB is 262016 bytes, which is 128 bytes shy of 256KiB (1/4 of my the s25fl512s page size!)

The (empty) volume I can succesfully mount using mount -t ubi0:rootfs /mnt, and I can then read/write to it just fine, and it will survive a reboot. Mounting gives me the following results:

# mount -t ubifs ubi0:rootfs /mnt/

[  435.523097] UBIFS: default file-system created

[  435.540930] UBIFS: background thread "ubifs_bgt0_0" started, PID 134

[  435.607335] UBIFS: mounted UBI device 0, volume 0, name "rootfs"

[  435.613676] UBIFS: LEB size: 262016 bytes (255 KiB), min./max. I/O unit sizes: 8 bytes/512 bytes

[  435.622665] UBIFS: FS size: 55023360 bytes (52 MiB, 210 LEBs), journal size 2882176 bytes (2 MiB, 11 LEBs)

[  435.632467] UBIFS: reserved for root: 2598889 bytes (2537 KiB)

[  435.638314] UBIFS: media format: w4/r0 (latest is w4/r0), UUID 7B5FC98C-827F-4E68-A6A4-81FE5334C047, small LPT model

However, when I scp my rootfs.ubifs image across, and attempt to flash it with ubiupdatevol /dev/ubi0_0 rootfs.ubifs, I am less successful. The ubiupdatevol command passes nicely, but when I mount the partition same way as before, I get:

# ubiupdatevol /dev/ubi0_0 rootfs.ubifs

# mount -t ubifs ubi0:rootfs /mnt

[  250.172597] UBIFS error (pid 148): validate_sb: min. I/O unit mismatch: 512 in superblock, 8 real

[  250.190542] UBIFS error (pid 148): validate_sb: bad superblock, error 1

[  250.202242]  magic          0x6101831

[  250.205914]  crc            0x7f86c959

[  250.209665]  node_type      6 (superblock node)

[  250.214243]  group_type     0 (no node group)

[  250.218605]  sqnum          1

[  250.221595]  len            4096

[  250.224827]  key_hash       0 (R5)

[  250.228231]  key_fmt        0 (simple)

[  250.232001]  flags          0x0

[  250.235145]    big_lpt      0

[  250.238112]    space_fixup  0

[  250.241096]  min_io_size    512

[  250.244240]  leb_size       261632

[  250.247642]  leb_cnt        96

[  250.250698]  max_leb_cnt    96

[  250.253768]  max_bud_bytes  2877952

[  250.257257]  log_lebs       4

[  250.260224]  lpt_lebs       2

[  250.263207]  orph_lebs      1

[  250.266176]  jhead_cnt      1

[  250.269145]  fanout         8

[  250.272127]  lsave_cnt      256

[  250.275270]  default_compr  1

[  250.278237]  rp_size        0

[  250.281219]  rp_uid         0

[  250.284188]  rp_gid         0

[  250.287155]  fmt_version    4

[  250.290122]  time_gran      1000000000

[  250.293889]  UUID           438B6F15-EE7D-432B-9E9A-282B5B0ED9BD

mount: mounting ubi0:root on /mnt failed: Invalid argument

The following command was used to create rootfs.ubifs

mkfs.ubifs -d ./output/target -e 0x3fe00 -c 96 -m 0x200 -x lzo  -o ./output/images/rootfs.ubifs

Here I specify 512 page size, and 255.5K LEB, which I believe to be correct for spansion s25fl512s device.

I seem to to be making a mistake in the generation of the ubifs, but who can help me specify the correct command line ?


I have also tried to set the page size to 128 byte, based on the output of ubinfo -a:

mkfs.ubifs -d ./output/target -e 0x3ff80 -c 96 -m 0x80 -x lzo  -o ./output/images/rootfs.ubifs

But I get the same result  - I/O unit real value is said to be only 8 - where is this defined ?

# mount -t ubifs ubi0:rootfs /mnt

[  538.670907] UBIFS error (pid 161): validate_sb: min. I/O unit mismatch: 128 in superblock, 8 real

[  538.679791] UBIFS error (pid 161): validate_sb: bad superblock, error 1

[  538.697621]  magic          0x6101831

[  538.701341]  crc            0xadede869

[  538.705096]  node_type      6 (superblock node)

[  538.709628]  group_type     0 (no node group)

[  538.714008]  sqnum          1

[  538.716978]  len            4096

[  538.720207]  key_hash       0 (R5)

[  538.723627]  key_fmt        0 (simple)

[  538.727379]  flags          0x0

[  538.730520]    big_lpt      0

[  538.733504]    space_fixup  0

[  538.736473]  min_io_size    128

[  538.739614]  leb_size       262016

[  538.743032]  leb_cnt        96

[  538.746087]  max_leb_cnt    96

[  538.749141]  max_bud_bytes  2882176

[  538.752645]  log_lebs       4

[  538.755614]  lpt_lebs       2

[  538.758581]  orph_lebs      1

[  538.761564]  jhead_cnt      1

[  538.764532]  fanout         8

[  538.767500]  lsave_cnt      256

[  538.770641]  default_compr  1

[  538.773623]  rp_size        0

[  538.776592]  rp_uid         0

[  538.779559]  rp_gid         0

[  538.782543]  fmt_version    4

[  538.785512]  time_gran      1000000000

[  538.789265]  UUID           BB09566E-A88D-4D18-8FE3-CB4D9EEA8374

Customer Application Support Engineer
ADAS-CAS (V2X & Radar)
Labels (2)
0 Kudos
3 Replies

1,451 Views
avanluijpen
NXP Employee
NXP Employee

I found the cause of my headaches ...

As the S25FL512S is a NOR Flash, I need to create my ubifs with a Min IO size of 1 (not 512).

Also, I still need to take into account manually that the LEB is PEB - 128 bytes (2x 64byte for EC and VID header).

So, the command is :

mkfs.ubifs -d ./output/target -e 0x3ff80 -c 96 -m 0x1 -x lzo  -o ./output/images/rootfs.ubifs

The generated rootfs.ubifs can be programmed using ubiupdatevol (but /dev/ubi must be ubiformatted first)

Alternatively, if I use ubinize to create rootfs.ubi, I can program this file directly when doing using ubiformat.

Note that I was not able to program the rootfs.ubi from uboot yet, as the .ubi file does not cover all erase-blocks (and each erase block needs at least the EC header). So I think I have some more work to do, to get ubi support for sf0 in uboot.

Customer Application Support Engineer
ADAS-CAS (V2X & Radar)
0 Kudos

1,451 Views
art
NXP Employee
NXP Employee

Thank you for sharing your experience. Please refer to the following community thread:

https://community.nxp.com/message/642665

Hope it would be of some help.


Have a great day,
Artur

0 Kudos

1,451 Views
avanluijpen
NXP Employee
NXP Employee

Hi Artur,

thanks for the parallel thread, but I could not find any usefull information in it, regarding UBIFS.

Re, Alexander

Customer Application Support Engineer
ADAS-CAS (V2X & Radar)
0 Kudos