Introduction
There is an EEPROM chip 24LC332A on Arria 10 development kit. This chip is used to store board related information including EMAC address. User has the option to get the EMAC address from locations below:
- U-boot environment, which is stored in flashes.
- EEPROM.
Per current EEPROM layout, the location of EMAC address is located in memory location below:
- 0x16c – HPS EMAC 0 address.
- 0x174 – HPS EMAC 1 address.
The driver codes are located in:
- /uboot-socfpga/include/configs/socfpga_arria10.h
- /uboot-socfpga/board/altera/socfpga_arria10/socfpga_common.c
Feature Configuration in U-Boot
a. EMAC is retrieved from u-boot environment.
Environment data that saved in flashes using command below in U-boot console.
# setenv ethaddr 02:11:22:33:44:55
# saveenv
After this is done, U-boot will set the ethaddr value every time it boots up. This information will be passed to kernel.
b. EMAC is retrieved from EEPROM.
U-boot will do the checking whether ethaddr environment variable is available upon boot up. U-boot will retrieve the EMAC address from EEPROM and assign to ethaddr environment if ethaddr environment is not set yet. At the same time, user can invoke it manually using command below in U-boot console.
# go $setenv_ethaddr_eeprom
U-boot will retrieve the EMAC address from EEPROM and set the ethaddr environment. This information will be passed to kernel.
c.
Additional commands for reading and writing EMAC to EEPROM from U-boot console. Reading from EEPROM
# i2c md 0x51 0x174.2 6
# 0x174: 55 44 33 22 11 02 UD3”
Writing to EEPROM, there are two commands available as shown below:
1st method (using i2c mm command):
# i2c mm 0x51 0x174.2
# 00000174: 55 ? 55
# 00000175: 44 ? 44
# 00000176: 33 ? 33
# 00000177: 22 ? 22
# 00000178: 11 ? 11
# 00000179: 02 ? 02
2nd method (using i2c mw command):
# i2c mw 0x51 0x16c.2 55
# i2c mw 0x51 0x16d.2 44
# i2c mw 0x51 0x16e.2 33
# i2c mw 0x51 0x16f.2 22
# i2c mw 0x51 0x170.2 11
# i2c mw 0x51 0x171.2 02
# i2c md 0x51 0x16c.2 6
Note: 0x51 is EEPROM base address. 0x174 is location for EMAC1 address within EEPROM and ‘2’ from 0x174.2 indicating 2 bytes length address format.