From patchwork Fri May 8 18:13:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Weber X-Patchwork-Id: 1286382 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rockwellcollins.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Jdjk67WGz9sSG for ; Sat, 9 May 2020 04:13:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E43E688A67; Fri, 8 May 2020 18:13:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xkk9rVKomHOx; Fri, 8 May 2020 18:13:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 43F968842A; Fri, 8 May 2020 18:13:10 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 39BBA1BF340 for ; Fri, 8 May 2020 18:13:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 369A488A4F for ; Fri, 8 May 2020 18:13:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zSAaPkqk7G8L for ; Fri, 8 May 2020 18:13:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from secvs05.rockwellcollins.com (secvs05.rockwellcollins.com [205.175.225.131]) by whitealder.osuosl.org (Postfix) with ESMTPS id 9528488A11 for ; Fri, 8 May 2020 18:13:06 +0000 (UTC) IronPort-SDR: WwYuIFuFpMKMZkTMVjvI3046PJnmjYpgC/YdUiOK9dUFvIbGx7dcJVlkcEdiILVkJKWlE25V69 GOMZ98znS/Is1yMMIK3Ontp4zQlHtDbPcayLPvldzSxu5fv+f3ZWoWvFSjc3Ilt3iyuNT4X/Hx XMS/ioIYUABxjxEZfFaWoVArPqCNQcNToTF/+3yz28+WkOfs+ndp9HJAbf35j6UDqdfkABFlim RjigNiUmM0ul5A0KH/Xu+ufeMVe2ebTPlcIxTUgQT83ZqztSNpSAaluSInYKbuStRs9TGnHb8Y V6g= Received: from ofwgwc03.rockwellcollins.com (HELO crulimr02.rockwellcollins.com) ([205.175.225.12]) by secvs05.rockwellcollins.com with ESMTP; 08 May 2020 13:13:05 -0500 X-Received: from biscuits.rockwellcollins.com (biscuits.rockwellcollins.lab [10.148.119.137]) by crulimr02.rockwellcollins.com (Postfix) with ESMTP id 1613860249; Fri, 8 May 2020 13:13:05 -0500 (CDT) From: Matt Weber To: buildroot@buildroot.org Date: Fri, 8 May 2020 13:13:04 -0500 Message-Id: <20200508181304.52228-1-matthew.weber@rockwellcollins.com> X-Mailer: git-send-email 2.17.1 Subject: [Buildroot] [PATCH] package/uboot-tools: add option to build env bin X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matt Weber MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Add an option to allow the creation of a u-boot environment binary from a set of provided source file(s) when the defconfig being built does not offer the option via the u-boot package. This feature requires environment source files unlike the u-boot package equivalent that can build the default environment based on the specific u-boot source tree and configuration. Signed-off-by: Matthew Weber --- I did not add conditions to force the user to use the u-boot pkg option if that is available. Seemed unnecessary as this would still work in that case. --- package/uboot-tools/Config.in.host | 54 ++++++++++++++++++++++++++++-- package/uboot-tools/uboot-tools.mk | 13 +++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/package/uboot-tools/Config.in.host b/package/uboot-tools/Config.in.host index 52a4c2ec30..fccd40e4e4 100644 --- a/package/uboot-tools/Config.in.host +++ b/package/uboot-tools/Config.in.host @@ -37,6 +37,56 @@ config BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SIGNATURE_SUPPORT public key is stored in a non-volatile place, any image can be verified in this way. -endif +endif # BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT -endif +config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE + bool "Environment image" + help + Generate a valid binary environment image from a text file + describing the key=value pairs of the environment. + + This option can be useful to build enviornment configurations + as part of a Linux / rootfs only defconfig instead of using + post scripts. This supports a hardware use case of a single + bootloader only defconfig but multiple Linux / rootfs + defconfigs with different boot environments. + + The environment image will be called uboot-env.bin. + +if BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE + +config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE + string "Source files for environment" + help + Text files describing the environment. Files should have + lines of the form var=value, one per line. Blank lines and + lines starting with a # are ignored. + + Multiple source files are concatenated in the order listed. + + Unlike the U-Boot package, the source files must be provided + as there is no uboot configured to define the compiled-in env. + +config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE + string "Size of environment" + help + Size of envronment, can be prefixed with 0x for hexadecimal + values. + +config BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_REDUNDANT + bool "Environment has two copies" + help + Some platforms define in their U-Boot configuration that the + U-Boot environment should be duplicated in two locations (for + extra safety). Check your U-Boot configuration for the + CONFIG_ENV_ADDR_REDUND and CONFIG_ENV_SIZE_REDUND settings to + see if this is the case for your platform. + + If it is the case, then you should enable this option to + ensure that the U-Boot environment image generated by + Buildroot is compatible with the "redundant environment" + mechanism of U-Boot. + +endif # BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE + +endif # BR2_PACKAGE_HOST_UBOOT_TOOLS diff --git a/package/uboot-tools/uboot-tools.mk b/package/uboot-tools/uboot-tools.mk index 55d1123bc8..de665e8fbf 100644 --- a/package/uboot-tools/uboot-tools.mk +++ b/package/uboot-tools/uboot-tools.mk @@ -112,10 +112,23 @@ define HOST_UBOOT_TOOLS_BUILD_CMDS $(BR2_MAKE1) -C $(@D) $(HOST_UBOOT_TOOLS_MAKE_OPTS) tools-only endef +ifneq ($(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE),) +UBOOT_TOOLS_GENERATE_ENV_FILE = $(call qstrip,$(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE)) +define UBOOT_TOOLS_GENERATE_ENV_IMAGE + cat $(UBOOT_TOOLS_GENERATE_ENV_FILE) > $(@D)/buildroot-env.txt + $(HOST_DIR)/bin/mkenvimage -s $(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE) \ + $(if $(BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_REDUNDANT),-r) \ + $(if $(filter "BIG",$(BR2_ENDIAN)),-b) \ + -o $(BINARIES_DIR)/uboot-env.bin \ + $(@D)/buildroot-env.txt +endef +endif + define HOST_UBOOT_TOOLS_INSTALL_CMDS $(INSTALL) -m 0755 -D $(@D)/tools/mkimage $(HOST_DIR)/bin/mkimage $(INSTALL) -m 0755 -D $(@D)/tools/mkenvimage $(HOST_DIR)/bin/mkenvimage $(INSTALL) -m 0755 -D $(@D)/tools/dumpimage $(HOST_DIR)/bin/dumpimage + $(UBOOT_TOOLS_GENERATE_ENV_IMAGE) endef $(eval $(generic-package))