Use HW boot ROM for renode simulation Use the same boot rom source code for renode simulation, verilator sim, and FPGA bitstream. Change-Id: Idb86d5492c0dbaa3df2286a6ce4336455c576a34
diff --git a/platforms/nexus/boot_rom.mk b/platforms/nexus/boot_rom.mk deleted file mode 100644 index fb6a41a..0000000 --- a/platforms/nexus/boot_rom.mk +++ /dev/null
@@ -1,39 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -NEXUS_BOOT_ROM_SOURCE_DIR:=$(ROOTDIR)/sw/multihart_boot_rom -NEXUS_BOOT_ROM_BUILD_DIR:=$(OUT)/shodan_boot_rom -NEXUS_BOOT_ROM_BUILD_NINJA_SCRIPT:=$(NEXUS_BOOT_ROM_BUILD_DIR)/build.ninja -NEXUS_BOOT_ROM_ELF:=multihart_boot_rom.elf - -$(NEXUS_BOOT_ROM_BUILD_DIR): - @mkdir -p "$(NEXUS_BOOT_ROM_BUILD_DIR)" - -$(NEXUS_BOOT_ROM_BUILD_NINJA_SCRIPT): | $(NEXUS_BOOT_ROM_BUILD_DIR) - cmake -B $(NEXUS_BOOT_ROM_BUILD_DIR) -G Ninja $(NEXUS_BOOT_ROM_SOURCE_DIR) - -## Build the Nexus boot ROM image -# -# This builds a simple multi-core boot ROM that can bootstrap the Nexus system -# in simulation. Source is in sw/multihart_boot_rom, while output is placed in -# out/nexus_boot_rom -multihart_boot_rom: $(NEXUS_BOOT_ROM_BUILD_NINJA_SCRIPT) - cmake --build $(NEXUS_BOOT_ROM_BUILD_DIR) --target $(NEXUS_BOOT_ROM_ELF) - -## Clean the Nexus boot ROM build directory -multihart_boot_rom_clean: - rm -rf $(NEXUS_BOOT_ROM_BUILD_DIR) - - -.PHONY:: multihart_boot_rom multihart_boot_rom_clean
diff --git a/platforms/nexus/matcha_hw.mk b/platforms/nexus/matcha_hw.mk index e1dd7cb..b630a7a 100644 --- a/platforms/nexus/matcha_hw.mk +++ b/platforms/nexus/matcha_hw.mk
@@ -19,6 +19,7 @@ MATCHA_FPGA_BINARY_DIR := $(MATCHA_OUT_DIR)/fpga_tests MATCHA_FPGA_MATCHA_BINARY_DIR := $(MATCHA_FPGA_BINARY_DIR)/matcha MATCHA_FPGA_KELVIN_BINARY_DIR := $(MATCHA_FPGA_BINARY_DIR)/kelvin +BOOT_ROM_ELF := boot_rom.elf $(MATCHA_OUT_DIR): mkdir -p $(MATCHA_OUT_DIR) @@ -135,6 +136,18 @@ //sw/device/tests:verilator_test_suite cd $(MATCHA_SRC_DIR) && cp -rf "bazel-testlogs/sw" "$(MATCHA_TESTLOG_DIR)" +## Build the boot ROM image +# +# This builds the HW boot rom executable for simulation. +# Source is in hw/matcha, while output is placed in +# out/matcha/hw/ +multihart_boot_rom: | $(MATCHA_OUT_DIR) + cd $(MATCHA_SRC_DIR) && \ + bazel build --config=riscv32 //sw/device/lib/testing/test_rom:test_rom_no_otp_fpga_nexus.elf + cd $(MATCHA_SRC_DIR) && \ + find "bazel-out/" -wholename "*test_rom/test_rom_no_otp_fpga_nexus.elf" \ + -exec cp -f '{}' "$(MATCHA_OUT_DIR)/$(BOOT_ROM_ELF)" \; + ## Clean Matcha HW artifact matcha_hw_clean: rm -rf $(MATCHA_OUT_DIR) @@ -144,3 +157,4 @@ .PHONY:: matcha_hw_verilator_sim matcha_hw_clean matcha_hw_verilator_tests .PHONY:: matcha_sw_all opentitantool_pkg .PHONY:: matcha_hw_fpga_nexus matcha_kelvin_fpga_tarballs +.PHONY:: multihart_boot_rom
diff --git a/platforms/nexus/platform.mk b/platforms/nexus/platform.mk index 303ab02..9ba485e 100644 --- a/platforms/nexus/platform.mk +++ b/platforms/nexus/platform.mk
@@ -7,7 +7,6 @@ # Put host tool targets first. include $(ROOTDIR)/build/platforms/nexus/renode.mk -include $(ROOTDIR)/build/platforms/nexus/boot_rom.mk include $(ROOTDIR)/build/platforms/nexus/cantrip.mk include $(ROOTDIR)/build/platforms/nexus/cantrip_builtins.mk include $(ROOTDIR)/build/platforms/nexus/iree.mk
diff --git a/platforms/nexus/sim.mk b/platforms/nexus/sim.mk index 26fec08..05b2779 100644 --- a/platforms/nexus/sim.mk +++ b/platforms/nexus/sim.mk
@@ -80,6 +80,7 @@ \$$cpio = @$(EXT_BUILTINS_RELEASE); \ \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \ \$$kernel = @$(CANTRIP_KERNEL_RELEASE); \ + \$$sc_bin =@$(TMP_RELEASE)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start" @@ -97,6 +98,7 @@ \$$cpio = @$(EXT_BUILTINS_DEBUG); \ \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \ \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \ + \$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) cpu1 CreateSeL4 0xffffffee; start" @@ -115,6 +117,7 @@ \$$cpio = @$(EXT_BUILTINS_DEBUG); \ \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \ \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \ + \$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; start" EXT_FLASH_MINISEL_DEBUG=$(CANTRIP_OUT_DEBUG)/ext_flash_minisel.tar @@ -150,6 +153,7 @@ \$$tar = @$(EXT_FLASH_MINISEL_DEBUG); \ \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \ \$$cpio = @/dev/null; \ + \$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start" @@ -159,6 +163,7 @@ \$$tar = @$(EXT_FLASH_MINISEL_RELEASE); \ \$$kernel = @$(CANTRIP_KERNEL_RELEASE); \ \$$cpio = @/dev/null; \ + \$$sc_bin =@$(TMP_RELEASE)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start"
diff --git a/platforms/nexus/sim_sel4test.mk b/platforms/nexus/sim_sel4test.mk index 93a9701..ecaf7d2 100644 --- a/platforms/nexus/sim_sel4test.mk +++ b/platforms/nexus/sim_sel4test.mk
@@ -39,6 +39,7 @@ \$$tar = @$(SEL4TEST_EXT_FLASH_TAR); \ \$$kernel = @$(SEL4TEST_KERNEL_DEBUG); \ \$$cpio = @/dev/null; \ + \$$sc_bin =@$(SEL4TEST_TMP)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start" @@ -68,6 +69,7 @@ \$$tar = @$(SEL4TEST_WRAPPER_EXT_FLASH_TAR); \ \$$kernel = @$(SEL4TEST_KERNEL_DEBUG); \ \$$cpio = @/dev/null; \ + \$$sc_bin =@$(SEL4TEST_WRAPPER_TMP)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start"
diff --git a/platforms/shodan/matcha_hw.mk b/platforms/shodan/matcha_hw.mk index 8b5cd09..8558900 100644 --- a/platforms/shodan/matcha_hw.mk +++ b/platforms/shodan/matcha_hw.mk
@@ -18,6 +18,7 @@ MATCHA_TESTLOG_DIR := $(MATCHA_OUT_DIR)/test-log MATCHA_FPGA_BINARY_DIR := $(MATCHA_OUT_DIR)/fpga_tests MATCHA_FPGA_KELVIN_BINARY_DIR := $(MATCHA_FPGA_BINARY_DIR)/kelvin +BOOT_ROM_ELF := boot_rom.elf $(MATCHA_OUT_DIR): mkdir -p $(MATCHA_OUT_DIR) @@ -116,6 +117,18 @@ //sw/device/tests:verilator_test_suite cd $(MATCHA_SRC_DIR) && cp -rf "bazel-testlogs/sw" "$(MATCHA_TESTLOG_DIR)" +## Build the boot ROM image +# +# This builds the HW boot rom executable for simulation. +# Source is in hw/matcha, while output is placed in +# out/matcha/hw/ +multihart_boot_rom: | $(MATCHA_OUT_DIR) + cd $(MATCHA_SRC_DIR) && \ + bazel build --config=riscv32 //sw/device/lib/testing/test_rom:test_rom_no_otp_fpga_nexus.elf + cd $(MATCHA_SRC_DIR) && \ + find "bazel-out/" -wholename "*test_rom/test_rom_no_otp_fpga_nexus.elf" \ + -exec cp -f '{}' "$(MATCHA_OUT_DIR)/$(BOOT_ROM_ELF)" \; + ## Clean Matcha HW artifact matcha_hw_clean: rm -rf $(MATCHA_OUT_DIR) @@ -125,3 +138,4 @@ .PHONY:: matcha_hw_verilator_sim matcha_hw_clean matcha_hw_verilator_tests .PHONY:: matcha_sw_all opentitantool_pkg .PHONY:: matcha_hw_fpga_nexus matcha_kelvin_fpga_tarballs +.PHONY:: multihart_boot_rom
diff --git a/platforms/shodan/platform.mk b/platforms/shodan/platform.mk index 84f5d6e..a6c80e9 100644 --- a/platforms/shodan/platform.mk +++ b/platforms/shodan/platform.mk
@@ -16,7 +16,6 @@ include $(ROOTDIR)/build/platforms/shodan/matcha_hw.mk include $(ROOTDIR)/build/platforms/shodan/opentitan_hw.mk include $(ROOTDIR)/build/platforms/shodan/opentitan_sw.mk -include $(ROOTDIR)/build/platforms/shodan/shodan_boot_rom.mk include $(ROOTDIR)/build/platforms/shodan/springbok.mk include $(ROOTDIR)/build/platforms/shodan/tbm.mk include $(ROOTDIR)/build/platforms/shodan/tock.mk
diff --git a/platforms/shodan/shodan_boot_rom.mk b/platforms/shodan/shodan_boot_rom.mk deleted file mode 100644 index 0b4fe6a..0000000 --- a/platforms/shodan/shodan_boot_rom.mk +++ /dev/null
@@ -1,39 +0,0 @@ -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -SHODAN_BOOT_ROM_SOURCE_DIR:=$(ROOTDIR)/sw/multihart_boot_rom -SHODAN_BOOT_ROM_BUILD_DIR:=$(OUT)/shodan_boot_rom -SHODAN_BOOT_ROM_BUILD_NINJA_SCRIPT:=$(SHODAN_BOOT_ROM_BUILD_DIR)/build.ninja -SHODAN_BOOT_ROM_ELF:=multihart_boot_rom.elf - -$(SHODAN_BOOT_ROM_BUILD_DIR): - @mkdir -p "$(SHODAN_BOOT_ROM_BUILD_DIR)" - -$(SHODAN_BOOT_ROM_BUILD_NINJA_SCRIPT): | $(SHODAN_BOOT_ROM_BUILD_DIR) - cmake -B $(SHODAN_BOOT_ROM_BUILD_DIR) -G Ninja $(SHODAN_BOOT_ROM_SOURCE_DIR) - -## Build the Shodan boot ROM image -# -# This builds a simple multi-core boot ROM that can bootstrap the Shodan system -# in simulation. Source is in sw/multihart_boot_rom, while output is placed in -# out/shodan_boot_rom -multihart_boot_rom: $(SHODAN_BOOT_ROM_BUILD_NINJA_SCRIPT) - cmake --build $(SHODAN_BOOT_ROM_BUILD_DIR) --target $(SHODAN_BOOT_ROM_ELF) - -## Clean the Shodan boot ROM build directory -multihart_boot_rom_clean: - rm -rf $(SHODAN_BOOT_ROM_BUILD_DIR) - - -.PHONY:: multihart_boot_rom multihart_boot_rom_clean
diff --git a/platforms/shodan/sim.mk b/platforms/shodan/sim.mk index 3e8abd5..304f659 100644 --- a/platforms/shodan/sim.mk +++ b/platforms/shodan/sim.mk
@@ -90,6 +90,7 @@ \$$cpio = @$(EXT_BUILTINS_DEBUG); \ \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \ \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \ + \$$sc_bin = @$(TMP_DEBUG)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) cpu1 CreateSeL4 0xffffffee; start" @@ -106,6 +107,7 @@ \$$cpio = @$(EXT_BUILTINS_DEBUG); \ \$$cpio_load_address = ${CPIO_LOAD_ADDRESS}; \ \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \ + \$$sc_bin = @$(TMP_DEBUG)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; start" EXT_FLASH_MINISEL_DEBUG=$(CANTRIP_OUT_DEBUG)/ext_flash_minisel.tar @@ -141,6 +143,7 @@ \$$tar = @$(EXT_FLASH_MINISEL_DEBUG); \ \$$kernel = @$(CANTRIP_KERNEL_DEBUG); \ \$$cpio = @/dev/null; \ + \$$sc_bin =@$(TMP_DEBUG)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start"
diff --git a/platforms/shodan/sim_sel4test.mk b/platforms/shodan/sim_sel4test.mk index 93a9701..ac18efd 100644 --- a/platforms/shodan/sim_sel4test.mk +++ b/platforms/shodan/sim_sel4test.mk
@@ -39,6 +39,7 @@ \$$tar = @$(SEL4TEST_EXT_FLASH_TAR); \ \$$kernel = @$(SEL4TEST_KERNEL_DEBUG); \ \$$cpio = @/dev/null; \ + \$$sc_bin = @$(SEL4TEST_TMP)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start" @@ -68,6 +69,7 @@ \$$tar = @$(SEL4TEST_WRAPPER_EXT_FLASH_TAR); \ \$$kernel = @$(SEL4TEST_KERNEL_DEBUG); \ \$$cpio = @/dev/null; \ + \$$sc_bin = @$(SEL4TEST_WRAPPER_TMP)/matcha-tock-bundle.bin; \ $(PORT_PRESTART_CMDS) i @sim/config/shodan.resc; \ $(RENODE_PRESTART_CMDS) start"