Skip to contentSkip to conversation

riscv: roms: Add 32-bit OpenSBI firmware image for sifive_u

PATCH In review Bin Meng 4 participants 10 messages Feb 20, 2020 – Feb 22, 2020

Subsystems (3)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/2 riscv: roms: Add 32-bit OpenSBI firmware image for sifive_u

Although the real world SiFive HiFive Unleashed board is a 64-bit hardware configuration, with QEMU it is possible to test 32-bit configuration with the same hardware features.

This updates the roms Makefile to add the build rules for creating the 32-bit OpenSBI firmware image for sifive_u machine. A pre-built OpenSBI image (built from commit 3e7d666) has been added as the default bios for 32-bit sifive_u machine.

---

 Makefile                                     |   2 +-
 pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin | Bin 0 -> 49472 bytes
 roms/Makefile                                |   7 +++++++
 3 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin
Makefile +1 -1
index b5a7377..ee7aa6d 100644
@@ -804,7 +804,7 @@ u-boot.e500 u-boot-sam460-20100605.bin \
 qemu_vga.ndrv \
 edk2-licenses.txt \
 hppa-firmware.img \
-opensbi-riscv32-virt-fw_jump.bin \
+opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
 opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
 
 
pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..93e2556baa261bfd796cdc484b345bf958c8afea
GIT binary patch
roms/Makefile +7 -0
index 28e1e55..f9acf39 100644
@@ -66,6 +66,7 @@ default help:
 	@echo "  efi                -- update UEFI (edk2) platform firmware"
 	@echo "  opensbi32-virt     -- update OpenSBI for 32-bit virt machine"
 	@echo "  opensbi64-virt     -- update OpenSBI for 64-bit virt machine"
+	@echo "  opensbi32-sifive_u -- update OpenSBI for 32-bit sifive_u machine"
 	@echo "  opensbi64-sifive_u -- update OpenSBI for 64-bit sifive_u machine"
 	@echo "  bios-microvm       -- update bios-microvm.bin (qboot)"
 	@echo "  clean              -- delete the files generated by the previous" \
@@ -181,6 +182,12 @@ opensbi64-virt:
 		PLATFORM="qemu/virt"
 	cp opensbi/build/platform/qemu/virt/firmware/fw_jump.bin ../pc-bios/opensbi-riscv64-virt-fw_jump.bin
 
+opensbi32-sifive_u:
+	$(MAKE) -C opensbi \
+		CROSS_COMPILE=$(riscv32_cross_prefix) \
+		PLATFORM="sifive/fu540"
+	cp opensbi/build/platform/sifive/fu540/firmware/fw_jump.bin ../pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin
+
 opensbi64-sifive_u:
 	$(MAKE) -C opensbi \
 		CROSS_COMPILE=$(riscv64_cross_prefix) \
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 riscv: sifive_u: Update BIOS_FILENAME for 32-bit

Update BIOS_FILENAME to consider 32-bit bios image file name.

Tested booting Linux v5.5 32-bit image (built from rv32_defconfig plus CONFIG_SOC_SIFIVE) with the default 32-bit bios image.

---

 hw/riscv/sifive_u.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/riscv/sifive_u.c +5 -1
index ca561d3..371133e 100644
@@ -57,7 +57,11 @@
 
 #include <libfdt.h>
 
-#define BIOS_FILENAME "opensbi-riscv64-sifive_u-fw_jump.bin"
+#if defined(TARGET_RISCV32)
+# define BIOS_FILENAME "opensbi-riscv32-sifive_u-fw_jump.bin"
+#else
+# define BIOS_FILENAME "opensbi-riscv64-sifive_u-fw_jump.bin"
+#endif
 
 static const struct MemmapEntry {
     hwaddr base;
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] riscv: sifive_u: Update BIOS_FILENAME for 32-bit

Quoted 5 lines · Bin Meng

Update BIOS_FILENAME to consider 32-bit bios image file name.

