From patchwork Mon Nov 18 21:21:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Cooper X-Patchwork-Id: 3199161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 667989F43F for ; Mon, 18 Nov 2013 21:23:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72066201BF for ; Mon, 18 Nov 2013 21:23:09 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8765D2017C for ; Mon, 18 Nov 2013 21:23:04 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViWGo-0003OM-Ac; Mon, 18 Nov 2013 21:22:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViWGc-0007Lv-H6; Mon, 18 Nov 2013 21:21:58 +0000 Received: from mho-02-ewr.mailhop.org ([204.13.248.72]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViWGJ-0007Jp-KK for linux-arm-kernel@lists.infradead.org; Mon, 18 Nov 2013 21:21:40 +0000 Received: from pool-108-39-110-144.nrflva.fios.verizon.net ([108.39.110.144] helo=titan) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1ViWFw-0000fC-Ox; Mon, 18 Nov 2013 21:21:16 +0000 Received: from triton.localdomain (omega.lakedaemon.net [10.16.5.5]) by titan (Postfix) with ESMTP id 89D7E4DA612; Mon, 18 Nov 2013 16:21:14 -0500 (EST) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 108.39.110.144 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX19DsmM2geuxQcUJG6ppFtqdtj29DlTSS/E= From: Jason Cooper To: Rob Herring , Pawel Moll , Mark Rutland , Stephen Warren , Ian Campbell , Olof Johansson Subject: [RFC PATCH V3 2/2] kbuild: dtbs_install: new make target Date: Mon, 18 Nov 2013 21:21:06 +0000 Message-Id: <13f06582c166343c055b8793305d4b9a00b2172e.1384809305.git.jason@lakedaemon.net> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: References: <1384201760-16785-1-git-send-email-jason@lakedaemon.net> In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131118_162139_726537_D2670529 X-CRM114-Status: GOOD ( 15.87 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, Jason Cooper , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unlike other build products in the Linux kernel, the devicetree blobs are simply the name of their source file, s/dts/dtb/. There is also no 'make *install' mechanism to put them in a standard place with a standard naming structure. Unfortunately, users have begun scripting pulling the needed dtbs from within the kernel tree, thus hardcoding the dtbs names. In turn, this means any changes to the dts filenames breaks these scripts. This patch is an attempt to fix this problem. Akin to 'make install', this creates a new make target, dtbs_install. The script that gets called defers to a vendor or distribution supplied installdtbs binary, if found in the system. Otherwise, the default action is to install a given dtb into /lib/modules/${kernel_version}/devicetree/${board_compat}.dtb This solves several problems for us. The board compatible string should be unique, this enforces/highlights that. While devicetrees are stablilizing, the fact is, devicetrees aren't (yet) independent of kernel version. This install target facilitates keeping track of that. Once the devicetree files are moved to their own repository, this install target can be removed as users will be modifying their scripts anyway. Signed-off-by: Jason Cooper --- changes since v2: - use fdtget instead of a modified dtc to get the board compat string changes since v1: - added this patch Makefile | 3 ++- arch/arm/Makefile | 4 ++++ arch/arm/boot/installdtbs.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boot/installdtbs.sh diff --git a/Makefile b/Makefile index 920ad07180c9..29d609e972d6 100644 --- a/Makefile +++ b/Makefile @@ -339,6 +339,7 @@ OBJDUMP = $(CROSS_COMPILE)objdump AWK = awk GENKSYMS = scripts/genksyms/genksyms INSTALLKERNEL := installkernel +INSTALLDTBS := installdtbs DEPMOD = /sbin/depmod PERL = perl CHECK = sparse @@ -391,7 +392,7 @@ KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(S export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC export CPP AR NM STRIP OBJCOPY OBJDUMP -export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE +export MAKE AWK GENKSYMS INSTALLKERNEL INSTALLDTBS PERL UTS_MACHINE export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS diff --git a/arch/arm/Makefile b/arch/arm/Makefile index c99b1086d83d..c16ebb1e74b0 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -314,6 +314,10 @@ PHONY += dtbs dtbs: scripts $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) dtbs +dtbs_install: dtbs + $(CONFIG_SHELL) $(srctree)/$(boot)/installdtbs.sh $(KERNELRELEASE) \ + "$(MODLIB)/devicetree" "$(srctree)/$(boot)/dts" + # We use MRPROPER_FILES and CLEAN_FILES now archclean: $(Q)$(MAKE) $(clean)=$(boot) diff --git a/arch/arm/boot/installdtbs.sh b/arch/arm/boot/installdtbs.sh new file mode 100644 index 000000000000..3adef376188f --- /dev/null +++ b/arch/arm/boot/installdtbs.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file "COPYING" in the main directory of this archive +# for more details. +# +# Copyright (C) 1995 by Linus Torvalds +# +# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin +# +# Further adapted from arch/x86/boot/install.sh by Jason Cooper +# +# "make dtbs_install" script +# +# Arguments: +# $1 - kernel version +# $2 - default install path (blank if root directory) +# $3 - directory containing dtbs +# + +# User may have a custom install script + +if [ -x ~/bin/${INSTALLDTBS} ]; then exec ~/bin/${INSTALLDTBS} "$@"; fi +if [ -x /sbin/${INSTALLDTBS} ]; then exec /sbin/${INSTALLDTBS} "$@"; fi + +FDTGET=./scripts/dtc/fdtget + +# Default install +[ -d "$2" ] && rm -rf "$2" + +mkdir -p "$2" + +for dtb in `find "$3" -name "*.dtb"`; do + # we use fdtget to parse the dtb, get the board compatible string, + # and then copy the dtb to $2/${board_compatible}.dtb + compat="`$FDTGET -t s "$dtb" / compatible | cut -d ' ' -f 1`" + + if [ -e "$2/${compat}.dtb" ]; then + echo "Install $dtb: $2/${compat}.dtb already exists!" 1>&2 + exit 1 + else + cp "$dtb" "$2/${compat}.dtb" + fi +done