summaryrefslogtreecommitdiffstats
path: root/env
Commit message (Collapse)AuthorAgeFilesLines
* common: Drop asm/global_data.h from common headerSimon Glass2021-02-0214-0/+14
| | | | | | | | | | | | Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
* env: sf: cosmetic: remove unnecessary spacePatrick Delaunay2021-01-291-2/+2
| | | | | | | Remove the unnecessary space before the 2 "done:" labels in env_sf_save(). Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
* env: Remove all dependencies for SYS_REDUNDAND_ENVIRONMENTMichal Simek2021-01-201-2/+3
| | | | | | | | | | | | | | | | | | | | CONFIG_SYS_REDUNDAND_ENVIRONMENT is changing in env_internal.h how u-boot works with variables. struct environment_s has one byte flags property which also affects ENV_SIZE macro. I have reached the case where CONFIG_ENV_IS_NOWHERE is default setup but custom scripts can be designed in a way that u-boot is asked to import/export variables from/to file which can be in certain format. That's why also for this configuration make sense to enable CONFIG_SYS_REDUNDAND_ENVIRONMENT because it depends on environment file format. The patch is removing dependency on this configuration to support selecting environment file format without any specific dependency where variables are stored. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: typo enougthHeinrich Schuchardt2020-11-191-1/+1
| | | | | | | %s/enougth/enough/ Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
* env: mmc: Correct partition comparison in mmc_offset_try_partitionHoyeonjiki Kim2020-11-181-1/+1
| | | | | | | | | | | | | | | The function mmc_offset_try_partition searches the MMC partition for locating environment data, by comparing the partition names with config "u-boot,mmc-env-parition". However, it only compares the first word-size bytes (size of 'const char *'), which may make the function to find unintended partition. Correct the function not to partially compare the partition name with config "u-boot,mmc-env-partition". Fixes: c9e87ba66540 ("env: Save environment at the end of an MMC partition") Signed-off-by: Hoyeonjiki Kim <jigi.kim@gmail.com> Reviewed-by: Wolfgang Denk <wd@denx.de>
* env: sf: fix init function behaviourHeiko Schocher2020-11-032-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Michael wrote: commit 92765f45bb95 ("env: Access Environment in SPI flashes before relocation") at least breaks the Kontron sl28 board. I guess it also breaks others which use a (late) SPI environment. reason is, that env_init() sets the init bit, if there is no init function defined in an environment driver, and use default return value -ENOENT in this case later for setting the default environment. Change: Environment driver can now implement an init function and return, if this function does nothing, simply -ENOENT. env_init() now handles -ENOENT correct by setting the inited bit for the environment driver. And if there is no other environment driver whose init function returns 0, load than the default environment. This prevents that each environment driver needs to set the default environment. Fixes: 92765f45bb95 ("env: Access Environment in SPI flashes before relocation") Reported-by: Michael Walle <michael@walle.cc> Tested-by: Michael Walle <michael@walle.cc> [For the SF environment] Signed-off-by: Heiko Schocher <hs@denx.de>
* env: Access Environment in SPI flashes before relocationHeiko Schocher2020-10-302-3/+105
| | | | | | | | | | Enable the new Kconfig option ENV_SPI_EARLY if you want to use Environment in SPI flash before relocation. Call env_init() and than you can use env_get_f() for accessing Environment variables. Signed-off-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* env: split env_import_redund() into 2 functionsHeiko Schocher2020-10-301-10/+32
| | | | | | | | | | | | split from env_import_redund() the part which checks which Environment is valid into a separate function called env_check_redund() and call it from env_import_redund(). So env_check_redund() can be used from places which also need to do this checks. Signed-off-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
* env/ext4.c: allow loading from an EXT4 partition on the MMC boot deviceDavid Woodhouse2020-10-142-0/+18
| | | | | | | | | | This parallels what I added for FAT in commit 6731bef6966, allowing the environment to be found in a specific partition on the device that the board's mmc_get_env_dev() returns. On the Banana Pi R2 that means the device that U-Boot was loaded from; either the internal eMMC or an SD card. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* mmc: remove duplicate mmc_get_env_dev() implementationsDavid Woodhouse2020-10-142-14/+0
| | | | | | | Since it's so trivial I could just about tolerate this when there were only two copies of it. But now there are about to be three. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
* Kconfig: Move VERSION_VARIABLE under environmentSimon Glass2020-10-091-0/+9
| | | | | | | This relates to the environment so should not be at the top level. Move it. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: kconfig: Add default option for ARCH_ZYNQMichal Simek2020-09-231-1/+1
| | | | | | | Zynq is similar to ZynqMP u-boot feature wise that's why also enable default option for ENV_FAT_DEVICE_AND_PART Kconfig entry. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
* env: Kconfig: Add missing dependency for ENV_IS_IN_EXT4Michal Simek2020-08-271-0/+1
| | | | | | | | | | | | ENV_IS_IN_EXT4 also need to enable FS_EXT4 which is not covered in Kconfig. Kconfig reports this as: WARNING: unmet direct dependencies detected for EXT4_WRITE Depends on [n]: FS_EXT4 [=n] Selected by [y]: - ENV_IS_IN_EXT4 [=y] && !CHAIN_OF_TRUST [=n] Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* Convert CONFIG_SYS_MMC_ENV_DEV et al to KconfigTom Rini2020-08-082-4/+19
| | | | | | | | | | | | This converts the following to Kconfig: CONFIG_SYS_MMC_ENV_DEV CONFIG_SYS_MMC_ENV_PART Note that with this conversion we now have consistent behavior with respect to ensuring that we have always selected the correct MMC device and hardware partition. Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Add support for explicit write access listMarek Vasut2020-07-312-11/+59
| | | | | | | | | | | This option marks any U-Boot variable which does not have explicit 'w' writeable flag set as read-only. This way the environment can be locked down and only variables explicitly configured to be writeable can ever be changed by either 'env import', 'env set' or loading user environment from environment storage. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Add option to only ever append environmentMarek Vasut2020-07-312-0/+11
| | | | | | | | | | Add configuration option which prevents the environment hash table to be ever cleared and reloaded with different content. This is useful in case the first environment loaded into the hash table contains e.g. sensitive content which must not be dropped or reloaded. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Discern environment coming from external storageMarek Vasut2020-07-3113-22/+23
| | | | | | | | Add another custom environment flag which discerns environment coming from external storage from environment set by U-Boot itself. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Add H_DEFAULT flagMarek Vasut2020-07-311-1/+2
| | | | | | | | | Add another internal environment flag which indicates that the operation is resetting the environment to the default one. This allows the env code to discern between import of external environment and reset to default. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: Warn on force access if ENV_ACCESS_IGNORE_FORCE setMarek Vasut2020-07-311-1/+3
| | | | | | | | If the ENV_ACCESS_IGNORE_FORCE is set, inform user that the variable cannot be force-set if such attempt happens. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: ext4: add support of command env erasePatrick Delaunay2020-07-311-0/+19
| | | | | | | | | | Add support of opts erase for env in ext4, this opts is used by command 'env erase'. This command only fill the env file (CONFIG_ENV_EXT4_FILE) with 0, the CRC and the saved environment becomes invalid. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: ext4: introduce new function env_ext4_save_bufferPatrick Delaunay2020-07-311-8/+20
| | | | | | Split the function env_ext4_save to prepare the erase support. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* cmd: env: add env select commandPatrick Delaunay2020-07-311-0/+42
| | | | | | | Add the new command 'env select' to force the persistent storage of environment, saved in gd->env_load_prio. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* cmd: env: add env load commandPatrick Delaunay2020-07-311-0/+28
| | | | | | | Add the new command env load to load the environment from the current location gd->env_load_prio. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: the ops driver load becomes mandatory in struct env_driverPatrick Delaunay2020-07-311-3/+0
| | | | | | | The ops driver load becomes mandatory in struct env_drive, change the comment for this ops and remove unnecessary test. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: nowhere: add .load opsPatrick Delaunay2020-07-311-0/+17
| | | | | | | | | Add the ops .load for nowhere ENV backend to load the default environment. This ops is needed for the command 'env load' Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: correctly handle env_load_prioPatrick Delaunay2020-07-311-3/+4
| | | | | | | | | | | | | Only update gd->env_load_prio in generic function env_load() and no more in the weak function env_get_location() which is called in many place (for example in env_driver_lookup, even for ENVOP_SAVE operation). This patch is a preliminary step to use env_driver_lookup()/ env_get_location() in new function env_select() without updating gd->env_load_prio. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: sf: avoid space in backend namePatrick Delaunay2020-07-311-1/+1
| | | | | | | Remove space in ENV backend name for SPI Flash (SF) to avoid issue with env select command. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: ext4: set gd->env_validPatrick Delaunay2020-07-311-1/+8
| | | | | | | | | | | | Add a missing initialization of gd->env_valid in env_ext4_load as it is already done in some other env device. Set gd->env_valid = ENV_VALID in env_ext4_save() and env_ext4_load(). This patch allows to have a correct information in 'env info' command. Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: add absolute path at CONFIG_ENV_EXT4_FILEPatrick Delaunay2020-07-311-1/+1
| | | | | | | | | | | | Add the absolute path to the default value of CONFIG_ENV_EXT4_FILE = "/uboot.env". This patch avoid the error : Saving Environment to EXT4... File System is consistent Please supply Absolute path Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* Convert CONFIG_ENV_OVERWRITE to KconfigAdam Ford2020-07-281-0/+6
| | | | | | | | | This converts the following to Kconfig: CONFIG_ENV_OVERWRITE Signed-off-by: Adam Ford <aford173@gmail.com> [trini: Rerun migration, remove some comments] Signed-off-by: Tom Rini <trini@konsulko.com>
* env: mmc: add redundancy support in mmc_offset_try_partitionPatrick Delaunay2020-07-261-3/+3
| | | | | | | | | | Manage 2 copy at the end of the partition selected by config "u-boot,mmc-env-partition" to save the U-Boot environment, with CONFIG_ENV_SIZE and 2*CONFIG_ENV_SIZE offset. This patch allows to support redundancy (CONFIG_ENV_OFFSET_REDUND). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: mmc: correct the offset returned by mmc_offset_try_partitionPatrick Delaunay2020-07-261-2/+2
| | | | | | | | | | | | | The output of the function mmc_offset_try_partition must be a byte offset in mmc and not a multiple of blksz. This function is used in mmc_offset(), called by mmc_get_env_addr() and the offset is used in write_env(), erase_env() and read_env(). In these function, blk_start = offset / mmc->read_bl_len or /write_bl_len so this offset is not a multiple of blksz. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: mmc: allow support of mmc_get_env_dev with OF_CONTROLPatrick Delaunay2020-07-261-6/+12
| | | | | | | | Use the weak function mmc_get_env_dev in mmc_offset_try_partition function to allow dynamic selection of mmc device to use and no more use directly the define CONFIG_SYS_MMC_ENV_DEV. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: add failing trace in env_savePatrick Delaunay2020-07-261-3/+7
| | | | | | | Add trace in env save to indicate any errors to end user and avoid silent output when the command 'env save' is not executed. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env: correct overflow check of env_has_init sizePatrick Delaunay2020-07-261-1/+1
| | | | | | | | | | | | Correct the overflow check of the bit-field env_has_init with the max value of env_location= ENVL_COUNT and no more with the size of env_locations. This bit-field is indexed by this enumerate and not by the position in the env_locations (only used in env_get_location) and the 2 values are different, depending of thea ctivated CONFIG_ENV_IS_ options. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
* env/fat.c: allow loading from a FAT partition on the MMC boot deviceDavid Woodhouse2020-07-262-2/+34
| | | | | | | | | | | | I don't want to have to specify the device; only the partition. This allows me to use the same image on internal eMMC or SD card for Banana Pi R2, and it finds its own environment either way. Signed-off-by: David Woodhouse <dwmw2@infradead.org> [trini: Add #if/#else/#endif logic around CONFIG_SYS_MMC_ENV_DEV usage, whitespace changes] Signed-off-by: Tom Rini <trini@konsulko.com>
* spi: Convert CONFIG_DM_SPI* to CONFIG_$(SPL_TPL_)DM_SPI*Lukasz Majewski2020-06-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change allows more fine tuning of driver model based SPI support in SPL and TPL. It is now possible to explicitly enable/disable the DM_SPI support in SPL and TPL via Kconfig option. Before this change it was necessary to use: /* SPI Flash Configs */ #if defined(CONFIG_SPL_BUILD) #undef CONFIG_DM_SPI #undef CONFIG_DM_SPI_FLASH #undef CONFIG_SPI_FLASH_MTD #endif in the ./include/configs/<board>.h, which is error prone and shall be avoided when we strive to switch to Kconfig. The goal of this patch: Provide distinction for DM_SPI support in both U-Boot proper and SPL (TPL). Valid use case is when U-Boot proper wants to use DM_SPI, but SPL must still support non DM driver. Another use case is the conversion of non DM/DTS SPI driver to support DM/DTS. When such driver needs to work in both SPL and U-Boot proper, the distinction is needed in Kconfig (also if SPL version of the driver supports OF_PLATDATA). In the end of the day one would have to support following use cases (in single driver file - e.g. mxs_spi.c): - U-Boot proper driver supporting DT/DTS - U-Boot proper driver without DT/DTS support (deprecated) - SPL driver without DT/DTS support - SPL (and TPL) driver with DT/DTS (when the SoC has enough resources to run full blown DT/DTS) - SPL driver with DT/DTS and SPL_OF_PLATDATA (when one have constrained environment with no fitImage and OF_LIBFDT support). Some boards do require SPI support (with DM) in SPL (TPL) and some only have DM_SPI{_FLASH} defined to allow compiling SPL. This patch converts #ifdef CONFIG_DM_SPI* to #if CONFIG_IS_ENABLED(DM_SPI) and provides corresponding defines in Kconfig. Signed-off-by: Lukasz Majewski <lukma@denx.de> Tested-by: Adam Ford <aford173@gmail.com> #da850-evm Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com> [trini: Fixup a few platforms] Signed-off-by: Tom Rini <trini@konsulko.com>
* env: Kconfig: cosmetics: update comment for SYS_RELOC_GD_ENV_ADDRPatrick Delaunay2020-06-151-1/+1
| | | | | | | | | Update the comment for SYS_RELOC_GD_ENV_ADDR as gd->env_addr is updated in board_r.c::initr_reloc_global_data() under the compilation flags CONFIG_SYS_RELOC_GD_ENV_ADDR Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Tom Rini <trini@konsulko.com>
* env: sf: Free the old env_flashJagan Teki2020-06-011-7/+6
| | | | | | | | | | | | | env_flash is a global flash pointer, and the probe would happen only if env_flash is NULL, but there is no checking and free the pointer if is not NULL. So, this patch frees the old env_flash, and get the probed flash in to env_flash pointer and finally check if is not NULL. Cc: Simon Glass <sjg@chromium.org> Cc: Vignesh R <vigneshr@ti.com> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
* env: Convert ENV_ACCESS_IGNORE_FORCE to KconfigMarek Vasut2020-05-251-0/+7
| | | | | | | Convert ENV_ACCESS_IGNORE_FORCE to Kconfig, no functional change. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@konsulko.com>
* common: Drop linux/bitops.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop linux/bug.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop log.h from common headerSimon Glass2020-05-183-0/+3
| | | | | | Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop bootstage.h from common headerSimon Glass2020-05-181-0/+1
| | | | | | Move this fairly uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop part.h from common headerSimon Glass2020-05-182-3/+4
| | | | | | Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
* part: Drop disk_partition_t typedefSimon Glass2020-05-183-5/+5
| | | | | | | We should not be using typedefs and these make it harder to use forward declarations (to reduce header file inclusions). Drop the typedef. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop net.h from common headerSimon Glass2020-05-182-0/+2
| | | | | | | | | | | Move this header out of the common header. Network support is used in quite a few places but it still does not warrant blanket inclusion. Note that this net.h header itself has quite a lot in it. It could be split into the driver-mode support, functions, structures, checksumming, etc. Signed-off-by: Simon Glass <sjg@chromium.org>
* common: Drop flash.h from common headerSimon Glass2020-05-181-0/+2
| | | | | | | | Move this uncommon header out of the common header. Fix up some style problems in flash.h while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
* env: Convert CONFIG_DELAY_ENVIRONMENT to KconfigOvidiu Panait2020-05-151-0/+12
| | | | | | This converts ad-hoc CONFIG_DELAY_ENVIRONMENT to Kconfig. Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
* env/sf.c: honour CONFIG_SPL_SAVEENVRasmus Villemoes2020-05-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deciding whether to compile the env_sf_save() function based solely on CONFIG_SPL_BUILD is wrong: For U-Boot proper, it leads to a build warning in case CONFIG_CMD_SAVEENV=n (because the initialization of the .save member is guarded by CONFIG_CMD_SAVEENV, while the env_sf_save() function is built if !CONFIG_SPL_BUILD - and even without the CONFIG_CMD_SAVEENV guard, the env_save_ptr() macro would just expand to NULL, with no reference to env_sf_save visible to the compiler). And for SPL, when one selects CONFIG_SPL_SAVEENV, one obviously expects to actually be able to save the environment. The compiler warning can be fixed by using a "<something> ? env_sf_save : NULL" construction instead of a macro that just eats its argument and expands to NULL. That way, if <something> is false, env_sf_save gets eliminated as dead code, but the compiler still sees the reference to it. For <something>, we can use CONFIG_IS_ENABLED(SAVEENV), which is true precisely: - For U-Boot proper, when CONFIG_CMD_SAVEENV is set (because CONFIG_SAVEENV is a hidden config symbol that gets set if and only if CONFIG_CMD_SAVEENV is set). - For SPL, when CONFIG_SPL_SAVEENV is set. As a bonus, this also removes quite a few preprocessor conditionals. This has been run-time tested on a mpc8309-derived board to verify that saving the environment does indeed work in SPL with these patches applied. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>