From b896db61b5da7f117beea0ad783359e85a5a0f29 Mon Sep 17 00:00:00 2001 From: John Klug Date: Mon, 31 Oct 2022 14:46:37 -0500 Subject: Linux 5.4 MTAC Ethernet fix so AP1 is eth1 and AP2 is eth2 --- recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh | 46 +++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh (limited to 'recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh') diff --git a/recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh b/recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh new file mode 100755 index 0000000..4273d30 --- /dev/null +++ b/recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +I2C_DIR="/sys/bus/i2c/devices" + +AP1_EEPROM="$I2C_DIR/1-0050/eeprom" +AP2_EEPROM="$I2C_DIR/1-0052/eeprom" +hw_version1='' +hw_version2='' + +if [[ -f $AP1_EEPROM ]] ; then + hw_version1=$(mts-id-eeprom --accessory-card --in-file "$AP1_EEPROM" 2>/dev/null | grep '^hw-version:') +fi +if [[ -f $AP2_EEPROM ]] ; then + hw_version2=$(mts-id-eeprom --accessory-card --in-file "$AP2_EEPROM" 2>/dev/null | grep '^hw-version:') +fi + +AP1=0 +AP2=0 + +if [[ $hw_version1 =~ ^hw-version:[[:space:]]*\"MTAC-ETH ]] ; then + AP1=1 +fi + +if [[ $hw_version2 =~ ^hw-version:[[:space:]]*\"MTAC-ETH ]] ; then + AP2=1 +fi + +if ((AP1 == 0)) && ((AP2 == 1)) ; then + if ip addr show eth1 >/dev/null 2>&1 && ! ip addr show eth2 >/dev/null 2>&1 ; then + ip link set eth1 name eth2 + fi +fi + +# Handle the case where we are coming out of reset. +# udev will assign eth# where # is the first open slot starting from zero. +# We assing by AP slot here. +if ((AP1 == 1)) && ((AP2 == 1)) ; then + if (($(mts-io-sysfs show ap2/reset) == 0)) ; then + : + # Nothing to do if ap2 is in reset. + elif (($(mts-io-sysfs show ap1/reset) == 0)) ; then + if ip addr show eth1 >/dev/null 2>&1 && ! ip addr show eth2 >/dev/null 2>&1 ; then + ip link set eth1 name eth2 + fi + fi +fi -- cgit v1.2.3