MLC Nand flash "Works for me" pre beta release

Discussion about writing software for VS1005 and the VSOS Operating System. Also posts about VS1005-related hardware design and device drivers should be posted here.
Post Reply
Hannu
User
Posts: 12
Joined: Mon 2016-05-30 11:54

MLC Nand flash "Works for me" pre beta release

Post by Hannu » Tue 2017-05-02 13:15

Hello everyone!

I'm happy to release pre beta MLC nand flash driver for VSOS. The name of the driver is purity.
It has been developed against 4GB chip with 4kB write page and 1MB erase block.
The nand flash on VS1005 developer board is supported. If your board doesn't have the MLC nand flash chip installed, please contact us.

This release is for testing purposes.
Feedback is appreciated.

Things to consider when using Purity nand flash driver
  • Purity must be unloaded (driver -purity) before reset or filesystem will corrupt
  • Performance isn't constant. From top 1MB/sec it can go down to 15 kB/sec.
  • Purity has huge memory footprint.
  • Purity is currently very verbose.
  • By default nand flash is drive M:
  • When accessing nand flash through USB, remember unmount (safely remove device) properly or else file system may corrupt.
  • Only FAT32 is supported
  • Please read Readme.txt I have tried to explain many features of the driver.
Invocation

Command line options are in code box below.

Code: Select all

purity

Without parameters, purity is loaded to memory and disk is taken to use.
If purity is already in memory, nothing happens.

purity c
       Clean the bookkeeping. Drop sectors which aren't used by filesystem.

purity D
       Continue desharding if paused and print desharding progress information.

purity i
       Print information of purity mapper

purity P
       Pause desharding

purity p
       Continue paused desharding

purity s
       Save the state of the mapper.

purity t
       Test the mapper. All mapped sectors are read.
       This is mostly used for debugging.

purity Z
       ZAP!! the disk. Disk is erased. All data is lost.
       New filesystem has to be created.
Preparing MLC nand flash for use
This example uses format tool from: viewtopic.php?f=13&t=2109

Code: Select all

------- Erase nand flash --------
S:>purity Z
NAND Feature: Timing: 0x0000, 0x0000
NAND Flash Ident: 0x2c68044689
Detected ONFI Flash: MICRON      MT29F32G08CBABAWP   
4f4e 4649 0e00 5800 ff01 0000 0000 0300 0000 0000 0000 0000 0000 0000 0000 0000   ONFI..X.�.......................
4d49 4352 4f4e 2020 2020 2020 4d54 3239 4633 3247 3038 4342 4142 4157 5020 2020   MICRON      MT29F32G08CBABAWP   
2c00 0000 0000 0000 0000 0000 0000 0000 0010 0000 e000 0002 0000 1c00 0001 0000   ,...................�...........
0010 0000 0123 0264 0005 0301 0000 0100 0c01 1e00 0000 0000 0000 0000 0000 0000   .....#.d........................
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ................................
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ................................
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ................................
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ................................
Geometry: 4096, 224, 8, 256, 2048, 4096, 0, Sectors: 8388608, Size: 4194304K
This memory should have 3970 user accessible eraseblocks

Read pre-exixting bad block table table from row 0xf8600

fdfe 0002 0157 0551 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ��...W.Q........................
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ................................
------ Zero rows omitted ------- 
Ok, 2 bad block(s).

___SHARDS___
Loaded state from rows 0..24
S:>
--------- Reset dev board ---------
S:>purity
NAND Feature: Timing: 0x0000, 0x0000
NAND Flash Ident: 0x2c68044689
Detected ONFI Flash: MICRON      MT29F32G08CBABAWP   
------- Bad block table is shown (omitted)----
------- Make filesystem ------
S:>format m:
Raw disk geometry:  7520256 sectors (3672 MiB =  3.6 GiB), 1 sect per block
  sectors 7520256, sectorsPerCluster 8, clusters 939008
  numberOfFats 1, sectorsPerFat 7337, reservedSectors 855
  startOfFat 0, startOfFileSystem startOfFat+8192
  serialID 0x7fbb389c
