[U-Boot] [PATCH] cmd_sf: add handler for +len arg for all commands

thomas.langer at lantiq.com thomas.langer at lantiq.com
Sun Oct 5 19:43:25 CEST 2014


Hello Maxime,

can you explain the usecase?
I think, only the erase is executed per sector, all other commands are working fine with a byte oriented length.

Best regards,
Thomas

---
Sent from my phone.

Maxime Hadjinlian <maxime.hadjinlian at gmail.com> hat geschrieben:


This patch adds [+]len handler for the all the commands that will
automatically round up the requested erase length to the flash's
sector_size.
It was previously only available for the erase command.

Signed-off-by: Maxime Hadjinlian <maxime.hadjinlian at gmail.com>
---

 common/cmd_sf.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index c60e8d1..d5af3fe 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -245,8 +245,8 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
        offset = simple_strtoul(argv[2], &endp, 16);
        if (*argv[2] == 0 || *endp != 0)
                return -1;
-       len = simple_strtoul(argv[3], &endp, 16);
-       if (*argv[3] == 0 || *endp != 0)
+       len = sf_parse_len_arg(argv[3], &len);
+       if (ret != 1)
                return -1;

        /* Consistency checking */
@@ -529,15 +529,15 @@ usage:
 U_BOOT_CMD(
        sf,     5,      1,      do_spi_flash,
        "SPI flash sub-system",
+       "Note: `+len' round up `len' to block size\n"
        "probe [[bus:]cs] [hz] [mode]   - init flash device on given SPI bus\n"
        "                                 and chip select\n"
-       "sf read addr offset len        - read `len' bytes starting at\n"
+       "sf read addr offset [+]len     - read `len' bytes starting at\n"
        "                                 `offset' to memory at `addr'\n"
-       "sf write addr offset len       - write `len' bytes from memory\n"
+       "sf write addr offset [+]len    - write `len' bytes from memory\n"
        "                                 at `addr' to flash at `offset'\n"
        "sf erase offset [+]len         - erase `len' bytes from `offset'\n"
-       "                                 `+len' round up `len' to block size\n"
-       "sf update addr offset len      - erase and write `len' bytes from memory\n"
+       "sf update addr offset [+]len   - erase and write `len' bytes from memory\n"
        "                                 at `addr' to flash at `offset'"
        SF_TEST_HELP
 );
--
2.1.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list