From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 22 Aug 2024 15:46:01 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sh88X-00CGR8-17 for lore@lore.pengutronix.de; Thu, 22 Aug 2024 15:46:01 +0200 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1sh88W-0001st-Kw; Thu, 22 Aug 2024 15:46:00 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sh88P-0001rr-2d; Thu, 22 Aug 2024 15:45:53 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sh88O-002GJk-Li; Thu, 22 Aug 2024 15:45:52 +0200 Received: from localhost ([::1] helo=dude05.red.stw.pengutronix.de) by dude05.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1sh88O-00DKOR-1q; Thu, 22 Aug 2024 15:45:52 +0200 From: Ahmad Fatoum To: distrokit@pengutronix.de Date: Thu, 22 Aug 2024 15:45:51 +0200 Message-Id: <20240822134551.3176638-3-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822134551.3176638-1-a.fatoum@pengutronix.de> References: <20240822134551.3176638-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 3/3] mipsel: qemu-run: enable emulation of little endian barebox 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: Ahmad Fatoum , ore@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.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false qemu-system-mipsel unlike GXemul requires that the 32-bit words inside the barebox binary are swapped when not using the default big-endian mode. Recent barebox versions generate an additional swapped image that can be used, so let's import the barebox patch that enables it. We can drop this patch again, when update to a barebox version that includes the stdout-path changes, probably v2024.10.0 or later. Signed-off-by: Ahmad Fatoum --- ...generate-swapped-image-as-part-of-mu.patch | 102 ++++++++++++++++++ .../patches/barebox-2021.06.0/series | 1 + .../platform-mipsel/rules/barebox-malta.make | 2 +- configs/platform-mipsel/run | 2 +- 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 configs/platform-mipsel/patches/barebox-2021.06.0/0003-MIPS-qemu-malta-generate-swapped-image-as-part-of-mu.patch diff --git a/configs/platform-mipsel/patches/barebox-2021.06.0/0003-MIPS-qemu-malta-generate-swapped-image-as-part-of-mu.patch b/configs/platform-mipsel/patches/barebox-2021.06.0/0003-MIPS-qemu-malta-generate-swapped-image-as-part-of-mu.patch new file mode 100644 index 000000000000..de704edffd40 --- /dev/null +++ b/configs/platform-mipsel/patches/barebox-2021.06.0/0003-MIPS-qemu-malta-generate-swapped-image-as-part-of-mu.patch @@ -0,0 +1,102 @@ +From 152bbdb7cfefab89132549ea83fb0b859c290e8a Mon Sep 17 00:00:00 2001 +From: Ahmad Fatoum +Date: Fri, 4 Jun 2021 10:46:55 +0200 +Subject: [PATCH] MIPS: qemu-malta: generate swapped image as part of + multi-image build + +Having to manually swap the words in the MIPS Malta image for QEMU +little endian emulation is annoying. + +Have the multi-image build for Malta generate a second .swapped +image that can be readily used if needed. + +Signed-off-by: Ahmad Fatoum +Link: https://lore.barebox.org/20210604084704.17410-5-a.fatoum@pengutronix.de +Signed-off-by: Sascha Hauer +--- + Documentation/boards/mips/qemu-malta.rst | 16 ++++------------ + images/.gitignore | 1 + + images/Makefile | 2 +- + images/Makefile.malta | 10 +++++++++- + 4 files changed, 15 insertions(+), 14 deletions(-) + +diff --git a/Documentation/boards/mips/qemu-malta.rst b/Documentation/boards/mips/qemu-malta.rst +index e188ae8c642a..fd37d5edb229 100644 +--- a/Documentation/boards/mips/qemu-malta.rst ++++ b/Documentation/boards/mips/qemu-malta.rst +@@ -10,31 +10,23 @@ QEMU run string: + + qemu-system-mips -nodefaults -M malta -m 256 \ + -device VGA -serial stdio -monitor null \ +- -bios barebox-flash-image ++ -bios ./images/barebox-qemu-malta.img + + + Little-endian mode + ------------------ + +-Running little-endian Malta is a bit tricky. + In little-endian mode the 32bit words in the boot flash image are swapped, + a neat trick which allows bi-endian firmware. + +-You have to swap words of ``zbarebox.bin`` image, e.g.: +- +-.. code-block:: sh +- +- echo arch/mips/pbl/zbarebox.bin \ +- | cpio --create \ +- | cpio --extract --swap --unconditional +- +-QEMU run string: ++The barebox build generates a second ``./images/barebox-qemu-malta.img.swapped`` ++image that can be used in this case, e.g.: + + .. code-block:: sh + + qemu-system-mipsel -nodefaults -M malta -m 256 \ + -device VGA -serial stdio -monitor null \ +- -bios barebox-flash-image ++ -bios ./images/barebox-qemu-malta.img.swapped + + + Using GXemul +diff --git a/images/.gitignore b/images/.gitignore +index eafdb44b5bdd..3a9a77dad16e 100644 +--- a/images/.gitignore ++++ b/images/.gitignore +@@ -32,3 +32,4 @@ barebox.sum + *.mvebu1img + *.stm32 + *.nmon ++*.swapped +diff --git a/images/Makefile b/images/Makefile +index c185982c17ed..cc330d957597 100644 +--- a/images/Makefile ++++ b/images/Makefile +@@ -218,5 +218,5 @@ $(flash-list): $(image-y-path) + clean-files := *.pbl *.pblb *.map start_*.imximg *.img barebox.z start_*.kwbimg \ + start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg *.t30img \ + *.t30img.cfg *.t124img *.t124img.cfg *.mlospi *.mlo *.mxsbs *.mxssd \ +- start_*.simximg start_*.usimximg *.zynqimg *.image ++ start_*.simximg start_*.usimximg *.zynqimg *.image *.swapped + clean-files += pbl.lds +diff --git a/images/Makefile.malta b/images/Makefile.malta +index 5739ec464092..96d7b86b1187 100644 +--- a/images/Makefile.malta ++++ b/images/Makefile.malta +@@ -1,3 +1,11 @@ ++quiet_cmd_bswap32_image = BSWAP4 $@ ++ cmd_bswap32_image = cp $< $@ && \ ++ truncate -s %4 $@ && \ ++ objcopy -I binary --reverse-byte=4 $@ ++ ++$(obj)/%.img.swapped: $(obj)/%.img FORCE ++ $(call if_changed,bswap32_image) ++ + pblb-$(CONFIG_BOARD_QEMU_MALTA) += start_qemu_malta + FILE_barebox-qemu-malta.img = start_qemu_malta.pblb +-image-$(CONFIG_BOARD_QEMU_MALTA) += barebox-qemu-malta.img ++image-$(CONFIG_BOARD_QEMU_MALTA) += barebox-qemu-malta.img barebox-qemu-malta.img.swapped +-- +2.39.2 + diff --git a/configs/platform-mipsel/patches/barebox-2021.06.0/series b/configs/platform-mipsel/patches/barebox-2021.06.0/series index b9b6f404fa41..4852ea3fdfaa 100644 --- a/configs/platform-mipsel/patches/barebox-2021.06.0/series +++ b/configs/platform-mipsel/patches/barebox-2021.06.0/series @@ -1,2 +1,3 @@ 0001-MIPS-dts-add-chosen-stdout-path-where-it-is-missing.patch 0002-MIPS-qemu-malta-explicitly-set-stdout-path.patch +0003-MIPS-qemu-malta-generate-swapped-image-as-part-of-mu.patch diff --git a/configs/platform-mipsel/rules/barebox-malta.make b/configs/platform-mipsel/rules/barebox-malta.make index 9143d47433c8..8eb765609ffe 100644 --- a/configs/platform-mipsel/rules/barebox-malta.make +++ b/configs/platform-mipsel/rules/barebox-malta.make @@ -48,7 +48,7 @@ BAREBOX_MALTA_CONF_OPT := \ BAREBOX_MALTA_MAKE_OPT := $(BAREBOX_MALTA_CONF_OPT) -BAREBOX_MALTA_IMAGES := images/barebox-qemu-malta.img +BAREBOX_MALTA_IMAGES := images/barebox-qemu-malta.img.swapped BAREBOX_MALTA_IMAGES := $(addprefix $(BAREBOX_MALTA_BUILD_DIR)/,$(BAREBOX_MALTA_IMAGES)) ifdef PTXCONF_BAREBOX_MALTA diff --git a/configs/platform-mipsel/run b/configs/platform-mipsel/run index 9ecf65b2e429..b6126531d8a8 100755 --- a/configs/platform-mipsel/run +++ b/configs/platform-mipsel/run @@ -72,7 +72,7 @@ QEMU_ARGS=( "${QEMU_ARGS[@]}" -rtc base=2021-01-01 ) QEMU_LINUX_ARGS=( -kernel ${PTXDIST_PLATFORMDIR}/images/vmlinuz-malta -dtb ${PTXDIST_PLATFORMDIR}/images/qemu-malta.dtb-bb ) # the barebox device tree has a state node for bootchooser -QEMU_BAREBOX_ARGS=( -bios ${PTXDIST_PLATFORMDIR}/images/barebox-qemu-malta.img ) +QEMU_BAREBOX_ARGS=( -bios ${PTXDIST_PLATFORMDIR}/images/barebox-qemu-malta.img.swapped-malta ) check_hd() { if [ ! -e "${PTXDIST_PLATFORMDIR}/images/malta.hdimg" ]; then -- 2.39.2