summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-04 10:46:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-09 12:20:05 +0200
commit152bbdb7cfefab89132549ea83fb0b859c290e8a (patch)
tree8f6f7d3aa7b0b8cd24462fb44d15429b1bd22265
parent550cfbc917c9d48110e6e4e7c348e928fa69a4c6 (diff)
downloadbarebox-152bbdb7cfefab89132549ea83fb0b859c290e8a.tar.gz
barebox-152bbdb7cfefab89132549ea83fb0b859c290e8a.tar.xz
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 <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210604084704.17410-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--Documentation/boards/mips/qemu-malta.rst16
-rw-r--r--images/.gitignore1
-rw-r--r--images/Makefile2
-rw-r--r--images/Makefile.malta10
4 files changed, 15 insertions, 14 deletions
diff --git a/Documentation/boards/mips/qemu-malta.rst b/Documentation/boards/mips/qemu-malta.rst
index e188ae8c64..fd37d5edb2 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 eafdb44b5b..3a9a77dad1 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 c185982c17..cc330d9575 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 5739ec4640..96d7b86b11 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