All of lore.kernel.org
 help / color / mirror / Atom feed
From: Olliver Schinagl <oliver@schinagl.nl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCHv6 00/28] Retrieve MAC address from EEPROM
Date: Mon, 15 May 2017 10:09:02 +0200	[thread overview]
Message-ID: <34fd744e-14cd-3ec1-473a-f20ca1caa075@schinagl.nl> (raw)
In-Reply-To: <20170515080244.21345-1-oliver@schinagl.nl>

Hey all,

On 15-05-17 10:02, Olliver Schinagl wrote:
> This patch-series introduces methods to retrieve the MAC address from an
> onboard EEPROM. The series does a few small cleanups at the start, as either
> I ran into them while doing this series and fixed them along the way or
> actually depended on them.
>
> A manufacturer wants to produce boards and may even have MAC addresses for
> boards. Maintaining unique environments on a per-board basis however is
> horrible. Also this data should be very persistent, and not easily deletable
> by simply wiping the environment or device tree. Finally there are
> chips available on the market with a pre-programmed MAC address chips
> (proms)
> that a board manufacturer wants to use. Because of this, the MAC needs to be
> stored be able to read from such an 'external' source.
>
> The current idea of the eeprom layout, is to skip the first 8 bytes, so that
> other information can be stored there if needed, for example a header
> with some magic to identify the EEPROM. Or equivalent purposes.
>
> After those 8 bytes the MAC address follows the first macaddress. The
> macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes.
> Following the first macaddress one can store a second, or a third etc etc
> macaddress.
>
> The CRC8 is optional (via a define) but is strongly recommended to have. It
> helps preventing user error and more importantly, checks if the bytes
> read are actually a user inserted address. E.g. only writing 1 macaddress into
> the eeprom but trying to consume 2.
>
> These patches where tested on Olimex OLinuXino Lime1 (A10/A20), Lime2 (NAND
> and eMMC) and A20-OLinuXino-MICRO-4G variants and have been in use
> internally on our production systems since v2 of this patch set.
>
> TODO in a follow up series:
> * Replace the I2C specific read function to a generic function using
> Maxime Ripard's EEPROM uclass once merged.
> * Upgrade to use the EERPOM layout functionality as suggested by Igor Grinberg
> * Add EEPROM/Mac commands suggested by York Sun
>
> The series was initially based ontop of Joe's u-boot_net/next branches, but I
> rebased it ontop of u-boot/master to get the latest sunxi changes, including:
> sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC
> ARM: dts: sunxi: Change node name for pwrseq pin on Olinuxino-lime2-emmc
>
> Which are on their way to being merged in master. So once those land into master
> this all should apply cleanly. Sorry Joe!

So I accidentally added those too to this patch series as well (first 
two patches). Which are technically not part of this series and are on 
their way as it is. Does patchwork figure out this automatically, or do 
you prefer a resend with the 2 patches removed?

Olliver

