[INFO] Flash Driver model

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
electronic_eel
Posts: 77
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 17 times

Re: [INFO] Flash Driver model

Postby electronic_eel » Wed May 11, 2016 10:30 pm

Giovanni wrote:The BaseFlash class is generic, not just meant for SPI devices but also memory mapped flash or other types, the "get id" thing is very specific of the SPI type I think.

All types of flash I know of have some kind of get id. I just browsed through the datasheets of some parallel flash ics of different manufacturers at Digikey and they all have it. And in all types I've seen it was modeled similar with a manufacturer and device id in front. Sometimes there was vendor specific stuff like feature bitmasks following in the output. But the get id command could ignore that.

Also interfaces like eMMC and SD card offer id data. But it is longer than on the SPI flashes. If you want to cover that with this interface too, you'd have to make the id variable length.

Maybe there is some odd flash device out there which does not offer it. But that would really be the exception and not the rule. Then the driver for that oddball device could return 0 as id. You could also add a feature flag telling if a driver returns a proper id or not.

Giovanni wrote:(and an API to send direct commands, all problems solved)

yeah, that would be nice and solve the problems with the custom write protection schemes and other vendor specific stuff.

I'm not sure if the direct command API needs to be limited to SPI. The parallel flashes have commands too, usually implemented with command registers. I don't know how you would implement flash without any kind of commands. You need at least some kind of page erase command. Implementing a read/write like parallel SRAM doesn't make any sense with flash.

Giovanni wrote:BTW, I am working on a QSPI driver while I am at it, it is becoming a standard feature nowadays.

Nice.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] Flash Driver model

Postby Giovanni » Thu May 12, 2016 2:09 pm

Apparently a standard does exist: http://www.jedec.org/standards-document ... ts/JESD216

The best approach could be to create a generic "JEST216" driver class and then specialize per family.

Giovanni

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] Flash Driver model

Postby Giovanni » Fri May 13, 2016 9:17 am

After going through a lot of data sheets this is my current understanding:

1) Common commands are common to most devices.
2) Erase/suspend is not a standard feature, its status bits are placed in different registers depending on manufacturer.
3) Program/erase status bits are not placed in a standard way, this is very annoying.

I think a common driver is not possible, however drivers for "families" rather specific devices are quite possible.

Giovanni

electronic_eel
Posts: 77
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 17 times

Re: [INFO] Flash Driver model

Postby electronic_eel » Fri May 13, 2016 8:55 pm

You may want to take a look at the Flashrom project. They support a plethora of flash ics with all kinds of different interfaces and so on.

I'm not saying you should replicate or integrate all their work. But it may give you an idea how to best differentiate the various flash ic types into families with a common driver.

Their main database of flash ics is here: https://code.coreboot.org/p/flashrom/source/tree/HEAD/trunk/flashchips.c.
From there they have function pointers to all the generic or specialized functions that are needed to handle a specific ic.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] Flash Driver model

Postby Giovanni » Tue Jun 07, 2016 2:16 pm

Updates:

- Implemented a class handling the JESD216B standard. It is able to exchange commands using either SPI or QSPI.
- Updated the Micron driver to use the new framework, it is able to use any device up to 128Mb now.
- Demo for STM32F3-Discovery and N25Q128 in SPI mode.
- Demo for STM32L476-Discovery and N25Q128 in QSPI mode.
- Added memory mapping feature to the QSPI driver. Now it is possible to see a QSPI serial flash memory as a memory mapped device and even execute code from it.

TODO: Support for DDR mode, support for 4 bytes addresses, more devices.

Giovanni

neums
Posts: 137
Joined: Fri May 08, 2015 1:09 pm
Location: Dresden, Germany
Has thanked: 10 times
Been thanked: 5 times

Re: [INFO] Flash Driver model

Postby neums » Wed Jun 08, 2016 7:05 am

Hi,
why the functions and variables are named with the prefix m25q? I thought the name of this flash is N25Q.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] Flash Driver model

Postby Giovanni » Wed Jun 08, 2016 8:09 am

Hi,

"M" is for Micron, the driver is meant to support also MT25Q devices (as soon I am able to have some HW). If the thing will prove difficult then the driver will be renamed to n25q.

Giovanni

lemmy
Posts: 10
Joined: Tue Oct 06, 2015 9:02 am

Re: [INFO] Flash Driver model

Postby lemmy » Mon Feb 27, 2017 10:08 pm

Hi,

Is there a demo for this driver?

An earlier post mentions these but I couldn't locate them.
- Demo for STM32F3-Discovery and N25Q128 in SPI mode.
- Demo for STM32L476-Discovery and N25Q128 in QSPI mode.

Thank you

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: [INFO] Flash Driver model

Postby Giovanni » Mon Feb 27, 2017 10:12 pm

Hi,

The demos are in the repository code, look under /testex/STM32.

Giovanni

lemmy
Posts: 10
Joined: Tue Oct 06, 2015 9:02 am

Re: [INFO] Flash Driver model

Postby lemmy » Mon Feb 27, 2017 10:22 pm

Got it, thank you Giovanni :D


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 14 guests