sunxi: Serial number support, obtained from SID bits and passed through ATAG
PATCH 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
--- board/sunxi/board.c | 33 ++++++++++++++++++++++++++++++--- include/configs/sunxi-common.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-)
board/sunxi/board.c +30 -3
@@ -248,13 +248,34 @@ int g_dnl_board_usb_cable_connected(void) }#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { -unsigned int sid[4 ]; +char serial_string[17 ] = {0 }; +unsigned int sid[4 ] = {0 }; +int ret; + + ret =sunxi_get_sid (sid); -if (!getenv ("ethaddr" ) &&sunxi_get_sid (sid) ==0 && - sid[0 ] !=0 && sid[3 ] !=0 ) { +if (!getenv ("ethaddr" ) && ret ==0 && sid[0 ] !=0 && sid[3 ] !=0 ) {uint8_t mac_addr[6 ]; mac_addr[0 ] =0x02 ;/* Non OUI / registered MAC address */
@@ -267,6 +288,12 @@ int misc_init_r(void)eth_setenv_enetaddr ("ethaddr" , mac_addr); } + ret =snprintf (serial_string,sizeof (serial_string),"%08x%08x" , + sid[0 ], sid[3 ]); + +if (ret >0 ) +setenv ("serial#" , serial_string); +#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );#endif
include/configs/sunxi-common.h +1 -0
@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
Signature · 1 line
1.9.1
PATCH 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
Hi,
Thanks for the patch, I've 1 comment inline, please send
a version with that fixed then I'll queue it up for merging upstream.
Quoted 49 lines · Paul Kocialkowski
Signed-off-by Paul Kocialkowski <[email protected]>--- board/sunxi/board.c | 33 ++++++++++++++++++++++++++++++--- include/configs/sunxi-common.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-)board/sunxi/board.c +24
-3@@ -248,13 +248,34 @@ int g_dnl_board_usb_cable_connected(void) }#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { -unsigned int sid[4 ]; +char serial_string[17 ] = {0 }; +unsigned int sid[4 ] = {0 }; +int ret; + + ret =sunxi_get_sid (sid); -if (!getenv ("ethaddr" ) &&sunxi_get_sid (sid) ==0 && - sid[0 ] !=0 && sid[3 ] !=0 ) { +if (!getenv ("ethaddr" ) && ret ==0 && sid[0 ] !=0 && sid[3 ] !=0 ) {uint8_t mac_addr[6 ]; mac_addr[0 ] =0x02 ;/* Non OUI / registered MAC address */
board/sunxi/board.c int misc_init_r(void) · line 290
Quoted 3 lines
board/sunxi/board.c +0
-0@@ -267,6 +288,12 @@ int misc_init_r(void)eth_setenv_enetaddr ("ethaddr" , mac_addr); }
You should check for get_sid succeeding before calling snprintf, also since your buffer is always large enough, there is no need to use or error check snprintf, and last you should check for serial# not already being set so that the user can override it if he wants.
board/sunxi/board.c int misc_init_r(void) · line 296
Quoted 6 lines
board/sunxi/board.c +6
-0+ ret =snprintf (serial_string,sizeof (serial_string),"%08x%08x" , + sid[0 ], sid[3 ]); + +if (ret >0 ) +setenv ("serial#" , serial_string); +
IOW, you should replace the above with:
if (!getenv("serial#") && ret == 0) {
sprintf(serial_string, "%08x%08x", sid[0], sid[3]);
setenv("serial#", serial_string);
}Quoted 9 lines
board/sunxi/board.c +0
-0#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );#endif include/configs/sunxi-common.h +0
-0
include/configs/sunxi-common.h line 104
Quoted 7 lines
include/configs/sunxi-common.h +1
-0@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
Otherwise this looks good.
Regards,
Hans
p.s.
A quick grep on serial# shows the following:board/gateworks/gw_ventana/gw_ventana.c
1202: * serial# env var
1207: char *serial = getenv("serial#");
1432: setenv("serial#", str);
1512: fdt_setprop(blob, 0, "system-serial", getenv("serial#"),
1513: strlen(getenv("serial#")) + 1);
Which may be used as an example for devicetree support, or not, the first thing to do would be to write a
Documentation/devicetree/bindings/system-serial.txt
patch for the kernel and send that to the devicetree list for review, once that is accepted we can actually start implementing it.
Regards,
Hans
PATCH v2 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
--- board/sunxi/board.c | 51 +++++++++++++++++++++++++++++++++--------- include/configs/sunxi-common.h | 1 + 2 files changed, 41 insertions(+), 11 deletions(-)
board/sunxi/board.c +40 -11
@@ -241,24 +241,53 @@ static struct musb_hdrc_platform_data musb_plat = { };#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { +char serial_string[17 ] = {0 };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 && - sid[0 ] !=0 && sid[3 ] !=0 ) { -uint8_t mac_addr[6 ]; +if (!getenv ("serial#" )) { +snprintf (serial_string,sizeof (serial_string), +"%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 ; +setenv ("serial#" , serial_string); -eth_setenv_enetaddr ("ethaddr" , mac_addr); - } + }#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );
include/configs/sunxi-common.h +1 -0
@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
Signature · 1 line
1.9.1
PATCH v2 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
Hi,
Quoted 1 line · Paul Kocialkowski
Signed-off-by Paul Kocialkowski <[email protected]>
Thanks this version looks good, but I would like to have some more certainty wrt how to deal with serial numbers in devicetree, where we may e.g. store the full 128 bits of the sid, so I've send a mail to the devicetree list about this with you in the Cc.
Regards,
Hans
Quoted 87 lines
--- board/sunxi/board.c | 51 +++++++++++++++++++++++++++++++++--------- include/configs/sunxi-common.h | 1 + 2 files changed, 41 insertions(+), 11 deletions(-)board/sunxi/board.c +40
-11@@ -241,24 +241,53 @@ static struct musb_hdrc_platform_data musb_plat = { };#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { +char serial_string[17 ] = {0 };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 && - sid[0 ] !=0 && sid[3 ] !=0 ) { -uint8_t mac_addr[6 ]; +if (!getenv ("serial#" )) { +snprintf (serial_string,sizeof (serial_string), +"%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 ; +setenv ("serial#" , serial_string); -eth_setenv_enetaddr ("ethaddr" , mac_addr); - } + }#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );include/configs/sunxi-common.h +1
-0@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
PATCH v2 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
Le dimanche 22 mars 2015 ? 12:27 +0100, Hans de Goede a ?crit :
Quoted 9 lines
Hi,
Quoted 1 line · Paul Kocialkowski
Signed-off-by Paul Kocialkowski <[email protected]>Thanks this version looks good, but I would like to have some more certainty wrt how to deal with serial numbers in devicetree, where we may e.g. store the full 128 bits of the sid, so I've send a mail to the devicetree list about this with you in the Cc.
In case it is possible to store the full 128 bits through device tree, I would still prefer to see only the 64 bits we selected being used, so that each device would show the same serial number in cpuinfo when using the legacy 3.4 kernel and a recent upstream kernel.
Quoted 88 lines
Regards,
Hans
Quoted 84 lines
--- board/sunxi/board.c | 51 +++++++++++++++++++++++++++++++++--------- include/configs/sunxi-common.h | 1 + 2 files changed, 41 insertions(+), 11 deletions(-)board/sunxi/board.c +40
-11@@ -241,24 +241,53 @@ static struct musb_hdrc_platform_data musb_plat = { };#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { +char serial_string[17 ] = {0 };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 && - sid[0 ] !=0 && sid[3 ] !=0 ) { -uint8_t mac_addr[6 ]; +if (!getenv ("serial#" )) { +snprintf (serial_string,sizeof (serial_string), +"%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 ; +setenv ("serial#" , serial_string); -eth_setenv_enetaddr ("ethaddr" , mac_addr); - } + }#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );include/configs/sunxi-common.h +1
-0@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG
Quoted 3 lines
include/configs/sunxi-common.h line 104
Quoted 3 lines
include/configs/sunxi-common.h +0
-0/* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150322/d234af55/attachment.sig>
PATCH v2 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
Hi,
Quoted 11 lines · Paul Kocialkowski
Le dimanche 22 mars 2015 ? 12:27 +0100, Hans de Goede a ?crit :
Quoted 9 lines
Hi,
Quoted 1 line · Paul Kocialkowski
Signed-off-by Paul Kocialkowski <[email protected]>Thanks this version looks good, but I would like to have some more certainty wrt how to deal with serial numbers in devicetree, where we may e.g. store the full 128 bits of the sid, so I've send a mail to the devicetree list about this with you in the Cc.
Quoted 4 lines
In case it is possible to store the full 128 bits through device tree, I would still prefer to see only the 64 bits we selected being used, so that each device would show the same serial number in cpuinfo when using the legacy 3.4 kernel and a recent upstream kernel.
Right in /proc/cpuinfo we should always show the same, and we can likely not extend the info to 128 bits there due to ABI compatibility concerns.
But we can e.g. show the entire 128 bit in /sys/firmware/devicetree/base/system-serial in which case it makes sense to have the full 128 bit in the u-boot environment and select word 0 and 3 in get_board_serial() at which point your patch needs to change which is why I want to have a discussion about how to deal with this in devicetree before merging the patch.
Regards,
Hans
Quoted 93 lines
Quoted 92 lines
Regards,
Hans
Quoted 87 lines
--- board/sunxi/board.c | 51 +++++++++++++++++++++++++++++++++--------- include/configs/sunxi-common.h | 1 + 2 files changed, 41 insertions(+), 11 deletions(-)board/sunxi/board.c +40
-11@@ -241,24 +241,53 @@ static struct musb_hdrc_platform_data musb_plat = { };#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { +char serial_string[17 ] = {0 };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 && - sid[0 ] !=0 && sid[3 ] !=0 ) { -uint8_t mac_addr[6 ]; +if (!getenv ("serial#" )) { +snprintf (serial_string,sizeof (serial_string), +"%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 ; +setenv ("serial#" , serial_string); -eth_setenv_enetaddr ("ethaddr" , mac_addr); - } + }#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );include/configs/sunxi-common.h +1
-0@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
PATCH v2 1/1 sunxi: Serial number support, obtained from SID bits and passed through ATAG
Le dimanche 22 mars 2015 ? 12:36 +0100, Hans de Goede a ?crit :
Quoted 19 lines
Hi,
Quoted 11 lines · Paul Kocialkowski
Le dimanche 22 mars 2015 ? 12:27 +0100, Hans de Goede a ?crit :
Quoted 9 lines
Hi,
Quoted 1 line · Paul Kocialkowski
Signed-off-by Paul Kocialkowski <[email protected]>Thanks this version looks good, but I would like to have some more certainty wrt how to deal with serial numbers in devicetree, where we may e.g. store the full 128 bits of the sid, so I've send a mail to the devicetree list about this with you in the Cc.
Quoted 4 lines
In case it is possible to store the full 128 bits through device tree, I would still prefer to see only the 64 bits we selected being used, so that each device would show the same serial number in cpuinfo when using the legacy 3.4 kernel and a recent upstream kernel.
Quoted 8 lines
Right in
/proc/cpuinfowe should always show the same, and we can likely not extend the info to 128 bits there due to ABI compatibility concerns.But we can e.g. show the entire 128 bit in
/sys/firmware/devicetree/base/system-serialin which case it makes sense to have the full 128 bit in the u-boot environment and select word 0 and 3 inget_board_serial()at which point your patch needs to change which is why I want to have a discussion about how to deal with this in devicetree before merging the patch.
That makes good sense, let's wait and see what kernel dt people think about this.
I'll still post a v3 just now because v2 was missing a closing bracket and didn't build.
Quoted 98 lines
Regards,
Hans
Quoted 93 lines
Quoted 92 lines
Regards,
Hans
Quoted 87 lines
--- board/sunxi/board.c | 51 +++++++++++++++++++++++++++++++++--------- include/configs/sunxi-common.h | 1 + 2 files changed, 41 insertions(+), 11 deletions(-)board/sunxi/board.c +40
-11@@ -241,24 +241,53 @@ static struct musb_hdrc_platform_data musb_plat = { };#endif +#ifdef CONFIG_SERIAL_TAG +void get_board_serial (struct tag_serialnr *serialnr) +{ +char *serial_string =getenv ("serial#" ); +unsigned long long serial; + +if (serial_string) { + serial =simple_strtoull (serial_string,NULL ,16 ); + + serialnr->high = (unsigned int ) (serial >>32 ); + serialnr->low = (unsigned int ) (serial &0xffffffff ); + }else { + serialnr->high =0 ; + serialnr->low =0 ; + } +} +#endif +#ifdef CONFIG_MISC_INIT_R int misc_init_r (void ) { +char serial_string[17 ] = {0 };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 && - sid[0 ] !=0 && sid[3 ] !=0 ) { -uint8_t mac_addr[6 ]; +if (!getenv ("serial#" )) { +snprintf (serial_string,sizeof (serial_string), +"%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 ; +setenv ("serial#" , serial_string); -eth_setenv_enetaddr ("ethaddr" , mac_addr); - } + }#if defined(CONFIG_MUSB_HOST ) || defined(CONFIG_MUSB_GADGET )musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE );include/configs/sunxi-common.h +1
-0@@ -98,6 +98,7 @@#define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F )
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150322/dd7cc5c4/attachment.sig>