Are you sure you want to format drive M:? All data will be lost! (Y/N)
Writing FAT32 information (4.0 MiB of data)...
LBA 0x     0-> 0x  1000, present: 0x      fe
Shards: 0 FUS: 0x  1000 NAS: 0x  1800 RealDataStart: 0x     0
fatStart: 0x0, fat2Start: 0x0, fatsize: 0x0
Page 0
	firstLba: 0x     0
	nextSba:  0x  1000
	lastSba:  0x  1800
	Present:  0x000000fe
Page 1
	firstLba: 0x     0
	nextSba:  0x     0
	lastSba:  0x     0
	Present:  0x00000000
Desharder mode: 11 page multiplier: 0 useless sectors: 0
Deshard page 
	firstLba: 0x     0
	nextSba:  0x     0
	lastSba:  0x     0
	sectors:  0x     0

___SHARDS___

___SHARDS___
  0:      0..  1fff ->   1000..  2fff (size   2000)  (D)
updateFatBorders
LBA 0x     0-> 0x  3000, present: 0x       1
Shards: 1 FUS: 0x  1000 NAS: 0x  3800 RealDataStart: 0x  2000
fatStart: 0x0, fat2Start: 0x0, fatsize: 0x0
Page 0
	firstLba: 0x     0
	nextSba:  0x  3000
	lastSba:  0x  3800
	Present:  0x00000001
Page 1
	firstLba: 0x     0
	nextSba:  0x     0
	lastSba:  0x     0
	Present:  0x00000000
Desharder mode: 11 page multiplier: 0 useless sectors: 0
Deshard page 
	firstLba: 0x     0
	nextSba:  0x     0
	lastSba:  0x     0
	sectors:  0x     0

___SHARDS___
  0:      0..  1fff ->   1000..  2fff (size   2000)  (D)
Shards: 3 FUS: 0x  1000 NAS: 0x  3800 RealDataStart: 0x  2000
fatStart: 0x357, fat2Start: 0x11ab, fatsize: 0xe54
Page 0
	firstLba: 0x     0
	nextSba:  0x  3008
	lastSba:  0x  3800
	Present:  0x00000000
Page 1
	firstLba: 0x     0
	nextSba:  0x     0
	lastSba:  0x     0
	Present:  0x00000000
Desharder mode: 11 page multiplier: 0 useless sectors: 0
Deshard page 
	firstLba: 0x     0
	nextSba:  0x     0
	lastSba:  0x     0
	sectors:  0x     0
Formatted capacity: 7512064 sectors (3668 MiB =  3.6 GiB)
S:>
Normally calling purity is enough to load the driver. Remember to unload it with driver -purity.

Simple USB mass storage use case

Below is copied about thousand files.

Code: Select all

S:>usbmsc m
USB publishing disk MLC Flash.
[Ctrl-C] to exit.
updateFatBorders
Shards: 3 FUS: 0x  1000 NAS: 0x  4000 RealDataStart: 0x  2000
fatStart: 0x357, fat2Start: 0x11ab, fatsize: 0xe54
-------- Much verbosity omitted while copying some files -------
-------- Flushing Page 1 is printed when FAT table is updated. -------
Flushing Page 1
Flushing Page 1
Flushing Page 1
-------- Safely removed device ------
S:>purity i
Shards: 17 FUS: 0x  1000 NAS: 0x 30800 RealDataStart: 0x  2000
fatStart: 0x357, fat2Start: 0x11ab, fatsize: 0xe54
Page 0
	firstLba: 0x  2270
	nextSba:  0x 302f8
	lastSba:  0x 30800
	Present:  0x00000003
Page 1
	firstLba: 0x     0
	nextSba:  0x  38a8
	lastSba:  0x  4000
	Present:  0x00000003
