Skip to content

Commit

Permalink
MIPS: qemu-malta: generate swapped image as part of multi-image build
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.barebox.org/[email protected]
Signed-off-by: Sascha Hauer <[email protected]>
  • Loading branch information
a3f authored and saschahauer committed Jun 9, 2021
1 parent 550cfbc commit 152bbdb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
16 changes: 4 additions & 12 deletions Documentation/boards/mips/qemu-malta.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions images/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ barebox.sum
*.mvebu1img
*.stm32
*.nmon
*.swapped
2 changes: 1 addition & 1 deletion images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion images/Makefile.malta
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 152bbdb

Please sign in to comment.