Flash memory and drivers

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
Senior User
Posts: 22
Joined: Sat 2016-11-05 19:36

Flash memory and drivers

Post by YuryShatz » Sun 2017-11-26 14:22

Hi there. It would be nice to have a summary of options that we have when designing our boards.

For our board we need at least 128 Mb (but better 1 Gb or so) of on-board storage. What are our options?

1) In the Kernel there's devSpiFlash.c file which supports "SPI Flash block devices which have 24-bit address, 4K erase sector size". However, maximum for 24-bit SPI flash is 16 Mb.

Question: Is there support anywhere for 32-bit SPI flash?

2) For SLC NAND there's a driver called k9f4g that says it supports "a single type of SLC NAND flash".

Question: Is it really true? Does it support a single type - or are there other similar chips?
Question: Is it really true? Does it support a single type - or are there other similar chips?

3) There's "purity" for MLC NAND that's advertised on this forum as "Beta" and "huge memory footprint". I am afraid it does not sound like a viable option for us yet.

- Am I missing something?
- Would you agree (subjectively) that k9f4g is the most realistic way to go?

Thank you

User avatar
VLSI Staff
Posts: 2467
Joined: Tue 2010-06-22 13:43

Re: Flash memory and drivers

Post by Panu » Tue 2017-11-28 15:12


You're basically right. The main problem is that most large flash chips have large erase block sizes. And general code that updates a small block of data inside an erase block, that need to do a read-modify-write operation need to store the contents of the whole erase block somewhere. The kernel spiflash routines use 4 kilobytes of RAM for this. Here's a little simplified example: when you write a single disk sector (512 bytes) to the flash, the driver reads 4 kilobytes eraseblock contents to RAM, overwrites the required 512 bytes in RAM, and when the 4Kbytes becomes full or an out of sequence access is made, it erases the flash and then rewrites the 4Kbytes from RAM to the flash.

Now, when you use a flash with a larger eraseblock, like 128 kilobytes or 1 megabyte in larger flash chips, there is no RAM anywhere in the system to hold that content. So over the years we have written a multitude of elaborate algorithms to either do a read-copy-erase-write-copy-erase sequence or hold bookkeeping information of what is where in the flash. These work on a case by case basis, depending on which capabilities the flash chips that each user happens to use, has. Add in the error correction requirements of MLC flashes, and combine it with the MLC requirement of always writing the entire megabyte in sequence, you start to get the feeling of the magnitude of the problem.

Lately, I've been experimenting with SPI NAND flash chips such as W25N01GVZEIT, and I'm quite happy with them. The SPI NAND flashes handle the error correction themselves, which takes one layer of burden off the driver's hands. Currently I can use SPI NAND chips for reading and can they are programmed by copying a raw disk image from an SD card. It's enough for some situations. And when I have the time, I'll continue writing a write capable driver for them.

What are your specific needs?

Info: Line In and Line Out, VS1000 User interface, Overlay howto, Latest VSIDE, MCU Howto, Youtube
Panu-Kristian Poiksalo, VLSI Solution Oy

Senior User
Posts: 22
Joined: Sat 2016-11-05 19:36

Re: Flash memory and drivers

Post by YuryShatz » Tue 2017-11-28 22:45

Panu, thank you for the answer

Basically in the device we are building we want to have a non-removeable on-board storage, ideally about 1Gb of it, but I guess we can squeeze into 256 Mb. It will contain small audiofiles (things like help files, hints, etc), in multiple languages. Mosty read-only (though we'll probably want update feature)

I am curious about k9f4g driver. The source code in nandmap.c says //Device driver for a single type of SLC NAND flash
Which I assume is Samsung k9f4g08

- on dev board you have a chip Spancion/Cypress logo.
- In this recent thread: viewtopic.php?f=13&t=2165 you wrote that "the old nand physical drivers work [with S34ML01G1]"

So, what do you mean by "old nand physical driver"? Can I use k9f4g with S34ML01G1? It seems to have the same block size. Or is there some other physical driver for that?

Another question about NAND - can we boot from it?

Thanks a lot

Senior User
Posts: 22
Joined: Sat 2016-11-05 19:36

Re: Flash memory and drivers

Post by YuryShatz » Sun 2017-12-03 1:41

Sorry for stupid questions, I found a thread about this driver saying it indeed supports the Spansion chip. Don't know why I overlooked it before.

Posts: 13
Joined: Thu 2016-09-01 10:58

Re: Flash memory and drivers

Post by Arek » Thu 2018-01-11 12:05

Hi Panu,

I am very happy with your W25N01GVZEIT experiments!

In case you have a time to continue the tests I am very interesting in following:
- Copy, paste, delete files (VS1010 as USB slave)
- Delete all files, active copy all from USB Stick. (VS1010 USB host)

I have a few IS37SML01G1-LLI. If you are interesting I can send it to you.

Now my question: What about your time? :)

Post Reply