diff options
Diffstat (limited to 'tools/env')
-rw-r--r-- | tools/env/README | 4 | ||||
-rw-r--r-- | tools/env/fw_env.c | 34 | ||||
-rw-r--r-- | tools/env/fw_env.config | 5 |
3 files changed, 30 insertions, 13 deletions
diff --git a/tools/env/README b/tools/env/README index df020e4afd..1020b57b05 100644 --- a/tools/env/README +++ b/tools/env/README @@ -8,7 +8,7 @@ In order to cross-compile fw_printenv, run in the root directory of the U-Boot distribution. For example, make HOSTCC=arm-linux-gcc env -For the run-time utiltity configuration uncomment the line +For the run-time utility configuration uncomment the line #define CONFIG_FILE "/etc/fw_env.config" in fw_env.h. @@ -34,7 +34,7 @@ following lines are relevant: #define DEVICE2_ESIZE 0x4000 #define DEVICE2_ENVSECTORS 2 -Un-define HAVE_REDUND, if you want to use the utlities on a system +Un-define HAVE_REDUND, if you want to use the utilities on a system that does not have support for redundant environment enabled. If HAVE_REDUND is undefined, DEVICE2_NAME is ignored, as is ENV2_SIZE and DEVICE2_ESIZE. diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 37b60b80a7..bf30234190 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -836,9 +836,9 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count, erase.start = blockstart; ioctl (fd, MEMUNLOCK, &erase); - - /* Dataflash does not need an explicit erase cycle */ - if (mtd_type != MTD_DATAFLASH) + /* These do not need an explicit erase cycle */ + if (mtd_type != MTD_ABSENT && + mtd_type != MTD_DATAFLASH) if (ioctl (fd, MEMERASE, &erase) != 0) { fprintf (stderr, "MTD erase error on %s: %s\n", DEVNAME (dev), @@ -949,19 +949,33 @@ static int flash_write (int fd_current, int fd_target, int dev_target) static int flash_read (int fd) { struct mtd_info_user mtdinfo; + struct stat st; int rc; - rc = ioctl (fd, MEMGETINFO, &mtdinfo); + rc = fstat(fd, &st); if (rc < 0) { - perror ("Cannot get MTD information"); + fprintf(stderr, "Cannot stat the file %s\n", + DEVNAME(dev_current)); return -1; } - if (mtdinfo.type != MTD_NORFLASH && - mtdinfo.type != MTD_NANDFLASH && - mtdinfo.type != MTD_DATAFLASH) { - fprintf (stderr, "Unsupported flash type %u\n", mtdinfo.type); - return -1; + if (S_ISCHR(st.st_mode)) { + rc = ioctl(fd, MEMGETINFO, &mtdinfo); + if (rc < 0) { + fprintf(stderr, "Cannot get MTD information for %s\n", + DEVNAME(dev_current)); + return -1; + } + if (mtdinfo.type != MTD_NORFLASH && + mtdinfo.type != MTD_NANDFLASH && + mtdinfo.type != MTD_DATAFLASH) { + fprintf (stderr, "Unsupported flash type %u on %s\n", + mtdinfo.type, DEVNAME(dev_current)); + return -1; + } + } else { + memset(&mtdinfo, 0, sizeof(mtdinfo)); + mtdinfo.type = MTD_ABSENT; } DEVTYPE(dev_current) = mtdinfo.type; diff --git a/tools/env/fw_env.config b/tools/env/fw_env.config index 8e21d5a5ab..90e499da1e 100644 --- a/tools/env/fw_env.config +++ b/tools/env/fw_env.config @@ -1,4 +1,4 @@ -# Configuration file for fw_(printenv/saveenv) utility. +# Configuration file for fw_(printenv/setenv) utility. # Up to two entries are valid, in this case the redundant # environment sector is assumed present. # Notice, that the "Number of sectors" is ignored on NOR and SPI-dataflash. @@ -17,3 +17,6 @@ # NAND example #/dev/mtd0 0x4000 0x4000 0x20000 2 + +# Block device example +#/dev/mmcblk0 0xc0000 0x20000 |