Skip to content

Instantly share code, notes, and snippets.

@pamolloy
Last active February 26, 2019 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamolloy/d9ba1fc2b0a6cfa6fbd66798cd2389ac to your computer and use it in GitHub Desktop.
Save pamolloy/d9ba1fc2b0a6cfa6fbd66798cd2389ac to your computer and use it in GitHub Desktop.
Enabling EEPROM support in U-Boot

Selecting CONFIG_SYS_I2C_ZYNQ and CONFIG_ZYNQ_I2C0 builds successfully (see Xilinx documentation). But those are old config options and should be replaced with CONFIG_I2C_CADENCE.

Selecting CONFIG_ENV_IS_IN_EEPROM causes the following assertion to fail:

cmd/eeprom.c:58:2: error: #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
 #error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
  ^~~~~

...

Selecting CONFIG_I2C_EEPROM and configuring it causes the following causes the following compiler errors:

cmd/eeprom.c:68:1: error: expected identifier or '(' before '{' token
 {
 ^
In file included from cmd/eeprom.c:22:
include/common.h:282:54: error: expected identifier or '(' before 'void'
 #define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
                                                      ^~~~

...

Selecting CONFIG_CMD_EEPROM, despite being deprecated, causes tons of compiler errors:

drivers/built-in.o: In function `i2c_eeprom_std_read':
/home/philip/repos/third-party/buildroot/output/build/uboot-custom/drivers/misc/i2c_eeprom.c:35: undefined reference to `dm_i2c_read'

Selecting CONFIG_DM_I2C, despite being deprected, results in the following compiler error:

In file included from include/config.h:8,
                 from ./include/common.h:17:
include/config_fallbacks.h:51:4: error: #error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
 #  error "Cannot define CONFIG_SYS_I2C when CONFIG_DM_I2C is used"
    ^~~~~

...
@pamolloy
Copy link
Author

I switched to mainline master, selected CMD_EEPROM, and various driver model options. I switched to the Cadence I2C driver from the ZYNQ one.

@pamolloy
Copy link
Author

U-Boot tools defaults to MTD_ABSENT, which increments a byte at the start of each image:

# xxd -l 1 -seek 0x4 uboot-renv.bin.org
00000004: 01                                       .
# xxd -l 1 -seek 0x1004 uboot-renv.bin.foo
00001004: 02                                       .
# xxd -l 1 -seek 0x4 uboot-renv.bin
00000004: 03                                       .

The U-Boot tools configuration for this example (i.e. /etc/fw_env.config):

/root/uboot-renv.bin	0x0000	0x1000
/root/uboot-renv.bin	0x1000	0x1000

Buildroot includes a configuration option to build a redundant binary environment image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment