From patchwork Wed Dec 10 21:26:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Bittorf X-Patchwork-Id: 419871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D4E171400B7 for ; Thu, 11 Dec 2014 08:22:31 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4984128C206; Wed, 10 Dec 2014 22:20:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4D55128C206 for ; Wed, 10 Dec 2014 22:20:27 +0100 (CET) X-policyd-weight: using cached result; rate: -6.11 Received: from fe0.bluebottle.com (hetz2.bluebottle.com [176.9.57.138]) by arrakis.dune.hu (Postfix) with ESMTP for ; Wed, 10 Dec 2014 22:20:24 +0100 (CET) Received: from localhost (p57AB33EF.dip0.t-ipconnect.de [87.171.51.239]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: bittorf@bluebottle.com) by fe0.bluebottle.com (Postfix) with ESMTPSA id A8AD0279E1 for ; Wed, 10 Dec 2014 21:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=bluebottle.com; s=fe0; t=1418246530; bh=rqO4I+M7UhspNXozJ/zcG1+8gie7yQZWWSVk/dsz0Cw=; l=3063; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=XbtkLdz3rtlMA8V2TDr1wypbc+oeT4cHuhs76f+vdD+a1SpzH6C3IGgYnZ3sDmCMM vJuPZsIAC+PsdUbpvRiA9hfvQNjZ4bYtwE0Ucsf1y5r/jge6XWgTL+mjBQV66RyyUi EhoUrLJ1IPG6qHKqy1D2BvmJ47DhORAx/pYCI60Y= Date: Wed, 10 Dec 2014 22:26:21 +0100 From: Bastian Bittorf To: mailinglist Message-ID: <20141210212621.GA4675@medion.lan> Mail-Followup-To: mailinglist MIME-Version: 1.0 Content-Disposition: inline X-Editor: vi http://ex-vi.sourceforge.net/ User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.98.1 at fe0 X-Virus-Status: Clean Subject: [OpenWrt-Devel] [PATCH] au1000: distinguish different models and set correct MAC-address X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" The target au1000 has at least 2 different models, the 'InternetBox' and the 'MeshCube' which look very similar from the kernel point of view but are totally different devices which base on the same design. Populating /tmp/sysinfo now. The 1st one has an issue which leads to a random mac-address after each boot which is corrected now via reading the bootloader-env. The real fix would be converting to DTS, this is only a workaround now. Signed-off-by: Bastian Bittorf --- .../au1000/base-files/etc/uci-defaults/02_network | 17 ++++++ target/linux/au1000/base-files/lib/au1000.sh | 59 ++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100755 target/linux/au1000/base-files/etc/uci-defaults/02_network create mode 100644 target/linux/au1000/base-files/lib/au1000.sh diff --git a/target/linux/au1000/base-files/etc/uci-defaults/02_network b/target/linux/au1000/base-files/etc/uci-defaults/02_network new file mode 100755 index 0000000..80bfb73 --- /dev/null +++ b/target/linux/au1000/base-files/etc/uci-defaults/02_network @@ -0,0 +1,17 @@ +#!/bin/sh + +. /lib/au1000.sh +. /lib/functions/system.sh +. /lib/functions/uci-defaults.sh +MAC= + +case "$(au1000_board_name)" in + 'internetbox') + MAC="$( au1000_yamonenv_getvar 'ethaddr' )" + MAC="$( macaddr_canonicalize "$MAC" )" + + [ -n "$MAC ] && ucidef_set_interface_macaddr lan "$MAC" + ;; +esac + +[ -z "$MAC" ] || uci commit network diff --git a/target/linux/au1000/base-files/lib/au1000.sh b/target/linux/au1000/base-files/lib/au1000.sh new file mode 100644 index 0000000..556598d --- /dev/null +++ b/target/linux/au1000/base-files/lib/au1000.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +au1000_yamonenv_getvar() +{ + local varname="$1" + local partition + + . /lib/functions.sh + + partition="$( find_mtd_part 'yamon env' )" + YAMONENVFILE="$partition" yamonenv "$varname" +} + +au1000_detect() +{ + local line board_name model + + while read line; do + case "$line" in + 'system type'*) + break + ;; + esac + done <'/proc/cpuinfo' + + case "$line" in + *' MTX-1') + # both models appear nearly similar: the 'InternetBox' has + # the same design but shrinked to 1 PCB and only 1 x miniPCI + # for WiFi/ath5k and 1 x miniPCI for CardBus/UMTS, they differ + # in BogoMIPS but there are old MeshCubes with 330 Mhz instead + # of 400 MHz and no Cube has 'imei' (for UMTS) set in bootloader-env + + if [ -n "$( au1000_yamonenv_getvar 'imei' )" ]; then + board_name='internetbox' + model='T-Mobile InternetBox TMD SB1-S' + else + board_name='meshcube' + model='4G Systems AccessCube/MeshCube' + fi + ;; + *) + board_name='unknown' + model='unknown' + ;; + esac + + mkdir -p '/tmp/sysinfo' + echo "$board_name" >'/tmp/sysinfo/board_name' + echo "$model" >'/tmp/sysinfo/model' +} + +au1000_board_name() +{ + local file='/tmp/sysinfo/board_name' + + [ -e "$file" ] || au1000_detect + cat "$file" +}