From patchwork Thu Jan 15 20:50:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 429572 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 3A0BA140217 for ; Fri, 16 Jan 2015 07:50:13 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 89579289C4A; Thu, 15 Jan 2015 21:47:52 +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, 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 A7A5128068C for ; Thu, 15 Jan 2015 21:47:46 +0100 (CET) X-policyd-weight: using cached result; rate: -7.6 Received: from fudo.makrotopia.org (fudo.makrotopia.org [5.135.190.93]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 15 Jan 2015 21:47:46 +0100 (CET) Received: from local by fudo.makrotopia.org with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1YBrMe-0005V5-Rq; Thu, 15 Jan 2015 21:50:00 +0100 Date: Thu, 15 Jan 2015 21:50:43 +0100 From: Daniel Golle To: openwrt-devel@lists.openwrt.org Message-ID: <20150115205038.GA6594@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [OpenWrt-Devel] [PATCH 1/2] sunxi: implement board_detect for device-tree kernels 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" board_detect previously relied on parsing the kernel cmdline out of the U-Boot environment stored on the the MMC card in order to get the board= parameter. Use /proc/device-tree/model instead. Signed-off-by: Daniel Golle --- target/linux/sunxi/base-files/lib/sunxi.sh | 168 ++++++++++++++++++++++------- 1 file changed, 130 insertions(+), 38 deletions(-) diff --git a/target/linux/sunxi/base-files/lib/sunxi.sh b/target/linux/sunxi/base-files/lib/sunxi.sh index adf9f84..b0a3874 100644 --- a/target/linux/sunxi/base-files/lib/sunxi.sh +++ b/target/linux/sunxi/base-files/lib/sunxi.sh @@ -1,45 +1,137 @@ #!/bin/sh # defaults -SUNXI_BOARD_NAME="generic sunxi" -SUNXI_BOARD_MODEL="generic sunxi" -SUNXI_ENV_DEV=/dev/mmcblk0 - -#Helper functions -get_cmdline_opt() -{ -cat /proc/cmdline | awk -F$1= '{print $2}' | awk '{print $1}' -} +SUNXI_BOARD_NAME="generic" +SUNXI_BOARD_MODEL="Generic sunxi board" -#Since fw_getenv doesn't work with blockdevs let's make a hack -uboot_getenv() -{ - dd if=$SUNXI_ENV_DEV bs=1024 skip=544 count=128 2>dev/null |\strings|grep $1|cut -d"=" -f2 -} +sunxi_board_detect() { + local board + local model -#Actual routines go below -sunxi_env_dev() -{ - local dev - dev=`get_cmdline_opt root|cut -d"p" -f1` - SUNXI_ENV_DEV=$dev - echo "probing $dev for uboot env data" -} + [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" -sunxi_board_detect() { - local board - local model - sunxi_env_dev - [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/" - board="`uboot_getenv wrt_board`" - model="`uboot_getenv wrt_model`" - if [ "$board" != "" ]; then - SUNXI_BOARD_NAME="$board" - fi - if [ "$model" != "" ]; then - SUNXI_BOARD_MODEL="$model" - fi - echo "$SUNXI_BOARD_NAME" > /tmp/sysinfo/board_name - echo "$SUNXI_BOARD_MODEL" > /tmp/sysinfo/model - echo "Detected $SUNXI_BOARD_NAME // $SUNXI_BOARD_MODEL" + model="$( cat /proc/device-tree/model )" + + case "$model" in + "Mele A1000") + board="a1000" + ;; + + "BA10 tvbox") + board="ba10-tvbox" + ;; + + "Cubietech Cubieboard") + board="cubieboard" + ;; + + "Miniand Hackberry") + board="hackberry" + ;; + + "INet-97F Rev 02") + board="inet97fv2" + ;; + + "PineRiver Mini X-Plus") + board="mini-xplus" + ;; + + "Olimex A10-OLinuXino-LIME") + board="olinuxino-lime" + ;; + + "LinkSprite pcDuino") + board="pcduino" + ;; + + "Olimex A10s-Olinuxino Micro") + board="olinuxino-micro" + ;; + + "R7 A10s hdmi tv-stick") + board="r7-tv-dongle" + ;; + + "HSG H702") + board="hsg-h702" + ;; + + "Olimex A13-Olinuxino") + board="olinuxino" + ;; + + "Olimex A13-Olinuxino Micro") + board="olinuxino-micro" + ;; + + "Allwinner A31 APP4 EVB1 Evaluation Board") + board="app4-evb1" + ;; + + "WITS A31 Colombus Evaluation Board") + board="colombus" + ;; + + "Merrii A31 Hummingbird") + board="hummingbird" + ;; + + "Mele M9 / A1000G Quad top set box") + board="m9" + ;; + + "LeMaker Banana Pi") + board="bananapi" + ;; + + "LeMaker Banana Pro") + board="bananapro" + ;; + + "Cubietech Cubieboard2") + board="cubieboard2" + ;; + + "Cubietech Cubietruck") + board="cubietruck" + ;; + + "Merrii A20 Hummingbird") + board="hummingbird" + ;; + + "I12 / Q5 / QT840A A20 tvbox") + board="i12-tvbox" + ;; + + "Olimex A20-OLinuXino-LIME") + board="olinuxino-lime" + ;; + + "Olimex A20-Olinuxino Micro") + board="olinuxino-micro" + ;; + + "LinkSprite pcDuino3") + board="pcduino3" + ;; + + "Ippo Q8H Dual Core Tablet (v5)") + board="ippo-q8h-v5" + ;; + esac + + if [ "$board" != "" ]; then + SUNXI_BOARD_NAME="$board" + fi + + if [ "$model" != "" ]; then + SUNXI_BOARD_MODEL="$model" + fi + + + echo "$SUNXI_BOARD_NAME" > /tmp/sysinfo/board_name + echo "$SUNXI_BOARD_MODEL" > /tmp/sysinfo/model + echo "Detected $SUNXI_BOARD_NAME // $SUNXI_BOARD_MODEL" }