1
0
mirror of https://git.yoctoproject.org/meta-ti synced 2026-07-21 03:17:18 +00:00
Files
Joel A Fernandes 89c54f502b gadget-init: Add network-gadget services and other fixes
* Add rule to start network-gadget when mass storage is ejected
* Add network-gadget-init service and scripts to switch to g_ether
* Add DHCP service / conf
* Update to storage-gadget: rmmod on stop

v2 changes:
* Fix g-ether MAC address by reading from mac_id
* Split into multiple packages

Signed-off-by: Joel A Fernandes <joelagnel@ti.com>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
2011-11-10 08:23:08 +01:00

47 lines
847 B
Bash
Executable File

#!/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}