[U-Boot] [PATCH 3/4] sunxi: nand: Add a20_nandread command to load image from NAND in SPL
Piotr Zierhoffer
pzierhoffer at antmicro.com
Thu Jul 16 13:25:14 CEST 2015
From: Piotr Zierhoffer <piotr.zierhoffer at cs.put.poznan.pl>
The usage of the command is:
a20_nandread <address> <offset> <bytes>
It allows user to copy data from NAND to memory. It employs
nand_spl_load_image from the sunxi NAND driver.
It is added only when the NAND support is enabled.
Signed-off-by: Peter Gielda <pgielda at antmicro.com>
Signed-off-by: Tomasz Gorochowik <tgorochowik at antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko at antmicro.com>
Signed-off-by: Piotr Zierhoffer <pzierhoffer at antmicro.com>
---
common/Makefile | 1 +
common/cmd_a20_nandread.c | 25 +++++++++++++++++++++++++
include/configs/sunxi-common.h | 2 ++
3 files changed, 28 insertions(+)
create mode 100644 common/cmd_a20_nandread.c
diff --git a/common/Makefile b/common/Makefile
index d6c1d48..ef31646 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -126,6 +126,7 @@ obj-$(CONFIG_ID_EEPROM) += cmd_mac.o
obj-$(CONFIG_CMD_MD5SUM) += cmd_md5sum.o
obj-$(CONFIG_CMD_MEMORY) += cmd_mem.o
obj-$(CONFIG_CMD_IO) += cmd_io.o
+obj-$(CONFIG_CMD_A20_NANDREAD) += cmd_a20_nandread.o
obj-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
obj-$(CONFIG_MII) += miiphyutil.o
obj-$(CONFIG_CMD_MII) += miiphyutil.o
diff --git a/common/cmd_a20_nandread.c b/common/cmd_a20_nandread.c
new file mode 100644
index 0000000..6469535
--- /dev/null
+++ b/common/cmd_a20_nandread.c
@@ -0,0 +1,25 @@
+#include <common.h>
+#include <command.h>
+#include <nand.h>
+
+static int do_a20_nandread(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ if (argc != 4) {
+ printf("usage: a20_nandread <destination> <source> <size>\n");
+ return 1;
+ }
+
+ uint32_t dst = simple_strtoul(argv[1], NULL, 16);
+ uint32_t src = simple_strtoul(argv[2], NULL, 16);
+ uint32_t cnt = simple_strtoul(argv[3], NULL, 16);
+ printf("Reading 0x%08X bytes from NAND @ 0x%08X to MEM @ 0x%08X...\n",
+ cnt, src, dst);
+ nand_spl_load_image(src, cnt, (void *)dst);
+ printf("\n");
+ return 0;
+}
+
+U_BOOT_CMD(a20_nandread, CONFIG_SYS_MAXARGS, 3,
+ do_a20_nandread, "a20_nandread", "[destination source size]\n" " "
+);
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 83922ab..e9cfa9a 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -148,6 +148,8 @@
#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x008000
#define CONFIG_SYS_NAND_PAGE_SIZE 0x002000 /* 8kb*/
#define CONFIG_SUNXI_ECC_STRENGTH 40
+
+#define CONFIG_CMD_A20_NANDREAD
#endif
/* mmc config */
--
2.3.6
More information about the U-Boot
mailing list