diff mbox

[U-Boot,v6,5/6] sandbox: Use md5sum and fatwrite to enable testing of fs commands

Message ID 1415069408-2978-6-git-send-email-suriyan.r@gmail.com
State Deferred
Delegated to: Simon Glass
Headers show

Commit Message

Suriyan Ramasami Nov. 4, 2014, 2:50 a.m. UTC
Enable md5sum to check the MD5 of the read and written files to check
their contents for validity.
Use map_sysmem() to map buffer in a sandbox environment.

Signed-off-by: Suriyan Ramasami <suriyan.r@gmail.com>

---

Changes in v6:
* Simon - Split this into a separate patch

Changes in v5: None

 common/cmd_md5sum.c       | 12 ++++++++++--
 include/configs/sandbox.h |  2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

Comments

Simon Glass Nov. 5, 2014, 1:05 a.m. UTC | #1
On 3 November 2014 18:50, Suriyan Ramasami <suriyan.r@gmail.com> wrote:
> Enable md5sum to check the MD5 of the read and written files to check
> their contents for validity.
> Use map_sysmem() to map buffer in a sandbox environment.
>
> Signed-off-by: Suriyan Ramasami <suriyan.r@gmail.com>

Acked-by: Simon Glass <sjg@chromium.org>

>
> ---
>
> Changes in v6:
> * Simon - Split this into a separate patch
>
> Changes in v5: None
>
>  common/cmd_md5sum.c       | 12 ++++++++++--
>  include/configs/sandbox.h |  2 ++
>  2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_md5sum.c b/common/cmd_md5sum.c
> index 3ac8cc4..d22ace5 100644
> --- a/common/cmd_md5sum.c
> +++ b/common/cmd_md5sum.c
> @@ -11,6 +11,7 @@
>  #include <common.h>
>  #include <command.h>
>  #include <u-boot/md5.h>
> +#include <asm/io.h>
>
>  /*
>   * Store the resulting sum to an address or variable
> @@ -79,6 +80,7 @@ int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         int verify = 0;
>         int ac;
>         char * const *av;
> +       void *buf;
>
>         if (argc < 3)
>                 return CMD_RET_USAGE;
> @@ -96,7 +98,9 @@ int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         addr = simple_strtoul(*av++, NULL, 16);
>         len = simple_strtoul(*av++, NULL, 16);
>
> -       md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5);
> +       buf = map_sysmem(addr, len);
> +       md5_wd(buf, len, output, CHUNKSZ_MD5);
> +       unmap_sysmem(buf);
>
>         if (!verify) {
>                 printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
> @@ -135,6 +139,7 @@ static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         unsigned long addr, len;
>         unsigned int i;
>         u8 output[16];
> +       void *buf;
>
>         if (argc < 3)
>                 return CMD_RET_USAGE;
> @@ -142,7 +147,10 @@ static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>         addr = simple_strtoul(argv[1], NULL, 16);
>         len = simple_strtoul(argv[2], NULL, 16);
>
> -       md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5);
> +       buf = map_sysmem(addr, len);
> +       md5_wd(buf, len, output, CHUNKSZ_MD5);
> +       unmap_sysmem(buf);
> +
>         printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
>         for (i = 0; i < 16; i++)
>                 printf("%02x", output[i]);
> diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
> index ee4b244..2b03841 100644
> --- a/include/configs/sandbox.h
> +++ b/include/configs/sandbox.h
> @@ -48,6 +48,7 @@
>  #define CONFIG_ANDROID_BOOT_IMAGE
>
>  #define CONFIG_FS_FAT
> +#define CONFIG_FAT_WRITE
>  #define CONFIG_FS_EXT4
>  #define CONFIG_EXT4_WRITE
>  #define CONFIG_CMD_FAT
> @@ -57,6 +58,7 @@
>  #define CONFIG_DOS_PARTITION
>  #define CONFIG_HOST_MAX_DEVICES 4
>  #define CONFIG_CMD_FS_GENERIC
> +#define CONFIG_CMD_MD5SUM
>
>  #define CONFIG_SYS_VSNPRINTF
>
> --
> 1.9.1
>
diff mbox

Patch

diff --git a/common/cmd_md5sum.c b/common/cmd_md5sum.c
index 3ac8cc4..d22ace5 100644
--- a/common/cmd_md5sum.c
+++ b/common/cmd_md5sum.c
@@ -11,6 +11,7 @@ 
 #include <common.h>
 #include <command.h>
 #include <u-boot/md5.h>
+#include <asm/io.h>
 
 /*
  * Store the resulting sum to an address or variable
@@ -79,6 +80,7 @@  int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	int verify = 0;
 	int ac;
 	char * const *av;
+	void *buf;
 
 	if (argc < 3)
 		return CMD_RET_USAGE;
@@ -96,7 +98,9 @@  int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	addr = simple_strtoul(*av++, NULL, 16);
 	len = simple_strtoul(*av++, NULL, 16);
 
-	md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5);
+	buf = map_sysmem(addr, len);
+	md5_wd(buf, len, output, CHUNKSZ_MD5);
+	unmap_sysmem(buf);
 
 	if (!verify) {
 		printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
@@ -135,6 +139,7 @@  static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	unsigned long addr, len;
 	unsigned int i;
 	u8 output[16];
+	void *buf;
 
 	if (argc < 3)
 		return CMD_RET_USAGE;
@@ -142,7 +147,10 @@  static int do_md5sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	addr = simple_strtoul(argv[1], NULL, 16);
 	len = simple_strtoul(argv[2], NULL, 16);
 
-	md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5);
+	buf = map_sysmem(addr, len);
+	md5_wd(buf, len, output, CHUNKSZ_MD5);
+	unmap_sysmem(buf);
+
 	printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
 	for (i = 0; i < 16; i++)
 		printf("%02x", output[i]);
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index ee4b244..2b03841 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -48,6 +48,7 @@ 
 #define CONFIG_ANDROID_BOOT_IMAGE
 
 #define CONFIG_FS_FAT
+#define CONFIG_FAT_WRITE
 #define CONFIG_FS_EXT4
 #define CONFIG_EXT4_WRITE
 #define CONFIG_CMD_FAT
@@ -57,6 +58,7 @@ 
 #define CONFIG_DOS_PARTITION
 #define CONFIG_HOST_MAX_DEVICES 4
 #define CONFIG_CMD_FS_GENERIC
+#define CONFIG_CMD_MD5SUM
 
 #define CONFIG_SYS_VSNPRINTF