common: movi: support environment partition
authorChanho Park <chanho61.park@samsung.com>
Tue, 28 Jul 2015 05:37:07 +0000 (14:37 +0900)
committerChanho Park <chanho61.park@samsung.com>
Tue, 28 Jul 2015 08:49:33 +0000 (17:49 +0900)
This patch supports to read and write the environment partition of movi
command. The u-boot environment variables are stored in the partition
and u-boot load the values from the partition

Signed-off-by: Chanho Park <chanho61.park@samsung.com>
common/cmd_movi.c

index 225dfcc5ac5ca2f417edc45d6346f4569fbd311c..552074548c8ae05f674e9c4773822b9e6a71a4aa 100644 (file)
@@ -88,6 +88,11 @@ int do_movi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
                        goto usage;
                attribute = 0x3;
                break;
+       case 'e':
+               if (argc != (6 - location))
+                       goto usage;
+               attribute = 0x4;
+               break;
        case 'k':
                if (argc != 5)
                        goto usage;
@@ -193,6 +198,25 @@ int do_movi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
                return 1;
        }
 
+       /* Environment */
+       if (attribute == 0x4) {
+               for (i = 0, image = raw_area_control.image; i < 15; i++) {
+                       if (image[i].attribute == attribute)
+                               break;
+               }
+               start_blk = image[i].start_blk;
+               blkcnt = image[i].used_blk;
+               printf("%s %d Environment.. Start %ld, Count %ld ",
+                               rw ? "writing" : "reading",
+                               dev_num, start_blk, blkcnt);
+               sprintf(run_cmd, "mmc %s %d 0x%lx 0x%lx 0x%lx",
+                       rw ? "write" : "read", dev_num,
+                       addr, start_blk, blkcnt);
+               run_command(run_cmd, dev_num);
+               printf("completed\n");
+               return 1;
+       }
+
        /* kernel r/w */
        if (attribute == 0x5) {
                for (i=0, image = raw_area_control.image; i<15; i++) {