[U-Boot] [PATCH v7 00/12] SPI-NAND support

Miquel Raynal miquel.raynal at bootlin.com
Thu Sep 6 07:15:37 UTC 2018


Hello,

I failed the numbering, this is actually the v8. The below changelog is
still right though. I don't plan to resend unless I am explicitly told
to do so.

Sorry for the mistake.

Thanks,
Miquèl


Miquel Raynal <miquel.raynal at bootlin.com> wrote on Thu,  6 Sep 2018
09:08:42 +0200:

> During the last months, Boris Brezillon shared his work to support
> serial flashes within Linux. First, he delivered (and merged) a new
> layer called spi-mem. He also initiated in Linux MTD subsystem the move
> of all 'raw' NAND related code to a raw/ subdirectory, adding at the
> same time a NAND core that would be shared with all NAND devices. Then,
> he contributed a generic SPI-NAND driver, making use of this NAND core,
> as well as some vendor code to drive a few chips.
> 
> On top of this work, I made some cleanups in the MTD layer and added an
> 'mtd' U-Boot command to handle all sort of MTD devices. This should
> become the default command instead of having one per flash flavor
> ('sf', 'nand', 'spi-nand' ?).
> 
> The series has been tested on an Ocelot board PCB123 (VSC7514),
> featuring a Macronix SPI NAND chip.
> 
> TL;DR: the series contains (stripped version since 23 patches have
> already been taken):
> - Various fixes
> - Support for spi-nand devices in mtdparts.
> - Generics mtdparts/mtdids parsers.
> - A new 'mtd' command.
> - A note to set mtdparts command legacy.
> 
> To test your SPI-NAND device with U-Boot, you can test someting like:
> 
> > setenv mtdparts 'spi-nand0:1m(foo),-(bar)'
> > setenv mtdids 'spi-nand0=spi0.0' # spi0.0 is Linux MTD name for this device
> > ubi part bar         # create a static UBI volume in the bar partition
> > mtd list             # show the current MTD devices/partitions  
> 
> Thanks,
> Miquèl
> 
> Changes since v7:
> -----------------
> * Added Stefan R-b tags.
> * Used tolower() as suggested by Stefan in lib/strto.c.
> * Added a mention saying that we continue to abuse the kB suffix in
>   lib/strto.c by not making a difference between kB and kiB which both
>   mean "* 1024" for us. This has been added in the commit log.
> * Fixed various bugs in the mtd command and in the parsers, they should
>   be pretty stable now (tested with two MTD devices probed and several
>   different partition configurations).
> * mtdids is not deprecated at all as opposed at what I wrote in
>   v6. U-Boot still uses its own MTD names (being <type><idx> like nor0
>   or spi-nand1) and mtdids is still needed to do the glue.
> * Removed a useless patch removing a Kconfig entry I added myself since
>   during a rebase someone else also added this symbol.
> 
> Changes since v6:
> -----------------
> * Squashed Boris' fixes about build issues in Travis.
> * Merged Stefan Roese's contributions.
> * cmd: mtdparts:
>   * added fallthrough comments in switch blocks deriving sizes.
>   * balanced debug messages to compare freed and allocated partitions.
>   * move mtdparts_init() declaration in mtd/partitions.h to be used in
>     mtd command as well.
>   * introduced a "compatibility" function to return what the MTD device
>     name could be thanks to the mtdids environment variable (which is
>     useless with the new partitioning logic).
> * mtd: mtdpart:
>   * reworked the way partitions are created/handled.
> * cmd: mtd:
>   * implement a partitioning logic that takes the best out of the MTD
>     layer without re-inventing the wheel. Partitions are all freed
>     correctly when the value of mtdparts changes.
>   * balance get_mtd_device() by put_mtd_device() calls.
>   * prevent memory leak by reorganizing the code a bit in do_mtd.
>   * do not reconstruct partition list when a partition is already in use
>     (complain about that instead).
>   * add support for the legacy mtdids (not needed anymore if mtdparts
>     directly uses the MTD device names as in Linux.
> * cmd: ubi:
>   * clean and simplify the partition handling a bit to make use the best
>     use of the MTD layer as well and keep the code simple.
> 
> Changes since v5:
> -----------------
> * Included Boris fixup about the build issues.
> * Added Rb/Ab tags from Jagan on patchs 20/21.
> 
> Changes since v4:
> -----------------
> * Added Jagan's Acked-by tags to every patch related to the
>   SPI-mem/SPI-NAND addition.
> * Rebased on top of master.
> 
> Changes since v3:
> -----------------
> * Fixed the debug messages in spi-mem to print either Rx or Tx data.
> * Fixed a Kconfig error that prevented to build mtdparts with plain
>   defconfig.
> * Fixed a compilation error due to the above error that prevented one
>   file to be compiled.
> * Adapted the mtd command to probe MTD partitions also.
> * Declared mtd_probe_devices() in a header so mtdparts or UBI could
>   use it too (to probe all devices and MTD partitions in a clean way).
> * As I worked on mtdparts, I found annoying and completely useless the
>   fact that we need to prefix the environment variable with
>   "mtdparts=". Canceled this obligation.
> * Added one patch to allow spi-nand devices to be recognized by mtdparts
>   (this is purely useless but needed to be done in order to use this
>   command).
> * Removed useless definitions of MTD device types in UBI code.
> * Wrote a generic mtdparts environment variable parser, used by the mtd
>   command.
> * Used the mtd_probe_devices() function from get_mtd_info() in
>   cmd/mtdparts.c to be sure the desired partition really does not exist
>   (otherwise it will be probed and then found).
> 
> Changes since v2:
> -----------------
> * Rebased on u-boot master branch.
> * Removed extra-parenthesis in
>   "mtd: Fallback to ->_read/write() when ->_read/write_oob() is missing"
> * s/fiels/files/ in "mtd: move NAND fiels into a raw/ subdirectory"
> * Do not describe generic SPI device properties in SPI NAND bindings.
> * Changes in the mtd command:
>   * Printing more information in 'mtd list' (device type, device
>     characteristics)
>   * Switch to do_div() instead of '(u32)value64b % value32b' which only
>     worked because value32b was a power of 2.
>   * Removed erase.chip option.
>   * By default, erase/read/write happen on the full MTD device while a
>     dump will only work on a single page.
> 
> Changes since v1:
> -----------------
> * Fixed the nand_memorg structure of the MX35LF2GE4AB chip.
> * Added Reviewed-by tags from Jagan.
> * Backported and squashed two patches fixing things in the SPI NAND core
>   received on the Linux ML.
> * Backported more changes in mtdcore.c from Linux.
> * Added a patch to add a fallback on mtd->_read/_write() in mtdcore.c
>   when mtd->_read/write_oob() is not supported.
> * Removed the DT changes, useless as the DTs are not available in
>   mainline yet.
> * Addressed Boris/Stefan comments on the 'mtd' command.
> * Added support for multi-pages OOB read/write.
> 
> 
> Miquel Raynal (12):
>   lib: strto: parse all lowercase metric prefixes in ustrtoul[l]
>   lib: strto: fix metric suffix parsing in strtoul[l]
>   cmd: mtdparts: accept spi-nand devices
>   cmd: mtdparts: remove mandatory 'mtdparts=' prefix
>   mtd: uclass: add probe function
>   mtd: uclass: add a generic 'mtdparts' parser
>   mtd: uclass: search for an equivalent MTD name with the mtdids
>   mtd: mtdpart: implement proper partition handling
>   cmd: mtd: add 'mtd' command
>   cmd: mtdparts: try to probe the MTD devices as a fallback
>   cmd: ubi: clean the partition handling
>   cmd: mtdparts: describe as legacy
> 
>  cmd/Kconfig                    |  18 +-
>  cmd/Makefile                   |   1 +
>  cmd/mtd.c                      | 521 ++++++++++++++++++++++++++
>  cmd/mtdparts.c                 |  46 ++-
>  cmd/ubi.c                      | 100 ++---
>  drivers/mtd/Makefile           |   2 +-
>  drivers/mtd/mtd-uclass.c       |  16 +
>  drivers/mtd/mtdcore.c          |   2 +
>  drivers/mtd/mtdpart.c          | 660 +++++++++++++++++++++------------
>  include/jffs2/load_kernel.h    |   7 +-
>  include/linux/mtd/mtd.h        |  31 ++
>  include/linux/mtd/partitions.h |   5 +-
>  include/mtd.h                  |   3 +
>  lib/strto.c                    |  36 +-
>  14 files changed, 1094 insertions(+), 354 deletions(-)
>  create mode 100644 cmd/mtd.c
> 



-- 
Miquel Raynal, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


More information about the U-Boot mailing list