[U-Boot] [PATCH v10 0/7] SPI-NAND support (third batch)

Jagan Teki jagan at amarulasolutions.com
Fri Sep 28 06:48:49 UTC 2018


On Thu, Sep 27, 2018 at 3:04 PM Miquel Raynal <miquel.raynal at bootlin.com> wrote:
>
> 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 ~30 patches have
> already been taken):
> - 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
>
>
> NB1: If UBI refuses to attach, verify the partition is epty with
>      # mtd erase bar
>
> NB2: If your U-Boot crashes and you are using a non SPI-NAND device,
>      don't forget to probe your device *first* (sf probe, ...).
>
>
> Changes since v9:
> -----------------
> * mtd_search_alternate_name() is moved in mtd_uboot.c (generic code,
>   everybody wants to use mtdids).
> * mtd_parse_partitions() is still in mtdparts.c because it depends on
>   partitions support, but the header file declaring it
>   (include/linux/mtd/partitions.h) also has a dummy function if
>   #if IS_ENABLED(CONFIG_MTD_PARTITIONS) is false.
> * Typo corrected in mtd_parse_partitions prototype
>   (s/_nb_parts/_nparts/).
> * Added Boris' R-b tags.
>
> Changes since v8 (called v7 by mistake):
> ----------------------------------------
> * Moved most of the generic logic to the core (mtd_uboot.c) so that it
>   can be reused by other parts of U-Boot without depending on anything
>   else than the MTD core itself.
> * Removed the "#ifdef CONFIG_MTD" around mtd_probe_devices() calls now
>   that the code is in the core.
> * Created an helper for partitions deletion (as there is one to
>   parse/create partition objects).
> * Drop "cmd: mtdparts: try to probe the MTD devices as a fallback" to
>   actually deprecate the command.
> * Enhanced a bit the text in Kconfig about deprecating mtdparts.
> * Fixed checkpatch.pl warnings in the mtdparts driver.
>
> cmd/mtd.c:
> * The logic in the mtd_is_aligned_with_*() functions was wrong, inversed
>   it so the result is what the reader expects (the logic in the end was
>   valid, though).
> * Discriminate two path: for NAND-like devices (pages, OOB, raw mode,
>   bad blocks) and the others.
> * Add the "bad" feature to display all bad blocks (if any).
> * Fix some typos/display strings.
> * Moved the refcounting put_mtd_device() below in the code as suggested
>   by Boris.
> * Avoid writing empty pages by default (add an option to force the
>   writing).
> * Always skip bad blocks.
> * Lightened the code by creating helpers.
>
> 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 (7):
>   mtd: uclass: add probe function
>   mtd: mtdpart: add a generic mtdparts-like parser
>   mtd: uboot: search for an equivalent MTD name with the mtdids
>   mtd: mtdpart: implement proper partition handling
>   cmd: mtd: add 'mtd' command
>   cmd: ubi: clean the partition handling
>   cmd: mtdparts: describe as legacy

I didn't find this mtdparts fallback change[1] in v10? does this
fallback issue fixed differently.

[1] https://github.com/openedev/u-boot-amarula/commit/9edbc2be512c9bd572884c53b5f54b583e897e9b


More information about the U-Boot mailing list