From patchwork Thu Mar 28 17:07:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Maciej Nowak X-Patchwork-Id: 1068475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=o2.pl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h8Eg8ADN"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.b="pPD8uvia"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44VWVv1Wkjz9sNq for ; Fri, 29 Mar 2019 04:06:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=YLs9zODJo3u66ju/MNa+x9IAsznrnUQEK7SFC4qZ1sc=; b=h8Eg8ADNEh/XV93RRcgQvrR/Zp LltfjBPcqTR2I03IBypFhaE5r3efC4IC2Sr3ghgHLeo1jK8Y/kyqm1QmWGwpfN23MrJDZBOa56Njh /uQXCAvmZwwOGOKseAqnZZxXPBgWLoKpbv/ggq7zlkbIgtgVMJohtcOtyn6tGlDW/t19YHi2WalLL vjVC/dsvu5HhEl2kq90D5MP+baNkwg5K33D11t7WJTmu/D0oGzAReY2Vu/oXGV1CbMCRax9XwPgIE tThnNTJTiFjt3W+/xq9LKXjtdNmfImXwiMHREEu9lZDUcz1ufqnqhSOlahdaxogjLe4rH6vpk7PcR W4ge1HYg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9YU4-000274-3A; Thu, 28 Mar 2019 17:06:32 +0000 Received: from mx-out.tlen.pl ([193.222.135.158]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9YTA-0000ir-RY for openwrt-devel@lists.openwrt.org; Thu, 28 Mar 2019 17:05:43 +0000 Received: (wp-smtpd smtp.tlen.pl 34741 invoked from network); 28 Mar 2019 18:05:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=1024a; t=1553792734; bh=X5v0c8ABbmDGh6JS/z3IkNkjHrAmuBqR8/DjFvq5hw0=; h=From:To:Subject; b=pPD8uviacFkrhWpWuHbYjxYi/hoCM7dvOp72uHzVk7Lg/ine45086cjt7gsi98Uhc aMSN0sUejI5XQJeCnkzpuMjH+ZUGVkXuIdaBeD9bje1j0ZAmBRVivTKsHu16TzJjuu zFU1WWtDUVBdponK5M6onQ0d3IKNshWXn0cTEXJA= Received: from 131.ip-164-132-48.eu (HELO localhost.localdomain) (tomek_n@o2.pl@[164.132.48.131]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 28 Mar 2019 18:05:33 +0100 From: Tomasz Maciej Nowak To: openwrt-devel@lists.openwrt.org Date: Thu, 28 Mar 2019 18:07:11 +0100 Message-Id: <20190328170711.3564-8-tomek_n@o2.pl> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190328170711.3564-1-tomek_n@o2.pl> References: <20190321185727.3239-1-tomek_n@o2.pl> <20190328170711.3564-1-tomek_n@o2.pl> MIME-Version: 1.0 X-WP-MailID: 7448c6453a1d08351274317050d645cb X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000000 [8RO0] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190328_100537_634522_6DB8C752 X-CRM114-Status: GOOD ( 10.33 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (tomek_n[at]o2.pl) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH v2 7/7] mvebu: espressobin: add u-boot environment X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This commit adds U-Boot environment defaults which extend the bootloader to automatically boot the ESPRESSObin board from other connected mediums i.e. SATA disk or USB disk. The assigned boot probe order is as follows: 1. USB (usb0), 2. SATA (scsi0), 3. µSD (mmc0), 4. eMMC (mmc1). U-Boot will iterate through them utill it'll find on one of devices the uEnv.txt file. If not found, it'll fall back to loading using boot.scr (loading from boot.scr is compatible only with U-Boot version 2017.03 or later). There is also self update mechanism implemented which will trigger if the variable 'owrt_uenv_ver' is changed. This commit also adds compatibility with newer U-Boot versions in which kernel_addr and fdt_addr environment variables changed names to kernel_addr_r and fdt_addr_r. The bootloader environment preparation needs to be done for every new deployment and for every board with U-Boot 2015.01 version. 1. Connect/insert boot device with OpenWrt, 2. Power on the board and enter U-Boot command line, 3. Execute following commands: usb start scsi scan ext4load mmc 0:1 $loadaddr uEnv.txt || ext4load scsi 0:1 $loadaddr uEnv.txt || ext4load usb 0:1 $loadaddr uEnv.txt env import -t $loadaddr env delete $old_or_temp_vars saveenv reset 4. Now board should automatically find boot medium with OpenWrt installation and boot it. Signed-off-by: Tomasz Maciej Nowak --- target/linux/mvebu/image/Makefile | 10 ++++++++ target/linux/mvebu/image/cortex-a53.mk | 2 +- .../image/globalscale-espressobin.bootscript | 14 ++++++++--- .../mvebu/image/globalscale-espressobin.uenv | 25 +++++++++++++++++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 target/linux/mvebu/image/globalscale-espressobin.uenv diff --git a/target/linux/mvebu/image/Makefile b/target/linux/mvebu/image/Makefile index 88790777d9..126136dc6a 100644 --- a/target/linux/mvebu/image/Makefile +++ b/target/linux/mvebu/image/Makefile @@ -26,6 +26,15 @@ define Build/boot-scr mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d $@-new.bootscript $@-boot.scr endef +define Build/uenv-txt + rm -f $@-uEnv.txt + sed \ + -e 's#@ROOT@#$(SIGNATURE)#g' \ + -e 's#@DTB@#$(DEVICE_DTS)#g' \ + -e 's#@KERNEL@#$(KERNEL_NAME)#g' \ + $(DEVICE_NAME).uenv > $@-uEnv.txt +endef + define Build/boot-img rm -f $@.boot mkfs.fat -C $@.boot $$(( $(CONFIG_TARGET_KERNEL_PARTSIZE) * 1024 )) @@ -40,6 +49,7 @@ define Build/boot-img-ext4 $(foreach dts,$(DEVICE_DTS), $(CP) $(DTS_DIR)/$(dts).dtb $@.boot;) $(CP) $(IMAGE_KERNEL) $@.boot/$(KERNEL_NAME) -$(CP) $@-boot.scr $@.boot/boot.scr + -$(CP) $@-uEnv.txt $@.boot/uEnv.txt make_ext4fs -J -l $(CONFIG_TARGET_KERNEL_PARTSIZE)M $@.bootimg $@.boot endef diff --git a/target/linux/mvebu/image/cortex-a53.mk b/target/linux/mvebu/image/cortex-a53.mk index dd6176100b..338c29c7f9 100644 --- a/target/linux/mvebu/image/cortex-a53.mk +++ b/target/linux/mvebu/image/cortex-a53.mk @@ -5,7 +5,7 @@ define Device/globalscale-espressobin KERNEL := kernel-bin DEVICE_TITLE := ESPRESSObin (Marvell Armada 3700 Community Board) IMAGES := sdcard.img.gz - IMAGE/sdcard.img.gz := boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata + IMAGE/sdcard.img.gz := uenv-txt | boot-scr | boot-img-ext4 | sdcard-img-ext4 | gzip | append-metadata DEVICE_DTS := armada-3720-espressobin DTS_DIR := $(DTS_DIR)/marvell SUPPORTED_DEVICES := globalscale,espressobin diff --git a/target/linux/mvebu/image/globalscale-espressobin.bootscript b/target/linux/mvebu/image/globalscale-espressobin.bootscript index 0d03ac8513..d2a9653613 100644 --- a/target/linux/mvebu/image/globalscale-espressobin.bootscript +++ b/target/linux/mvebu/image/globalscale-espressobin.bootscript @@ -1,10 +1,18 @@ +if test -z "${owrt_uenv_ver}"; then + load mmc 0:1 ${loadaddr} uEnv.txt + env import -t ${loadaddr} + env delete ${old_or_temp_vars} + saveenv + boot +fi + setenv bootargs "root=PARTUUID=@ROOT@-02 rw rootwait" if test -n "${console}"; then setenv bootargs "${bootargs} ${console}" fi -load mmc 0:1 ${fdt_addr} armada-3720-espressobin.dtb -load mmc 0:1 ${kernel_addr} Image +load mmc 0:1 ${fdt_addr}${fdt_addr_r} armada-3720-espressobin.dtb +load mmc 0:1 ${kernel_addr}${kernel_addr_r} Image -booti ${kernel_addr} - ${fdt_addr} +booti ${kernel_addr}${kernel_addr_r} - ${fdt_addr}${fdt_addr_r} diff --git a/target/linux/mvebu/image/globalscale-espressobin.uenv b/target/linux/mvebu/image/globalscale-espressobin.uenv new file mode 100644 index 0000000000..986db9884b --- /dev/null +++ b/target/linux/mvebu/image/globalscale-espressobin.uenv @@ -0,0 +1,25 @@ +owrt_uenv_ver=1 +old_or_temp_vars=devnum devtype fileaddr filesize root uenv_ver old_or_temp_vars +boot_a_script=ext4load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} ${prefix}${script}; run set_owrt_uenv_ver; if test "${script}" = "uEnv.txt"; then env import -t ${loadaddr}; elif test "${script}" = "boot.scr"; then source ${loadaddr}; fi; run upg_owrt_uenv; run boot_owrt +boot_owrt=setenv bootargs "${console} ${root} rw rootwait ${extra_params}"; ext4load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr}${fdt_addr_r} ${fdt_name}; ext4load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr}${kernel_addr_r} ${image_name}; booti ${kernel_addr}${kernel_addr_r} - ${fdt_addr}${fdt_addr_r} +boot_prefixes=/ /boot/ +boot_scripts=uEnv.txt boot.scr +boot_targets=usb0 scsi0 mmc0 mmc1 +bootcmd=run distro_bootcmd +bootcmd_mmc0=setenv devnum 0; run mmc_boot +bootcmd_mmc1=setenv devnum 1; run mmc_boot +bootcmd_scsi0=setenv devnum 0; run scsi_boot +bootcmd_usb0=setenv devnum 0; run usb_boot +distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done +distro_bootpart=1 +extra_params=pci=pcie_bus_safe +fdt_name=@DTB@.dtb +image_name=@KERNEL@ +mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot; fi +root=root=PARTUUID=@ROOT@-02 +scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_scripts; done; +scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done +scsi_boot=scsi scan; if scsi dev ${devnum}; then setenv devtype scsi; run scan_dev_for_boot; fi +set_owrt_uenv_ver=if test -n ${owrt_uenv_ver}; then setenv uenv_ver ${owrt_uenv_ver}; fi +upg_owrt_uenv=if test ${uenv_ver} != ${owrt_uenv_ver}; then env delete ${old_or_temp_vars}; saveenv; echo U-Boot environment changed to version ${owrt_uenv_ver}; boot; fi +usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot; fi