From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 24 Mar 2023 19:28:57 +0100 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pfm9p-00DRXH-0C for lore@lore.pengutronix.de; Fri, 24 Mar 2023 19:28:57 +0100 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pfm9o-000802-Nx; Fri, 24 Mar 2023 19:28:56 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pfm9i-0007yS-E6; Fri, 24 Mar 2023 19:28:50 +0100 Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pfm9h-006RZz-PW; Fri, 24 Mar 2023 19:28:49 +0100 Received: from jzi by dude03.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pfm9g-0026Js-PO; Fri, 24 Mar 2023 19:28:48 +0100 From: Johannes Zink To: distrokit@pengutronix.de Date: Fri, 24 Mar 2023 19:28:43 +0100 Message-Id: <20230324182845.500894-2-j.zink@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230324182845.500894-1-j.zink@pengutronix.de> References: <20230324182845.500894-1-j.zink@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 1/3] v8a: rock3a: autostart usb fastboot and ACM gadget on ROCK 3A X-BeenThere: distrokit@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: DistroKit Mailinglist List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Zink , jzi@pengutronix.de Sender: "DistroKit" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: distrokit-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false This allows the board to be booted by supplying kernel, oftree and initramfs over usb fastboot. This is particularly useful for board bringup and testing in situations where network boot is not possible. Also, it may be used to flash the SD card or eMMC (if fitted). While at, also improve the netboot target in such that tftboot and nfsroot are used if available. While at it: also autostart the ACM USB Gadget, which exposes a serial console over USB. Signed-off-by: Johannes Zink --- .../barebox-rock3a-defaultenv/boot/net | 28 +++++++++++++++++++ .../barebox-rock3a-defaultenv/init/bootsource | 1 - .../barebox-rock3a-defaultenv/nv/fastboot.bbu | 1 + .../nv/fastboot.partitions | 1 + .../nv/usbgadget.acm | 1 + .../nv/usbgadget.autostart | 1 + 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 configs/platform-v8a/barebox-rock3a-defaultenv/boot/net create mode 100644 configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.bbu create mode 100644 configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.partitions create mode 100644 configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.acm create mode 100644 configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.autostart diff --git a/configs/platform-v8a/barebox-rock3a-defaultenv/boot/net b/configs/platform-v8a/barebox-rock3a-defaultenv/boot/net new file mode 100644 index 000000000000..e79432eb277c --- /dev/null +++ b/configs/platform-v8a/barebox-rock3a-defaultenv/boot/net @@ -0,0 +1,28 @@ +#!/bin/sh + +path="/mnt/tftp" + +# global.net.server and global.hostname may be set by DHCP, so trigger it first +ifup -a + +global.bootm.image="${path}/${global.user}-linux-${global.hostname}" + +oftree="${path}/${global.user}-oftree-${global.hostname}" +if [ -f "${oftree}" ]; then + global.bootm.oftree="$oftree" +fi + +host ${global.net.server} nfsserver +if [ $? != 0 ]; then + echo "Cannot resolve \"${global.net.server}\"" + exit 1 +fi + +initramfs="${path}/${global.user}-initramfs-${global.hostname}" +if [ -f "${initramfs}" ]; then + global.bootm.initrd="$initramfs" +else + nfsroot="${nfsserver}:/home/${global.user}/nfsroot/${global.hostname}" + ip_route_get -b ${global.net.server} global.linux.bootargs.dyn.ip + global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp" +fi diff --git a/configs/platform-v8a/barebox-rock3a-defaultenv/init/bootsource b/configs/platform-v8a/barebox-rock3a-defaultenv/init/bootsource index 6a3bb42ba3af..5a227bbf8927 100644 --- a/configs/platform-v8a/barebox-rock3a-defaultenv/init/bootsource +++ b/configs/platform-v8a/barebox-rock3a-defaultenv/init/bootsource @@ -9,6 +9,5 @@ if [ "$bootsource" = mmc ]; then global.boot.default="mmc$bootsource_instance net" of_property -df mmc0 sd-uhs-sdr104 elif [ "$bootsource" = "spi-nor" ]; then - usbgadget -A '/dev/mmc0(sd)' global.autoboot=abort fi diff --git a/configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.bbu b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.bbu new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.bbu @@ -0,0 +1 @@ +1 diff --git a/configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.partitions b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.partitions new file mode 100644 index 000000000000..a67f90305dd6 --- /dev/null +++ b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/fastboot.partitions @@ -0,0 +1 @@ +/dev/mmc0(sd)o,/dev/mmc1(emmc)o,/tmp/kernel(kernel)c,/tmp/initramfs(initramfs)c,/tmp/oftree(oftree)c diff --git a/configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.acm b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.acm new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.acm @@ -0,0 +1 @@ +1 diff --git a/configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.autostart b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.autostart new file mode 100644 index 000000000000..d00491fd7e5b --- /dev/null +++ b/configs/platform-v8a/barebox-rock3a-defaultenv/nv/usbgadget.autostart @@ -0,0 +1 @@ +1 -- 2.30.2