Skip to content
Snippets Groups Projects
Commit 8c816573 authored by Paul Kocialkowski's avatar Paul Kocialkowski Committed by Hans de Goede
Browse files

sunxi: Serial number support, obtained from SID bits

parent 9816d52d
No related branches found
No related tags found
No related merge requests found
...@@ -372,20 +372,31 @@ int g_dnl_board_usb_cable_connected(void) ...@@ -372,20 +372,31 @@ int g_dnl_board_usb_cable_connected(void)
#ifdef CONFIG_MISC_INIT_R #ifdef CONFIG_MISC_INIT_R
int misc_init_r(void) int misc_init_r(void)
{ {
char serial_string[17] = { 0 };
unsigned int sid[4]; unsigned int sid[4];
uint8_t mac_addr[6];
int ret;
ret = sunxi_get_sid(sid);
if (ret == 0 && sid[0] != 0 && sid[3] != 0) {
if (!getenv("ethaddr")) {
/* Non OUI / registered MAC address */
mac_addr[0] = 0x02;
mac_addr[1] = (sid[0] >> 0) & 0xff;
mac_addr[2] = (sid[3] >> 24) & 0xff;
mac_addr[3] = (sid[3] >> 16) & 0xff;
mac_addr[4] = (sid[3] >> 8) & 0xff;
mac_addr[5] = (sid[3] >> 0) & 0xff;
eth_setenv_enetaddr("ethaddr", mac_addr);
}
if (!getenv("ethaddr") && sunxi_get_sid(sid) == 0 && if (!getenv("serial#")) {
sid[0] != 0 && sid[3] != 0) { snprintf(serial_string, sizeof(serial_string),
uint8_t mac_addr[6]; "%08x%08x", sid[0], sid[3]);
mac_addr[0] = 0x02; /* Non OUI / registered MAC address */
mac_addr[1] = (sid[0] >> 0) & 0xff;
mac_addr[2] = (sid[3] >> 24) & 0xff;
mac_addr[3] = (sid[3] >> 16) & 0xff;
mac_addr[4] = (sid[3] >> 8) & 0xff;
mac_addr[5] = (sid[3] >> 0) & 0xff;
eth_setenv_enetaddr("ethaddr", mac_addr); setenv("serial#", serial_string);
}
} }
#if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET) #if defined(CONFIG_MUSB_HOST) || defined(CONFIG_MUSB_GADGET)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment