2 * (C) Copyright 2006-2007 OpenMoko, Inc.
3 * Author: Harald Welte <laforge@openmoko.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <environment.h>
26 #include <asm/errno.h>
28 #if defined(CFG_ENV_OFFSET_OOB)
30 int do_dynenv(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *argv
[])
32 struct mtd_info
*mtd
= &nand_info
[0];
38 buf
= malloc(mtd
->oobsize
);
42 if (!strcmp(cmd
, "get")) {
43 ret
= mtd
->read_oob(mtd
, 8, size
, (size_t *) &size
, (u_char
*) buf
);
45 if (buf
[0] == 'E' && buf
[1] == 'N' &&
46 buf
[2] == 'V' && buf
[3] == '0')
47 printf("0x%08x\n", *((u_int32_t
*) &buf
[4]));
49 printf("No dynamic environment marker in OOB block 0\n");
51 } else if (!strcmp(cmd
, "set")) {
60 addr
= simple_strtoul(argv
[2], NULL
, 16);
61 memcpy(buf
+4, &addr
, 4);
63 printf("%02x %02x %02x %02x - %02x %02x %02x %02x\n",
64 buf
[0], buf
[1], buf
[2], buf
[3],
65 buf
[4], buf
[5], buf
[6], buf
[7]);
67 ret
= mtd
->write_oob(mtd
, 8, size
, (size_t *) &size
, (u_char
*) buf
);
76 printf("Usage:\n%s\n", cmdtp
->usage
);
80 U_BOOT_CMD(dynenv
, 3, 1, do_dynenv
,
81 "dynenv - dynamically placed (NAND) environment\n",
82 "dynenv set off - set enviromnent offset\n"
83 "dynenv get - get environment offset\n");
85 #endif /* CFG_ENV_OFFSET_OOB */