Tested booting Linux v5.5 32-bit image (built from rv32_defconfig plus CONFIG_SOC_SIFIVE) with the default 32-bit bios image.

Do we really want to support a 32-bit sifive_u machine?

Alistair

Quoted 28 lines

---

 hw/riscv/sifive_u.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
hw/riscv/sifive_u.c +5 -2
index ca561d3..371133e 100644
@@ -57,7 +57,11 @@
 
 #include <libfdt.h>
 
-#define BIOS_FILENAME "opensbi-riscv64-sifive_u-fw_jump.bin"
+#if defined(TARGET_RISCV32)
+# define BIOS_FILENAME "opensbi-riscv32-sifive_u-fw_jump.bin"
+#else
+# define BIOS_FILENAME "opensbi-riscv64-sifive_u-fw_jump.bin"
+#endif
 
 static const struct MemmapEntry {
     hwaddr base;
--

2.7.4

author
#3 lore raw

Re: [PATCH 2/2] riscv: sifive_u: Update BIOS_FILENAME for 32-bit

Quoted 10 lines · Alistair Francis
Quoted 5 lines · Bin Meng

Update BIOS_FILENAME to consider 32-bit bios image file name.

Tested booting Linux v5.5 32-bit image (built from rv32_defconfig plus CONFIG_SOC_SIFIVE) with the default 32-bit bios image.

Do we really want to support a 32-bit sifive_u machine?

QEMU is an emulator, why not? With 32-bit sifive_u machine, we can have 32-bit test coverage for SiFive specific drivers that cannot be done with the 'virt' machine.

Regards,
Bin

Reviewed-by
#4 lore raw

Re: [PATCH 2/2] riscv: sifive_u: Update BIOS_FILENAME for 32-bit

Quoted 10 lines · Bin Meng
Quoted 8 lines · Alistair Francis
Quoted 5 lines · Bin Meng

Update BIOS_FILENAME to consider 32-bit bios image file name.

Tested booting Linux v5.5 32-bit image (built from rv32_defconfig plus CONFIG_SOC_SIFIVE) with the default 32-bit bios image.

Quoted 6 lines
Quoted 2 lines

Do we really want to support a 32-bit sifive_u machine?

QEMU is an emulator, why not? With 32-bit sifive_u machine, we can have 32-bit test coverage for SiFive specific drivers that cannot be done with the 'virt' machine.

That is a good point.

Alistair

Quoted 3 lines

Regards,
Bin

#5 lore raw
In reply to Bin Meng

Hi Bin,

Quoted 8 lines · Bin Meng

Although the real world SiFive HiFive Unleashed board is a 64-bit hardware configuration, with QEMU it is possible to test 32-bit configuration with the same hardware features.

This updates the roms Makefile to add the build rules for creating the 32-bit OpenSBI firmware image for sifive_u machine. A pre-built OpenSBI image (built from commit 3e7d666) has been added as the default bios for 32-bit sifive_u machine.

With QEMU:

fatal: ambiguous argument '3e7d666': unknown revision or path not in the working tree.

This looks like an OpenSBI commit but QEMU only include up to v0.5.

Can you build v0.5? Else can you update the submodule?

Also, can you add a CI job to build this, so we have reproducible builds (see QEMU commit 71920809ceabed as example)?

Thanks,

Phil.

Quoted 590 lines

---

  Makefile                                     |   2 +-
  pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin | Bin 0 -> 49472 bytes
  roms/Makefile                                |   7 +++++++
  3 files changed, 8 insertions(+), 1 deletion(-)

create mode 100644 pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin

Makefile +1 -1
index b5a7377..ee7aa6d 100644
@@ -804,7 +804,7 @@ u-boot.e500 u-boot-sam460-20100605.bin \
  qemu_vga.ndrv \
  edk2-licenses.txt \
  hppa-firmware.img \
-opensbi-riscv32-virt-fw_jump.bin \
+opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
  opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
 
 
pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..93e2556baa261bfd796cdc484b345bf958c8afea
GIT binary patch
roms/Makefile +7 -0
index 28e1e55..f9acf39 100644
@@ -66,6 +66,7 @@ default help:
  	@echo "  efi                -- update UEFI (edk2) platform firmware"
  	@echo "  opensbi32-virt     -- update OpenSBI for 32-bit virt machine"
  	@echo "  opensbi64-virt     -- update OpenSBI for 64-bit virt machine"
+	@echo "  opensbi32-sifive_u -- update OpenSBI for 32-bit sifive_u machine"
  	@echo "  opensbi64-sifive_u -- update OpenSBI for 64-bit sifive_u machine"
  	@echo "  bios-microvm       -- update bios-microvm.bin (qboot)"
  	@echo "  clean              -- delete the files generated by the previous" \
@@ -181,6 +182,12 @@ opensbi64-virt:
  		PLATFORM="qemu/virt"
  	cp opensbi/build/platform/qemu/virt/firmware/fw_jump.bin ../pc-bios/opensbi-riscv64-virt-fw_jump.bin
 
+opensbi32-sifive_u:
+	$(MAKE) -C opensbi \
+		CROSS_COMPILE=$(riscv32_cross_prefix) \
+		PLATFORM="sifive/fu540"
+	cp opensbi/build/platform/sifive/fu540/firmware/fw_jump.bin ../pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin
+
  opensbi64-sifive_u:
  	$(MAKE) -C opensbi \
  		CROSS_COMPILE=$(riscv64_cross_prefix) \
author
#6 lore raw

Hi Philippe,

Quoted 13 lines · Philippe Mathieu-Daudé

Hi Bin,

Quoted 8 lines · Bin Meng

Although the real world SiFive HiFive Unleashed board is a 64-bit hardware configuration, with QEMU it is possible to test 32-bit configuration with the same hardware features.

This updates the roms Makefile to add the build rules for creating the 32-bit OpenSBI firmware image for sifive_u machine. A pre-built OpenSBI image (built from commit 3e7d666) has been added as the default bios for 32-bit sifive_u machine.

Quoted 9 lines

With QEMU:

fatal: ambiguous argument '3e7d666': unknown revision or path not in the working tree.

This looks like an OpenSBI commit but QEMU only include up to v0.5.

Can you build v0.5? Else can you update the submodule?

Will do in v2.

Quoted 2 lines

Also, can you add a CI job to build this, so we have reproducible builds (see QEMU commit 71920809ceabed as example)?

I cannot find any document for how to test CI job with gitlab CI. Does QEMU has a public CI runner for testing?

Regards,
Bin

#7 lore raw
Quoted 23 lines · Bin Meng

Hi Philippe,

Quoted 18 lines · Philippe Mathieu-Daudé

Hi Bin,

Quoted 8 lines · Bin Meng

Although the real world SiFive HiFive Unleashed board is a 64-bit hardware configuration, with QEMU it is possible to test 32-bit configuration with the same hardware features.

This updates the roms Makefile to add the build rules for creating the 32-bit OpenSBI firmware image for sifive_u machine. A pre-built OpenSBI image (built from commit 3e7d666) has been added as the default bios for 32-bit sifive_u machine.

With QEMU:

fatal: ambiguous argument '3e7d666': unknown revision or path not in the working tree.

Quoted 6 lines
Quoted 4 lines

This looks like an OpenSBI commit but QEMU only include up to v0.5.

Can you build v0.5? Else can you update the submodule?

Will do in v2.

We plan to release OpenSBI v0.6 on monday (24th Feb 2020) so maybe you can update all RISC-V ROM images based on OpenSBI v0.6 ??

Quoted 10 lines
Quoted 3 lines

Also, can you add a CI job to build this, so we have reproducible builds (see QEMU commit 71920809ceabed as example)?

I cannot find any document for how to test CI job with gitlab CI. Does QEMU has a public CI runner for testing?

Regards,
Bin

Regards,
Anup

#8 lore raw
Quoted 26 lines · Anup Patel
Quoted 25 lines · Bin Meng

Hi Philippe,

Quoted 20 lines · Philippe Mathieu-Daudé

Hi Bin,

Quoted 8 lines · Bin Meng

Although the real world SiFive HiFive Unleashed board is a 64-bit hardware configuration, with QEMU it is possible to test 32-bit configuration with the same hardware features.

This updates the roms Makefile to add the build rules for creating the 32-bit OpenSBI firmware image for sifive_u machine. A pre-built OpenSBI image (built from commit 3e7d666) has been added as the default bios for 32-bit sifive_u machine.

With QEMU:

fatal: ambiguous argument '3e7d666': unknown revision or path not in the working tree.

This looks like an OpenSBI commit but QEMU only include up to v0.5.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Can you build v0.5? Else can you update the submodule?

Will do in v2.

We plan to release OpenSBI v0.6 on monday (24th Feb 2020) so maybe you can update all RISC-V ROM images based on OpenSBI v0.6 ??

Sounds cleaner.

Suggestions when updating a QEMU git-submodule:

- Include output of submodule 'git-log --reverse --oneline'

- Send series/pull-request with 'git-format-patch --no-binary'

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Also, can you add a CI job to build this, so we have reproducible builds (see QEMU commit 71920809ceabed as example)?

I cannot find any document for how to test CI job with gitlab CI. Does QEMU has a public CI runner for testing?

There is:

https://wiki.qemu.org/Testing
https://wiki.qemu.org/Testing/CI

Currently you can use whatever CI best suits you (although long term is probably to rely more on GitLab, because it allows adding runners on particular hardware/setup).

Quoted 8 lines
Quoted 4 lines

Regards,
Bin

Regards,
Anup

author
#9 lore raw

Hi Philippe,

Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 29 lines · Anup Patel
Quoted 28 lines · Bin Meng

Hi Philippe,

Quoted 22 lines · Philippe Mathieu-Daudé

Hi Bin,

Quoted 8 lines · Bin Meng

Although the real world SiFive HiFive Unleashed board is a 64-bit hardware configuration, with QEMU it is possible to test 32-bit configuration with the same hardware features.

This updates the roms Makefile to add the build rules for creating the 32-bit OpenSBI firmware image for sifive_u machine. A pre-built OpenSBI image (built from commit 3e7d666) has been added as the default bios for 32-bit sifive_u machine.

With QEMU:

fatal: ambiguous argument '3e7d666': unknown revision or path not in the working tree.

This looks like an OpenSBI commit but QEMU only include up to v0.5.

Can you build v0.5? Else can you update the submodule?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Will do in v2.

We plan to release OpenSBI v0.6 on monday (24th Feb 2020) so maybe you can update all RISC-V ROM images based on OpenSBI v0.6 ??

Sounds cleaner.

Yes, will update all RISC-V ROM images to v0.6 in v2.

Quoted 8 lines

Suggestions when updating a QEMU git-submodule:

- Include output of submodule 'git-log --reverse --oneline'

- Send series/pull-request with 'git-format-patch --no-binary'

Sure. I believe with "--no-binary" I will need provide a repo for pull?

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Also, can you add a CI job to build this, so we have reproducible builds (see QEMU commit 71920809ceabed as example)?

I cannot find any document for how to test CI job with gitlab CI. Does QEMU has a public CI runner for testing?

Quoted 8 lines

There is:

https://wiki.qemu.org/Testing
https://wiki.qemu.org/Testing/CI

Currently you can use whatever CI best suits you (although long term is probably to rely more on GitLab, because it allows adding runners on particular hardware/setup).

Thank you very much for the pointers. I will add a CI job in v2.

Regards,
Bin