17 Jul, 2019

1 commit

  • Add env_get_offset interface to override static CONFIG_ENV_OFFSET,
    and update env location driver to use env_get_offset. So for different
    storage medium, we are able to store the env at different offset.

    We don't support this feature when CONFIG_ENV_IS_EMBEDDED is set.

    Signed-off-by: Ye Li
    (cherry picked from commit 5b12d7cabb14bab9a95af7460b36c6c85db1b328)

    Ye Li
     

26 Mar, 2019

1 commit

  • This converts the following to Kconfig:
    CONFIG_ENV_SPI_BUS
    CONFIG_ENV_SPI_CS
    CONFIG_ENV_SPI_MAX_HZ
    CONFIG_ENV_SPI_MODE

    Most of time these value are not needed, CONFIG_SF_DEFAULT
    with same value is used, so I introduced CONFIG_USE_ENV_SPI_*
    to force the associated value for the environment.

    Signed-off-by: Patrick Delaunay

    Patrick Delaunay
     

14 Mar, 2019

1 commit

  • This reverts commit 9a9d66f5eff0f443de4c2c6ca3e27771ed14b1b4.

    because it breaks fw_setenv and U-Boot interworking, if
    U-Boot environment is stored in a SPI-NOR.

    Reproduce it with:
    boot linux with empty Environment and store a variable
    with fw_setenv into it, the Environment is now filled
    with 0xff:

    root@ckey5e:10:8e:~# hexdump -C /dev/mtd4
    00000000 e9 e8 07 fa 01 62 6f 6f 74 63 6d 64 3d 72 75 6e |.....bootcmd=run|
    [...]
    00000f30 7d 00 75 62 69 62 6f 6f 74 76 6f 6c 3d 32 00 00 |}.ubibootvol=2..|
    00000f40 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|

    Boot now U-Boot prints:

    Loading Environment from SPI Flash... SF: Detected s25fl128l with page size 256 Bytes, erase size 4 KiB, total 16 MiB
    *** Warning - bad CRC, using default environment

    Reason is the above commit, as it only reads until \0\0
    is found, and assumes the rest of the Environment
    space is filled with 0x00, which is not the case when
    saving an Environment under linux with fw_setenv.

    Signed-off-by: Heiko Schocher
    Acked-by: Stefano Babic

    Heiko Schocher
     

22 Jan, 2019

1 commit


19 Jan, 2019

1 commit

  • commit 9a9d66f5eff0 ("env: add spi_flash_read_env function")

    breaks Environment functionality, as it reads only
    until 2 \0 are found, but fills the buffer with 0x0
    instead 0xff which leads in an incorrect crc sum.

    Fix: init the read buffer with 0xff instead 0x00

    Signed-off-by: Heiko Schocher

    Heiko Schocher
     

17 Jan, 2019

1 commit

  • The spi_flash_read_env function is a wrapper over spi_flash_read, which
    enables the env to read multiple flash page size from flash until '\0\0'
    is read or the end of env partition is reached. Instead of reading the
    entire env size. When it reads '\0\0', it stops reading further the env
    and assumes that the rest of env is '\0'.

    This is an optimization for large environments that contain few bytes
    environment variables. In this case it doesn't need to read the entire
    environment and only few pages.

    Signed-off-by: Horatiu Vultur

    Horatiu Vultur
     

05 Dec, 2018

1 commit


19 Sep, 2018

1 commit

  • For some reason the spi_flash_probe_bus_cs() is called
    inside the setup_flash_device() with zero values in place
    of configurated SPI flash mode and maximum flash speed.
    This code causes HALT error during startup environment
    relocation on some platforms - namely Armada-38x-GP board.
    Fix the function call by replacing zeros with the appropriate
    values - CONFIG_ENV_SPI_MAX_HZ and CONFIG_ENV_SPI_MODE.

    Signed-off-by: Konstantin Porotchkin
    Cc: Igal Liberman
    Cc: Stefan Roese
    Signed-off-by: Stefan Roese

    Konstantin Porotchkin
     

20 Jul, 2018

