Guys,
Read MAC from EEPROM is working. I wrote into EEPROM and kernel picks up nicely. No need to do anything for your guys except writing correctly into EEPROM the first 6 bytes see CODE below Index is 0 which kernel is expected.
The first 3 bytes is OUI which EGC will provide it according to our meeting. See my last email on IEEE-OUI.
Here are 2 examples that I wrote into the EEPROM and kernel reads back and ifconfig shows correctly MAC address that I wrote into EEPROM. You can see from the dmesg log.
./.tv
Set MAC address 00:65:D1:50:9A:AF using i2c-tools
I finished the ic2-tools allow to read and write into eeprom for more details please i2c-tools.doc. tftp i2cdump, i2cset, i2cget into directory i.2 ~/temp then execute from there.
Source code and cross compile in 2013..../i2c-tools
Kernel dmesg log:
------
brd: module loaded
at24 1-0050: 1024 byte 24c01 EEPROM (writable)
Read MAC addr from EEPROM: 00:65:d1:50:9a:af
ONFI flash detected
ONFIparam page 0 valid
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron NAND 512MiB 3,3V 8-bit
)
Creating 5 MTD partitions on "davinci_nand.1":
0x000000000000-0x000000020000 : "u-boot env"
0x000000020000-0x000000040000 : "UBL"
0x000000040000-0x0000000c0000 : "u-boot"
0x000000200000-0x000000600000 : "kernel"
0x000000600000-0x000020000000 : "filesystem"
ifconfig
------
am1808-scb login: root
root@am1808-scb:~# ifconfig
eth0 Link encap:Ethernet HWaddr00:65:D1:50:9A:AF
inet addr:192.168.3.196 Bcast:192.168.3.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:49586 errors:0 dropped:0 overruns:0 frame:0
TX packets:61012 errors:0 dropped:0 overruns:0 carrier:0
collisions:4118 txqueuelen:1000
RX bytes:44599484 (42.5 MiB) TX bytes:10411658 (9.9 MiB)
Interrupt:33
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:595 (595.0 B) TX bytes:595 (595.0 B)
Write into EEPROM using i2c-tools
------
root@am1808-scb:~/temp#
root@am1808-scb:~/temp# ls
i2cdump i2cdetect i2cget runscript
dial i2cset
eeprog libi2c.so usb_modeswitch
eeprom libi2c.so.0 wvdial
minicom wvdial.conf modemtest pppd
(cp libi2c.so and lib2c.so.0 to /lib)
root@am1808-scb:~/temp# i2cset -f -y 1 0x50 0x00 0x00
root@am1808-scb:~/temp# i2cset -f -y 1 0x50 0x01 0x65
root@am1808-scb:~/temp# i2cset -f -y 1 0x50 0x02 0xD1
root@am1808-scb:~/temp# i2cset -f -y 1 0x50 0x03 0x50
root@am1808-scb:~/temp# i2cset -f -y 1 0x50 0x04 0x9A
root@am1808-scb:~/temp# i2cset -f -y 1 0x50 0x05 0xAF
(-f force -y do not ask confirmation, 1 is /dev/i2c-1 device, 0x50 address eeprom, 0x00 memory location of eeprom, 0x00 is data to write into this location)
using i2cdump to read back
------
root@am1808-scb:~/temp# i2cdump -f 1 0x50
No size specified (using byte-data access)
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1, address 0x50, mode byte
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 65 d1 50 9a af 30 2d 08 09 0a 0b 0c 0d 0e 0f .e?P??0-????????
usinghexdump to read eeprom file
------
cd to directory /sys/devices/platform/i2c-gpio.1/i2c-1/1-0050
root@am1808-scb:/sys/devices/platform/i2c-gpio.1/i2c-1/1-0050# hexdump -C eeprom
00000000 00 65 d1 50 9a af 30 2d 08 09 0a 0b 0c 0d 0e 0f |.e.P..0-...... |
00000010 ffffffffffffffff ffffffffffffffff |...... |
00000020 a5 ff ffffff a5 a5a5 ff ffffffffffffff |...... |
00000030 ffffffffffffffff ffffffffffffffff |
CODE:
-----
In common.c
voiddavinci_get_mac_addr(structmemory_accessor *mem_acc, void *context)
{
char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
off_t offset = (off_t)context;
/* Read MAC addr from EEPROM */
if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
}
inboard-da850-evm.c
#ifndefCONFIG_EGC_BOARD
staticstruct at24_platform_data da850_evm_i2c_eeprom_info = {
.byte_len = SZ_1K,
.page_size = 64,
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x0,
};
#else
staticstruct at24_platform_data da850_egc_i2c_eeprom_info = {
.byte_len = SZ_1K,
.page_size = 64,
.setup = davinci_get_mac_addr,
.context = (void *)0x0,
};
ToVan Tran - Software Design Engineer
Creating value that increases customer competitiveness
21Richardson Side Road
Ottawa, Ontario, CanadaK2K 2C1
+1 613 895 2050 x2800
I