Message ID | MMXP123MB1376BBFC7E874E415E96D287AC060@MMXP123MB1376.GBRP123.PROD.OUTLOOK.COM |
---|---|
State | Changes Requested |
Delegated to: | Simon Glass |
Headers | show |
Hi Simon, On 2017-04-18 06:01, Simon Glass wrote: > Hi Jonas, > > On 17 April 2017 at 15:13, Jonas Karlman <jonas@kwiboo.se > <mailto:jonas@kwiboo.se>> wrote: > > Set ethernet mac address in late init for Tinker Board, > > prevents getting a random mac address each boot. > > > > Read mac address from eeprom, first 6 bytes from 0x50 on i2c2. > > Same as /etc/init.d/rockchip.sh on Tinker OS. > > > > Signed-off-by: Jonas Karlman <jonas@kwiboo.se <mailto:jonas@kwiboo.se>> > > --- > > > > board/rockchip/tinker_rk3288/tinker-rk3288.c | 26 > ++++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c > b/board/rockchip/tinker_rk3288/tinker-rk3288.c > > index 79541a3939..48165b2545 100644 > > --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c > > +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c > > @@ -5,3 +5,29 @@ > > */ > > > > #include <common.h> > > +#include <i2c.h> > > +#include <netdev.h> > > + > > +int rk_board_late_init(void) > > +{ > > + struct udevice *dev; > > + int ret; > > + u8 mac[6]; > > + > > + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev); > > + if (ret) { > > + debug("failed to get eeprom\n"); > > + return 0; > > + } > > I'm sure this works, but really we should have this chip mentioned in > the device tree under &i2c2. Then we should be able to use the > i2c_eeprom driver. I cannot see this board supported in Linux to figure > out how it does it there. Thanks, I will rework this patch to use the device tree and the i2c_eeprom driver. The device tree for Asus Tinker Board is not yet in mainline linux. This is the eeprom part taken from asus's tinker os device tree: m24c08@50 { compatible = "at,24c08"; reg = <0x50>; }; > > I think tinker is the CHIP board, right? Are there instructions > somewhere on how to load U-Boot onto it? > > > + > > + ret = dm_i2c_read(dev, 0x0, mac, 6); > > + if (ret) { > > + debug("failed to read mac\n"); > > + return 0; > > + } > > + > > + if (is_valid_ethaddr(mac)) > > + eth_setenv_enetaddr("ethaddr", mac); > > + > > + return 0; > > +} > > -- > > 2.11.0 > > > > Regards, > Simon Regards, Jonas
Hi Jonas, On 18 April 2017 at 12:04, Jonas Karlman <jonas@kwiboo.se> wrote: > > Hi Simon, > > On 2017-04-18 06:01, Simon Glass wrote: > > Hi Jonas, > > > > On 17 April 2017 at 15:13, Jonas Karlman <jonas@kwiboo.se > > <mailto:jonas@kwiboo.se>> wrote: > > > Set ethernet mac address in late init for Tinker Board, > > > prevents getting a random mac address each boot. > > > > > > Read mac address from eeprom, first 6 bytes from 0x50 on i2c2. > > > Same as /etc/init.d/rockchip.sh on Tinker OS. > > > > > > Signed-off-by: Jonas Karlman <jonas@kwiboo.se <mailto:jonas@kwiboo.se>> > > > --- > > > > > > board/rockchip/tinker_rk3288/tinker-rk3288.c | 26 > > ++++++++++++++++++++++++++ > > > 1 file changed, 26 insertions(+) > > > > > > diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c > > b/board/rockchip/tinker_rk3288/tinker-rk3288.c > > > index 79541a3939..48165b2545 100644 > > > --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c > > > +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c > > > @@ -5,3 +5,29 @@ > > > */ > > > > > > #include <common.h> > > > +#include <i2c.h> > > > +#include <netdev.h> > > > + > > > +int rk_board_late_init(void) > > > +{ > > > + struct udevice *dev; > > > + int ret; > > > + u8 mac[6]; > > > + > > > + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev); > > > + if (ret) { > > > + debug("failed to get eeprom\n"); > > > + return 0; > > > + } > > > > I'm sure this works, but really we should have this chip mentioned in > > the device tree under &i2c2. Then we should be able to use the > > i2c_eeprom driver. I cannot see this board supported in Linux to figure > > out how it does it there. > > Thanks, I will rework this patch to use the device tree and the > i2c_eeprom driver. > > The device tree for Asus Tinker Board is not yet in mainline linux. > This is the eeprom part taken from asus's tinker os device tree: > > m24c08@50 { > compatible = "at,24c08"; > reg = <0x50>; > }; > OK that's great, thanks. You'll need to add the compatible string to the eeprom driver to make it come up, but hopefully then it will work OK. > > > > I think tinker is the CHIP board, right? Are there instructions > > somewhere on how to load U-Boot onto it? > > > > > + > > > + ret = dm_i2c_read(dev, 0x0, mac, 6); > > > + if (ret) { > > > + debug("failed to read mac\n"); > > > + return 0; > > > + } > > > + > > > + if (is_valid_ethaddr(mac)) > > > + eth_setenv_enetaddr("ethaddr", mac); > > > + > > > + return 0; > > > +} > > > -- > > > 2.11.0 > > > Regards, Simon
Hi Eddie, On 18 April 2017 at 08:53, Eddie Cai <eddie.cai.linux@gmail.com> wrote: > > > 2017-04-18 12:01 GMT+08:00 Simon Glass <sjg@chromium.org>: >> >> Hi Jonas, >> >> On 17 April 2017 at 15:13, Jonas Karlman <jonas@kwiboo.se> wrote: >> > Set ethernet mac address in late init for Tinker Board, >> > prevents getting a random mac address each boot. >> > >> > Read mac address from eeprom, first 6 bytes from 0x50 on i2c2. >> > Same as /etc/init.d/rockchip.sh on Tinker OS. >> > >> > Signed-off-by: Jonas Karlman <jonas@kwiboo.se> >> > --- >> > >> > board/rockchip/tinker_rk3288/tinker-rk3288.c | 26 >> ++++++++++++++++++++++++++ >> > 1 file changed, 26 insertions(+) >> > >> > diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c >> b/board/rockchip/tinker_rk3288/tinker-rk3288.c >> > index 79541a3939..48165b2545 100644 >> > --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c >> > +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c >> > @@ -5,3 +5,29 @@ >> > */ >> > >> > #include <common.h> >> > +#include <i2c.h> >> > +#include <netdev.h> >> > + >> > +int rk_board_late_init(void) >> > +{ >> > + struct udevice *dev; >> > + int ret; >> > + u8 mac[6]; >> > + >> > + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev); >> > + if (ret) { >> > + debug("failed to get eeprom\n"); >> > + return 0; >> > + } >> >> I'm sure this works, but really we should have this chip mentioned in the >> device tree under &i2c2. Then we should be able to use the i2c_eeprom >> driver. I cannot see this board supported in Linux to figure out how it >> does it there. >> >> I think tinker is the CHIP board, right? Are there instructions somewhere >> on how to load U-Boot onto it? > > tinker board is made by Asus. it use sd card as its boot media. to build > U-Boot for tinker board > CROSS_COMPILE=arm-linux-gnueabihf- make tinker-rk3288_defconfig all -j4 > tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl-dtb.bin out > cat u-boot-dtb.bin >> out > to flash u-boot, mount sd card to your host PC. use below command. (please > make sure /dev/sdb is the mount point of your sd card) > sudo dd if=out of=/dev/sdb seek=64 conv=notrunc Thanks for the info, will live it a try. What do you think about doing a patch for README.rockchip with this info? [...] Regards, Simon
Hi Jonas 2017-04-19 2:04 GMT+08:00 Jonas Karlman <jonas@kwiboo.se>: > Hi Simon, > > On 2017-04-18 06:01, Simon Glass wrote: >> Hi Jonas, >> >> On 17 April 2017 at 15:13, Jonas Karlman <jonas@kwiboo.se >> <mailto:jonas@kwiboo.se>> wrote: >> > Set ethernet mac address in late init for Tinker Board, >> > prevents getting a random mac address each boot. >> > >> > Read mac address from eeprom, first 6 bytes from 0x50 on i2c2. >> > Same as /etc/init.d/rockchip.sh on Tinker OS. >> > >> > Signed-off-by: Jonas Karlman <jonas@kwiboo.se <mailto:jonas@kwiboo.se>> >> > --- >> > >> > board/rockchip/tinker_rk3288/tinker-rk3288.c | 26 >> ++++++++++++++++++++++++++ >> > 1 file changed, 26 insertions(+) >> > >> > diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c >> b/board/rockchip/tinker_rk3288/tinker-rk3288.c >> > index 79541a3939..48165b2545 100644 >> > --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c >> > +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c >> > @@ -5,3 +5,29 @@ >> > */ >> > >> > #include <common.h> >> > +#include <i2c.h> >> > +#include <netdev.h> >> > + >> > +int rk_board_late_init(void) >> > +{ >> > + struct udevice *dev; >> > + int ret; >> > + u8 mac[6]; >> > + >> > + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev); >> > + if (ret) { >> > + debug("failed to get eeprom\n"); >> > + return 0; >> > + } >> >> I'm sure this works, but really we should have this chip mentioned in >> the device tree under &i2c2. Then we should be able to use the >> i2c_eeprom driver. I cannot see this board supported in Linux to figure >> out how it does it there. It will be in main line when 4.12 release https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git/commit/?h=v4.12-armsoc/dts32&id=223599514133293bb9afe7b82937140c3b275877 > > Thanks, I will rework this patch to use the device tree and the > i2c_eeprom driver. > > The device tree for Asus Tinker Board is not yet in mainline linux. > This is the eeprom part taken from asus's tinker os device tree: > > m24c08@50 { > compatible = "at,24c08"; > reg = <0x50>; > }; > >> >> I think tinker is the CHIP board, right? Are there instructions >> somewhere on how to load U-Boot onto it? >> >> > + >> > + ret = dm_i2c_read(dev, 0x0, mac, 6); >> > + if (ret) { >> > + debug("failed to read mac\n"); >> > + return 0; >> > + } >> > + >> > + if (is_valid_ethaddr(mac)) >> > + eth_setenv_enetaddr("ethaddr", mac); >> > + >> > + return 0; >> > +} >> > -- >> > 2.11.0 >> > >> >> Regards, >> Simon > > Regards, > Jonas > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > https://lists.denx.de/listinfo/u-boot
2017-04-19 2:18 GMT+08:00 Simon Glass <sjg@chromium.org>: > Hi Eddie, > > On 18 April 2017 at 08:53, Eddie Cai <eddie.cai.linux@gmail.com> wrote: >> >> >> 2017-04-18 12:01 GMT+08:00 Simon Glass <sjg@chromium.org>: >>> >>> Hi Jonas, >>> >>> On 17 April 2017 at 15:13, Jonas Karlman <jonas@kwiboo.se> wrote: >>> > Set ethernet mac address in late init for Tinker Board, >>> > prevents getting a random mac address each boot. >>> > >>> > Read mac address from eeprom, first 6 bytes from 0x50 on i2c2. >>> > Same as /etc/init.d/rockchip.sh on Tinker OS. >>> > >>> > Signed-off-by: Jonas Karlman <jonas@kwiboo.se> >>> > --- >>> > >>> > board/rockchip/tinker_rk3288/tinker-rk3288.c | 26 >>> ++++++++++++++++++++++++++ >>> > 1 file changed, 26 insertions(+) >>> > >>> > diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c >>> b/board/rockchip/tinker_rk3288/tinker-rk3288.c >>> > index 79541a3939..48165b2545 100644 >>> > --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c >>> > +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c >>> > @@ -5,3 +5,29 @@ >>> > */ >>> > >>> > #include <common.h> >>> > +#include <i2c.h> >>> > +#include <netdev.h> >>> > + >>> > +int rk_board_late_init(void) >>> > +{ >>> > + struct udevice *dev; >>> > + int ret; >>> > + u8 mac[6]; >>> > + >>> > + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev); >>> > + if (ret) { >>> > + debug("failed to get eeprom\n"); >>> > + return 0; >>> > + } >>> >>> I'm sure this works, but really we should have this chip mentioned in the >>> device tree under &i2c2. Then we should be able to use the i2c_eeprom >>> driver. I cannot see this board supported in Linux to figure out how it >>> does it there. >>> >>> I think tinker is the CHIP board, right? Are there instructions somewhere >>> on how to load U-Boot onto it? >> >> tinker board is made by Asus. it use sd card as its boot media. to build >> U-Boot for tinker board >> CROSS_COMPILE=arm-linux-gnueabihf- make tinker-rk3288_defconfig all -j4 >> tools/mkimage -n rk3288 -T rksd -d spl/u-boot-spl-dtb.bin out >> cat u-boot-dtb.bin >> out >> to flash u-boot, mount sd card to your host PC. use below command. (please >> make sure /dev/sdb is the mount point of your sd card) >> sudo dd if=out of=/dev/sdb seek=64 conv=notrunc > > Thanks for the info, will live it a try. What do you think about doing > a patch for README.rockchip with this info? It is the same way booting from SD card. not specify for tinker board. README.rockchip already including it. > > [...] > > Regards, > Simon
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c index 79541a3939..48165b2545 100644 --- a/board/rockchip/tinker_rk3288/tinker-rk3288.c +++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c @@ -5,3 +5,29 @@ */ #include <common.h> +#include <i2c.h> +#include <netdev.h> + +int rk_board_late_init(void) +{ + struct udevice *dev; + int ret; + u8 mac[6]; + + ret = i2c_get_chip_for_busnum(2, 0x50, 1, &dev); + if (ret) { + debug("failed to get eeprom\n"); + return 0; + } + + ret = dm_i2c_read(dev, 0x0, mac, 6); + if (ret) { + debug("failed to read mac\n"); + return 0; + } + + if (is_valid_ethaddr(mac)) + eth_setenv_enetaddr("ethaddr", mac); + + return 0; +}
Set ethernet mac address in late init for Tinker Board, prevents getting a random mac address each boot. Read mac address from eeprom, first 6 bytes from 0x50 on i2c2. Same as /etc/init.d/rockchip.sh on Tinker OS. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> --- board/rockchip/tinker_rk3288/tinker-rk3288.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)