blob: f9400649125209ca6ede44dfa047f81852a49464 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/bin/sh
function get_devmem()
{
/usr/bin/devmem2 $1 | grep ": " | cut -d ":" -f 2|cut -d "x" -f 2
}
function hex_to_mac_addr()
{
addr=$1
n=0
mac_addr=$(echo ${addr} | while read -r -n2 c; do
if [ ! -z "$c" ]; then
if [ $n -ne 0 ] ; then
echo -n ":${c}"
else
echo -n "${c}"
fi
fi
n=$(($n+1))
done)
echo ${mac_addr}
}
function reverse_bytes()
{
addr=$1
New_addr=$(echo ${addr} | while read -r -n2 c; do
if [ ! -z "$c" ]; then
New_addr=${c}${New_addr}
else echo
echo ${New_addr}
fi
done)
echo ${New_addr}
}
DEVMEM_ADDR_LO=$(get_devmem 0x44e10638|bc)
DEVMEM_ADDR_LO=$(reverse_bytes ${DEVMEM_ADDR_LO})
DEVMEM_ADDR_HI=$(get_devmem 0x44e1063C)
DEVMEM_ADDR_HI=$(reverse_bytes ${DEVMEM_ADDR_HI})
DEV_ADDR=$(hex_to_mac_addr "${DEVMEM_ADDR_HI}${DEVMEM_ADDR_LO}")
modprobe g_ether host_addr=${DEV_ADDR}
|