summaryrefslogtreecommitdiff
path: root/tools/env
Commit message (Collapse)AuthorAgeLines
* tools: env: include compiler.hPeter Robinson2015-12-13-0/+1
| | | | | | | With gcc 5.2 and later we get a bunch of "error: unknown type name" for 'uint8_t', 'uint32_t' and friends. Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
* Allow fw env tools to be available as libraryStefano Babic2015-11-18-1/+3
| | | | | | | | | | | Sometimes it can be useful to link the fw_ tools instead of having the fw_setenv/fw_printenv installed. Patch exports the tool as library and allowes to link it with own programs. Signed-off-by: Stefano Babic <sbabic@denx.de> CC: Tom Rini <trini@konsulko.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* tools/env: allow config filename to be passed via command line argumentMichael Heimpold2015-11-18-3/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When for example generating/manipulating SD card/eMMC images which contain U-Boot and its environment(s), it is handy to use a given configuration file instead of the compiled-in default one. And since the default configuration file is expected under /etc it's hard for an usual linux user account without special permissions to use fw_printenv/fw_setenv for this purpose. So allow to pass an optional filename via a new '-c' command line argument. Example: $ ln -s fw_printenv tools/env/fw_setenv $ cat fw_env.config test.img 0x20000 0x20000 test.img 0x40000 0x20000 $ tools/env/fw_printenv -c ./fw_env.config fdt_file fdt_file=imx28-duckbill.dtb $ tools/env/fw_setenv -c ./fw_env.config fdt_file imx28-duckbill-spi.dtb $ tools/env/fw_printenv -c ./fw_env.config fdt_file fdt_file=imx28-duckbill-spi.dtb Signed-off-by: Michael Heimpold <mhei@heimpold.de>
* tools/env/fw_env.h: Correct include orderPeter Robinson2015-06-18-1/+2
| | | | | | | | | | | | | | | When building tools-only (or env) we need to be sure that we do use <linux/kconfig.h> and do not use <generated/autoconf.h>. This will fix problems such as running 'make defconfig' or 'make sandbox_config' and then 'make tools-only'. Based on the responses below to the thread add linux/kconfig.h higher in the includes and drop the now unneeded autoconf.h lower down to ensure the default environment is included correctly http://lists.denx.de/pipermail/u-boot/2015-June/216849.html Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
* Fix musl buildJörg Krause2015-05-08-0/+2
| | | | | | | | | | | This patch fixes cross-compiling U-Boot tools with the musl C library: * including <sys/types.h> is needed for ulong * defining _GNU_SOURCE is needed for loff_t Tested for target at91sam9261ek_dataflash_cs3. Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks> Cc: Tom Rini <trini@konsulko.com>
* fw_env.h: include autoconf.hMax Krummenacher2015-05-05-0/+1
| | | | | | | | | | | | | | Without this, when CONFIG_ENV_VARS_UBOOT_CONFIG is active we get a compile time error when doing 'make env'. In file included from tools/env/fw_env.c:117:0: include/env_default.h:110:11: error: expected ‘}’ before ‘CONFIG_SYS_ARCH’ When building U-Boot this is included indirectly by the compiler switch -include /home/trdx/git.toradex.com/u-boot-2014.10-toradex/include/linux/kconfig.h Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com> Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
* add example for file on VFAT filesystem usageWaldemar Brodkorb2015-02-17-0/+3
| | | | | | | | For example on a raspberry pi the u-boot environment can be saved in a file on the first VFAT partition. This example illustrates how to use it with fw_printenv/fw_setenv. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
* 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>
* tools/env: change stripping strategy to allow no-strippingThomas Petazzoni2014-09-24-6/+8
| | | | | | | | | | | | | | | | | | | | | When building the U-Boot tools for non-ELF platforms (such as Blackfin FLAT), since commit 79fc0c5f498c3982aa4740c273ab1a9255063d9c ("tools/env: cross-compile fw_printenv without setting HOSTCC"), the build fails because it tries to strip a FLAT binary, which does not make sense. This commit solves this by changing the stripping logic in tools/env/Makefile to be similar to the one in tools/Makefile. This logic continues to apply strip to the final binary, but does not abort the build if it fails, and does the stripping in place on the final binary. This allows the logic to work fine if stripping doesn't work, as it leaves the final binary untouched. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Masahiro Yamada <yamada.m@jp.panasonic.com> Cc: Sonic Zhang <sonic.zhang@analog.com> Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Reviewed-by: Sonic Zhang <sonic.zhang@analog.com>
* kconfig: switch to KconfigMasahiro Yamada2014-07-30-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit enables Kconfig. Going forward, we use Kconfig for the board configuration. mkconfig will never be used. Nor will include/config.mk be generated. Kconfig must be adjusted for U-Boot because our situation is a little more complicated than Linux Kernel. We have to generate multiple boot images (Normal, SPL, TPL) from one source tree. Each image needs its own configuration input. Usage: Run "make <board>_defconfig" to do the board configuration. It will create the .config file and additionally spl/.config, tpl/.config if SPL, TPL is enabled, respectively. You can use "make config", "make menuconfig" etc. to create a new .config or modify the existing one. Use "make spl/config", "make spl/menuconfig" etc. for spl/.config and do likewise for tpl/.config file. The generic syntax of configuration targets for SPL, TPL is: <target_image>/<config_command> Here, <target_image> is either 'spl' or 'tpl' <config_command> is 'config', 'menuconfig', 'xconfig', etc. When the configuration is done, run "make". (Or "make <board>_defconfig all" will do the configuration and build in one time.) For futher information of how Kconfig works in U-Boot, please read the comment block of scripts/multiconfig.py. By the way, there is another item worth remarking here: coexistence of Kconfig and board herder files. Prior to Kconfig, we used C headers to define a set of configs. We expect a very long term to migrate from C headers to Kconfig. Two different infractructure must coexist in the interim. In our former configuration scheme, include/autoconf.mk was generated for use in makefiles. It is still generated under include/, spl/include/, tpl/include/ directory for the Normal, SPL, TPL image, respectively. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Acked-by: Simon Glass <sjg@chromium.org>
* tools: env: Add aes.c placeholderMarek Vasut2014-05-12-0/+1
| | | | | | | | | | | Add missing aes.c placeholder which includes lib/aes.c . Without this one, tools/env/ will fail to build. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com> Cc: Masahiro Yamada <yamada.m@jp.panasonic.com> Tested-by: Alexey Brodkin <abrodkin@synopsys.com> Tested-by: Heiko Schocher <hs@denx.de>
* Merge branch 'u-boot/master'Albert ARIBAUD2014-05-09-8/+140
|\ | | | | | | | | | | | | Conflicts: drivers/net/Makefile (trivial merge)
| * env: Implement support for AES encryption into fw_* toolsMarek Vasut2014-03-21-8/+140
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* kbuild: rename SRCTREE to srctreeMasahiro Yamada2014-03-12-1/+1
| | | | | | | | | | | | | | | Prior to Kbuild, $(TOPDIR) or $(SRCTREE) was used for pointing to the top of source directory. (No difference between the two.) In Kbuild style, $(srctree) is used for instead. This commit renames SRCTREE to srctree and deletes the defition of SRCTREE. Note that SRCTREE in scripts/kernel-doc, scripts/docproc.c, doc/DocBook/Makefile should be keep. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.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-7/+9
| | | | | | | | | | | | | | | 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>
* tools/env: cross-compile fw_printenv without setting HOSTCCMasahiro Yamada2014-02-19-6/+18
| | | | | | | | | | | | | | | fw_printenv is a program which mostly runs on the target Linux. Before switching to Kbuild, we needed to set HOSTCC at the command line like this: make HOSTCC=<your CC cross-compiler> env Going forward we can cross compile it by specifying CROSS_COMPILE: make CROSS_COMPILE=<your cross-compiler prefix> env This looks more natural. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Tested-by: Gerhard Sittig <gsi@denx.de>
* Makefile: refactor include path settingsMasahiro Yamada2014-02-19-3/+1
| | | | | | | | This commit merges commonly-used header include paths to UBOOTINCLUDE and NOSTDINC_FLAGS variables, which are placed at the top Makefile. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
* tools: convert makefiles to kbuild styleMasahiro Yamada2014-02-19-25/+12
| | | | | | | | | | | | | Before this commit, makefiles under tools/ directory were implemented with their own way. This commit refactors them by using "hostprogs-y" variable. Several C sources have been added to wrap other C sources to simplify Makefile. For example, tools/crc32.c includes lib/crc32.c Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
* Makefile: do not create a symbolic link to arch/${ARCH}/include/asmMasahiro Yamada2013-11-08-1/+1
| | | | | | | | | | | | | | | In-tree build: - Do not create a symbolic link from include/asm to arch/${ARCH}/include/asm - Add ${SRCTREE}/arch/arm/include into the header search path Out-of-tree build: - Do not create a directory ${OBJTREE}/include2 - Do not create a symbolic link from ${OBJTREE}/include2/asm to ${SRCTREE}/arch/${ARCH}/include/asm - Add ${SRCTREE}/arch/arm/include into the header search path Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
* Coding Style cleanup: remove trailing white spaceWolfgang Denk2013-10-14-2/+2
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* 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-68/+4
| | | | | | 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/+27
| | | | | | | 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>
* Fix a couple typoes in tools/env/READMERobert P. J. Day2013-03-11-2/+2
| | | | Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
* fw_env.config: Correct "fw_saveenv" to "fw_setenv".Robert P. J. Day2013-02-19-1/+1
| | | | | | Fix a comment in the fw_env.config file, no functional change. Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
* Revert "fw_env: fix building w/out a config.h"Tom Rini2012-12-20-10/+26
| | | | | | | | I had missed Joe's NAK on this patch, so... This reverts commit 92ace272d06cec1d7f1533bb9edf914fb5845fba. Signed-off-by: Tom Rini <trini@ti.com>
* fw_env: fix building w/out a config.hMike Frysinger2012-12-19-26/+10
| | | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
* fw_env: fix incorrect usage of open(O_CREAT)Mike Frysinger2012-12-19-1/+1
| | | | | | | | | | | | | | | When using open(), the O_CREAT flag must be given a mode, otherwise it uses random garbage from the stack. Also, it can fail to build: In file included from /usr/include/fcntl.h:290:0, from fw_env_main.c:42: In function 'open', inlined from 'main' at fw_env_main.c:97:9: /usr/include/bits/fcntl2.h:50:24: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT in second argument needs 3 arguments Signed-off-by: Mike Frysinger <vapier@gentoo.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* 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/+12
| | | | | | | | | | | | | | 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>
* tools: Add a README note about fw_printenv lock fileJoe Hershberger2012-10-15-0/+4
| | | | | | | Add a mention of the lock file to the README for the fw_printenv tool. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reported-by: Luka Perkov <uboot@lukaperkov.net>
* 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: Serialize calls to fw_*envJoe Hershberger2012-10-15-22/+37
| | | | | | | Use a lock file at /var/lock/fw_printenv.lock. Avoids seriously confusing the MTD driver. 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-17/+35
| | | | | | | | | | | | | | | | | | | 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>
* Strip fw_printenv like the other toolsLoïc Minier2012-06-21-0/+1
| | | | Signed-off-by: Loïc Minier <lool@debian.org>