[U-Boot] [PATCHv6 12/28] net: Add ability to set MAC address via EEPROM

Simon Glass sjg at chromium.org
Wed May 17 01:38:26 UTC 2017


Hi Oliver,

On 15 May 2017 at 02:02, Olliver Schinagl <oliver at schinagl.nl> wrote:
> This patch allows Kconfig to enable and set parameters to make it
> possible to read the MAC address from an EEPROM. The net core layer then
> uses this information to read MAC addresses from this EEPROM.
>
> Besides the various tuneables as to how to access the eeprom (bus,
> address, addressing mode/length, 2 configurable that are EEPROM generic
> (e.g. SPI or some other form of access) which are:
>
> NET_ETHADDR_EEPROM_OFFSET, indicating where in the EEPROM the start of
> the MAC address is. The default is 8 allowing for 8 bytes before the MAC
> for other purposes (header MAGIC for example).
>
> NET_ETHADDR_EEPROM_CRC8, indicating the MAC is appended with a CRC8-CCIT
> checksum that should be verified.
>
> Currently only I2C eeproms have been tested and thus only those options
> are available, but shouldn't be a limit. NET_ETHADDR_EEPROM_SPI can be
> just as created and added.
>
> The code currently first checks if there is a non-zero MAC address in
> the eeprom. If that fails to be the case, the read_rom_hwaddr can be
> used by a board to supply the MAC in other ways.
>
> If both these fails, the other code is still in place to query the
> environent, which then can be used to override the hardware supplied
> data.
>
> Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
> ---
>  arch/arm/mach-sunxi/Kconfig                |  8 +--
>  configs/A10-OLinuXino-Lime_defconfig       |  1 -
>  configs/A20-OLinuXino-Lime2-eMMC_defconfig |  1 -
>  configs/A20-OLinuXino-Lime2_defconfig      |  1 -
>  configs/A20-OLinuXino-Lime_defconfig       |  1 -
>  configs/A20-OLinuXino_MICRO_defconfig      |  1 -
>  doc/README.enetaddr                        | 95 ++++++++++++++++++++++++++++++
>  include/net.h                              | 14 +++++
>  net/Kconfig                                | 59 +++++++++++++++++++
>  net/eth-uclass.c                           | 42 +++++++------
>  net/eth_common.c                           | 37 ++++++++++++
>  net/eth_legacy.c                           |  2 +
>  12 files changed, 231 insertions(+), 31 deletions(-)
>

Please don't implement this feature in legacy code / legacy I2C. New
features should only use DM - otherwise it just makes it harder and
harder to ever finish the port.

Regards,
Simon


More information about the U-Boot mailing list