* Consistent MAC address for Beagleboard xM @ 2010-10-28 3:39 Matt Johnson 2010-10-28 3:39 ` [PATCH] linux-omap-2.6.36rc -- Consistent MAC address for BeagleBoard xM Matt Johnson 0 siblings, 1 reply; 3+ messages in thread From: Matt Johnson @ 2010-10-28 3:39 UTC (permalink / raw) To: openembedded-devel Sorry about the previous 2 emails, didn't know how the text file mapped to the email. Let me know if the code or the patch submission need to be improved. Two potential improvements I've thought about are checking for a BeagleBoard xM instead of just CONFIG_MACH_OMAP_BEAGLE and making the MAC out of a cryptographically-sound hash, rather than the raw die ID bits, in case those bits give away too much. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] linux-omap-2.6.36rc -- Consistent MAC address for BeagleBoard xM 2010-10-28 3:39 Consistent MAC address for Beagleboard xM Matt Johnson @ 2010-10-28 3:39 ` Matt Johnson 2010-10-28 4:50 ` Khem Raj 0 siblings, 1 reply; 3+ messages in thread From: Matt Johnson @ 2010-10-28 3:39 UTC (permalink / raw) To: openembedded-devel Adding a patch to linux-omap-2.6.36rc for beagleboard. Patch is adapted from one submitted by Mark Crichton to the Beagleboard Google Group (see http://groups.google.com/group/beagleboard/browse_thread/thread/92d41bb344f8939b?fwc=1). BeagleBoard xM now uses the OMAP's die ID as a MAC instead of generating a random one (since it doesn't have an EEPROM to store it), so you have a consistent MAC across boots. Signed-off-by: Matt Johnson <johnso87@crhc.illinois.edu> --- ...e-beagleboard-xm-a-consistent-MAC-address.patch | 82 ++++++++++++++++++++ recipes/linux/linux-omap_2.6.36rc.bb | 1 + 2 files changed, 83 insertions(+), 0 deletions(-) create mode 100644 recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch diff --git a/recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch b/recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch new file mode 100644 index 0000000..0526e0d --- /dev/null +++ b/recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch @@ -0,0 +1,82 @@ +From 60ec781c775e8413ef8ca521b63a07ba9ed2f4aa Mon Sep 17 00:00:00 2001 +From: Matt Johnson <johnso87@crhc.illinois.edu> +Date: Wed, 27 Oct 2010 22:17:36 -0500 +Subject: [PATCH] Give BeagleBoard xM a consistent MAC address + + Adapting the patch submitted by Mark Crichton to the Beagleboard Google Group + (see http://groups.google.com/group/beagleboard/browse_thread/thread/92d41bb344f8939b?fwc=1) + The Beagleboard xM includes an smsc95xx ethernet interface attached to the DM3730 via USB. + The Beagleboard lacks an EEPROM to store the MAC address, so the driver generates a random + MAC address on every boot. This patch instead uses the OMAP's die ID as the MAC address + (modifying a couple bits to make it a valid MAC), so that the MAC is consistent across boots. + A consistent MAC is important if the Beagleboard is to be used on a network with MAC filtering + and/or static IP addresses. + + Signed-off-by: Matt Johnson <johnso87@crhc.illinois.edu> + +--- + drivers/net/usb/smsc95xx.c | 36 +++++++++++++++++++++++++++++++++++- + 1 files changed, 35 insertions(+), 1 deletions(-) + +diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c +index 12a3c88..1219bb6 100644 +--- a/drivers/net/usb/smsc95xx.c ++++ b/drivers/net/usb/smsc95xx.c +@@ -29,6 +29,9 @@ + #include <linux/crc32.h> + #include <linux/usb/usbnet.h> + #include <linux/slab.h> ++#if defined (CONFIG_MACH_OMAP_BEAGLE) ++#include <mach/id.h> ++#endif + #include "smsc95xx.h" + + #define SMSC_CHIPNAME "smsc95xx" +@@ -639,6 +642,14 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) + + static void smsc95xx_init_mac_address(struct usbnet *dev) + { ++#if defined (CONFIG_MACH_OMAP3_BEAGLE) ++ u32 i; ++ struct omap_die_id odi; ++ union { ++ u32 idi[2]; ++ u8 id[8]; ++ } cpu; ++#endif + /* try reading mac address from EEPROM */ + if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, + dev->net->dev_addr) == 0) { +@@ -648,7 +659,30 @@ static void smsc95xx_init_mac_address(struct usbnet *dev) + return; + } + } +- ++#if defined (CONFIG_MACH_OMAP3_BEAGLE) ++ /* The BeagleBoard xM has a smsm95xx, but no EEPROM. */ ++ /* Rather than just come up with a random MAC address, we'll */ ++ /* Use a hash of our DM3730's die ID, so at least it's consistent */ ++ /* between boots. */ ++ ++ /* Look at section 1.5.2 of DM3730 documentation */ ++ omap_get_die_id(&odi); ++ cpu.idi[0] = odi.id_0; ++ cpu.idi[1] = odi.id_1; ++ /* Now interpret the die id as a MAC address */ ++ /* We need to clear the multicast bit */ ++ cpu.id[0] &= 0xfe; ++ /* Set local assignment bit (IEEE802) */ ++ cpu.id[1] |= 0x02; ++ ++ for(i = 0; i < ETH_ALEN; i++) { ++ dev->net->dev_addr[i] = cpu.id[i]; ++ } ++ //TODO: Do error checking, etc. on die_id. ++ //TODO: Allow the user to set MAC after boot. ++ //TODO: Allow user to select whether they want this behavior or not */ ++ return; ++#endif + /* no eeprom, or eeprom values are invalid. generate random MAC */ + random_ether_addr(dev->net->dev_addr); + netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr\n"); +-- +1.6.3.3 + diff --git a/recipes/linux/linux-omap_2.6.36rc.bb b/recipes/linux/linux-omap_2.6.36rc.bb index 64200e1..c79ffa9 100644 --- a/recipes/linux/linux-omap_2.6.36rc.bb +++ b/recipes/linux/linux-omap_2.6.36rc.bb @@ -25,6 +25,7 @@ SRC_URI_append = " \ file://0005-mmc-don-t-display-single-block-read-console-messages.patch \ file://0006-MTD-silence-ecc-errors-on-mtdblock0.patch \ file://0007-OMAP-DSS2-OMAPFB-use-phys_to_virt-for-RAM-mappings.patch \ + file://0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch \ " SRC_URI_append_beagleboard = " file://logo_linux_clut224.ppm \ -- 1.6.3.3 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] linux-omap-2.6.36rc -- Consistent MAC address for BeagleBoard xM 2010-10-28 3:39 ` [PATCH] linux-omap-2.6.36rc -- Consistent MAC address for BeagleBoard xM Matt Johnson @ 2010-10-28 4:50 ` Khem Raj 0 siblings, 0 replies; 3+ messages in thread From: Khem Raj @ 2010-10-28 4:50 UTC (permalink / raw) To: openembedded-devel On (27/10/10 22:39), Matt Johnson wrote: > Adding a patch to linux-omap-2.6.36rc for beagleboard. Patch is adapted > from one submitted by Mark Crichton to the Beagleboard Google Group > (see http://groups.google.com/group/beagleboard/browse_thread/thread/92d41bb344f8939b?fwc=1). > BeagleBoard xM now uses the OMAP's die ID as a MAC instead of generating a random one > (since it doesn't have an EEPROM to store it), so you have a consistent MAC across boots. > > Signed-off-by: Matt Johnson <johnso87@crhc.illinois.edu> Thank you for your contribution. Your patch looks good however you need to bump the PR for the recipe. Please resend the patch with PR update included Thanks -Khem > > --- > ...e-beagleboard-xm-a-consistent-MAC-address.patch | 82 ++++++++++++++++++++ > recipes/linux/linux-omap_2.6.36rc.bb | 1 + > 2 files changed, 83 insertions(+), 0 deletions(-) > create mode 100644 recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch > > diff --git a/recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch b/recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch > new file mode 100644 > index 0000000..0526e0d > --- /dev/null > +++ b/recipes/linux/linux-omap-2.6.36rc/0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch > @@ -0,0 +1,82 @@ > +From 60ec781c775e8413ef8ca521b63a07ba9ed2f4aa Mon Sep 17 00:00:00 2001 > +From: Matt Johnson <johnso87@crhc.illinois.edu> > +Date: Wed, 27 Oct 2010 22:17:36 -0500 > +Subject: [PATCH] Give BeagleBoard xM a consistent MAC address > + > + Adapting the patch submitted by Mark Crichton to the Beagleboard Google Group > + (see http://groups.google.com/group/beagleboard/browse_thread/thread/92d41bb344f8939b?fwc=1) > + The Beagleboard xM includes an smsc95xx ethernet interface attached to the DM3730 via USB. > + The Beagleboard lacks an EEPROM to store the MAC address, so the driver generates a random > + MAC address on every boot. This patch instead uses the OMAP's die ID as the MAC address > + (modifying a couple bits to make it a valid MAC), so that the MAC is consistent across boots. > + A consistent MAC is important if the Beagleboard is to be used on a network with MAC filtering > + and/or static IP addresses. > + > + Signed-off-by: Matt Johnson <johnso87@crhc.illinois.edu> > + > +--- > + drivers/net/usb/smsc95xx.c | 36 +++++++++++++++++++++++++++++++++++- > + 1 files changed, 35 insertions(+), 1 deletions(-) > + > +diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c > +index 12a3c88..1219bb6 100644 > +--- a/drivers/net/usb/smsc95xx.c > ++++ b/drivers/net/usb/smsc95xx.c > +@@ -29,6 +29,9 @@ > + #include <linux/crc32.h> > + #include <linux/usb/usbnet.h> > + #include <linux/slab.h> > ++#if defined (CONFIG_MACH_OMAP_BEAGLE) > ++#include <mach/id.h> > ++#endif > + #include "smsc95xx.h" > + > + #define SMSC_CHIPNAME "smsc95xx" > +@@ -639,6 +642,14 @@ static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) > + > + static void smsc95xx_init_mac_address(struct usbnet *dev) > + { > ++#if defined (CONFIG_MACH_OMAP3_BEAGLE) > ++ u32 i; > ++ struct omap_die_id odi; > ++ union { > ++ u32 idi[2]; > ++ u8 id[8]; > ++ } cpu; > ++#endif > + /* try reading mac address from EEPROM */ > + if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, > + dev->net->dev_addr) == 0) { > +@@ -648,7 +659,30 @@ static void smsc95xx_init_mac_address(struct usbnet *dev) > + return; > + } > + } > +- > ++#if defined (CONFIG_MACH_OMAP3_BEAGLE) > ++ /* The BeagleBoard xM has a smsm95xx, but no EEPROM. */ > ++ /* Rather than just come up with a random MAC address, we'll */ > ++ /* Use a hash of our DM3730's die ID, so at least it's consistent */ > ++ /* between boots. */ > ++ > ++ /* Look at section 1.5.2 of DM3730 documentation */ > ++ omap_get_die_id(&odi); > ++ cpu.idi[0] = odi.id_0; > ++ cpu.idi[1] = odi.id_1; > ++ /* Now interpret the die id as a MAC address */ > ++ /* We need to clear the multicast bit */ > ++ cpu.id[0] &= 0xfe; > ++ /* Set local assignment bit (IEEE802) */ > ++ cpu.id[1] |= 0x02; > ++ > ++ for(i = 0; i < ETH_ALEN; i++) { > ++ dev->net->dev_addr[i] = cpu.id[i]; > ++ } > ++ //TODO: Do error checking, etc. on die_id. > ++ //TODO: Allow the user to set MAC after boot. > ++ //TODO: Allow user to select whether they want this behavior or not */ > ++ return; > ++#endif > + /* no eeprom, or eeprom values are invalid. generate random MAC */ > + random_ether_addr(dev->net->dev_addr); > + netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr\n"); > +-- > +1.6.3.3 > + > diff --git a/recipes/linux/linux-omap_2.6.36rc.bb b/recipes/linux/linux-omap_2.6.36rc.bb > index 64200e1..c79ffa9 100644 > --- a/recipes/linux/linux-omap_2.6.36rc.bb > +++ b/recipes/linux/linux-omap_2.6.36rc.bb > @@ -25,6 +25,7 @@ SRC_URI_append = " \ > file://0005-mmc-don-t-display-single-block-read-console-messages.patch \ > file://0006-MTD-silence-ecc-errors-on-mtdblock0.patch \ > file://0007-OMAP-DSS2-OMAPFB-use-phys_to_virt-for-RAM-mappings.patch \ > + file://0008-give-the-beagleboard-xm-a-consistent-MAC-address.patch \ > " > > SRC_URI_append_beagleboard = " file://logo_linux_clut224.ppm \ > -- > 1.6.3.3 > > > _______________________________________________ > Openembedded-devel mailing list > Openembedded-devel@lists.openembedded.org > http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-10-28 4:51 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-10-28 3:39 Consistent MAC address for Beagleboard xM Matt Johnson 2010-10-28 3:39 ` [PATCH] linux-omap-2.6.36rc -- Consistent MAC address for BeagleBoard xM Matt Johnson 2010-10-28 4:50 ` Khem Raj
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.