README: refer to toolchain-layer in meta-openembedded
[glsdk/meta-ti-glsdk.git] / recipes-ti / beagleboard / gadget-init / g-ether-load.sh
1 #!/bin/sh
3 function get_devmem()
4 {
5         /usr/bin/devmem2 $1 | grep ": " | cut -d ":" -f 2|cut -d "x" -f 2
6 }
8 function hex_to_mac_addr()
9 {
10         addr=$1
11         n=0
12         mac_addr=$(echo ${addr} | while read -r -n2 c; do 
13                 if [ ! -z "$c" ]; then
14                         if [ $n -ne 0 ] ; then
15                                 echo -n ":${c}"
16                         else
17                                 echo -n "${c}"
18                         fi
19                 fi
20                 n=$(($n+1))
21         done)
22         echo ${mac_addr}
23 }
25 function reverse_bytes()
26 {
27         addr=$1
28         New_addr=$(echo ${addr} | while read -r -n2 c; do 
29                 if [ ! -z "$c" ]; then
30                         New_addr=${c}${New_addr}
31                 else echo
32                         echo ${New_addr}
33                 fi
34         done)
35         echo ${New_addr}
36 }
38 DEVMEM_ADDR_LO=$(get_devmem 0x44e10638|bc)
39 DEVMEM_ADDR_LO=$(reverse_bytes ${DEVMEM_ADDR_LO})
41 DEVMEM_ADDR_HI=$(get_devmem 0x44e1063C)
42 DEVMEM_ADDR_HI=$(reverse_bytes ${DEVMEM_ADDR_HI})
44 DEV_ADDR=$(hex_to_mac_addr "${DEVMEM_ADDR_HI}${DEVMEM_ADDR_LO}")
46 modprobe g_ether host_addr=${DEV_ADDR}