From patchwork Wed Jun 1 15:09:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jo-Philipp Wich X-Patchwork-Id: 628701 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rKYhM3bHVz9t4F for ; Thu, 2 Jun 2016 01:10:43 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b87n5-0002in-Vq; Wed, 01 Jun 2016 15:10:40 +0000 Received: from mxout01.bytecamp.net ([212.204.60.217]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b87n4-0002c7-I1 for lede-dev@lists.infradead.org; Wed, 01 Jun 2016 15:10:39 +0000 Received: by mxout01.bytecamp.net (Postfix, from userid 1001) id D3B0030FE74; Wed, 1 Jun 2016 17:09:52 +0200 (CEST) Received: from mail.bytecamp.net (mailstore.bytecamp.net [212.204.60.20]) by mxout01.bytecamp.net (Postfix) with ESMTP id 9AC4730FE6E for ; Wed, 1 Jun 2016 17:09:51 +0200 (CEST) Received: (qmail 52003 invoked by uid 89); 1 Jun 2016 17:09:51 +0200 Received: from unknown (HELO localhost.localdomain) (jo%wwsnet.net@213.61.250.148) by mail.bytecamp.net with AES128-SHA encrypted SMTP; 1 Jun 2016 17:09:51 +0200 From: Jo-Philipp Wich To: lede-dev@lists.infradead.org Date: Wed, 1 Jun 2016 17:09:46 +0200 Message-Id: <1464793786-27075-3-git-send-email-jo@mein.io> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464793786-27075-1-git-send-email-jo@mein.io> References: <1464793786-27075-1-git-send-email-jo@mein.io> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160601_081038_786055_8FC49317 X-CRM114-Status: GOOD ( 11.68 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [212.204.60.217 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [212.204.60.217 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Subject: [LEDE-DEV] [RFC v2 2/2] x86: use sysfs DMI information to populate sysinfo X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jo-Philipp Wich MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use the DMI data available in sysfs to extract manufacturer and model info and write it to /tmp/sysinfo/. The data will be picked up by board_detect and can be used by e.g. LuCI to display a more appropriate model description. On an APU board the files will contain the following values: # cat /tmp/sysinfo/model PC Engines APU # cat /tmp/sysinfo/board_name pc-engines-apu Signed-off-by: Jo-Philipp Wich --- target/linux/x86/Makefile | 2 +- target/linux/x86/base-files/lib/preinit/20_sysinfo | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 target/linux/x86/base-files/lib/preinit/20_sysinfo diff --git a/target/linux/x86/Makefile b/target/linux/x86/Makefile index 1eae227..7e397ab 100644 --- a/target/linux/x86/Makefile +++ b/target/linux/x86/Makefile @@ -13,7 +13,7 @@ FEATURES:=squashfs ext4 vdi vmdk pcmcia targz SUBTARGETS=generic xen_domu geode 64 MAINTAINER:=Felix Fietkau -DEFAULT_PACKAGES += partx-utils +DEFAULT_PACKAGES += partx-utils dmidecode KERNEL_PATCHVER:=4.4 diff --git a/target/linux/x86/base-files/lib/preinit/20_sysinfo b/target/linux/x86/base-files/lib/preinit/20_sysinfo new file mode 100644 index 0000000..ab2fbeb --- /dev/null +++ b/target/linux/x86/base-files/lib/preinit/20_sysinfo @@ -0,0 +1,18 @@ +do_sysinfo_x86() { + local manufacturer productname boardname + + [ -x /usr/sbin/dmidecode ] || return + + manufacturer="$(dmidecode -s system-manufacturer 2>/dev/null)" + productname="$(dmidecode -s system-product-name 2>/dev/null)" + + [ -n "$manufacturer" -a -n "$productname" ] || return + + boardname="$(printf "%s %s" "$manufacturer" "$productname" | tr 'A-Z' 'a-z' | tr -cs 'a-z0-9_-' '-')" + + mkdir -p /tmp/sysinfo + echo "$boardname" > /tmp/sysinfo/board_name + echo "$manufacturer $productname" > /tmp/sysinfo/model +} + +boot_hook_add preinit_main do_sysinfo_x86