1 commit

  • The function set_default_env() sets the hashtable flags for import_r().
    Formally set_default_env() doesn't accept flags from its callers. In
    practice the caller can (un)set the H_INTERACTIVE flag, but it has to be
    done using the first character of the function's string argument. Other
    flags like H_FORCE can't be set by the caller.

    Change the function to accept flags argument. The benefits are:
    1. The caller will have to explicitly set the H_INTERACTIVE flag,
    instead of un-setting it using a special char in a string.
    2. Add the ability to propagate flags from the caller to himport(),
    especially the H_FORCE flag from do_env_default() in nvedit.c that
    currently gets ignored for "env default -a -f" commands.
    3. Flags and messages will not be coupled together. A caller will be
    able to set flags without passing a string and vice versa.

    Please note:
    The propagation of H_FORCE from do_env_default() does not introduce any
    functional changes, because currently himport_r() is set to destroy the
    old environment regardless if H_FORCE flag is set or not. More changes
    are needed to utilize the propagation of H_FORCE.

    Signed-off-by: Yaniv Levinsky
    Acked-by: Igor Grinberg

    Yaniv Levinsky
     

07 May, 2018

1 commit

  • When U-Boot started using SPDX tags we were among the early adopters and
    there weren't a lot of other examples to borrow from. So we picked the
    area of the file that usually had a full license text and replaced it
    with an appropriate SPDX-License-Identifier: entry. Since then, the
    Linux Kernel has adopted SPDX tags and they place it as the very first
    line in a file (except where shebangs are used, then it's second line)
    and with slightly different comment styles than us.

    In part due to community overlap, in part due to better tag visibility
    and in part for other minor reasons, switch over to that style.

    This commit changes all instances where we have a single declared
    license in the tag as both the before and after are identical in tag
    contents. There's also a few places where I found we did not have a tag
    and have introduced one.

    Signed-off-by: Tom Rini

    Tom Rini
     

01 Feb, 2018

2 commits

  • For the redundant environment configuration, env_sf_load still
    contained duplicate code instead of using env_import_redund().

    Simplify the code by only executing the load twice and delegating
    everything else to env_import_redund.

    Signed-off-by: Simon Goldschmidt
    Acked-by: Maxime Ripard

    Simon Goldschmidt
     
  • env_import (and env_import_redund) currently return 1 on success
    and 0 on error. However, they are only used from functions
    returning 0 on success or a negative value on error.

    Let's clean this up by making env_import and env_import_redund
    return 0 on success and -EIO on error (as was the case for all
    users before).

    Users that cared for the return value are also updated. Funny
    enough, this only affects onenand.c and sf.c

    Signed-off-by: Simon Goldschmidt
    Acked-by: Maxime Ripard

    Simon Goldschmidt
     

18 Jan, 2018

1 commit


04 Oct, 2017

1 commit

  • U-Boot widely uses error() as a bit noisier variant of printf().

    This macro causes name conflict with the following line in
    include/linux/compiler-gcc.h:

    # define __compiletime_error(message) __attribute__((error(message)))

    This prevents us from using __compiletime_error(), and makes it
    difficult to fully sync BUILD_BUG macros with Linux. (Notice
    Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().)

    Let's convert error() into now treewide-available pr_err().

    Done with the help of Coccinelle, excluing tools/ directory.

    The semantic patch I used is as follows:

    //
    @@@@
    -error
    +pr_err
    (...)
    //

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Simon Glass
    [trini: Re-run Coccinelle]
    Signed-off-by: Tom Rini

    Masahiro Yamada
     

16 Aug, 2017

4 commits


15 Aug, 2017

3 commits

  • Set up a location driver for each supported environment location. At
    present this just points to the global functions and is not used. A
    later patch will switch this over to use private functions in each driver.

    There are several special cases here in various drivers to handle
    peculiarities of certain boards:

    1. Some boards define CONFIG_ENV_IS_IN_FAT and CONFIG_SPL_ENV_SUPPORT but
    do not actually load the environment in SPL. The env load code was
    optimised out before but with the driver, it is not. Therefore a special
    case is added to env/fat.c. The correct fix (depending on board testing
    might be to disable CONFIG_SPL_ENV_SUPPORT.

    2. A similar situations happens with CONFIG_ENV_IS_IN_FLASH. Some boards
    do not actually load the environment in SPL, so to reduce code size we
    need to drop that code. A similar fix may be possible with these boards,
    or it may be possible to adjust the environment CONFIG settings.

    Added to the above is that the CONFIG_SPL_ENV_SUPPORT option does not
    apply when the environment is in flash.

    Obviously the above has been discovered through painful and time-consuming
    trial and error. Hopefully board maintainers can take a look and figure
    out what is actually needed.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • At present we have three states for the environment, numbered 0, 1 and 2.
    Add an enum to record this to avoid open-coded values.

    Signed-off-by: Simon Glass
    Reviewed-by: Tom Rini

    Simon Glass
     
  • About a quarter of the files in common/ relate to the environment. It
    seems better to put these into their own subdirectory and remove the
    prefix.

    Signed-off-by: Simon Glass
    Reviewed-by: Tom Rini

    Simon Glass