summaryrefslogtreecommitdiff
path: root/tools/env/fw_env.c
Commit message (Collapse)AuthorAgeLines
* tools/env: Fix environment size and CRC on 64-bit hostsDominic Sacré2014-11-07-1/+1
| | | | | | | | | | | On architectures where 'long' is 64 bit, the u-boot environment as seen by the fw_env tools was missing 4 bytes. This patch fixes getenvsize(), and thus also ensures that the environment's CRC32 checksum is calculated correctly. Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de> Cc: Wolfgang Denk <wd@denx.de> Cc: Tom Rini <trini@ti.com>
* Merge branch 'u-boot/master'Albert ARIBAUD2014-05-09-2/+127
|\ | | | | | | | | | | | | Conflicts: drivers/net/Makefile (trivial merge)
| * env: Implement support for AES encryption into fw_* toolsMarek Vasut2014-03-21-2/+127
| | | | | | | | | | | | | | | | | | | | | | | | Implement support for encrypting/decrypting the environment block into the tools/env/fw_* tools. The cipher used is AES 128 CBC and the implementation depends solely on components internal to U-Boot. To allow building against the internal AES library, the library did need minor adjustments to not include U-Boot's headers which are not wanted to be included and define missing types. Signed-off-by: Marek Vasut <marex@denx.de>
* | fw_env.c: Switch get_config to use '%ms' in sscanfTom Rini2014-04-17-5/+8
|/ | | | | | | | | | We currently limit ourself to 16 characters for the device name to read the environment from. This is insufficient for /dev/mmcblk0boot1 to work for example. Switch to '%ms' which gives us a dynamically allocated buffer instead. We're short lived enough to not bother free()ing the buffer. Signed-off-by: Tom Rini <trini@ti.com>
* fw_env: correct writes to devices with small erase blocksDustin Byford2014-03-12-2/+2
| | | | | | | | | | | | | | | | | Some NOR flash devices have a small erase block size. For example, the Micron N25Q512 can erase in 4K blocks. These devices expose a bug in fw_env.c where flash_write_buf() incorrectly calculates bytes written and attempts to write past the environment sectors. Luckily, a range check prevents any real damage, but this does cause fw_setenv to fail with an error. This change corrects the write length calculation. The bug was introduced with commit 56086921 from 2008 and only affects configurations where the erase block size is smaller than the total environment data size. Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
* fw_env: calculate default number of env sectorsDustin Byford2014-03-12-6/+8
| | | | | | | | | | | | | | | The assumed number of environment sectors (always 1) leads to an incorrect top_of_range calculation in fw.env.c when a flash device has an erase block size smaller than the environment data size (number of environment sectors > 1). This change updates the default number of environment sectors to at least cover the size of the environment. Also corrected a false statement about the number of sectors column in fw_env.config. Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
* fw_env: fix writing environment for mtd devicesOliver Metz2013-09-06-28/+42
| | | | | Signed-off-by: Oliver Metz <oliver@freetz.org> Tested-by: Luka Perkov <luka@openwrt.org>
* fw_env: add redundant env support for MTD_ABSENTOliver Metz2013-09-06-0/+3
| | | | | Signed-off-by: Oliver Metz <oliver@freetz.org> Tested-by: Luka Perkov <luka@openwrt.org>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-24-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* env: Add redundant env support to UBI envJoe Hershberger2013-04-11-0/+3
| | | | | | Allow the user to specify two UBI volumes to use for the environment Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Add support for UBI environmentJoe Hershberger2013-04-11-1/+2
| | | | | | | | | UBI is a better place for the environment on NAND devices because it handles wear-leveling and bad blocks. Gluebi is needed in Linux to access the env as an MTD partition. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Allow accessing non-mtd devicesLubomir Rintel2013-03-11-10/+24
| | | | | | | In certain cases, memory device is present as flat file or block device (via mmc or mtdblock layer). Do not attempt MTD operations against it. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
* fw_env: fix type of lenMike Frysinger2012-12-19-1/+2
| | | | | | | | | | | This variable is assigned by a size_t, and is printed that way, but is incorrectly declared as an int. Which means we get warnings: fw_env.c: In function 'fw_setenv': fw_env.c:409:5: warning: format '%zu' expects argument of type 'size_t', but argument 3 has type 'int' [-Wformat] Signed-off-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Handle write-once ethaddr and serial# genericallyJoe Hershberger2012-12-13-17/+0
| | | | | | | Use the variable access flags to implement the protection for ethaddr and serial# instead of hard-coding them. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Add support for access control to .flagsJoe Hershberger2012-12-13-4/+70
| | | | | | Add support for read-only, write-once, and change-default. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* tools/env: Add environment variable flags supportJoe Hershberger2012-12-13-0/+9
| | | | | | | | | | | | | | Currently just validates variable types as decimal, hexidecimal, boolean, ip address, and mac address. Call env_acl_validate_setenv_params() from setenv() in fw_env.c. If the entry is not found in the env .flags, then look in the static one. This allows the env to override the static definitions, but prevents the need to have every definition in the environment distracting you. Need to build in _ctype for isdigit for Linux. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env: cosmetic: Consilidate the default env definitionJoe Hershberger2012-10-19-96/+2
| | | | | | | There used to be a huge structure duplicated 3 times in the source. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Tom Rini <trini@ti.com>
* tools/env: Improve debug printsJoe Hershberger2012-10-16-5/+22
| | | | | | | Provide more information when using redundant environments Consistently print debug info to stderr Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* tools/env: Fix variable delete operationJoe Hershberger2012-10-16-2/+3
| | | | | | | Fix crash introduced by a073d63a36524453a817ab029fad5b188f46127e when attempting to delete a variable. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* tools/env: Fix build failure from missing header includeJoe Hershberger2012-10-15-0/+1
| | | | | | | | | | This was introduced in: 8679d0ffdcc0beafea8e6942c0c67cf859afa18e - COMMON: Use __stringify() instead of MK_STR() The header is now needed since common.h is not included in this tool. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* env: Check for NULL pointer in envmatch()Joe Hershberger2012-10-15-0/+2
| | | | | | | If the pointer passed into envmatch() is NULL, return -1 instead of crashing. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* tools/env: Don't call env_init() in fw_getenv()Joe Hershberger2012-10-15-3/+0
| | | | | | We will only call fw_getenv when the env has already been initialized. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* tools/env: Remove unneeded complexityJoe Hershberger2012-10-15-20/+13
| | | | | | | | | The length included the name length, and then it was subtracted back out on each use. Now we don't include it in the first place. Also realloc as we process arguments and eliminate memset. Use memcpy instead of manually copying each byte. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* tools/env: Use a board-specific default envJoe Hershberger2012-10-15-15/+13
| | | | | | | | | | | | | | | | | | | Originally added in aa701b94336b358798d676eef12a7b90bdac23f5 Before this patch, there was a hard-coded env that was used as default if the env in flash is detected as invalid. Now this tool (compiled for a given board) will share the default env with the u-boot for the board. Fix include of config.h Need to define "TEXT_BASE" when building the fw_env tool so that the default env will be correct for environments which use it. Define __ASSEMBLY__ when calling #include <config.h> so that we only get #defines (all we're interested in). Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
* COMMON: Use __stringify() instead of MK_STR()Marek Vasut2012-10-15-20/+17
| | | | | | | | | Kill multiple occurances and redeclaration of MK_STR in favor of __stringify(). Signed-off-by: Marek Vasut <marex@denx.de> Cc: Wolfgang Denk <wd@denx.de> Signed-off-by: Tom Rini <trini@ti.com>
* fw_env: Add env vars describing U-Boot target boardBenoît Thébaudeau2012-09-18-0/+11
| | | | | | | | Commit 5e724ca did the same thing for env_common and env_embedded, but forgot fw_env. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com> Cc: Wolfgang Denk <wd@denx.de>
* tools/env: allow overwrite of ethaddr on defaultGrant Erickson2012-01-05-2/+11
| | | | | | | | | | | | | This patch allows the U-Boot user space companion utility, fw_setenv, to overwrite the 'ethaddr' key/value pair if the current value is set to a per-board-configured default. This change allows 'fw_setenv' to match the behavior of 'setenv' / 'env set' on the U-Boot command line. Signed-off-by: Grant Erickson <marathon96@gmail.com> Fixed excessive white space. Signed-off-by: Wolfgang Denk <wd@denx.de>
* common: cosmetic: CONFIG_BOOTFILE checkpatch complianceJoe Hershberger2011-10-22-1/+1
| | | | | | | | | Remove MK_STR from places that consume CONFIG_BOOTFILE to force all definitions to be string literals. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Cc: Joe Hershberger <joe.hershberger@gmail.com> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* common: cosmetic: CONFIG_ROOTPATH checkpatch complianceJoe Hershberger2011-10-22-1/+1
| | | | | | | | | Remove MK_STR from places that consume CONFIG_ROOTPATH to force all definitions to be string literals. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Cc: Joe Hershberger <joe.hershberger@gmail.com> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* fix compile warning for env toolsLuka Perkov2011-10-22-2/+2
| | | | | | | | | | | | Patch fixes this issue: fw_env.c: In function ‘fw_setenv’: fw_env.c:492:5: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t’ [-Wformat] fw_env.c: In function ‘flash_write_buf’: fw_env.c:806:6: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t’ [-Wformat] Signed-off-by: Luka Perkov <lists@lukaperkov.net> Acked-by: Mike Frysinger <vapier@gentoo.org>
* tools/env: fix redundant env flag comparisonJon Povey2011-04-21-7/+6
| | | | | | | | | | | | | | | | | | This fixes two bugs with comparison of redundant environment flags on read. flag0 and flag1 in fw_env_open() were declared signed instead of unsigned char breaking BOOLEAN mode "== 0xFF" tests and in INCREMENTAL mode the wrong environment would be chosen where the flag values are 127 and 128 (either way round). With both flags over 128, both signs flipped and the logic worked by happy accident. Also there was a logic bug in the INCREMENTAL test (after signedness was fixed) in the case flag0=0, flag1=255, env 1 would be incorrectly chosen. Fix both of these. Signed-off-by: Jon Povey <jon.povey@racelogic.co.uk>
* Add support for dataflash to U-boot environment settings tool.Remy Bohmer2011-04-12-25/+47
| | | | | | | | | | * The sector size for SPI-dataflash (like AT45 flashes) are not always a power-of-2. So, the sector calculations are rewritten such that it works for either power-of-2 as any size sectors. * Make the flash sector size optional in case it is the same value as the environment size. Signed-off-by: Remy Bohmer <linux@bohmer.net>
* tools/env/fw_printenv: Make redundant env work on locked flashes alsoDetlev Zundel2010-08-09-1/+6
| | | | | | | The invalidation of the old environment instance did not work for flashes supporting hardware locking. Now we unlock/lock around this update also. Signed-off-by: Detlev Zundel <dzu@denx.de>
* Tools: set multiple variable with fw_setenv utilityStefano Babic2010-06-29-45/+224
| | | | | | | | | | Add a sort of batch mode to fw_setenv, allowing to set multiple variables in one shot, without updating the flash after each set as now. It is added the possibility to pass a config file with a list of pairs <variable, value> to be set, separated by a TAB character. Signed-off-by: Stefano Babic <sbabic@denx.de>
* rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD2008-10-18-2/+2
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Adds two more ethernet interface to 83xxrichardretanubun2008-10-18-0/+6
| | | | | | | | | Added as a convenience for other platforms that uses MPC8360 (has 8 UCC). Six eth interface is chosen because the platform I am using combines UCC1&2 and UCC3&4 as 1000 Eth and the other four UCCs as 10/100 Eth. Signed-off-by: Richard Retanubun <RichardRetanubun@RugggedCom.com> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
* rename CFG_ENV macros to CONFIG_ENVJean-Christophe PLAGNIOL-VILLARD2008-09-10-10/+10
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* fw_env: add NAND supportGuennadi Liakhovetski2008-09-09-263/+600
| | | | | | | | Add support for environment in NAND with automatic NOR / NAND recognition, including unaligned environment, bad-block skipping, redundant environment copy. Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
* fw_env.c: fix build problems with MTD_VERSION=oldWolfgang Denk2008-09-02-1/+2
| | | | | | (as needed to support old 2.4 Linux kernel based releases) Signed-off-by: Wolfgang Denk <wd@denx.de>
* Propagate Error Status to the Shell on fw_printenv ErrorsGrant Erickson2008-05-09-8/+13
| | | | | | | | | | | | Changed implementation such that fw_printenv returns failure status when one or more specified variables do not exist or when incorrect command syntax is used. This aids scripting fw_printenv such that the script can key of the return status rather than relying on standard error "scraping". Signed-off-by: Grant Erickson <gerickson@nuovations.com> Signed-off-by: Wolfgang Denk <wd@denx.de>
* Fix compile problem with new env code.Wolfgang Denk2008-01-08-0/+1
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* tools: fix fw_printenv tool to compile againMarkus Klotzbücher2008-01-08-26/+30
| | | | | | | | | | This patch updates the fw_printenv/fw_setenv userspace tool to include the correct MTD header in order to compile against current kernel headers. Backward compatibility is preserved by introducing an option MTD_VERSION which can be set to "old" for compilation using the old MTD headers. Along with this a number of warnings are fixed. Signed-off-by: Markus Klotzbuecher <mk@denx.de>
* Fix array overflow with fw_setenv on uninitialised environmentWolfgang Denk2006-03-12-4/+2
| | | | Patch by Murray Jensen, 15 Jul 2005
* Fix error handling in tools/env/fw_env.cWolfgang Denk2005-09-25-1/+1
| | | | Patch by Ara Avanesyan, 01 Feb 2005
* * Code cleanup, mostly for GCC-3.3.xwdenk2004-12-31-0/+3
| | | | | | | | | | | | * Cleanup confusing use of CONFIG_ETH*ADDR - ust his only to pre-define a MAC address; use CONFIG_HAS_ETH* to enable support for additional ethernet addresses. * Cleanup drivers/i82365.c - avoid duplication of code * Fix bogus "cannot span across banks" flash error message * Add support for CompactFlash for the CPC45 Board.
* Patch by Murray Jensen, 20 Jun 2003:wdenk2003-06-21-1/+1
| | | | | - hymod update - cleanup (especially for gcc-3.x compilers)
* * Patch by Lutz Dennig, 10 Apr 2003:wdenk2003-04-12-244/+240
| | | | | | | | | | | | | Update for R360MPI board * Add new meaning to "autostart" environment variable: If set to "no", a standalone image passed to the "bootm" command will be copied to the load address (and eventually uncompressed), but NOT be started. This can be used to load and uncompress arbitrary data. * Set max brightness for MN11236 displays on TRAB board
* * Add support for 16 MB flash configuration of TRAB boardwdenk2003-02-28-41/+41
| | | | | | | | | | | | | | | | | * Patch by Erwin Rol, 27 Feb 2003: Add support for RTEMS * Add image information to README * Fix dual PCMCIA slot support (when running with just one slot populated) * Add VFD type detection to trab board * extend drivers/cs8900.c driver to synchronize ethaddr environment variable with value in the EEPROM * Start adding MIPS support files
* Add "pcidelay" environment variable (in ms, enabled via CONFIG_PCI_BOOTDELAY).stroese2003-02-14-41/+44
|
* * Restrict baudrate settings on LWMON to higher speedswdenk2003-01-11-116/+222
| | | | | | | | | | | | when watchdog is on * Update baudrate in bd_info when it gets changed * Add watchdog trigger points while waiting for serial port (so far only 8xx -- needed on LWMON with 100ms watchdog) * Improve command line tool to access the U-Boot's environment (figuration of the utility, using a config file)