Desharder mode: 11 page multiplier: 0 useless sectors: 30bc
Deshard page 
	firstLba: 0x  5b50
	nextSba:  0x  f5d0
	lastSba:  0x 29800
	sectors:  0x     8

___SHARDS___
  0:      0..   37f ->   b968..  bce7 (size    380)  (1)
  1:    380..  11aa ->   1380..  21aa (size    e2b) 
  2:   1fff..  27f6 ->   e048..  e83f (size    7f8)  (0)
  3:   27f7..  4127 ->   4007..  5937 (size   1931) 
  4:   4128..  476f ->   d7c0..  de07 (size    648) 
  5:   4770..  5467 ->  29800.. 2a4f7 (size    cf8) 
  6:   5468..  5b4f ->  2a538.. 2ac1f (size    6e8) 
  7:   5b50..  5c0f ->  2ac78.. 2ad37 (size     c0)  (D)
  8:   5c10..  62ef ->   eef8..  f5d7 (size    6e0) 
  9:   62f0..  6b4f ->  2b498.. 2bcf7 (size    860) 
 10:   6b50..  7207 ->   e840..  eef7 (size    6b8) 
 11:   7208..  7aaf ->   9d58..  a5ff (size    8a8) 
 12:   7ab0..  804f ->  2ce78.. 2d417 (size    5a0) 
 13:   8050..  85bf ->   b288..  b7f7 (size    570) 
 14:   85c0..  8d8f ->   a600..  adcf (size    7d0) 
 15:   8d90..  92b7 ->  2e3e0.. 2e907 (size    528) 
 16:   92b8..  a597 ->   c4e0..  d7bf (size   12e0) 
S:>
S:>dir m:
L    1. VSOS                  0 2017-05-02 10:18:34 VSOS
D    2. VSOS_3~1              0 2016-12-05 12:04:50 VSOS_340_RootAndLibrariesSourceCode
S:>
Attachments
purity.zip
purity nand flash driver pre beta
(275.29 KiB) Downloaded 19 times

User avatar
Henrik
VLSI Staff
Posts: 1041
Joined: Tue 2010-06-22 14:10

Re: MLC Nand flash "Works for me" pre beta release

Post by Henrik » Wed 2017-05-03 9:34

Hello!
Hannu wrote:The nand flash on VS1005 developer board is supported. If your board doesn't have the MLC nand flash chip installed, please contact us.
To elaborate on this:
all VS1005 Developer Boards contain a Nand Flash memory. However, some boards contain an SLC (Single Level Cell) Flash, and some an MLC (Multi-Level Cell) Flash. To see which kind your board has, you can run the "purity Z" command and see the relevent output. For instance:

Code: Select all

S:>purity Z
NAND Feature: Timing: 0x0101, 0x0101
NAND Flash Ident: 0x01dc909554
Detected ONFI Flash: SPANSION    S34ML04G1           
4f4e 4649 0200 1c00 1b00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000   ONFI............................
5350 414e 5349 4f4e 2020 2020 5333 344d 4c30 3447 3120 2020 2020 2020 2020 2020   SPANSION    S34ML04G1           
0100 0000 0000 0000 0000 0000 0000 0000 0008 0000 4000 0002 0000 1000 4000 0000   ....................@.......@...
0010 0000 0123 0150 0001 0501 0103 0400 0101 0400 0000 0000 0000 0000 0000 0000   .....#.P........................
[... one gazillion lines removed ...]
Googling with the words SPANSION and S34ML04G1 you quickly find a datasheet that tells it is an SLC memory, so in the example board the new MLC driver will NOT work.

As Hannu told, if your project requires MLC Flash functionality, please let us know, preferably in this thread, and we will see how best to help you.

Kind regards,
- Henrik
Good signatures never die. They just fade away.

Post Reply

Who is online

Users browsing this forum: No registered users