From patchwork Sat Sep 17 04:57:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 671200 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3sbg6c24b8z9rxv for ; Sat, 17 Sep 2016 15:04:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D3F1C4B98A; Sat, 17 Sep 2016 07:04:02 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uesXtUa_4ZjV; Sat, 17 Sep 2016 07:04:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 142D54B71E; Sat, 17 Sep 2016 07:04:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 64C044B71E for ; Sat, 17 Sep 2016 07:03:58 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I4PhK26ah7Z2 for ; Sat, 17 Sep 2016 07:03:58 +0200 (CEST) X-Greylist: delayed 1199 seconds by postgrey-1.34 at theia; Sat, 17 Sep 2016 07:03:55 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from 9.mo173.mail-out.ovh.net (9.mo173.mail-out.ovh.net [46.105.72.44]) by theia.denx.de (Postfix) with ESMTPS id 189044B6B3 for ; Sat, 17 Sep 2016 07:03:55 +0200 (CEST) Received: from player711.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id 6948C1004B59 for ; Sat, 17 Sep 2016 06:57:49 +0200 (CEST) Received: from localhost.localdomain (unknown [109.241.15.61]) (Authenticated sender: l.majewski@majess.pl) by player711.ha.ovh.net (Postfix) with ESMTPSA id 001DA38006A; Sat, 17 Sep 2016 06:57:45 +0200 (CEST) From: Lukasz Majewski To: Tom Rini , U-Boot Mailing List Date: Sat, 17 Sep 2016 06:57:39 +0200 Message-Id: <1474088259-10095-1-git-send-email-l.majewski@majess.pl> X-Mailer: git-send-email 2.1.4 X-Ovh-Tracer-Id: 14793480351183716873 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeluddrjeelgddvieculddtuddrfeeltddrtddtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Subject: [U-Boot] [PATCHv2] scripts: Add script to extract default environment X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This script looks for env_common.o object file and extracts from it default u-boot environment, which is afterwards printed on standard output. Usage example: get_default_envs.sh > u-boot-env-default.txt The generated text file can be used as input for mkenvimage. Signed-off-by: Lukasz Majewski Reviewed-by: Simon Glass --- Changes for v2: - Sort uniquely entries - Exclude env_common.o generated for SPL --- scripts/get_default_envs.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/get_default_envs.sh diff --git a/scripts/get_default_envs.sh b/scripts/get_default_envs.sh new file mode 100755 index 0000000..7955db6 --- /dev/null +++ b/scripts/get_default_envs.sh @@ -0,0 +1,34 @@ +#! /bin/bash +# +# Copyright (C) 2016, Lukasz Majewski +# +# SPDX-License-Identifier: GPL-2.0+ +# + +# This file extracts default envs from built u-boot +# usage: get_default_envs.sh > u-boot-env-default.txt +set -ue + +ENV_OBJ_FILE="env_common.o" +ENV_OBJ_FILE_COPY="copy_${ENV_OBJ_FILE}" + +echoerr() { echo "$@" 1>&2; } + +path=$(readlink -f $0) +env_obj_file_path=$(find ${path%/scripts*} -not -path "*/spl/*" \ + -name "${ENV_OBJ_FILE}") +[ -z "${env_obj_file_path}" ] && \ + { echoerr "File '${ENV_OBJ_FILE}' not found!"; exit 1; } + +cp ${env_obj_file_path} ${ENV_OBJ_FILE_COPY} + +# NOTE: objcopy saves its output to file passed in +# (copy_env_common.o in this case) +objcopy -O binary -j ".rodata.default_environment" ${ENV_OBJ_FILE_COPY} + +# Replace default '\0' with '\n' and sort entries +tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort -u + +rm ${ENV_OBJ_FILE_COPY} + +exit 0