Skip to content

SPI-NAND support (third batch)

Miquel Raynal u-boot 34 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v13 Latest7 patches 0 repliesNew
  2. v128 patches 0 repliesSuperseded
  3. v10 posting 5/50 of 7 patches 0 repliesSuperseded
Earlier versions · 31
VersionPostedPatchesRepliesStatus
v10 posting 4/50 of 7 patches0 repliesSuperseded
v10 posting 3/50 of 7 patches0 repliesSuperseded
v10 posting 2/50 of 7 patches0 repliesSuperseded
v10 posting 1/57 patches0 repliesSuperseded
v9 posting 2/20 of 7 patches0 repliesSuperseded
v7 posting 5/50 of 12 patches0 repliesSuperseded
v9 posting 1/27 patches0 repliesSuperseded
v7 posting 4/50 of 12 patches0 repliesSuperseded
v7 posting 3/50 of 12 patches0 repliesSuperseded
v7 posting 2/50 of 12 patches0 repliesSuperseded
v7 posting 1/512 patches0 repliesSuperseded
v6 posting 10/100 of 31 patches0 repliesSuperseded
v6 posting 9/100 of 31 patches0 repliesSuperseded
v6 posting 8/100 of 31 patches0 repliesSuperseded
v6 posting 7/1031 patches0 repliesSuperseded
v6 posting 6/100 of 27 patches0 repliesSuperseded
v6 posting 5/100 of 27 patches0 repliesSuperseded
v6 posting 4/100 of 27 patches0 repliesSuperseded
v6 posting 3/100 of 27 patches0 repliesSuperseded
v6 posting 2/100 of 27 patches0 repliesSuperseded
v6 posting 1/1027 patches0 repliesSuperseded
v5 posting 2/20 of 27 patches0 repliesSuperseded
v4 posting 4/40 of 27 patches0 repliesSuperseded
v5 posting 1/227 patches0 repliesSuperseded
v4 posting 3/40 of 27 patches0 repliesSuperseded
v4 posting 2/40 of 27 patches0 repliesSuperseded
v4 posting 1/427 patches0 repliesSuperseded
v3 posting 2/20 of 21 patches0 repliesSuperseded
v3 posting 1/221 patches0 repliesSuperseded
v221 patches0 repliesSuperseded
v1 RFC0 of 20 patches0 repliesSuperseded

Changes in v13 from the cover letter

------------------
* Dropped the patch removing a DM-helper without users that was breaking the build when included from a file that can be compiled either with and without DM support. Instead, added a forward declaration of struct udevice, then enclosed the declarations in a #if defined(CONFIG_DM) conditional with dummy helpers on the other side.
* Build test with Travis CI:
https://travis-ci.org/miquelraynal/u-boot/builds/435575048

Patches in v13 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7mtd: uclass: add probe functiondrivers/mtd/mtd-uclass.c include/mtd.h+18 -00 replies
2/7mtd: mtdpart: add a generic mtdparts-like parserdrivers/mtd/mtdpart.c include/linux/mtd/partitions.h+231 -00 replies
3/7mtd: uboot: search for an equivalent MTD name with the mtdidsdrivers/mtd/mtd_uboot.c include/linux/mtd/mtd.h+69 -10 replies
4/7mtd: mtdpart: implement proper partition handlingdrivers/mtd/mtdcore.c drivers/mtd/mtdpart.c include/linux/mtd/mtd.h +1 more+209 -2390 replies
5/7cmd: mtd: add 'mtd' commandcmd/Kconfig cmd/Makefile cmd/mtd.c +3 more+659 -46 replies
5/7cmd: mtd: add 'mtd' command+0 -00 replies
5/7cmd: mtd: add 'mtd' command+0 -01 reply
5/7cmd: mtd: add 'mtd' command+0 -00 replies
5/7cmd: mtd: add 'mtd' command+0 -06 replies
6/7cmd: ubi: clean the partition handlingcmd/Kconfig cmd/ubi.c+27 -710 replies
7/7cmd: mtdparts: describe as legacycmd/Kconfig+5 -10 replies

Reviews trailers per patch

All 11 patches have a Reviewed-by or Acked-by.

PatchJagan TekiStefan RoeseBoris Brezillon
1/7A-b R-b R-b
2/7A-b R-b R-b
3/7R-b R-b
4/7R-b R-b
5/7A-b R-b R-b
5/7A-b R-b R-b
5/7A-b R-b R-b
5/7A-b R-b R-b
5/7A-b R-b R-b
6/7R-b R-b
7/7R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v13 thread

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

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:

Quoted 4 lines

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 v12:
------------------
* Dropped the patch removing a DM-helper without users that was breaking the build when included from a file that can be compiled either with and without DM support. Instead, added a forward declaration of struct udevice, then enclosed the declarations in a #if defined(CONFIG_DM) conditional with dummy helpers on the other side.
* Build test with Travis CI:
https://travis-ci.org/miquelraynal/u-boot/builds/435575048

Changes since v11:
------------------
* Due to the number of small changes I had to do to handle the various build failures reported by Travis, I decided to send a full v12 so that all the patches can be replaced and are known to compile properly.
* Adding a patch to drop an unused helper in mtd_uboot.c that in some cases causes build issues (if compiled without DM support enabled).
* Travis CI status (build success except for one unrelated issue):
https://travis-ci.org/miquelraynal/u-boot/builds/434796123

Changes since v10:
------------------
* Only two patches sent independently with small fixes to handle build failures for some configurations (reported by Travis)

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

 cmd/Kconfig                    |  18 +-
 cmd/Makefile                   |   1 +
 cmd/mtd.c                      | 473 +++++++++++++++++++++++++
 cmd/ubi.c                      |  96 ++---
 drivers/mtd/Makefile           |   2 +-
 drivers/mtd/mtd-uclass.c       |  16 +
 drivers/mtd/mtd_uboot.c        | 224 +++++++++++-
 drivers/mtd/mtdcore.c          |   2 +
 drivers/mtd/mtdpart.c          | 623 ++++++++++++++++++++-------------
 include/linux/mtd/mtd.h        |  37 ++
 include/linux/mtd/partitions.h |  22 +-
 include/mtd.h                  |  18 +
 12 files changed, 1217 insertions(+), 315 deletions(-)
 create mode 100644 cmd/mtd.c
Signature · 1 line
2.17.1