Fixed for updated SMC control, SPI loading in release
- The renode model of the control block was changed to match with the
RTL version, so update load_sel4 accordingly.
- Instead of checking whether we run on FPGA to decide whether to load
from SPI, check whether we're a debug or release build:
- On debug builds, load from the memory mapped binaries (since debug
binaries are enormous, and renode SPI isn't that fast)
- On release builds, load from SPI (and since release builds don't fit
in FPGA, this also means that FPGA always loads from SPI).
Change-Id: I09a50e603e11c020cb6004a921709a44fac88802
diff --git a/capsules/src/elfloader_capsule.rs b/capsules/src/elfloader_capsule.rs
index 64157af..c24226f 100644
--- a/capsules/src/elfloader_capsule.rs
+++ b/capsules/src/elfloader_capsule.rs
@@ -20,7 +20,6 @@
pub struct ElfLoaderCapsule<'a, F: hil::flash::Flash + 'static> {
mailbox_hal: Option<&'static dyn MailboxHAL>,
smc_ctrl_hal: Option<&'static dyn smc_ctrl_hal::SmcCtrlHal>,
- fpga: bool,
flash: Option<&'static capsules::virtual_flash::FlashUser<'static, F>>,
flash_busy: Cell<bool>,
read_page: TakeCell<'static, F::Page>,
@@ -94,11 +93,10 @@
}
impl<'a, F: hil::flash::Flash> ElfLoaderCapsule<'a, F> {
- pub fn new(fpga: bool) -> Self {
+ pub fn new() -> Self {
Self {
mailbox_hal: None,
smc_ctrl_hal: None,
- fpga: fpga,
flash: None,
flash_busy: Cell::new(false),
read_page: TakeCell::empty(),
@@ -607,10 +605,15 @@
if minor_num == matcha_config::CMD_ELFLOADER_BOOT_SEL4 {
match self.flash {
Some(_) => {
- if self.fpga {
+ #[cfg(debug_assertions)]
+ let debug = true;
+
+ #[cfg(not(debug_assertions))]
+ let debug = false;
+ if !debug {
self.load_sel4();
} else {
- dprintf!("Simulation; bypass loading from SPI flash\r\n");
+ dprintf!("Debug; bypass loading from SPI flash\r\n");
self.mailbox_hal.map(|mb| {
matcha_utils::load_sel4(mb);
});
diff --git a/platform/src/main.rs b/platform/src/main.rs
index 2ce5d09..bae0922 100644
--- a/platform/src/main.rs
+++ b/platform/src/main.rs
@@ -28,7 +28,6 @@
use matcha_hal::timer_hal;
use matcha_hal::uart_hal;
use matcha_hal::smc_ctrl_hal;
-use matcha_hal::rv_core_ibex_hal;
use rv32i::csr;
pub mod chip;
@@ -275,7 +274,6 @@
)
);
- let fpga_version = rv_core_ibex_hal::RV_CORE_IBEX_SEC.fpga_version();
let elfloader_capsule = static_init!(
matcha_capsules::elfloader_capsule::ElfLoaderCapsule<
'static,
@@ -283,7 +281,7 @@
'static,
capsules::virtual_spi::VirtualSpiMasterDevice<'static, spi_host_hal::SpiHw>,
>>,
- matcha_capsules::elfloader_capsule::ElfLoaderCapsule::new(fpga_version != 0)
+ matcha_capsules::elfloader_capsule::ElfLoaderCapsule::new()
);
let mailbox_capsule = static_init!(
diff --git a/utils/src/lib.rs b/utils/src/lib.rs
index 25f0f1f..b73c168 100644
--- a/utils/src/lib.rs
+++ b/utils/src/lib.rs
@@ -11,7 +11,7 @@
pub mod elf_loader;
pub mod tar_loader;
-pub const SMC_CONTROL_BLOCK: *mut u32 = 0x54020000 as *mut u32;
+pub const SMC_CONTROL_BLOCK: *mut u32 = 0x54020004 as *mut u32;
pub const SMC_PAGE_SIZE: usize = 4096; // SMC page size
pub const SMC_BEGIN: usize = 0x50000000; // Start of SMC memory in SEC map
@@ -63,9 +63,6 @@
dprintf!("Starting management core\n");
- let entry_point: u32 = (*sel4_elf).e_entry
- - (elf_loader::elf_virt_min(sel4_segments) - elf_loader::elf_phys_min(sel4_segments));
-
smc_send_bootmsg(mailbox, [
ui_p_reg_start,
ui_p_reg_start
@@ -77,7 +74,7 @@
(*capdl_elf).e_entry,
]);
- SMC_CONTROL_BLOCK.write_volatile(entry_point);
+ SMC_CONTROL_BLOCK.write_volatile(1);
}
}