Merge "Fixed for updated SMC control, SPI loading in release"
diff --git a/capsules/src/elfloader_capsule.rs b/capsules/src/elfloader_capsule.rs
index 1345f43..22ec75a 100644
--- a/capsules/src/elfloader_capsule.rs
+++ b/capsules/src/elfloader_capsule.rs
@@ -34,7 +34,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>,
@@ -108,11 +107,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(),
@@ -621,10 +619,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 752c07c..98186f1 100644
--- a/platform/src/main.rs
+++ b/platform/src/main.rs
@@ -42,7 +42,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;
@@ -289,7 +288,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,
@@ -297,7 +295,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 b39fced..32c544c 100644
--- a/utils/src/lib.rs
+++ b/utils/src/lib.rs
@@ -25,7 +25,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
@@ -77,9 +77,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
@@ -91,7 +88,7 @@
             (*capdl_elf).e_entry,
         ]);
 
-        SMC_CONTROL_BLOCK.write_volatile(entry_point);
+        SMC_CONTROL_BLOCK.write_volatile(1);
     }
 }