>
> =======
> Changes since v5:
> * Removed changes to eth_legacy as per Simon's request
> * Adapted, improved and fixed the emac/gmac Kconfig conversion
> * Renamed sunxi_[eg]mac to sun[47]_mac to be more clear and allowing preparing
>   to merge common parts into sunxi_common
> * Added a few more MAC helpers
> * Added PHY_GIGE as Kconfig symbol
>
> Changes since v4:
> * Some patches have been merged, so those are no longer included in the set.
> * Reworked review comments
> * Added the source of a MAC address
> * Made sunxi-gmac a subclassed driver
> * Switch sunxi-[eg]mac to Kconfig
> * Drop the FDT injection code for now, this needs more thought/discussion
>
> Changes since v3:
> * Split off board specific stuff and only modify the generic functions
> * Make reading of an eeprom available to every board. By default this is
>    unconfigure and thus should just fall through
> * Clean some minor bits up (ARP_HLEN) and use it more generically
> * Update the gen_ethaddr_crc as suggested by simon
> * Let the fixup_ethernet from fdt_common insert mac addresses to the
> environment
>    for unconfigured devices. There is a small caveat here however as
> described
>    in the TODO above.
> * Print the mac address that u-boot assigned to each device.
>
> Changes since v2:
> * Drop the id byte altogether and just mark it as reserved. The 'index'
> can be
> used to indicate the interface instead
> * Addopt the read_rom_hwaddr hooks
> * Renamed crc8 tool to gen_ethaddr_crc
> * Improved the layout EEPROM example
> * Made a function out of the hwaddress writing function in sunxi_emac so it
> can be re-used as the write_hwaddr net_ops hook.
> * No longer handle fdt parameters in board.c
>
> Changes since v1:
> * Do not CRC the id byte, move it just after the crc byte.
> One of the reasons I decided to move it after the crc8 was mostly due to
> mass
> generation of MAC + CRC combo's where the ID is still unknown. Also not
> crc-ing
> the ID means that it is much easier for a user to change it (via the
> u-boot i2c
> cmd line or from within linux) without having to worry about the crc.
> * Add a generator to convert a MAC address from the input to a MAC + CRC8 on
> the output.
>
> Emmanuel Vadot (1):
>   ARM: dts: sunxi: Change node name for pwrseq pin on
>     Olinuxino-lime2-emmc
>
> Olliver Schinagl (27):
>   sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC
>   net: core: Add PHY_GIGE as a Kconfig symbol
>   net: sunxi simplify defconfig
>   net: sunxi: Re-add RTL8211X_PHY_FORCE_MASTER
>   net: sunxi: Restore sunxi_[eg]mac behavior
>   net: sunxi: Move GMAC_TX_DELAY to the driver
>   net: cosmetic: Do not use magic values for ARP_HLEN
>   net: core: Sanitize get/set operations for enetaddr
>   net: core: Inform the user of the device MAC address
>   net: core: Add MAC address helper functions
>   net: Add ability to set MAC address via EEPROM
>   net: core: print the source of the MAC address
>   net: cosmetic: A MAC address is not limited to SROM
>   net: core: Check return value of read_rom_hwaddr
>   fdt: fixup_eth: Remove code duplication with a function
>   fdt: fixup_eth: improve error catching/reduce identation
>   arm: sunxi: Expose function to generate sunxi-specific a MAC address
>   net: sunxi_emac: Write HW address via net_ops hook
>   net: sunxi: Rename sunxi_emac to a more specific sun4i_mac
>   net: sunxi: Have sunxi common functions together
>   net: sun4i_mac: Add read_rom_hwaddr hook
>   net: sun7i_mac: Make the sun7i a dw driver subclass
>   net: dw: Expose designware_eth_start
>   net: sun7i_mac: Add read_rom_hwaddr hook
>   net: sun8i_gmac: Add read_rom_hwaddr hook
>   net: sun8i: fix whitespace
>   net: sunxi: Enable eeprom on OLinuXino Lime boards (again)
>
>  arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts |   2 +-
>  arch/arm/include/asm/arch-sunxi/sys_proto.h     |   4 +-
>  arch/arm/mach-sunxi/Kconfig                     |  14 +-
>  arch/arm/mach-sunxi/board.c                     |   1 -
>  board/sunxi/MAINTAINERS                         |   5 +
>  board/sunxi/Makefile                            |   1 -
>  board/sunxi/board.c                             | 146 ++++++++-----
>  common/fdt_support.c                            |  33 ++-
>  configs/A10-OLinuXino-Lime_defconfig            |   4 +-
>  configs/A20-OLinuXino-Lime2-eMMC_defconfig      |  36 ++++
>  configs/A20-OLinuXino-Lime2_defconfig           |   8 +-
>  configs/A20-OLinuXino-Lime_defconfig            |   8 +-
>  configs/A20-OLinuXino_MICRO_defconfig           |   8 +-
>  configs/A20-Olimex-SOM-EVB_defconfig            |   4 +-
>  configs/Bananapi_defconfig                      |   3 +-
>  configs/Bananapro_defconfig                     |   3 +-
>  configs/CSQ_CS908_defconfig                     |   4 +-
>  configs/Colombus_defconfig                      |   3 +-
>  configs/Cubieboard2_defconfig                   |   4 +-
>  configs/Cubietruck_defconfig                    |   3 +-
>  configs/Hummingbird_A31_defconfig               |   3 +-
>  configs/Itead_Ibox_A20_defconfig                |   4 +-
>  configs/Lamobo_R1_defconfig                     |   3 +-
>  configs/Linksprite_pcDuino3_Nano_defconfig      |   3 +-
>  configs/Linksprite_pcDuino3_defconfig           |   4 +-
>  configs/Mele_A1000G_quad_defconfig              |   4 +-
>  configs/Mele_I7_defconfig                       |   4 +-
>  configs/Mele_M3_defconfig                       |   4 +-
>  configs/Mele_M5_defconfig                       |   4 +-
>  configs/Mele_M9_defconfig                       |   4 +-
>  configs/Orangepi_defconfig                      |   3 +-
>  configs/Orangepi_mini_defconfig                 |   3 +-
>  configs/Sinlinx_SinA31s_defconfig               |   4 +-
>  configs/Sinovoip_BPI_M2_defconfig               |   3 +-
>  configs/Wits_Pro_A20_DKT_defconfig              |   3 +-
>  configs/i12-tvbox_defconfig                     |   4 +-
>  configs/icnova-a20-swac_defconfig               |   4 +-
>  configs/mixtile_loftq_defconfig                 |   3 +-
>  doc/README.enetaddr                             |  95 +++++++++
>  drivers/net/Kconfig                             |  76 +++++--
>  drivers/net/Makefile                            |   5 +-
>  drivers/net/designware.c                        |   3 +-
>  drivers/net/designware.h                        |   1 +
>  drivers/net/{sunxi_emac.c => sun4i_mac.c}       | 267 +++++++++++++-----------
>  board/sunxi/gmac.c => drivers/net/sun7i_mac.c   |  54 ++++-
>  drivers/net/sun8i_emac.c                        |  15 +-
>  drivers/net/sunxi_common.c                      |  33 +++
>  drivers/net/sunxi_common.h                      |  13 ++
>  include/configs/sunxi-common.h                  |  13 +-
>  include/net.h                                   |  76 ++++++-
>  net/Kconfig                                     |  59 ++++++
>  net/eth-uclass.c                                |  65 +++---
>  net/eth_common.c                                |  53 ++++-
>  net/eth_legacy.c                                |   4 +-
>  scripts/config_whitelist.txt                    |   2 -
>  55 files changed, 842 insertions(+), 350 deletions(-)
>  create mode 100644 configs/A20-OLinuXino-Lime2-eMMC_defconfig
>  rename drivers/net/{sunxi_emac.c => sun4i_mac.c} (59%)
>  rename board/sunxi/gmac.c => drivers/net/sun7i_mac.c (67%)
>  create mode 100644 drivers/net/sunxi_common.c
>  create mode 100644 drivers/net/sunxi_common.h
>

  parent reply	other threads:[~2017-05-15  8:09 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15  8:02 [U-Boot] [PATCHv6 00/28] Retrieve MAC address from EEPROM Olliver Schinagl
2017-05-15  8:02 ` [U-Boot] [PATCHv6 01/28] ARM: dts: sunxi: Change node name for pwrseq pin on Olinuxino-lime2-emmc Olliver Schinagl
2017-05-15  8:02 ` [U-Boot] [PATCHv6 02/28] sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC Olliver Schinagl
2017-05-15  8:02 ` [U-Boot] [PATCHv6 03/28] net: core: Add PHY_GIGE as a Kconfig symbol Olliver Schinagl
2017-05-15 12:47   ` Tom Rini
2017-05-30 20:45   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 04/28] net: sunxi simplify defconfig Olliver Schinagl
2017-05-15  8:14   ` Maxime Ripard
2017-05-30 20:58   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 05/28] net: sunxi: Re-add RTL8211X_PHY_FORCE_MASTER Olliver Schinagl
2017-05-30 20:59   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 06/28] net: sunxi: Restore sunxi_[eg]mac behavior Olliver Schinagl
2017-05-30 21:04   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 07/28] net: sunxi: Move GMAC_TX_DELAY to the driver Olliver Schinagl
2017-05-30 21:06   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 08/28] net: cosmetic: Do not use magic values for ARP_HLEN Olliver Schinagl
2017-05-15 12:47   ` Tom Rini
2017-05-30 21:06   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 09/28] net: core: Sanitize get/set operations for enetaddr Olliver Schinagl
2017-05-15 12:52   ` Tom Rini
2017-05-30 21:07   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 10/28] net: core: Inform the user of the device MAC address Olliver Schinagl
2017-05-30 21:08   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 11/28] net: core: Add MAC address helper functions Olliver Schinagl
2017-05-15 12:54   ` Tom Rini
2017-05-30 21:09   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 12/28] net: Add ability to set MAC address via EEPROM Olliver Schinagl
2017-05-15  8:18   ` Maxime Ripard
2017-05-15 12:18     ` Olliver Schinagl
2017-05-16 12:15       ` Maxime Ripard
2017-05-17  1:38   ` Simon Glass
2017-12-04 23:51   ` [U-Boot] [linux-sunxi] " Jonathan Liu
2017-05-15  8:02 ` [U-Boot] [PATCHv6 13/28] net: core: print the source of the MAC address Olliver Schinagl
2017-05-30 21:11   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 14/28] net: cosmetic: A MAC address is not limited to SROM Olliver Schinagl
2017-05-15 12:53   ` Tom Rini
2017-05-15 13:23     ` Olliver Schinagl
2017-05-30 21:12     ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 15/28] net: core: Check return value of read_rom_hwaddr Olliver Schinagl
2017-05-15 12:49   ` Tom Rini
2017-05-30 21:13   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 16/28] fdt: fixup_eth: Remove code duplication with a function Olliver Schinagl
2017-05-30 21:14   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 17/28] fdt: fixup_eth: improve error catching/reduce identation Olliver Schinagl
2017-05-30 21:15   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 18/28] arm: sunxi: Expose function to generate sunxi-specific a MAC address Olliver Schinagl
2017-05-30 21:19   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 19/28] net: sunxi_emac: Write HW address via net_ops hook Olliver Schinagl
2017-05-30 21:20   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 20/28] net: sunxi: Rename sunxi_emac to a more specific sun4i_mac Olliver Schinagl
2017-05-15  8:20   ` Maxime Ripard
2017-05-15  8:02 ` [U-Boot] [PATCHv6 21/28] net: sunxi: Have sunxi common functions together Olliver Schinagl
2017-05-30 21:22   ` Joe Hershberger
2017-05-30 21:24   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 22/28] net: sun4i_mac: Add read_rom_hwaddr hook Olliver Schinagl
2017-05-30 21:26   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 23/28] net: sun7i_mac: Make the sun7i a dw driver subclass Olliver Schinagl
2017-05-15  8:22   ` Maxime Ripard
2017-05-15  8:02 ` [U-Boot] [PATCHv6 24/28] net: dw: Expose designware_eth_start Olliver Schinagl
2017-05-17  1:38   ` Simon Glass
2017-05-30 19:36   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 25/28] net: sun7i_mac: Add read_rom_hwaddr hook Olliver Schinagl
2017-05-15  8:22   ` Maxime Ripard
2017-05-15 12:20     ` Olliver Schinagl
2017-05-16 12:17       ` Maxime Ripard
2017-05-15  8:02 ` [U-Boot] [PATCHv6 26/28] net: sun8i_gmac: " Olliver Schinagl
2017-05-15  8:02 ` [U-Boot] [PATCHv6 27/28] net: sun8i: fix whitespace Olliver Schinagl
2017-05-30 21:30   ` Joe Hershberger
2017-05-15  8:02 ` [U-Boot] [PATCHv6 28/28] net: sunxi: Enable eeprom on OLinuXino Lime boards (again) Olliver Schinagl
2017-05-30 21:30   ` Joe Hershberger
2017-05-15  8:09 ` Olliver Schinagl [this message]
2017-05-15 12:47   ` [U-Boot] [PATCHv6 00/28] Retrieve MAC address from EEPROM Tom Rini
2017-08-11 11:35     ` Jagan Teki
2017-08-11 12:17 ` [U-Boot] [linux-sunxi] " Vincent Legoll

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34fd744e-14cd-3ec1-473a-f20ca1caa075@schinagl.nl \
    --to=oliver@schinagl.nl \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.