Bump Tock kernel version (#374)
* Bump Tock kernel version * Update boards to new kernel * Update patches to new kernel * Update PR template * Bump libtock-rs * Use new layout from libtock-rs * Fix clippy warnings due to updated toolchain * Fix new toolchain file format * Bump elf2tab to v0.7.0 * Fix worklow and setup.sh script to use the TOML rust-toolchain file * New libtock-rs style of declaring the stack. * Fix padding in layout file. The layout from libtock-rs generates invalid flash padding. The value is 32-bit and therefore setting padding to 0xff yields 0xff000000 instead of 0xffffffff that we want. * adds tock patch for app break hard fault * sets in deploy, removed patch 04-mpu-fix * fixed the if deploy * fixes indentation * updates board names in install.md * fix docs and deploy style Co-authored-by: Fabian Kaczmarczyck <kaczmarczyck@google.com> Co-authored-by: kaczmarczyck <43844792+kaczmarczyck@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c2b3aeca88
commit
c1f2551d0d
@@ -1,5 +1,5 @@
|
||||
diff --git a/chips/nrf52/src/nvmc.rs b/chips/nrf52/src/nvmc.rs
|
||||
index b70162cae..9934f3a31 100644
|
||||
index adbc2a2b5..7594ec867 100644
|
||||
--- a/chips/nrf52/src/nvmc.rs
|
||||
+++ b/chips/nrf52/src/nvmc.rs
|
||||
@@ -3,15 +3,19 @@
|
||||
@@ -37,37 +37,38 @@ index b70162cae..9934f3a31 100644
|
||||
|
||||
/// This is a wrapper around a u8 array that is sized to a single page for the
|
||||
/// nrf. Users of this module must pass an object of this type to use the
|
||||
@@ -219,6 +229,11 @@ impl Nvmc {
|
||||
@@ -217,6 +227,10 @@ impl Nvmc {
|
||||
}
|
||||
}
|
||||
|
||||
+ pub fn configure_readonly(&self) {
|
||||
+ let regs = &*self.registers;
|
||||
+ regs.config.write(Configuration::WEN::Ren);
|
||||
+ self.registers.config.write(Configuration::WEN::Ren);
|
||||
+ }
|
||||
+
|
||||
/// Configure the NVMC to allow writes to flash.
|
||||
pub fn configure_writeable(&self) {
|
||||
let regs = &*self.registers;
|
||||
@@ -234,7 +249,7 @@ impl Nvmc {
|
||||
let regs = &*self.registers;
|
||||
regs.config.write(Configuration::WEN::Een);
|
||||
self.registers.config.write(Configuration::WEN::Wen);
|
||||
@@ -229,9 +243,7 @@ impl Nvmc {
|
||||
pub fn erase_uicr(&self) {
|
||||
self.registers.config.write(Configuration::WEN::Een);
|
||||
while !self.is_ready() {}
|
||||
- regs.erasepage.write(ErasePage::ERASEPAGE.val(0x10001000));
|
||||
+ regs.eraseuicr.write(EraseUicr::ERASEUICR::ERASE);
|
||||
- self.registers
|
||||
- .erasepage
|
||||
- .write(ErasePage::ERASEPAGE.val(0x10001000));
|
||||
+ self.registers.eraseuicr.write(EraseUicr::ERASEUICR::ERASE);
|
||||
while !self.is_ready() {}
|
||||
}
|
||||
|
||||
@@ -326,7 +341,7 @@ impl Nvmc {
|
||||
@@ -319,7 +331,7 @@ impl Nvmc {
|
||||
// Put the NVMC in write mode.
|
||||
regs.config.write(Configuration::WEN::Wen);
|
||||
self.registers.config.write(Configuration::WEN::Wen);
|
||||
|
||||
- for i in (0..data.len()).step_by(4) {
|
||||
+ for i in (0..data.len()).step_by(WORD_SIZE) {
|
||||
let word: u32 = (data[i + 0] as u32) << 0
|
||||
| (data[i + 1] as u32) << 8
|
||||
| (data[i + 2] as u32) << 16
|
||||
@@ -394,3 +409,236 @@ impl hil::flash::Flash for Nvmc {
|
||||
@@ -387,3 +399,236 @@ impl hil::flash::Flash for Nvmc {
|
||||
self.erase_page(page_number)
|
||||
}
|
||||
}
|
||||
@@ -305,10 +306,10 @@ index b70162cae..9934f3a31 100644
|
||||
+ }
|
||||
+}
|
||||
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
|
||||
index dbe503515..428d90c29 100644
|
||||
index 49e1e5182..807170195 100644
|
||||
--- a/kernel/src/lib.rs
|
||||
+++ b/kernel/src/lib.rs
|
||||
@@ -123,7 +123,7 @@ pub use crate::sched::cooperative::{CoopProcessNode, CooperativeSched};
|
||||
@@ -122,7 +122,7 @@ pub use crate::sched::cooperative::{CoopProcessNode, CooperativeSched};
|
||||
pub use crate::sched::mlfq::{MLFQProcessNode, MLFQSched};
|
||||
pub use crate::sched::priority::PrioritySched;
|
||||
pub use crate::sched::round_robin::{RoundRobinProcessNode, RoundRobinSched};
|
||||
@@ -348,10 +349,10 @@ index 348c746a5..5465c95f4 100644
|
||||
}
|
||||
}
|
||||
diff --git a/kernel/src/process.rs b/kernel/src/process.rs
|
||||
index 4dfde3b4f..8380af673 100644
|
||||
index c52754be3..ae6a58341 100644
|
||||
--- a/kernel/src/process.rs
|
||||
+++ b/kernel/src/process.rs
|
||||
@@ -360,6 +360,15 @@ pub trait ProcessType {
|
||||
@@ -359,6 +359,15 @@ pub trait ProcessType {
|
||||
/// writeable flash region.
|
||||
fn get_writeable_flash_region(&self, region_index: usize) -> (u32, u32);
|
||||
|
||||
@@ -367,7 +368,7 @@ index 4dfde3b4f..8380af673 100644
|
||||
/// Debug function to update the kernel on where the stack starts for this
|
||||
/// process. Processes are not required to call this through the memop
|
||||
/// system call, but it aids in debugging the process.
|
||||
@@ -1015,6 +1024,35 @@ impl<C: Chip> ProcessType for Process<'_, C> {
|
||||
@@ -1048,6 +1057,35 @@ impl<C: Chip> ProcessType for Process<'_, C> {
|
||||
self.header.get_writeable_flash_region(region_index)
|
||||
}
|
||||
|
||||
@@ -403,7 +404,7 @@ index 4dfde3b4f..8380af673 100644
|
||||
fn update_stack_start_pointer(&self, stack_pointer: *const u8) {
|
||||
if stack_pointer >= self.mem_start() && stack_pointer < self.mem_end() {
|
||||
self.debug.map(|debug| {
|
||||
@@ -1664,6 +1702,33 @@ impl<C: 'static + Chip> Process<'_, C> {
|
||||
@@ -1751,6 +1789,33 @@ impl<C: 'static + Chip> Process<'_, C> {
|
||||
return Err(ProcessLoadError::MpuInvalidFlashLength);
|
||||
}
|
||||
|
||||
@@ -438,7 +439,7 @@ index 4dfde3b4f..8380af673 100644
|
||||
// memory space just for kernel and grant state. We need to make
|
||||
// sure we allocate enough memory just for that.
|
||||
diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs
|
||||
index 88eea4042..ed3ae8260 100644
|
||||
index 10626a2e1..8844bc6c3 100644
|
||||
--- a/kernel/src/sched.rs
|
||||
+++ b/kernel/src/sched.rs
|
||||
@@ -118,6 +118,12 @@ pub enum SchedulingDecision {
|
||||
@@ -482,7 +483,7 @@ index 88eea4042..ed3ae8260 100644
|
||||
process_identifier_max: Cell::new(0),
|
||||
grant_counter: Cell::new(0),
|
||||
grants_finalized: Cell::new(false),
|
||||
@@ -899,4 +916,8 @@ impl Kernel {
|
||||
@@ -900,4 +917,8 @@ impl Kernel {
|
||||
|
||||
(return_reason, time_executed_us)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
diff --git a/boards/components/src/lib.rs b/boards/components/src/lib.rs
|
||||
index dc56c94d2..917497af4 100644
|
||||
index 64fe46b7b..a3bbe724b 100644
|
||||
--- a/boards/components/src/lib.rs
|
||||
+++ b/boards/components/src/lib.rs
|
||||
@@ -36,3 +36,4 @@ pub mod spi;
|
||||
pub mod st7735;
|
||||
pub mod temperature;
|
||||
@@ -52,3 +52,4 @@ pub mod tickv;
|
||||
pub mod touch;
|
||||
pub mod udp_driver;
|
||||
pub mod udp_mux;
|
||||
+pub mod usb_ctap;
|
||||
diff --git a/boards/components/src/usb_ctap.rs b/boards/components/src/usb_ctap.rs
|
||||
new file mode 100644
|
||||
@@ -101,152 +101,8 @@ index 000000000..69e95c3c7
|
||||
+ usb_driver
|
||||
+ }
|
||||
+}
|
||||
diff --git a/boards/nordic/nrf52840_dongle_opensk/src/main.rs b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
index f9c104251..115e17280 100644
|
||||
--- a/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
@@ -40,6 +40,17 @@ const _SPI_CLK: Pin = Pin::P1_04;
|
||||
/// UART Writer
|
||||
pub mod io;
|
||||
|
||||
+const VENDOR_ID: u16 = 0x1915; // Nordic Semiconductor
|
||||
+const PRODUCT_ID: u16 = 0x521f; // nRF52840 Dongle (PCA10059)
|
||||
+static STRINGS: &'static [&'static str] = &[
|
||||
+ // Manufacturer
|
||||
+ "Nordic Semiconductor ASA",
|
||||
+ // Product
|
||||
+ "OpenSK",
|
||||
+ // Serial number
|
||||
+ "v1.0",
|
||||
+];
|
||||
+
|
||||
// State for loading and holding applications.
|
||||
// How should the kernel respond when a process faults.
|
||||
const FAULT_RESPONSE: kernel::procs::FaultResponse = kernel::procs::FaultResponse::Panic;
|
||||
@@ -84,6 +95,11 @@ pub struct Platform {
|
||||
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52840::rtc::Rtc<'static>>,
|
||||
>,
|
||||
nvmc: &'static nrf52840::nvmc::SyscallDriver,
|
||||
+ usb: &'static capsules::usb::usb_ctap::CtapUsbSyscallDriver<
|
||||
+ 'static,
|
||||
+ 'static,
|
||||
+ nrf52840::usbd::Usbd<'static>,
|
||||
+ >,
|
||||
}
|
||||
|
||||
impl kernel::Platform for Platform {
|
||||
@@ -100,6 +116,7 @@ impl kernel::Platform for Platform {
|
||||
capsules::rng::DRIVER_NUM => f(Some(self.rng)),
|
||||
capsules::analog_comparator::DRIVER_NUM => f(Some(self.analog_comparator)),
|
||||
nrf52840::nvmc::DRIVER_NUM => f(Some(self.nvmc)),
|
||||
+ capsules::usb::usb_ctap::DRIVER_NUM => f(Some(self.usb)),
|
||||
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
|
||||
_ => f(None),
|
||||
}
|
||||
@@ -292,6 +309,21 @@ pub unsafe fn reset_handler() {
|
||||
.expect("no deferred call slot available for nvmc"),
|
||||
);
|
||||
|
||||
+ // Enable power events to be sent to USB controller
|
||||
+ nrf52840::power::POWER.set_usb_client(&nrf52840::usbd::USBD);
|
||||
+ nrf52840::power::POWER.enable_interrupts();
|
||||
+
|
||||
+ // Configure USB controller
|
||||
+ let usb = components::usb_ctap::UsbCtapComponent::new(
|
||||
+ board_kernel,
|
||||
+ &nrf52840::usbd::USBD,
|
||||
+ capsules::usb::usbc_client::MAX_CTRL_PACKET_SIZE_NRF52840,
|
||||
+ VENDOR_ID,
|
||||
+ PRODUCT_ID,
|
||||
+ STRINGS,
|
||||
+ )
|
||||
+ .finalize(components::usb_ctap_component_buf!(nrf52840::usbd::Usbd));
|
||||
+
|
||||
nrf52_components::NrfClockComponent::new().finalize(());
|
||||
|
||||
let platform = Platform {
|
||||
@@ -304,6 +336,7 @@ pub unsafe fn reset_handler() {
|
||||
alarm,
|
||||
analog_comparator,
|
||||
nvmc,
|
||||
+ usb,
|
||||
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
|
||||
};
|
||||
|
||||
diff --git a/boards/nordic/nrf52840dk_opensk/src/main.rs b/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
index c80732f8d..41047a390 100644
|
||||
--- a/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
@@ -104,6 +104,17 @@ pub mod io;
|
||||
// - Set to true to use Segger RTT over USB.
|
||||
const USB_DEBUGGING: bool = true;
|
||||
|
||||
+const VENDOR_ID: u16 = 0x1915; // Nordic Semiconductor
|
||||
+const PRODUCT_ID: u16 = 0x521f; // nRF52840 Dongle (PCA10059)
|
||||
+static STRINGS: &'static [&'static str] = &[
|
||||
+ // Manufacturer
|
||||
+ "Nordic Semiconductor ASA",
|
||||
+ // Product
|
||||
+ "OpenSK",
|
||||
+ // Serial number
|
||||
+ "v1.0",
|
||||
+];
|
||||
+
|
||||
// State for loading and holding applications.
|
||||
// How should the kernel respond when a process faults.
|
||||
const FAULT_RESPONSE: kernel::procs::FaultResponse = kernel::procs::FaultResponse::Panic;
|
||||
@@ -147,6 +158,11 @@ pub struct Platform {
|
||||
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52840::rtc::Rtc<'static>>,
|
||||
>,
|
||||
nvmc: &'static nrf52840::nvmc::SyscallDriver,
|
||||
+ usb: &'static capsules::usb::usb_ctap::CtapUsbSyscallDriver<
|
||||
+ 'static,
|
||||
+ 'static,
|
||||
+ nrf52840::usbd::Usbd<'static>,
|
||||
+ >,
|
||||
}
|
||||
|
||||
impl kernel::Platform for Platform {
|
||||
@@ -163,6 +179,7 @@ impl kernel::Platform for Platform {
|
||||
capsules::rng::DRIVER_NUM => f(Some(self.rng)),
|
||||
capsules::analog_comparator::DRIVER_NUM => f(Some(self.analog_comparator)),
|
||||
nrf52840::nvmc::DRIVER_NUM => f(Some(self.nvmc)),
|
||||
+ capsules::usb::usb_ctap::DRIVER_NUM => f(Some(self.usb)),
|
||||
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
|
||||
_ => f(None),
|
||||
}
|
||||
@@ -377,6 +394,21 @@ pub unsafe fn reset_handler() {
|
||||
.expect("no deferred call slot available for nvmc"),
|
||||
);
|
||||
|
||||
+ // Enable power events to be sent to USB controller
|
||||
+ nrf52840::power::POWER.set_usb_client(&nrf52840::usbd::USBD);
|
||||
+ nrf52840::power::POWER.enable_interrupts();
|
||||
+
|
||||
+ // Configure USB controller
|
||||
+ let usb = components::usb_ctap::UsbCtapComponent::new(
|
||||
+ board_kernel,
|
||||
+ &nrf52840::usbd::USBD,
|
||||
+ capsules::usb::usbc_client::MAX_CTRL_PACKET_SIZE_NRF52840,
|
||||
+ VENDOR_ID,
|
||||
+ PRODUCT_ID,
|
||||
+ STRINGS,
|
||||
+ )
|
||||
+ .finalize(components::usb_ctap_component_buf!(nrf52840::usbd::Usbd));
|
||||
+
|
||||
nrf52_components::NrfClockComponent::new().finalize(());
|
||||
|
||||
let platform = Platform {
|
||||
@@ -389,6 +421,7 @@ pub unsafe fn reset_handler() {
|
||||
alarm,
|
||||
analog_comparator,
|
||||
nvmc,
|
||||
+ usb,
|
||||
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
|
||||
};
|
||||
|
||||
diff --git a/capsules/src/driver.rs b/capsules/src/driver.rs
|
||||
index 256fc0e9d..ae458b309 100644
|
||||
index 3dad0f50b..b6124c4c0 100644
|
||||
--- a/capsules/src/driver.rs
|
||||
+++ b/capsules/src/driver.rs
|
||||
@@ -26,6 +26,7 @@ pub enum NUM {
|
||||
@@ -258,11 +114,12 @@ index 256fc0e9d..ae458b309 100644
|
||||
// Radio
|
||||
BleAdvertising = 0x30000,
|
||||
diff --git a/capsules/src/usb/mod.rs b/capsules/src/usb/mod.rs
|
||||
index 767f5de83..3f3a4f646 100644
|
||||
index 6d5daa444..17cab4c23 100644
|
||||
--- a/capsules/src/usb/mod.rs
|
||||
+++ b/capsules/src/usb/mod.rs
|
||||
@@ -1,5 +1,7 @@
|
||||
@@ -1,6 +1,8 @@
|
||||
pub mod cdc;
|
||||
pub mod ctap;
|
||||
pub mod descriptors;
|
||||
+pub mod usb_ctap;
|
||||
pub mod usb_user;
|
||||
@@ -1005,16 +862,3 @@ index 000000000..642039120
|
||||
+ self.client.map(|client| client.packet_transmitted());
|
||||
+ }
|
||||
+}
|
||||
diff --git a/chips/nrf52840/src/lib.rs b/chips/nrf52840/src/lib.rs
|
||||
index 942d0288f..ce73e1f82 100644
|
||||
--- a/chips/nrf52840/src/lib.rs
|
||||
+++ b/chips/nrf52840/src/lib.rs
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
pub use nrf52::{
|
||||
acomp, adc, aes, ble_radio, clock, constants, crt1, ficr, i2c, ieee802154_radio, init, nvmc,
|
||||
- pinmux, ppi, pwm, rtc, spi, temperature, timer, trng, uart, uicr, usbd,
|
||||
+ pinmux, power, ppi, pwm, rtc, spi, temperature, timer, trng, uart, uicr, usbd,
|
||||
};
|
||||
pub mod chip;
|
||||
pub mod gpio;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index 83c48558e..75b1abacc 100644
|
||||
index 06acc26d2..e5db0740b 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -12,7 +12,11 @@ members = [
|
||||
"boards/imix",
|
||||
@@ -20,7 +20,11 @@ members = [
|
||||
"boards/msp_exp432p401r",
|
||||
"boards/microbit_v2",
|
||||
"boards/nordic/nrf52840dk",
|
||||
+ "boards/nordic/nrf52840dk_opensk",
|
||||
"boards/nordic/nrf52840_dongle",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs
|
||||
index ed3ae8260..f109960d3 100644
|
||||
--- a/kernel/src/sched.rs
|
||||
+++ b/kernel/src/sched.rs
|
||||
@@ -632,6 +632,7 @@ impl Kernel {
|
||||
let context_switch_reason = process.switch_to();
|
||||
scheduler_timer.disarm();
|
||||
chip.mpu().disable_app_mpu();
|
||||
+ chip.mpu().clear_mpu();
|
||||
|
||||
// Now the process has returned back to the kernel. Check
|
||||
// why and handle the process as appropriate.
|
||||
@@ -1,13 +1,38 @@
|
||||
diff --git a/boards/nordic/nrf52_components/src/startup.rs b/boards/nordic/nrf52_components/src/startup.rs
|
||||
index e6cf3ff56..7b3ea5a59 100644
|
||||
--- a/boards/nordic/nrf52_components/src/startup.rs
|
||||
+++ b/boards/nordic/nrf52_components/src/startup.rs
|
||||
@@ -53,6 +53,9 @@ impl<'a> Component for NrfStartupComponent<'a> {
|
||||
erase_uicr |= !uicr.is_nfc_pins_protection_enabled();
|
||||
}
|
||||
|
||||
+ // Avoid killing the DFU bootloader if present
|
||||
+ let (dfu_start_addr, dfu_settings_addr) = uicr.get_dfu_params();
|
||||
+
|
||||
if erase_uicr {
|
||||
self.nvmc.erase_uicr();
|
||||
}
|
||||
@@ -62,6 +65,11 @@ impl<'a> Component for NrfStartupComponent<'a> {
|
||||
|
||||
let mut needs_soft_reset: bool = false;
|
||||
|
||||
+ // Restore DFU bootloader settings if we erased
|
||||
+ if erase_uicr {
|
||||
+ uicr.set_dfu_params(dfu_start_addr, dfu_settings_addr);
|
||||
+ }
|
||||
+
|
||||
// Configure reset pins
|
||||
if uicr
|
||||
.get_psel0_reset_pin()
|
||||
diff --git a/chips/nrf52/src/uicr.rs b/chips/nrf52/src/uicr.rs
|
||||
index 6bb6c86b7..3bb8b5a7d 100644
|
||||
index 4924bbd44..788533210 100644
|
||||
--- a/chips/nrf52/src/uicr.rs
|
||||
+++ b/chips/nrf52/src/uicr.rs
|
||||
@@ -1,38 +1,45 @@
|
||||
@@ -1,38 +1,44 @@
|
||||
//! User information configuration registers
|
||||
-//!
|
||||
-//! Minimal implementation to support activation of the reset button on
|
||||
-//! nRF52-DK.
|
||||
+
|
||||
|
||||
use enum_primitive::cast::FromPrimitive;
|
||||
-use kernel::common::registers::{register_bitfields, ReadWrite};
|
||||
@@ -75,7 +100,7 @@ index 6bb6c86b7..3bb8b5a7d 100644
|
||||
}
|
||||
|
||||
register_bitfields! [u32,
|
||||
@@ -58,6 +65,21 @@ register_bitfields! [u32,
|
||||
@@ -58,6 +64,21 @@ register_bitfields! [u32,
|
||||
DISABLED = 0xff
|
||||
]
|
||||
],
|
||||
@@ -97,3 +122,22 @@ index 6bb6c86b7..3bb8b5a7d 100644
|
||||
/// Setting of pins dedicated to NFC functionality: NFC antenna or GPIO
|
||||
NfcPins [
|
||||
/// Setting pins dedicated to NFC functionality
|
||||
@@ -172,6 +193,18 @@ impl Uicr {
|
||||
self.registers.nfcpins.matches_all(NfcPins::PROTECT::NFC)
|
||||
}
|
||||
|
||||
+ pub fn get_dfu_params(&self) -> (u32, u32) {
|
||||
+ (
|
||||
+ self.registers.nrffw[0].get(), // DFU start address
|
||||
+ self.registers.nrffw[1].get(), // DFU settings address
|
||||
+ )
|
||||
+ }
|
||||
+
|
||||
+ pub fn set_dfu_params(&self, dfu_start_addr: u32, dfu_settings_addr: u32) {
|
||||
+ self.registers.nrffw[0].set(dfu_start_addr);
|
||||
+ self.registers.nrffw[1].set(dfu_settings_addr);
|
||||
+ }
|
||||
+
|
||||
pub fn is_ap_protect_enabled(&self) -> bool {
|
||||
// Here we compare to DISABLED value because any other value should enable the protection.
|
||||
!self
|
||||
@@ -75,105 +75,19 @@ index 000000000..58695af81
|
||||
+ }
|
||||
+}
|
||||
diff --git a/boards/components/src/lib.rs b/boards/components/src/lib.rs
|
||||
index 917497af4..520408fcb 100644
|
||||
index a3bbe724b..95625f91f 100644
|
||||
--- a/boards/components/src/lib.rs
|
||||
+++ b/boards/components/src/lib.rs
|
||||
@@ -9,6 +9,7 @@ pub mod console;
|
||||
pub mod crc;
|
||||
@@ -13,6 +13,7 @@ pub mod crc;
|
||||
pub mod ctap;
|
||||
pub mod debug_queue;
|
||||
pub mod debug_writer;
|
||||
+pub mod firmware_protection;
|
||||
pub mod ft6x06;
|
||||
pub mod fxos8700;
|
||||
pub mod gpio;
|
||||
pub mod hd44780;
|
||||
diff --git a/boards/nordic/nrf52840_dongle_opensk/src/main.rs b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
index 115e17280..3e35f7e90 100644
|
||||
--- a/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
@@ -100,6 +100,7 @@ pub struct Platform {
|
||||
'static,
|
||||
nrf52840::usbd::Usbd<'static>,
|
||||
>,
|
||||
+ crp: &'static capsules::firmware_protection::FirmwareProtection<nrf52840::uicr::Uicr>,
|
||||
}
|
||||
|
||||
impl kernel::Platform for Platform {
|
||||
@@ -117,6 +118,7 @@ impl kernel::Platform for Platform {
|
||||
capsules::analog_comparator::DRIVER_NUM => f(Some(self.analog_comparator)),
|
||||
nrf52840::nvmc::DRIVER_NUM => f(Some(self.nvmc)),
|
||||
capsules::usb::usb_ctap::DRIVER_NUM => f(Some(self.usb)),
|
||||
+ capsules::firmware_protection::DRIVER_NUM => f(Some(self.crp)),
|
||||
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
|
||||
_ => f(None),
|
||||
}
|
||||
@@ -324,6 +326,14 @@ pub unsafe fn reset_handler() {
|
||||
)
|
||||
.finalize(components::usb_ctap_component_buf!(nrf52840::usbd::Usbd));
|
||||
|
||||
+ let crp = components::firmware_protection::FirmwareProtectionComponent::new(
|
||||
+ board_kernel,
|
||||
+ nrf52840::uicr::Uicr::new(),
|
||||
+ )
|
||||
+ .finalize(components::firmware_protection_component_helper!(
|
||||
+ nrf52840::uicr::Uicr
|
||||
+ ));
|
||||
+
|
||||
nrf52_components::NrfClockComponent::new().finalize(());
|
||||
|
||||
let platform = Platform {
|
||||
@@ -337,6 +347,7 @@ pub unsafe fn reset_handler() {
|
||||
analog_comparator,
|
||||
nvmc,
|
||||
usb,
|
||||
+ crp,
|
||||
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
|
||||
};
|
||||
|
||||
diff --git a/boards/nordic/nrf52840dk_opensk/src/main.rs b/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
index 41047a390..05e19b821 100644
|
||||
--- a/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
@@ -163,6 +163,7 @@ pub struct Platform {
|
||||
'static,
|
||||
nrf52840::usbd::Usbd<'static>,
|
||||
>,
|
||||
+ crp: &'static capsules::firmware_protection::FirmwareProtection<nrf52840::uicr::Uicr>,
|
||||
}
|
||||
|
||||
impl kernel::Platform for Platform {
|
||||
@@ -180,6 +181,7 @@ impl kernel::Platform for Platform {
|
||||
capsules::analog_comparator::DRIVER_NUM => f(Some(self.analog_comparator)),
|
||||
nrf52840::nvmc::DRIVER_NUM => f(Some(self.nvmc)),
|
||||
capsules::usb::usb_ctap::DRIVER_NUM => f(Some(self.usb)),
|
||||
+ capsules::firmware_protection::DRIVER_NUM => f(Some(self.crp)),
|
||||
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
|
||||
_ => f(None),
|
||||
}
|
||||
@@ -409,6 +411,14 @@ pub unsafe fn reset_handler() {
|
||||
)
|
||||
.finalize(components::usb_ctap_component_buf!(nrf52840::usbd::Usbd));
|
||||
|
||||
+ let crp = components::firmware_protection::FirmwareProtectionComponent::new(
|
||||
+ board_kernel,
|
||||
+ nrf52840::uicr::Uicr::new(),
|
||||
+ )
|
||||
+ .finalize(components::firmware_protection_component_helper!(
|
||||
+ nrf52840::uicr::Uicr
|
||||
+ ));
|
||||
+
|
||||
nrf52_components::NrfClockComponent::new().finalize(());
|
||||
|
||||
let platform = Platform {
|
||||
@@ -422,6 +432,7 @@ pub unsafe fn reset_handler() {
|
||||
analog_comparator,
|
||||
nvmc,
|
||||
usb,
|
||||
+ crp,
|
||||
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
|
||||
};
|
||||
|
||||
diff --git a/capsules/src/driver.rs b/capsules/src/driver.rs
|
||||
index ae458b309..f536dad32 100644
|
||||
index b6124c4c0..90a18ea47 100644
|
||||
--- a/capsules/src/driver.rs
|
||||
+++ b/capsules/src/driver.rs
|
||||
@@ -16,6 +16,7 @@ pub enum NUM {
|
||||
@@ -276,10 +190,10 @@ index 000000000..8cf63d6a4
|
||||
+ }
|
||||
+}
|
||||
diff --git a/capsules/src/lib.rs b/capsules/src/lib.rs
|
||||
index e4423fe05..7538aad18 100644
|
||||
index 925b4ba41..919638c5d 100644
|
||||
--- a/capsules/src/lib.rs
|
||||
+++ b/capsules/src/lib.rs
|
||||
@@ -22,6 +22,7 @@ pub mod crc;
|
||||
@@ -25,6 +25,7 @@ pub mod ctap;
|
||||
pub mod dac;
|
||||
pub mod debug_process_restart;
|
||||
pub mod driver;
|
||||
@@ -288,13 +202,12 @@ index e4423fe05..7538aad18 100644
|
||||
pub mod ft6x06;
|
||||
pub mod fxos8700cq;
|
||||
diff --git a/chips/nrf52/src/uicr.rs b/chips/nrf52/src/uicr.rs
|
||||
index 3bb8b5a7d..ea96cb2ae 100644
|
||||
index 788533210..655a98d5b 100644
|
||||
--- a/chips/nrf52/src/uicr.rs
|
||||
+++ b/chips/nrf52/src/uicr.rs
|
||||
@@ -1,13 +1,14 @@
|
||||
@@ -1,12 +1,14 @@
|
||||
//! User information configuration registers
|
||||
|
||||
-
|
||||
use enum_primitive::cast::FromPrimitive;
|
||||
+use hil::firmware_protection::ProtectionLevel;
|
||||
use kernel::common::registers::{register_bitfields, register_structs, ReadWrite};
|
||||
@@ -303,11 +216,11 @@ index 3bb8b5a7d..ea96cb2ae 100644
|
||||
use kernel::ReturnCode;
|
||||
|
||||
use crate::gpio::Pin;
|
||||
+use crate::nvmc::NVMC;
|
||||
+use crate::nvmc;
|
||||
|
||||
const UICR_BASE: StaticRef<UicrRegisters> =
|
||||
unsafe { StaticRef::new(0x10001000 as *const UicrRegisters) };
|
||||
@@ -210,3 +211,49 @@ impl Uicr {
|
||||
@@ -217,3 +219,49 @@ impl Uicr {
|
||||
self.registers.approtect.write(ApProtect::PALL::ENABLED);
|
||||
}
|
||||
}
|
||||
@@ -335,7 +248,7 @@ index 3bb8b5a7d..ea96cb2ae 100644
|
||||
+ return ReturnCode::EALREADY;
|
||||
+ }
|
||||
+
|
||||
+ unsafe { NVMC.configure_writeable() };
|
||||
+ nvmc::Nvmc::new().configure_writeable();
|
||||
+ if level >= ProtectionLevel::JtagDisabled {
|
||||
+ self.set_ap_protect();
|
||||
+ }
|
||||
@@ -348,7 +261,7 @@ index 3bb8b5a7d..ea96cb2ae 100644
|
||||
+ .write(DebugControl::CPUNIDEN::DISABLED + DebugControl::CPUFPBEN::DISABLED);
|
||||
+ // TODO(jmichel): prevent returning into bootloader if present
|
||||
+ }
|
||||
+ unsafe { NVMC.configure_readonly() };
|
||||
+ nvmc::Nvmc::new().configure_readonly();
|
||||
+
|
||||
+ if self.get_protection() == level {
|
||||
+ ReturnCode::SUCCESS
|
||||
@@ -412,10 +325,10 @@ index 000000000..de0824646
|
||||
+ fn set_protection(&self, level: ProtectionLevel) -> ReturnCode;
|
||||
+}
|
||||
diff --git a/kernel/src/hil/mod.rs b/kernel/src/hil/mod.rs
|
||||
index 4f42afa02..83e7702ab 100644
|
||||
index f2d3629a9..d6eb39d2d 100644
|
||||
--- a/kernel/src/hil/mod.rs
|
||||
+++ b/kernel/src/hil/mod.rs
|
||||
@@ -8,6 +8,7 @@ pub mod dac;
|
||||
@@ -9,6 +9,7 @@ pub mod dac;
|
||||
pub mod digest;
|
||||
pub mod eic;
|
||||
pub mod entropy;
|
||||
56
patches/tock/06-upgrade-partitions.patch
Normal file
56
patches/tock/06-upgrade-partitions.patch
Normal file
@@ -0,0 +1,56 @@
|
||||
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
|
||||
index 807170195..a13413791 100644
|
||||
--- a/kernel/src/lib.rs
|
||||
+++ b/kernel/src/lib.rs
|
||||
@@ -122,7 +122,7 @@ pub use crate::sched::cooperative::{CoopProcessNode, CooperativeSched};
|
||||
pub use crate::sched::mlfq::{MLFQProcessNode, MLFQSched};
|
||||
pub use crate::sched::priority::PrioritySched;
|
||||
pub use crate::sched::round_robin::{RoundRobinProcessNode, RoundRobinSched};
|
||||
-pub use crate::sched::{Kernel, Scheduler, StorageLocation};
|
||||
+pub use crate::sched::{Kernel, Scheduler, StorageLocation, StorageType};
|
||||
|
||||
// Export only select items from the process module. To remove the name conflict
|
||||
// this cannot be called `process`, so we use a shortened version. These
|
||||
diff --git a/kernel/src/memop.rs b/kernel/src/memop.rs
|
||||
index 5465c95f4..e596648f7 100644
|
||||
--- a/kernel/src/memop.rs
|
||||
+++ b/kernel/src/memop.rs
|
||||
@@ -127,6 +127,14 @@ pub(crate) fn memop(process: &dyn ProcessType, op_type: usize, r1: usize) -> Ret
|
||||
}
|
||||
}
|
||||
|
||||
+ // Op Type 15: The type of the storage location indexed by r1.
|
||||
+ 15 => {
|
||||
+ match process.get_storage_location(r1) {
|
||||
+ None => ReturnCode::FAIL,
|
||||
+ Some(x) => ReturnCode::SuccessWithValue { value: x.storage_type as usize }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
_ => ReturnCode::ENOSUPPORT,
|
||||
}
|
||||
}
|
||||
diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs
|
||||
index 031159500..0cbfea929 100644
|
||||
--- a/kernel/src/sched.rs
|
||||
+++ b/kernel/src/sched.rs
|
||||
@@ -118,10 +118,19 @@ pub enum SchedulingDecision {
|
||||
TrySleep,
|
||||
}
|
||||
|
||||
+/// Represents the type of a storage slice.
|
||||
+#[derive(Copy, Clone)]
|
||||
+pub enum StorageType {
|
||||
+ STORE = 1,
|
||||
+ PARTITION = 2,
|
||||
+ METADATA = 3,
|
||||
+}
|
||||
+
|
||||
/// Represents a storage location in flash.
|
||||
pub struct StorageLocation {
|
||||
pub address: usize,
|
||||
pub size: usize,
|
||||
+ pub storage_type: StorageType,
|
||||
}
|
||||
|
||||
/// Main object for the kernel. Each board will need to create one.
|
||||
13
patches/tock/07-app-break-fix.patch
Normal file
13
patches/tock/07-app-break-fix.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/arch/cortex-m/src/syscall.rs b/arch/cortex-m/src/syscall.rs
|
||||
index c78b1c9fb..2769d0138 100644
|
||||
--- a/arch/cortex-m/src/syscall.rs
|
||||
+++ b/arch/cortex-m/src/syscall.rs
|
||||
@@ -65,7 +65,7 @@ impl kernel::syscall::UserspaceKernelBoundary for SysCall {
|
||||
//
|
||||
// The 1.x Tock kernel allocates at least 3 kB to processes, and we need
|
||||
// to ensure that happens as userspace may expect it.
|
||||
- 3 * 1024
|
||||
+ 16 * 1024
|
||||
|
||||
// TOCK 2.0
|
||||
//
|
||||
@@ -1,92 +0,0 @@
|
||||
diff --git a/boards/nordic/nrf52840_dongle_opensk/src/main.rs b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
index 3e35f7e90..b624e19a2 100644
|
||||
--- a/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
|
||||
@@ -64,6 +64,7 @@ static mut PROCESSES: [Option<&'static dyn kernel::procs::ProcessType>; NUM_PROC
|
||||
static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 1] = [kernel::StorageLocation {
|
||||
address: 0xC0000,
|
||||
size: 0x40000,
|
||||
+ storage_type: kernel::StorageType::STORE,
|
||||
}];
|
||||
|
||||
// Static reference to chip for panic dumps
|
||||
diff --git a/boards/nordic/nrf52840_mdk_dfu/src/main.rs b/boards/nordic/nrf52840_mdk_dfu/src/main.rs
|
||||
index 25bd61460..84c7cff70 100644
|
||||
--- a/boards/nordic/nrf52840_mdk_dfu/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840_mdk_dfu/src/main.rs
|
||||
@@ -59,6 +59,7 @@ static mut PROCESSES: [Option<&'static dyn kernel::procs::ProcessType>; NUM_PROC
|
||||
static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 1] = [kernel::StorageLocation {
|
||||
address: 0xC0000,
|
||||
size: 0x40000,
|
||||
+ storage_type: kernel::StorageType::STORE,
|
||||
}];
|
||||
|
||||
// Static reference to chip for panic dumps
|
||||
diff --git a/boards/nordic/nrf52840dk_opensk/src/main.rs b/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
index 05e19b821..47b27bf0a 100644
|
||||
--- a/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
+++ b/boards/nordic/nrf52840dk_opensk/src/main.rs
|
||||
@@ -128,6 +128,7 @@ static mut PROCESSES: [Option<&'static dyn kernel::procs::ProcessType>; NUM_PROC
|
||||
static mut STORAGE_LOCATIONS: [kernel::StorageLocation; 1] = [kernel::StorageLocation {
|
||||
address: 0xC0000,
|
||||
size: 0x40000,
|
||||
+ storage_type: kernel::StorageType::STORE,
|
||||
}];
|
||||
|
||||
static mut CHIP: Option<&'static nrf52840::chip::Chip> = None;
|
||||
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs
|
||||
index 428d90c29..2109a207e 100644
|
||||
--- a/kernel/src/lib.rs
|
||||
+++ b/kernel/src/lib.rs
|
||||
@@ -123,7 +123,7 @@ pub use crate::sched::cooperative::{CoopProcessNode, CooperativeSched};
|
||||
pub use crate::sched::mlfq::{MLFQProcessNode, MLFQSched};
|
||||
pub use crate::sched::priority::PrioritySched;
|
||||
pub use crate::sched::round_robin::{RoundRobinProcessNode, RoundRobinSched};
|
||||
-pub use crate::sched::{Kernel, Scheduler, StorageLocation};
|
||||
+pub use crate::sched::{Kernel, Scheduler, StorageLocation, StorageType};
|
||||
|
||||
// Export only select items from the process module. To remove the name conflict
|
||||
// this cannot be called `process`, so we use a shortened version. These
|
||||
diff --git a/kernel/src/memop.rs b/kernel/src/memop.rs
|
||||
index 5465c95f4..e596648f7 100644
|
||||
--- a/kernel/src/memop.rs
|
||||
+++ b/kernel/src/memop.rs
|
||||
@@ -127,6 +127,14 @@ pub(crate) fn memop(process: &dyn ProcessType, op_type: usize, r1: usize) -> Ret
|
||||
}
|
||||
}
|
||||
|
||||
+ // Op Type 15: The type of the storage location indexed by r1.
|
||||
+ 15 => {
|
||||
+ match process.get_storage_location(r1) {
|
||||
+ None => ReturnCode::FAIL,
|
||||
+ Some(x) => ReturnCode::SuccessWithValue { value: x.storage_type as usize }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
_ => ReturnCode::ENOSUPPORT,
|
||||
}
|
||||
}
|
||||
diff --git a/kernel/src/sched.rs b/kernel/src/sched.rs
|
||||
index f109960d3..9eaf98585 100644
|
||||
--- a/kernel/src/sched.rs
|
||||
+++ b/kernel/src/sched.rs
|
||||
@@ -118,10 +118,19 @@ pub enum SchedulingDecision {
|
||||
TrySleep,
|
||||
}
|
||||
|
||||
+/// Represents the type of a storage slice.
|
||||
+#[derive(Copy, Clone)]
|
||||
+pub enum StorageType {
|
||||
+ STORE = 1,
|
||||
+ PARTITION = 2,
|
||||
+ METADATA = 3,
|
||||
+}
|
||||
+
|
||||
/// Represents a storage location in flash.
|
||||
pub struct StorageLocation {
|
||||
pub address: usize,
|
||||
pub size: usize,
|
||||
+ pub storage_type: StorageType,
|
||||
}
|
||||
|
||||
/// Main object for the kernel. Each board will need to create one.
|
||||
Reference in New Issue
Block a user