Merge "Revert "Temporarily pin IREE release to resolve multiple issues""
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..ab993df
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,28 @@
+# How to Contribute
+
+We'd love to accept your patches and contributions to this project. There are
+just a few small guidelines you need to follow.
+
+## Contributor License Agreement
+
+Contributions to this project must be accompanied by a Contributor License
+Agreement. You (or your employer) retain the copyright to your contribution;
+this simply gives us permission to use and redistribute your contributions as
+part of the project. Head over to <https://cla.developers.google.com/> to see
+your current agreements on file or to sign a new one.
+
+You generally only need to submit a CLA once, so if you've already submitted one
+(even if it was for a different project), you probably don't need to do it
+again.
+
+## Code Reviews
+
+All submissions, including submissions by project members, require review. We
+use Gerrit code review for this purpose. Consult
+[Gerrit User Guide](https://gerrit-documentation.storage.googleapis.com/Documentation/3.8.2/intro-user.html)
+for more information.
+
+## Community Guidelines
+
+This project follows [Google's Open Source Community
+Guidelines](https://opensource.google/conduct/).
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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
+
+ http://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.
diff --git a/Makefile b/Makefile
index f5457bc..5f00742 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,6 @@
include $(ROOTDIR)/build/cantrip_tests.mk
include $(ROOTDIR)/build/minisel.mk
include $(ROOTDIR)/build/flatbuffers.mk
-include $(ROOTDIR)/build/spike.mk
include $(ROOTDIR)/build/verilator.mk
include $(ROOTDIR)/build/platforms/$(PLATFORM)/platform.mk
@@ -54,10 +53,10 @@
## Installs the RISCV compiler and emulator tooling
#
-# This includes Rust, GCC, CLANG, verilator, qemu, and renode.
+# This includes Rust, GCC, CLANG, verilator, and renode.
#
# Output is placed in cache/ and out/host.
-tools:: install_rust install_gcc install_llvm install_kelvin renode qemu
+tools:: install_rust install_gcc install_llvm install_kelvin renode
## Cleans the entire system
#
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..46634cc
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+# Top Level Build repository
+
+This is the project containing all the top-level build targets of all the
+projects within the GoB to set up the environment and build the e2e artifacts.
diff --git a/cantrip_tests.mk b/cantrip_tests.mk
index bc7bb0b..6d6a810 100644
--- a/cantrip_tests.mk
+++ b/cantrip_tests.mk
@@ -22,6 +22,7 @@
# cargo_test_cantrip_proc_interface; they need to be rewritten (or tossed)
CARGO_TEST_CANTRIP=\
cargo_test_cantrip_os_common_slot_allocator \
+ cargo_test_i2s_driver \
cargo_test_mailbox_driver \
cargo_test_opentitan_timer \
cargo_test_uart_driver \
@@ -52,6 +53,10 @@
cargo_test_debugconsole_zmodem: | cantrip-gen-headers
cd $(CANTRIP_COMPONENTS)/DebugConsole/zmodem && $(CARGO_TEST)
+## Runs cargo unit tests for the I2SDriver
+cargo_test_i2s_driver: | cantrip-gen-headers
+ cd $(CANTRIP_COMPONENTS)/SDKRuntime/tests && $(CARGO_TEST)
+
## Runs cargo unit tests for the MailboxDriver
cargo_test_mailbox_driver: | cantrip-gen-headers
cd $(CANTRIP_COMPONENTS)/SecurityCoordinator/tests && $(CARGO_TEST)
diff --git a/patches/kelvin/kelvin-opc.c b/patches/kelvin/kelvin-opc.c
index a400aa7..51f4bcd 100644
--- a/patches/kelvin/kelvin-opc.c
+++ b/patches/kelvin/kelvin-opc.c
@@ -1,6 +1,16 @@
// Copyright 2023 Google LLC
-// Licensed under the Apache License, Version 2.0, see LICENSE for details.
-// SPDX-License-Identifier: Apache-2.0
+//
+// 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
+//
+// http://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.
//
// clang-format off
diff --git a/patches/kelvin/kelvin-opc.h b/patches/kelvin/kelvin-opc.h
index f8a4f69..084e738 100644
--- a/patches/kelvin/kelvin-opc.h
+++ b/patches/kelvin/kelvin-opc.h
@@ -1,6 +1,16 @@
// Copyright 2023 Google LLC
-// Licensed under the Apache License, Version 2.0, see LICENSE for details.
-// SPDX-License-Identifier: Apache-2.0
+//
+// 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
+//
+// http://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.
//
// clang-format off
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 8b5cd09..b630a7a 100644
--- a/platforms/nexus/matcha_hw.mk
+++ b/platforms/nexus/matcha_hw.mk
@@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-MATCHA_SRC_DIR := $(ROOTDIR)/hw/matcha
-MATCHA_OUT_DIR := $(OUT)/matcha/hw
-MATCHA_VERILATOR_TB := $(MATCHA_OUT_DIR)/sim-verilator/Vchip_sim_tb
-MATCHA_TESTLOG_DIR := $(MATCHA_OUT_DIR)/test-log
-MATCHA_FPGA_BINARY_DIR := $(MATCHA_OUT_DIR)/fpga_tests
+MATCHA_SRC_DIR := $(ROOTDIR)/hw/matcha
+MATCHA_OUT_DIR := $(OUT)/matcha/hw
+MATCHA_VERILATOR_TB := $(MATCHA_OUT_DIR)/sim-verilator/Vchip_sim_tb
+MATCHA_TESTLOG_DIR := $(MATCHA_OUT_DIR)/test-log
+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)
@@ -76,6 +78,24 @@
bazel build --define DISABLE_VERILATOR_BUILD=true --build_tag_filters="-kelvin_fpga" \
//sw/device/...
+$(MATCHA_FPGA_MATCHA_BINARY_DIR):
+ mkdir -p $(MATCHA_FPGA_MATCHA_BINARY_DIR)
+
+## Build test binaries that run on FPGA
+matcha_fpga_tests: | $(MATCHA_FPGA_MATCHA_BINARY_DIR)
+ cd $(MATCHA_SRC_DIR) && \
+ bazel query //sw/device/tests/... \
+ | grep 'fpga_nexus' \
+ | egrep '_bin$$' \
+ | grep -v '/smc:' \
+ | grep -v 'kelvin' \
+ | grep -v 'example_test_from_rom_rom_prog_fpga_nexus_bin' \
+ | xargs bazel build
+ cd $(MATCHA_SRC_DIR) && \
+ find 'bazel-out/' \
+ -type f \
+ \( -wholename "*ST-*/*fpga_nexus.elf" -o -wholename "*ST-*/*fpga_nexus.bin" \) \
+ -exec cp -f '{}' "$(MATCHA_FPGA_MATCHA_BINARY_DIR)" \;
$(MATCHA_FPGA_KELVIN_BINARY_DIR):
mkdir -p "$(MATCHA_FPGA_KELVIN_BINARY_DIR)"
@@ -116,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)
@@ -125,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/setup.sh b/platforms/nexus/setup.sh
index 151aac6..c6275e5 100644
--- a/platforms/nexus/setup.sh
+++ b/platforms/nexus/setup.sh
@@ -36,6 +36,7 @@
# regtool.py.
export REGTOOL="${OPENTITAN_SOURCE}/util/regtool.py"
# The following files are the input to regtool.py
+export I2S_HJSON="${ROOTDIR}/hw/matcha/hw/top_matcha/ip/i2s/data/i2s.hjson"
export MBOX_HJSON="${ROOTDIR}/hw/matcha/hw/top_matcha/ip/tlul_mailbox/data/tlul_mailbox.hjson"
export ML_TOP_HJSON="${ROOTDIR}/hw/matcha/hw/top_matcha/ip/ml_top/data/ml_top.hjson"
export TIMER_HJSON="${OPENTITAN_GEN_DIR}/rv_timer.hjson"
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..864dbbe 100644
--- a/platforms/shodan/platform.mk
+++ b/platforms/shodan/platform.mk
@@ -7,6 +7,7 @@
# Put host tool targets first.
include $(ROOTDIR)/build/platforms/shodan/renode.mk
include $(ROOTDIR)/build/platforms/shodan/riscv_toolchain.mk
+include $(ROOTDIR)/build/platforms/shodan/sim_tools.mk
include $(ROOTDIR)/build/platforms/shodan/verible.mk
include $(ROOTDIR)/build/platforms/shodan/cantrip.mk
@@ -16,7 +17,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/riscv_toolchain.mk b/platforms/shodan/riscv_toolchain.mk
index 4c25b76..71fd52b 100644
--- a/platforms/shodan/riscv_toolchain.mk
+++ b/platforms/shodan/riscv_toolchain.mk
@@ -52,7 +52,7 @@
--with-arch=rv32imac \
--with-abi=ilp32
$(MAKE) -C $(TOOLCHAIN_BUILD_DIR) newlib \
- GDB_TARGET_FLAGS="--with-expat=yes --with-python=python3.10"
+ GDB_TARGET_FLAGS="--with-expat=yes --with-python=python3.11"
$(MAKE) -C $(TOOLCHAIN_BUILD_DIR) clean
$(OUT)/toolchain_$(TOOLCHAIN_BUILD_DATE).tar.gz: $(TOOLCHAIN_BIN)
@@ -105,7 +105,7 @@
--with-abi=ilp32 \
--with-cmodel=medany
$(MAKE) -C $(TOOLCHAINIREE_BUILD_DIR) newlib \
- GDB_TARGET_FLAGS="--with-expat=yes --with-python=python3.10"
+ GDB_TARGET_FLAGS="--with-expat=yes --with-python=python3.11"
$(MAKE) -C $(TOOLCHAINIREE_BUILD_DIR) clean
# Build with 32-bit baremetal config.
diff --git a/platforms/shodan/setup.sh b/platforms/shodan/setup.sh
index 9e2ebe9..1aa0c0d 100644
--- a/platforms/shodan/setup.sh
+++ b/platforms/shodan/setup.sh
@@ -36,6 +36,7 @@
# regtool.py.
export REGTOOL="${OPENTITAN_SOURCE}/util/regtool.py"
# The following files are the input to regtool.py
+export I2S_HJSON="${ROOTDIR}/hw/matcha/hw/top_matcha/ip/i2s/data/i2s.hjson"
export MBOX_HJSON="${ROOTDIR}/hw/matcha/hw/top_matcha/ip/tlul_mailbox/data/tlul_mailbox.hjson"
export ML_TOP_HJSON="${ROOTDIR}/hw/matcha/hw/top_matcha/ip/ml_top/data/ml_top.hjson"
export TIMER_HJSON="${OPENTITAN_GEN_DIR}/rv_timer.hjson"
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"
diff --git a/spike.mk b/platforms/shodan/sim_tools.mk
similarity index 64%
rename from spike.mk
rename to platforms/shodan/sim_tools.mk
index 0065d58..8bd847e 100644
--- a/spike.mk
+++ b/platforms/shodan/sim_tools.mk
@@ -43,4 +43,31 @@
spike_clean:
rm -r $(SPIKE_BUILD_DIR) $(SPIKE_INSTALL_DIR)
+QEMU_SRC_DIR := $(ROOTDIR)/toolchain/riscv-qemu
+QEMU_OUT_DIR := $(OUT)/host/qemu
+QEMU_BINARY := $(QEMU_OUT_DIR)/riscv32-softmmu/qemu-system-riscv32
+
+
+QEMU_DEPS=$(wildcard $(QEMU_SRC_DIR)/**/*.[ch])
+
+$(QEMU_OUT_DIR): | $(QEMU_SRC_DIR)
+ mkdir -p $(QEMU_OUT_DIR);
+
+# Disable configure check to be compatible with lib6 2.36.
+$(QEMU_BINARY): $(QEMU_DEPS) | $(QEMU_OUT_DIR)
+ cd $(QEMU_OUT_DIR) && $(QEMU_SRC_DIR)/configure \
+ --target-list=riscv32-softmmu,riscv32-linux-user --disable-werror
+ $(MAKE) -C $(QEMU_OUT_DIR)
+
+## Builds and installs the QEMU RISCV32 simulator.
+#
+# Sources are in toolchain/riscv-qemu, while outputs are stored in
+# out/host/qemu.
+qemu: $(QEMU_BINARY)
+
+## Removes only the QEMU build artifacts from out/
+qemu_clean:
+ rm -rf $(QEMU_OUT_DIR)
+
.PHONY:: spike spike_clean
+.PHONY:: qemu qemu_clean
diff --git a/toolchain.mk b/toolchain.mk
index 5b97f3d..0e46452 100644
--- a/toolchain.mk
+++ b/toolchain.mk
@@ -12,10 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-QEMU_SRC_DIR := $(ROOTDIR)/toolchain/riscv-qemu
-QEMU_OUT_DIR := $(OUT)/host/qemu
-QEMU_BINARY := $(QEMU_OUT_DIR)/riscv32-softmmu/qemu-system-riscv32
-
## Installs the rust toolchains for cantrip and matcha_tock.
#
# This fetches the tarball from google cloud storage, verifies the checksums and
@@ -70,23 +66,6 @@
$(ROOTDIR)/scripts/install-rust-toolchain.sh -p $(MATCHA_PLATFORM_SRC_DIR)/rust-toolchain riscv32imc-unknown-none-elf
$(ROOTDIR)/scripts/install-rust-toolchain.sh -p $(MATCHA_APP_SRC_DIR)/rust-toolchain riscv32imc-unknown-none-elf
-QEMU_DEPS=$(wildcard $(QEMU_SRC_DIR)/**/*.[ch])
-
-$(QEMU_OUT_DIR): | $(QEMU_SRC_DIR)
- mkdir -p $(QEMU_OUT_DIR);
-
-# Disable configure check to be compatible with lib6 2.36.
-$(QEMU_BINARY): $(QEMU_DEPS) | $(QEMU_OUT_DIR)
- cd $(QEMU_OUT_DIR) && $(QEMU_SRC_DIR)/configure \
- --target-list=riscv32-softmmu,riscv32-linux-user --disable-werror
- $(MAKE) -C $(QEMU_OUT_DIR)
-
-## Builds and installs the QEMU RISCV32 simulator.
-#
-# Sources are in toolchain/riscv-qemu, while outputs are stored in
-# out/host/qemu.
-qemu: $(QEMU_BINARY)
-
$(OUT)/tmp: | $(OUT)
mkdir -p $(OUT)/tmp
@@ -122,9 +101,5 @@
# extracts it locally to the cache/.
install_kelvin: $(CACHE)/toolchain_kelvin/bin/riscv32-unknown-elf-gcc
-## Removes only the QEMU build artifacts from out/
-qemu_clean:
- rm -rf $(QEMU_OUT_DIR)
-
-.PHONY:: qemu toolchain_clean qemu_clean install_llvm install_gcc install_rust rust_presence_check
+.PHONY:: toolchain_clean install_llvm install_gcc install_rust rust_presence_check
.PHONY:: collate_rust_toolchains collate_cantrip_rust_toolchain collate_matcha_rust_toolchain