Commit 794449551d342d9ec3bd619e7ab887f7faec7f2a

Authored by Suriyan Ramasami
Committed by Tom Rini
1 parent 9fdee7d730

sandbox: Use md5sum and fatwrite to enable testing of fs commands

Enable md5sum to obtain 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>

Showing 2 changed files with 12 additions and 2 deletions Side-by-side Diff

... ... @@ -11,6 +11,7 @@
11 11 #include <common.h>
12 12 #include <command.h>
13 13 #include <u-boot/md5.h>
  14 +#include <asm/io.h>
14 15  
15 16 /*
16 17 * Store the resulting sum to an address or variable
... ... @@ -79,6 +80,7 @@
79 80 int verify = 0;
80 81 int ac;
81 82 char * const *av;
  83 + void *buf;
82 84  
83 85 if (argc < 3)
84 86 return CMD_RET_USAGE;
... ... @@ -96,7 +98,9 @@
96 98 addr = simple_strtoul(*av++, NULL, 16);
97 99 len = simple_strtoul(*av++, NULL, 16);
98 100  
99   - md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5);
  101 + buf = map_sysmem(addr, len);
  102 + md5_wd(buf, len, output, CHUNKSZ_MD5);
  103 + unmap_sysmem(buf);
100 104  
101 105 if (!verify) {
102 106 printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
... ... @@ -135,6 +139,7 @@
135 139 unsigned long addr, len;
136 140 unsigned int i;
137 141 u8 output[16];
  142 + void *buf;
138 143  
139 144 if (argc < 3)
140 145 return CMD_RET_USAGE;
... ... @@ -142,7 +147,10 @@
142 147 addr = simple_strtoul(argv[1], NULL, 16);
143 148 len = simple_strtoul(argv[2], NULL, 16);
144 149  
145   - md5_wd((unsigned char *) addr, len, output, CHUNKSZ_MD5);
  150 + buf = map_sysmem(addr, len);
  151 + md5_wd(buf, len, output, CHUNKSZ_MD5);
  152 + unmap_sysmem(buf);
  153 +
146 154 printf("md5 for %08lx ... %08lx ==> ", addr, addr + len - 1);
147 155 for (i = 0; i < 16; i++)
148 156 printf("%02x", output[i]);
include/configs/sandbox.h
... ... @@ -48,6 +48,7 @@
48 48 #define CONFIG_ANDROID_BOOT_IMAGE
49 49  
50 50 #define CONFIG_FS_FAT
  51 +#define CONFIG_FAT_WRITE
51 52 #define CONFIG_FS_EXT4
52 53 #define CONFIG_EXT4_WRITE
53 54 #define CONFIG_CMD_FAT
... ... @@ -57,6 +58,7 @@
57 58 #define CONFIG_DOS_PARTITION
58 59 #define CONFIG_HOST_MAX_DEVICES 4
59 60 #define CONFIG_CMD_FS_GENERIC
  61 +#define CONFIG_CMD_MD5SUM
60 62  
61 63 #define CONFIG_SYS_VSNPRINTF
62 64