Retrieve MAC address from EEPROM
Subsystems (2)
cover Retrieve MAC address from EEPROM
From: Olliver Schinagl <[email protected]>
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. I know there is probably a thing or two that might needed to be changed to make the concept apply in a more generic way.
The reason we might want to read the MAC address from an EEPROM instead of storing the entire environment is mostly a size thing. Our default environment already is bigger then the EEPROM so it is understandable that someone might not give up the entire eeprom just for the u-boot environment. Especially if only board specific things might be stored in the eeprom (MAC, serial, product number etc).
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 and identifier byte to indicate the interface the MAC is applicable too, 0x00 - 0xFE to indicate ethernet interface 0 to 254. 0xFF has special meaning that it does not matter. This bit (no pun intended) is where I am not sure it should be in here at all, but it seemed more logical than simple order based. For example, if there are 2 ethernet devices on a board, eth0 being an internal device, and eth1 being an external facing device and only 1 MAC address per device is allotted, it can seem logical that eth1 gets the MAC address and eth0 gets a randomly chosen MAC address (or whatever the fall back behavior is).
These 7 bytes are then appended with a CRC8 byte and can be optionally checked, although the whole optional-ness could be very well dropped.
Hans de Goede and I talked about retrieving the MAC from the EEPROM for sunxi based boards a while ago, but hopefully this patch makes possible to have something slightly more generic, even if only the configuration option and the EEPROM layout.
Since the Olimex OLinuXino sunxi boards all seem to have an eeprom, I started my work on one of these and tested the implementation with one of our own real MAC addresses.
Features planned for v2, simple tool to write the MAC address to the eeprom from Linux.
Olliver Schinagl (3):
net: Add ability to set MAC address via EEPROM to Kconfig
sunxi: net: Allow the sunxi to set the MAC from an EEPROM
sunxi: net: Enable eeprom on OLinuXino Lime2 boards
board/sunxi/Kconfig | 4 +++ board/sunxi/board.c | 36 +++++++++++++++++++++ configs/A20-OLinuXino-Lime2_defconfig | 3 ++ doc/README.enetaddr | 36 +++++++++++++++++++++ net/Kconfig | 59 +++++++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+)
Signature · 1 line
2.6.2
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
From: Olliver Schinagl <[email protected]>
This patch allows Kconfig to enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.
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.
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)
doc/README.enetaddr +36 -0
@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address (summarized): Previous behavior had the MAC address always being programmed into hardware in the device's init() function. +-------- + EEPROM +-------- + +When there is an EEPROM available on a board, but the EEPROM is not large enough +to store the whole environment, it may be desired to store a MAC address in the +onboard EEPROM. Using CONFIG_NET_ETHADDR_EEPROM enables this feature. Depending +on the board, the EEPROM may be connected on various methods, but currently, +only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom is present and +CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally use single byte +addressing but larger EEPROM's may use double byte addressing, which can be +configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitrary offset, +CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however, allowing +the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte field to indicate +the ID of the network interface this MAC address is for. 0xff here means 'for +the first available interface' and 0x00 means the first network interface, 0x01 +the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byte over the +previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0 |!Magic.!.#Eg....| + +where the Header magic (!Magic.!) is spread over the first 8 bytes, and the MAC +address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8 +checksum 0xc0. + ------- Usage -------
net/Kconfig +58 -0
64 lines not on this page · raw message
Signature · 1 line
2.6.2
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
Hi Olliver and Joe,
Quoted 15 lines · Oliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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).
Quoted 8 lines
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_SPIcan be just as created.Signed-off-by Olliver Schinagl <[email protected]>
Thanks, from a sunxi pov this and the other 2 patches look good.
Joe can we have your ack for this one please and/or can you merge this one through your tree? Either way I will take care of the other 2 patches in this set.
From my pov this is fine as v2016.01 material, but if you would
rather postpone this to v2016.04 that is fine too.
Thanks & Regards,
Hans
Quoted 122 lines
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)doc/README.enetaddr +36
-0@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address (summarized): Previous behavior had the MAC address always being programmed into hardware in the device's init() function. +-------- + EEPROM +-------- + +When there is an EEPROM available on a board, but the EEPROM is not large enough +to store the whole environment, it may be desired to store a MAC address in the +onboard EEPROM. Using CONFIG_NET_ETHADDR_EEPROM enables this feature. Depending +on the board, the EEPROM may be connected on various methods, but currently, +only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom is present and +CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally use single byte +addressing but larger EEPROM's may use double byte addressing, which can be +configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitrary offset, +CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however, allowing +the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte field to indicate +the ID of the network interface this MAC address is for. 0xff here means 'for +the first available interface' and 0x00 means the first network interface, 0x01 +the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byte over the +previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0 |!Magic.!.#Eg....| + +where the Header magic (!Magic.!) is spread over the first 8 bytes, and the MAC +address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8 +checksum 0xc0. + ------- Usage -------net/Kconfig +58
-0@@ -7,6 +7,64 @@ menuconfig NET if NET +config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from an onboard + EEPROM and set into the environment if and only if the environment + does currently not already hold a MAC address. For more information + see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus. Naturally + this will only work if there is an actual EEPROM connected on the + I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus 0. + +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "eeprom address" + default 0x50 + help + Select the address of the eeprom, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "eeprom address length" + default 1 + help + Number of bytes to be used for the I2C address length. Typically 1, + 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + int "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byte append. + This option enables the CRC check of the MAC address against the CRC + byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
Hans, Joe,
Quoted 25 lines · Hans de Goede
Hi Olliver and Joe,
Quoted 22 lines · Oliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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_SPIcan be just as created.
Quoted 7 lines
Quoted 1 line
Signed-off-by Olliver Schinagl <[email protected]>Thanks, from a sunxi pov this and the other 2 patches look good.
Joe can we have your ack for this one please and/or can you merge this one through your tree? Either way I will take care of the other 2 patches in this set.
I do intend to make a v2 and one of the things I hoped would bring up some discussion is wether to do the CRC with or without the interface ID. In this patch I calculate the CRC on 7 bytes, MAC + id, but I kinda went back on that and do a mac + crc + id.
Since nobody commented before, I haven't sent the v2 just yet (which will include a generator tool).
Any thoughts before merging this on that subject?
Olliver
Quoted 157 lines
From my pov this is fine as v2016.01 material, but if you would rather postpone this to v2016.04 that is fine too.
Thanks & Regards,
Hans
Quoted 148 lines
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)doc/README.enetaddr +0
-0@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address(summarized):
Previous behavior had the MAC address always being programmed into
hardware
in the device'sinit()function.+--------
+ EEPROM
+--------doc/README.enetaddr +2
-0+ +When there is an EEPROM available on a board, but the EEPROM is notlarge enough
+to store the whole environment, it may be desired to store a MAC address in the
+onboard EEPROM. UsingCONFIG_NET_ETHADDR_EEPROMenables this feature. Depending
+on the board, the EEPROM may be connected on various methods, but currently,doc/README.enetaddr +2
-0+only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom ispresent and
doc/README.enetaddr +2
-0+CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally usesingle byte
+addressing but larger EEPROM's may use double byte addressing, which can bedoc/README.enetaddr +3
-0+configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitraryoffset,
+CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however, allowingdoc/README.enetaddr +3
-0+the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte fieldto indicate
+the ID of the network interface this MAC address is for.0xffhere means 'for
+the first available interface' and0x00means the first network interface,0x01doc/README.enetaddr +3
-0+the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byteover the
doc/README.enetaddr +6
-0+previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0|!Magic.!.#Eg....|
doc/README.enetaddr +2
-0+ +where the Header magic (!Magic.!) is spread over the first 8 bytes,and the MAC
+address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8doc/README.enetaddr +2
-0+checksum 0xc0. + ------- Usage -------net/Kconfig +4
-0@@ -7,6 +7,64 @@ menuconfig NET if NET +config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from anonboard
+ EEPROM and set into the environment if and only if the
environment
+ does currently not already hold a MAC address. For more
informationnet/Kconfig +7
-0+ see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus.Naturally
net/Kconfig +24
-0+ this will only work if there is an actual EEPROM connected on the + I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus 0. + +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "eeprom address" + default 0x50 + help + Select the address of the eeprom, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "eeprom address length" + default 1 + help + Number of bytes to be used for the I2C address length.Typically 1,
net/Kconfig +18
-0+ 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + int "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byteappend.
+ This option enables the CRC check of the MAC address against
the CRCnet/Kconfig +2
-0+ byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND
Signature · 6 lines
Met vriendelijke groeten, Kind regards, ?????? Olliver Schinagl Software Engineer Research & Development Ultimaker B.V.
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
Hi Olliver,
Quoted 45 lines · Olliver Schinagl
Hans, Joe,
Quoted 27 lines · Hans de Goede
Hi Olliver and Joe,
Quoted 23 lines · Oliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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_SPIcan be just as created.Quoted 8 lines
Quoted 1 line
Signed-off-by Olliver Schinagl <[email protected]>Thanks, from a sunxi pov this and the other 2 patches look good.
Joe can we have your ack for this one please and/or can you merge this one through your tree? Either way I will take care of the other 2 patches in this set.
I do intend to make a v2 and one of the things I hoped would bring up some discussion is wether to do the CRC with or without the interface ID. In this patch I calculate the CRC on 7 bytes, MAC + id, but I kinda went back on that and do a mac + crc + id.
Quoted 4 lines
Since nobody commented before, I haven't sent the v2 just yet (which will include a generator tool).
Any thoughts before merging this on that subject?
Seems to me that if you are worried about the integrity of the MAC address in EEPROM, then the interface number is just as important to check for integrity.
Quoted 168 lines
Quoted 146 lines
From my pov this is fine as v2016.01 material, but if you would rather postpone this to v2016.04 that is fine too.
Thanks & Regards,
Hans
Quoted 137 lines
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)doc/README.enetaddr +0
-0@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address(summarized):
Previous behavior had the MAC address always being programmed into
hardware
in the device'sinit()function.+--------
+ EEPROM
+--------doc/README.enetaddr +2
-0+ +When there is an EEPROM available on a board, but the EEPROM is notlarge enough
+to store the whole environment, it may be desired to store a MAC address in the
+onboard EEPROM. UsingCONFIG_NET_ETHADDR_EEPROMenables this feature. Depending
+on the board, the EEPROM may be connected on various methods, but currently,doc/README.enetaddr +2
-0+only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom is presentand
doc/README.enetaddr +2
-0+CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally usesingle byte
+addressing but larger EEPROM's may use double byte addressing, which can bedoc/README.enetaddr +3
-0+configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitraryoffset,
+CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however, allowingdoc/README.enetaddr +3
-0+the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte field toindicate
+the ID of the network interface this MAC address is for.0xffhere means 'for
+the first available interface' and0x00means the first network interface,0x01doc/README.enetaddr +3
-0+the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byte overthe
doc/README.enetaddr +6
-0+previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0|!Magic.!.#Eg....|
doc/README.enetaddr +2
-0+ +where the Header magic (!Magic.!) is spread over the first 8 bytes, andthe MAC
doc/README.enetaddr +3
-0+address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8 +checksum 0xc0. + ------- Usage -------net/Kconfig +4
-0@@ -7,6 +7,64 @@ menuconfig NET if NET +config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from anonboard
net/Kconfig +2
-0+ EEPROM and set into the environment if and only if the environment + does currently not already hold a MAC address. For moreinformation
net/Kconfig +31
-0+ see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus. Naturally + this will only work if there is an actual EEPROM connected on the + I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus 0. + +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "eeprom address" + default 0x50 + help + Select the address of the eeprom, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "eeprom address length" + default 1 + help + Number of bytes to be used for the I2C address length. Typically1,
net/Kconfig +18
-0+ 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + int "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byteappend.
Quoted 8 lines
net/Kconfig menuconfig NET · line 70
Quoted 8 lines
+ This option enables the CRC check of the MAC address against the
CRCnet/Kconfig +2
-0+ byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND--
Met vriendelijke groeten, Kind regards, ??????Olliver Schinagl
Software Engineer
Research & Development
Ultimaker B.V._______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
Hey Joe,
Quoted 45 lines · Joe Hershberger
Hi Olliver,
Quoted 41 lines · Olliver Schinagl
Hans, Joe,
Quoted 25 lines · Hans de Goede
Hi Olliver and Joe,
Quoted 22 lines · Oliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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_SPIcan be just as created.Quoted 7 lines
Quoted 1 line
Signed-off-by Olliver Schinagl <[email protected]>Thanks, from a sunxi pov this and the other 2 patches look good.
Joe can we have your ack for this one please and/or can you merge this one through your tree? Either way I will take care of the other 2 patches in this set.
I do intend to make a v2 and one of the things I hoped would bring up some discussion is wether to do the CRC with or without the interface ID. In this patch I calculate the CRC on 7 bytes, MAC + id, but I kinda went back on that and do a mac + crc + id.
Quoted 7 lines
Quoted 4 lines
Since nobody commented before, I haven't sent the v2 just yet (which will include a generator tool).
Any thoughts before merging this on that subject?
Seems to me that if you are worried about the integrity of the MAC address in EEPROM, then the interface number is just as important to check for integrity.
I'm not worried about the EEPROM failing etc, I'm worried about user error. A user may knowingly want to change the ID (via u-boot i2c-cmd's or via linux by writing the eeprom), so protect the eeprom from accidental fudging. Also generating macs + crc is trivial, but then you may have to change it all again when you change the ID (shuffle mac's around interfaces on boards).
I'll send the v2 now though.
Olliver
Quoted 167 lines
Quoted 167 lines
Quoted 146 lines
From my pov this is fine as v2016.01 material, but if you would
rather postpone this to v2016.04 that is fine too.Thanks & Regards,
Hans
Quoted 137 lines
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)doc/README.enetaddr +0
-0@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address(summarized):
Previous behavior had the MAC address always being programmed into
hardware
in the device'sinit()function.+--------
+ EEPROM
+--------doc/README.enetaddr +2
-0+ +When there is an EEPROM available on a board, but the EEPROM is notlarge enough
+to store the whole environment, it may be desired to store a MAC address in the
+onboard EEPROM. UsingCONFIG_NET_ETHADDR_EEPROMenables this feature. Depending
+on the board, the EEPROM may be connected on various methods, but currently,doc/README.enetaddr +2
-0+only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom is presentand
doc/README.enetaddr +2
-0+CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally usesingle byte
+addressing but larger EEPROM's may use double byte addressing, which can bedoc/README.enetaddr +3
-0+configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitraryoffset,
+CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however, allowingdoc/README.enetaddr +3
-0+the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte field toindicate
+the ID of the network interface this MAC address is for.0xffhere means 'for
+the first available interface' and0x00means the first network interface,0x01doc/README.enetaddr +3
-0+the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byte overthe
doc/README.enetaddr +6
-0+previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0|!Magic.!.#Eg....|
doc/README.enetaddr +2
-0+ +where the Header magic (!Magic.!) is spread over the first 8 bytes, andthe MAC
doc/README.enetaddr +3
-0+address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8 +checksum 0xc0. + ------- Usage -------net/Kconfig +4
-0@@ -7,6 +7,64 @@ menuconfig NET if NET +config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from anonboard
net/Kconfig +2
-0+ EEPROM and set into the environment if and only if the environment + does currently not already hold a MAC address. For moreinformation
net/Kconfig +31
-0+ see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus. Naturally + this will only work if there is an actual EEPROM connected on the + I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus 0. + +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "eeprom address" + default 0x50 + help + Select the address of the eeprom, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "eeprom address length" + default 1 + help + Number of bytes to be used for the I2C address length. Typically1,
net/Kconfig +18
-0+ 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + int "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byteappend.
Quoted 8 lines
net/Kconfig menuconfig NET · line 70
Quoted 8 lines
+ This option enables the CRC check of the MAC address against the
CRCnet/Kconfig +2
-0+ byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND--
Met vriendelijke groeten, Kind regards, ??????Olliver Schinagl
Software Engineer
Research & Development
Ultimaker B.V._______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Signature · 6 lines
Met vriendelijke groeten, Kind regards, ?????? Olliver Schinagl Software Engineer Research & Development Ultimaker B.V.
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
In reply to Hans de GoedeHi Hans,
Quoted 26 lines · Hans de Goede
Hi Olliver and Joe,
Quoted 23 lines · Oliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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_SPIcan be just as created.
Quoted 8 lines
Quoted 1 line
Signed-off-by Olliver Schinagl <[email protected]>Thanks, from a sunxi pov this and the other 2 patches look good.
Joe can we have your ack for this one please and/or can you merge this one through your tree? Either way I will take care of the other 2 patches in this set.
I'm fine either way. I'm thinking I'll be pulling anything assigned to me in patchwork next week.
Quoted 2 lines
From my pov this is fine as v2016.01 material, but if you would rather postpone this to v2016.04 that is fine too.
Seems safe enough. v2016.01 is fine with me.
Quoted 158 lines
Thanks & Regards,
Hans
Quoted 143 lines
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)doc/README.enetaddr +0
-0@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address(summarized):
Previous behavior had the MAC address always being programmed into
hardware
in the device'sinit()function.+--------
+ EEPROM
+--------doc/README.enetaddr +2
-0+ +When there is an EEPROM available on a board, but the EEPROM is not largeenough
+to store the whole environment, it may be desired to store a MAC address in the
+onboard EEPROM. UsingCONFIG_NET_ETHADDR_EEPROMenables this feature. Depending
+on the board, the EEPROM may be connected on various methods, but currently,doc/README.enetaddr +2
-0+only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom is presentand
doc/README.enetaddr +2
-0+CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally usesingle byte
+addressing but larger EEPROM's may use double byte addressing, which can bedoc/README.enetaddr +4
-0+configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitrary offset, +CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however,allowing
doc/README.enetaddr +3
-0+the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte field toindicate
+the ID of the network interface this MAC address is for.0xffhere means 'for
+the first available interface' and0x00means the first network interface,0x01doc/README.enetaddr +3
-0+the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byte overthe
doc/README.enetaddr +6
-0+previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0|!Magic.!.#Eg....|
doc/README.enetaddr +2
-0+ +where the Header magic (!Magic.!) is spread over the first 8 bytes, andthe MAC
doc/README.enetaddr +3
-0+address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8 +checksum 0xc0. + ------- Usage -------net/Kconfig +4
-0@@ -7,6 +7,64 @@ menuconfig NET if NET +config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from anonboard
+ EEPROM and set into the environment if and only if the
environment
+ does currently not already hold a MAC address. For more
informationnet/Kconfig +7
-0+ see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus.Naturally
+ this will only work if there is an actual EEPROM connected on
thenet/Kconfig +9
-0+ I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus0.
net/Kconfig +14
-0+ +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "eeprom address" + default 0x50 + help + Select the address of the eeprom, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "eeprom address length" + default 1 + help + Number of bytes to be used for the I2C address length. Typically1,
net/Kconfig +18
-0+ 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + int "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byteappend.
+ This option enables the CRC check of the MAC address against the
CRCnet/Kconfig menuconfig NET · line 70
Quoted 5 lines
net/Kconfig +2
-0+ byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
Hi,
Quoted 32 lines · Joe Hershberger
Hi Hans,
Quoted 29 lines · Hans de Goede
Hi Olliver and Joe,
Quoted 24 lines · Oliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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_SPIcan be just as created.Signed-off-by Olliver Schinagl <[email protected]>
Quoted 8 lines
Quoted 5 lines
Thanks, from a sunxi pov this and the other 2 patches look good.
Joe can we have your ack for this one please and/or can you merge this one through your tree? Either way I will take care of the other 2 patches in this set.
I'm fine either way. I'm thinking I'll be pulling anything assigned to me in patchwork next week.
Ok, Olliver if you can get a v2 to Joe before next week then he can pick that one up, and then I'll merge the other 2 after the v2 of this one has been merged.
Regards,
Hans
Quoted 164 lines
Quoted 3 lines
From my pov this is fine as v2016.01 material, but if you would
rather postpone this to v2016.04 that is fine too.Seems safe enough. v2016.01 is fine with me.
Quoted 158 lines
Thanks & Regards,
Hans
Quoted 143 lines
--- doc/README.enetaddr | 36 +++++++++++++++++++++++++++++++++ net/Kconfig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+)doc/README.enetaddr +0
-0@@ -47,6 +47,42 @@ Correct flow of setting up the MAC address(summarized):
Previous behavior had the MAC address always being programmed into
hardware
in the device'sinit()function.+--------
+ EEPROM
+--------doc/README.enetaddr +2
-0+ +When there is an EEPROM available on a board, but the EEPROM is not largeenough
+to store the whole environment, it may be desired to store a MAC address in the
+onboard EEPROM. UsingCONFIG_NET_ETHADDR_EEPROMenables this feature. Depending
+on the board, the EEPROM may be connected on various methods, but currently,doc/README.enetaddr +2
-0+only the I2C bus is available via CONFIG_NET_ETHADDR_EEPROM_I2C. +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS I2C bus on which the eeprom is presentand
doc/README.enetaddr +2
-0+CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR set the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally usesingle byte
+addressing but larger EEPROM's may use double byte addressing, which can bedoc/README.enetaddr +4
-0+configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitrary offset, +CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however,allowing
doc/README.enetaddr +3
-0+the first 8 bytes to be used for some header magic for example. + +After the 6 bytes used for the MAC address, there is an 8 byte field toindicate
+the ID of the network interface this MAC address is for.0xffhere means 'for
+the first available interface' and0x00means the first network interface,0x01doc/README.enetaddr +3
-0+the second, etc. It is up to the platform however to enforce this. + +Appending the 6 MAC bytes and the 7th interface byte is a CRC8 byte overthe
doc/README.enetaddr +6
-0+previous 7 bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +Layout example: + +00000000 21 4d 61 67 69 63 2e 21 01 23 45 67 89 ab ff c0|!Magic.!.#Eg....|
doc/README.enetaddr +2
-0+ +where the Header magic (!Magic.!) is spread over the first 8 bytes, andthe MAC
doc/README.enetaddr +3
-0+address '01-23-45-67-89-ab' for the first interface (0xff) with the CRC8 +checksum 0xc0. + ------- Usage -------net/Kconfig +4
-0@@ -7,6 +7,64 @@ menuconfig NET if NET +config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from anonboard
+ EEPROM and set into the environment if and only if the
environment
+ does currently not already hold a MAC address. For more
informationnet/Kconfig +7
-0+ see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus.Naturally
+ this will only work if there is an actual EEPROM connected on
thenet/Kconfig +9
-0+ I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus0.
net/Kconfig +14
-0+ +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "eeprom address" + default 0x50 + help + Select the address of the eeprom, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "eeprom address length" + default 1 + help + Number of bytes to be used for the I2C address length. Typically1,
net/Kconfig +18
-0+ 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + int "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byteappend.
+ This option enables the CRC check of the MAC address against the
CRCnet/Kconfig menuconfig NET · line 70
Quoted 5 lines
net/Kconfig +2
-0+ byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 1/3 net: Add ability to set MAC address via EEPROM to Kconfig
In reply to Olliver SchinaglQuoted 15 lines · Olliver Schinagl
From: Olliver Schinagl <[email protected]>
This patch allows
Kconfigto enable and set parameters to make it possible to read the MAC address from an EEPROM. This patch only sets up some environment variables, it is up to the specific boards to actually use these defines.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).
Quoted 8 lines
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_SPIcan be just as created.Signed-off-by Olliver Schinagl <[email protected]>
PATCH 2/3 sunxi: net: Allow the sunxi to set the MAC from an EEPROM
In reply to Olliver SchinaglFrom: Olliver Schinagl <[email protected]>
This patch uses the newly introduced Kconfig options to set the MAC address from an EEPROM, this will be especially useful for the Olimex OLinuXino series of sunxi boards as they all have an 2k i2c eeprom chip.
The MAC address is in the eeprom is ignored if there is already a MAC address in the environment or (if enabled) the CRC8 check fails.
--- board/sunxi/Kconfig | 4 ++++ board/sunxi/board.c | 36 ++++++++++++++++++++++++++++++++++++ net/Kconfig | 1 + 3 files changed, 41 insertions(+)
board/sunxi/Kconfig +4 -0
@@ -339,18 +339,21 @@ config I2C0_ENABLE config I2C1_ENABLE bool "Enable I2C/TWI controller 1" + default y if (NET_ETHADDR_EEPROM_I2C_BUS = 1) default n ---help--- See I2C0_ENABLE help text. config I2C2_ENABLE bool "Enable I2C/TWI controller 2" + default y if NET_ETHADDR_EEPROM_I2C_BUS = 2 default n ---help--- See I2C0_ENABLE help text. if MACH_SUN6I || MACH_SUN7I config I2C3_ENABLE + default y if NET_ETHADDR_EEPROM_I2C_BUS = 3 bool "Enable I2C/TWI controller 3" default n ---help---
@@ -359,6 +362,7 @@ endif if MACH_SUN7I config I2C4_ENABLE + default y if NET_ETHADDR_EEPROM_I2C_BUS = 4 bool "Enable I2C/TWI controller 4" default n ---help---
board/sunxi/board.c +36 -0
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <i2c.h> #include <mmc.h> #include <axp_pmic.h> #include <asm/arch/clock.h>
@@ -23,6 +24,7 @@#include <asm/arch/usb_phy.h> #include <asm/gpio.h> #include <asm/io.h> +#include <linux/crc8.h> #include <nand.h> #include <net.h>
@@ -510,6 +512,37 @@ void get_board_serial(struct tag_serialnr *serialnr) }#endif +#if defined(CONFIG_NET_ETHADDR_EEPROM ) && defined(CONFIG_NET_ETHADDR_EEPROM_I2C ) +static int read_mac_from_eeprom (uint8_t *mac_addr) +{ +uint8_t eeprom[8 ]; +int old_i2c_bus; + + old_i2c_bus =i2c_get_bus_num (); +i2c_set_bus_num (CONFIG_NET_ETHADDR_EEPROM_I2C_BUS ); +if (i2c_read (CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR , +CONFIG_NET_ETHADDR_EEPROM_OFFSET , +CONFIG_NET_ETHADDR_EEPROM_I2C_ADDRLEN , + eeprom,8 )) { +i2c_set_bus_num (old_i2c_bus); +puts ("Could not read the EEPROM; EEPROM missing?\n" ); +return -1 ; + } +i2c_set_bus_num (old_i2c_bus); +#ifdef CONFIG_NET_ETHADDR_EEPROM_CRC8 +if (crc8 (eeprom,7 ) != eeprom[7 ]) { +puts ("CRC error on MAC address from EEPROM.\n" ); +return -1 ; + } +#endif +memcpy (mac_addr, eeprom,6 ); + +return 0 ; +} +#else +static int read_mac_from_eeprom (uint8_t *mac_addr) {return -1 ; } +#endif +#if !defined(CONFIG_SPL_BUILD )#include <asm/arch/spl.h>
@@ -553,6 +586,9 @@ int misc_init_r(void) }#endif +if ((!getenv ("ethaddr" )) && (!read_mac_from_eeprom (mac_addr))) +eth_setenv_enetaddr ("ethaddr" , mac_addr); + ret =sunxi_get_sid (sid);if (ret ==0 && sid[0 ] !=0 && sid[3 ] !=0 ) {if (!getenv ("ethaddr" )) {
net/Kconfig +1 -0
@@ -8,6 +8,7 @@ menuconfig NET if NET config NET_ETHADDR_EEPROM + depends on ARCH_SUNXI bool "Get ethaddr from eeprom" help Selecting this will try to get the Ethernet address from an onboard
Signature · 1 line
2.6.2
PATCH 3/3 sunxi: net: Enable eeprom on OLinuXino Lime2 boards
In reply to Olliver SchinaglFrom: Olliver Schinagl <[email protected]>
This patch enables the I2C EEPROM to be probed for a MAC address on the OLinuXino board.
--- configs/A20-OLinuXino-Lime2_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/A20-OLinuXino-Lime2_defconfig +3 -0
@@ -14,4 +14,7 @@ CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,AHCI,SATAPWR=SUNXI_GPC(3)" # CONFIG_CMD_FPGA is not set CONFIG_CMD_GPIO=y CONFIG_ETH_DESIGNWARE=y +CONFIG_NET_ETHADDR_EEPROM=y +CONFIG_NET_ETHADDR_EEPROM_I2C=y +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 CONFIG_USB_EHCI_HCD=y
Signature · 1 line
2.6.2