I am working with YOCTO dunfell and i have to use libubootenv for fw_printenv and fw_setenv. But iam unable to set variables using fw_setenv. Also the fw_printenv output is also not correct. But i can use the printenv setenv from the u-boot command line and it is working properly.We are using our custom board with AM335 TI Processor.
My u-boot env variables are stored in the spi flash and below is my fw_env.config(/etc/fw_env.config)
/dev/mtd2 0x0A0000 0x010000
/dev/mtd3 0x0B0000 0x010000
Also when i use fw_printenv/fw_setenv , Iam getting the error "Can not read from default". But its printing the variables which is in the u-boot-initial-env file.
I want to set and read using fw_printenv and fw_setenv from the userspace and it should change the variables in the spi flash.
Right now Iam not able to change the spi flash u-boot-env variables using fw_setenv and print using fw_printenv.
Please help with this issue. Any helps are appreciated. Iam pasting small part of board.h file here.
/*
* Default to using SPI for environment, etc.
* 0x000000 - 0x020000 : SPL (128KiB)
* 0x020000 - 0x0A0000 : U-Boot (512KiB)
* 0x0A0000 - 0x0BFFFF : First copy of U-Boot Environment
(128KiB)
* 0x0C0000 - 0x0DFFFF : Second copy of U-Boot Environment
(128KiB)
* 0x0E0000 - 0x442000 : Linux Kernel
* 0x442000 - 0x800000 : Userland
*/
/* SPI flash. */
#define CONFIG_SYS_SPI_ARGS_OFFS (768 << 10)
#define CONFIG_SYS_SPI_ARGS_SIZE SZ_128K
#define CONFIG_SYS_SPI_KERNEL_OFFS (CONFIG_SYS_SPI_ARGS_OFFS +
CONFIG_SYS_SPI_ARGS_SIZE)
#if defined(CONFIG_SPI_BOOT)
/* SPL related */
#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x20000
#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
#define CONFIG_ENV_SECT_SIZE (4 << 10) /* 4 KB
sectors */
#define CONFIG_ENV_OFFSET (768 << 10) /* 768 KiB
in */
#define CONFIG_ENV_OFFSET_REDUND (896 << 10) /* 896 KiB
in */