Kernel minimization (#334)

* adds patch to remove unused kernel components

* new boards, rebase patches to match

* rename boards for deployment
This commit is contained in:
kaczmarczyck
2021-06-28 14:55:20 +02:00
committed by GitHub
parent 5f20ba544b
commit ce0ee6c054
32 changed files with 1234 additions and 155 deletions

View File

@@ -1,8 +1,8 @@
diff --git a/boards/nordic/nrf52840_dongle/src/main.rs b/boards/nordic/nrf52840_dongle/src/main.rs
index fc53f59c8..d72d20482 100644
--- a/boards/nordic/nrf52840_dongle/src/main.rs
+++ b/boards/nordic/nrf52840_dongle/src/main.rs
@@ -55,6 +55,11 @@ const NUM_PROCS: usize = 8;
diff --git a/boards/nordic/nrf52840_dongle_opensk/src/main.rs b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
index e0e292a7e..b485a0997 100644
--- a/boards/nordic/nrf52840_dongle_opensk/src/main.rs
+++ b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
@@ -50,6 +50,11 @@ const NUM_PROCS: usize = 8;
static mut PROCESSES: [Option<&'static dyn kernel::procs::ProcessType>; NUM_PROCS] =
[None; NUM_PROCS];
@@ -14,7 +14,7 @@ index fc53f59c8..d72d20482 100644
// Static reference to chip for panic dumps
static mut CHIP: Option<&'static nrf52840::chip::Chip> = None;
@@ -90,6 +95,7 @@ pub struct Platform {
@@ -78,6 +83,7 @@ pub struct Platform {
'static,
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52840::rtc::Rtc<'static>>,
>,
@@ -22,9 +22,9 @@ index fc53f59c8..d72d20482 100644
}
impl kernel::Platform for Platform {
@@ -108,10 +114,30 @@ impl kernel::Platform for Platform {
capsules::ieee802154::DRIVER_NUM => f(Some(self.ieee802154_radio)),
capsules::temperature::DRIVER_NUM => f(Some(self.temp)),
@@ -93,10 +99,30 @@ impl kernel::Platform for Platform {
capsules::button::DRIVER_NUM => f(Some(self.button)),
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)),
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
@@ -53,7 +53,7 @@ index fc53f59c8..d72d20482 100644
}
/// Entry point in the vector table called on hard reset.
@@ -120,7 +146,10 @@ pub unsafe fn reset_handler() {
@@ -105,7 +131,10 @@ pub unsafe fn reset_handler() {
// Loads relocations and clears BSS
nrf52840::init();
@@ -65,7 +65,7 @@ index fc53f59c8..d72d20482 100644
// GPIOs
let gpio = components::gpio::GpioComponent::new(
@@ -286,6 +315,14 @@ pub unsafe fn reset_handler() {
@@ -249,6 +278,14 @@ pub unsafe fn reset_handler() {
nrf52840::acomp::Comparator
));
@@ -80,19 +80,19 @@ index fc53f59c8..d72d20482 100644
nrf52_components::NrfClockComponent::new().finalize(());
let platform = Platform {
@@ -300,6 +337,7 @@ pub unsafe fn reset_handler() {
temp,
@@ -260,6 +297,7 @@ pub unsafe fn reset_handler() {
rng,
alarm,
analog_comparator,
+ nvmc,
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
};
diff --git a/boards/nordic/nrf52840dk/src/main.rs b/boards/nordic/nrf52840dk/src/main.rs
index 169f3d393..2ebb384d8 100644
--- a/boards/nordic/nrf52840dk/src/main.rs
+++ b/boards/nordic/nrf52840dk/src/main.rs
@@ -123,6 +123,11 @@ const NUM_PROCS: usize = 8;
diff --git a/boards/nordic/nrf52840dk_opensk/src/main.rs b/boards/nordic/nrf52840dk_opensk/src/main.rs
index 8e4238018..ebee8704b 100644
--- a/boards/nordic/nrf52840dk_opensk/src/main.rs
+++ b/boards/nordic/nrf52840dk_opensk/src/main.rs
@@ -114,6 +114,11 @@ const NUM_PROCS: usize = 8;
static mut PROCESSES: [Option<&'static dyn kernel::procs::ProcessType>; NUM_PROCS] =
[None; NUM_PROCS];
@@ -104,18 +104,18 @@ index 169f3d393..2ebb384d8 100644
static mut CHIP: Option<&'static nrf52840::chip::Chip> = None;
/// Dummy buffer that causes the linker to reserve enough space for the stack.
@@ -158,6 +163,7 @@ pub struct Platform {
@@ -141,6 +146,7 @@ pub struct Platform {
'static,
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52840::rtc::Rtc<'static>>,
>,
nonvolatile_storage: &'static capsules::nonvolatile_storage_driver::NonvolatileStorage<'static>,
+ nvmc: &'static nrf52840::nvmc::SyscallDriver,
}
impl kernel::Platform for Platform {
@@ -177,10 +183,30 @@ impl kernel::Platform for Platform {
capsules::temperature::DRIVER_NUM => f(Some(self.temp)),
@@ -156,10 +162,30 @@ impl kernel::Platform for Platform {
capsules::button::DRIVER_NUM => f(Some(self.button)),
capsules::rng::DRIVER_NUM => f(Some(self.rng)),
capsules::analog_comparator::DRIVER_NUM => f(Some(self.analog_comparator)),
capsules::nonvolatile_storage_driver::DRIVER_NUM => f(Some(self.nonvolatile_storage)),
+ nrf52840::nvmc::DRIVER_NUM => f(Some(self.nvmc)),
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
_ => f(None),
@@ -143,7 +143,7 @@ index 169f3d393..2ebb384d8 100644
}
/// Entry point in the vector table called on hard reset.
@@ -204,7 +230,10 @@ pub unsafe fn reset_handler() {
@@ -183,7 +209,10 @@ pub unsafe fn reset_handler() {
UartChannel::Pins(UartPins::new(UART_RTS, UART_TXD, UART_CTS, UART_RXD))
};
@@ -155,7 +155,7 @@ index 169f3d393..2ebb384d8 100644
let gpio = components::gpio::GpioComponent::new(
board_kernel,
@@ -411,6 +440,14 @@ pub unsafe fn reset_handler() {
@@ -334,6 +363,14 @@ pub unsafe fn reset_handler() {
nrf52840::acomp::Comparator
));
@@ -170,10 +170,10 @@ index 169f3d393..2ebb384d8 100644
nrf52_components::NrfClockComponent::new().finalize(());
let platform = Platform {
@@ -426,6 +463,7 @@ pub unsafe fn reset_handler() {
@@ -345,6 +382,7 @@ pub unsafe fn reset_handler() {
rng,
alarm,
analog_comparator,
nonvolatile_storage,
+ nvmc,
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
};

View File

@@ -101,11 +101,11 @@ index 000000000..69e95c3c7
+ usb_driver
+ }
+}
diff --git a/boards/nordic/nrf52840_dongle/src/main.rs b/boards/nordic/nrf52840_dongle/src/main.rs
index d72d20482..118ea6d68 100644
--- a/boards/nordic/nrf52840_dongle/src/main.rs
+++ b/boards/nordic/nrf52840_dongle/src/main.rs
@@ -45,6 +45,17 @@ const PAN_ID: u16 = 0xABCD;
diff --git a/boards/nordic/nrf52840_dongle_opensk/src/main.rs b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
index b485a0997..f5d29d025 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;
@@ -123,7 +123,7 @@ index d72d20482..118ea6d68 100644
// 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;
@@ -96,6 +107,11 @@ pub struct Platform {
@@ -84,6 +95,11 @@ pub struct Platform {
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52840::rtc::Rtc<'static>>,
>,
nvmc: &'static nrf52840::nvmc::SyscallDriver,
@@ -135,15 +135,15 @@ index d72d20482..118ea6d68 100644
}
impl kernel::Platform for Platform {
@@ -115,6 +131,7 @@ impl kernel::Platform for Platform {
capsules::temperature::DRIVER_NUM => f(Some(self.temp)),
@@ -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),
}
@@ -323,6 +340,21 @@ pub unsafe fn reset_handler() {
@@ -286,6 +303,21 @@ pub unsafe fn reset_handler() {
)
);
@@ -165,7 +165,7 @@ index d72d20482..118ea6d68 100644
nrf52_components::NrfClockComponent::new().finalize(());
let platform = Platform {
@@ -338,6 +370,7 @@ pub unsafe fn reset_handler() {
@@ -298,6 +330,7 @@ pub unsafe fn reset_handler() {
alarm,
analog_comparator,
nvmc,
@@ -173,13 +173,13 @@ index d72d20482..118ea6d68 100644
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
};
diff --git a/boards/nordic/nrf52840dk/src/main.rs b/boards/nordic/nrf52840dk/src/main.rs
index 2ebb384d8..4a7bfffdd 100644
--- a/boards/nordic/nrf52840dk/src/main.rs
+++ b/boards/nordic/nrf52840dk/src/main.rs
@@ -113,6 +113,17 @@ pub mod io;
diff --git a/boards/nordic/nrf52840dk_opensk/src/main.rs b/boards/nordic/nrf52840dk_opensk/src/main.rs
index ebee8704b..6a2f8715b 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 = false;
const USB_DEBUGGING: bool = true;
+const VENDOR_ID: u16 = 0x1915; // Nordic Semiconductor
+const PRODUCT_ID: u16 = 0x521f; // nRF52840 Dongle (PCA10059)
@@ -195,9 +195,9 @@ index 2ebb384d8..4a7bfffdd 100644
// 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;
@@ -164,6 +175,11 @@ pub struct Platform {
@@ -147,6 +158,11 @@ pub struct Platform {
capsules::virtual_alarm::VirtualMuxAlarm<'static, nrf52840::rtc::Rtc<'static>>,
>,
nonvolatile_storage: &'static capsules::nonvolatile_storage_driver::NonvolatileStorage<'static>,
nvmc: &'static nrf52840::nvmc::SyscallDriver,
+ usb: &'static capsules::usb::usb_ctap::CtapUsbSyscallDriver<
+ 'static,
@@ -207,15 +207,15 @@ index 2ebb384d8..4a7bfffdd 100644
}
impl kernel::Platform for Platform {
@@ -184,6 +200,7 @@ 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)),
capsules::nonvolatile_storage_driver::DRIVER_NUM => f(Some(self.nonvolatile_storage)),
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),
}
@@ -448,6 +465,21 @@ pub unsafe fn reset_handler() {
@@ -371,6 +388,21 @@ pub unsafe fn reset_handler() {
)
);
@@ -237,9 +237,9 @@ index 2ebb384d8..4a7bfffdd 100644
nrf52_components::NrfClockComponent::new().finalize(());
let platform = Platform {
@@ -464,6 +496,7 @@ pub unsafe fn reset_handler() {
@@ -383,6 +415,7 @@ pub unsafe fn reset_handler() {
alarm,
analog_comparator,
nonvolatile_storage,
nvmc,
+ usb,
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),

View File

@@ -1,11 +1,14 @@
diff --git a/Cargo.toml b/Cargo.toml
index 83c4855..cfd63b1 100644
index 83c48558e..75b1abacc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,8 @@ members = [
@@ -12,7 +12,11 @@ members = [
"boards/imix",
"boards/msp_exp432p401r",
"boards/nordic/nrf52840dk",
+ "boards/nordic/nrf52840dk_opensk",
"boards/nordic/nrf52840_dongle",
+ "boards/nordic/nrf52840_dongle_opensk",
+ "boards/nordic/nrf52840_dongle_dfu",
+ "boards/nordic/nrf52840_mdk_dfu",
"boards/nordic/nrf52dk",

View File

@@ -1,13 +0,0 @@
diff --git a/boards/nordic/nrf52840dk/src/main.rs b/boards/nordic/nrf52840dk/src/main.rs
index 303a451..18fd331 100644
--- a/boards/nordic/nrf52840dk/src/main.rs
+++ b/boards/nordic/nrf52840dk/src/main.rs
@@ -112,7 +112,7 @@ pub mod io;
// Whether to use UART debugging or Segger RTT (USB) debugging.
// - Set to false to use UART.
// - Set to true to use Segger RTT over USB.
-const USB_DEBUGGING: bool = false;
+const USB_DEBUGGING: bool = true;
const VENDOR_ID: u16 = 0x1915; // Nordic Semiconductor
const PRODUCT_ID: u16 = 0x521f; // nRF52840 Dongle (PCA10059)

View File

@@ -1,5 +1,5 @@
diff --git a/chips/nrf52/src/uicr.rs b/chips/nrf52/src/uicr.rs
index 6bb6c86..3bb8b5a 100644
index 6bb6c86b7..3bb8b5a7d 100644
--- a/chips/nrf52/src/uicr.rs
+++ b/chips/nrf52/src/uicr.rs
@@ -1,38 +1,45 @@
@@ -97,4 +97,3 @@ index 6bb6c86..3bb8b5a 100644
/// Setting of pins dedicated to NFC functionality: NFC antenna or GPIO
NfcPins [
/// Setting pins dedicated to NFC functionality

View File

@@ -1,6 +1,6 @@
diff --git a/boards/components/src/firmware_protection.rs b/boards/components/src/firmware_protection.rs
new file mode 100644
index 0000000..58695af
index 000000000..58695af81
--- /dev/null
+++ b/boards/components/src/firmware_protection.rs
@@ -0,0 +1,70 @@
@@ -75,7 +75,7 @@ index 0000000..58695af
+ }
+}
diff --git a/boards/components/src/lib.rs b/boards/components/src/lib.rs
index 917497a..520408f 100644
index 917497af4..520408fcb 100644
--- a/boards/components/src/lib.rs
+++ b/boards/components/src/lib.rs
@@ -9,6 +9,7 @@ pub mod console;
@@ -86,11 +86,11 @@ index 917497a..520408f 100644
pub mod ft6x06;
pub mod gpio;
pub mod hd44780;
diff --git a/boards/nordic/nrf52840_dongle/src/main.rs b/boards/nordic/nrf52840_dongle/src/main.rs
index 118ea6d..76436f3 100644
--- a/boards/nordic/nrf52840_dongle/src/main.rs
+++ b/boards/nordic/nrf52840_dongle/src/main.rs
@@ -112,6 +112,7 @@ pub struct Platform {
diff --git a/boards/nordic/nrf52840_dongle_opensk/src/main.rs b/boards/nordic/nrf52840_dongle_opensk/src/main.rs
index f5d29d025..051943867 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>,
>,
@@ -98,7 +98,7 @@ index 118ea6d..76436f3 100644
}
impl kernel::Platform for Platform {
@@ -132,6 +133,7 @@ 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)),
@@ -106,7 +106,7 @@ index 118ea6d..76436f3 100644
kernel::ipc::DRIVER_NUM => f(Some(&self.ipc)),
_ => f(None),
}
@@ -355,6 +357,14 @@ pub unsafe fn reset_handler() {
@@ -318,6 +320,14 @@ pub unsafe fn reset_handler() {
)
.finalize(components::usb_ctap_component_buf!(nrf52840::usbd::Usbd));
@@ -121,7 +121,7 @@ index 118ea6d..76436f3 100644
nrf52_components::NrfClockComponent::new().finalize(());
let platform = Platform {
@@ -371,6 +381,7 @@ pub unsafe fn reset_handler() {
@@ -331,6 +341,7 @@ pub unsafe fn reset_handler() {
analog_comparator,
nvmc,
usb,
@@ -129,11 +129,11 @@ index 118ea6d..76436f3 100644
ipc: kernel::ipc::IPC::new(board_kernel, &memory_allocation_capability),
};
diff --git a/boards/nordic/nrf52840dk/src/main.rs b/boards/nordic/nrf52840dk/src/main.rs
index b1d0d3c..3cfb38d 100644
--- a/boards/nordic/nrf52840dk/src/main.rs
+++ b/boards/nordic/nrf52840dk/src/main.rs
@@ -180,6 +180,7 @@ pub struct Platform {
diff --git a/boards/nordic/nrf52840dk_opensk/src/main.rs b/boards/nordic/nrf52840dk_opensk/src/main.rs
index 6a2f8715b..7898562dd 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>,
>,
@@ -141,15 +141,15 @@ index b1d0d3c..3cfb38d 100644
}
impl kernel::Platform for Platform {
@@ -201,6 +202,7 @@ impl kernel::Platform for Platform {
capsules::nonvolatile_storage_driver::DRIVER_NUM => f(Some(self.nonvolatile_storage)),
@@ -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),
}
@@ -480,6 +482,14 @@ pub unsafe fn reset_handler() {
@@ -403,6 +405,14 @@ pub unsafe fn reset_handler() {
)
.finalize(components::usb_ctap_component_buf!(nrf52840::usbd::Usbd));
@@ -164,8 +164,8 @@ index b1d0d3c..3cfb38d 100644
nrf52_components::NrfClockComponent::new().finalize(());
let platform = Platform {
@@ -497,6 +507,7 @@ pub unsafe fn reset_handler() {
nonvolatile_storage,
@@ -416,6 +426,7 @@ pub unsafe fn reset_handler() {
analog_comparator,
nvmc,
usb,
+ crp,
@@ -173,7 +173,7 @@ index b1d0d3c..3cfb38d 100644
};
diff --git a/capsules/src/driver.rs b/capsules/src/driver.rs
index ae458b3..f536dad 100644
index ae458b309..f536dad32 100644
--- a/capsules/src/driver.rs
+++ b/capsules/src/driver.rs
@@ -16,6 +16,7 @@ pub enum NUM {
@@ -186,7 +186,7 @@ index ae458b3..f536dad 100644
Ipc = 0x10000,
diff --git a/capsules/src/firmware_protection.rs b/capsules/src/firmware_protection.rs
new file mode 100644
index 0000000..8cf63d6
index 000000000..8cf63d6a4
--- /dev/null
+++ b/capsules/src/firmware_protection.rs
@@ -0,0 +1,85 @@
@@ -276,7 +276,7 @@ index 0000000..8cf63d6
+ }
+}
diff --git a/capsules/src/lib.rs b/capsules/src/lib.rs
index e4423fe..7538aad 100644
index e4423fe05..7538aad18 100644
--- a/capsules/src/lib.rs
+++ b/capsules/src/lib.rs
@@ -22,6 +22,7 @@ pub mod crc;
@@ -288,7 +288,7 @@ index e4423fe..7538aad 100644
pub mod ft6x06;
pub mod fxos8700cq;
diff --git a/chips/nrf52/src/uicr.rs b/chips/nrf52/src/uicr.rs
index 3bb8b5a..ea96cb2 100644
index 3bb8b5a7d..ea96cb2ae 100644
--- a/chips/nrf52/src/uicr.rs
+++ b/chips/nrf52/src/uicr.rs
@@ -1,13 +1,14 @@
@@ -359,7 +359,7 @@ index 3bb8b5a..ea96cb2 100644
+}
diff --git a/kernel/src/hil/firmware_protection.rs b/kernel/src/hil/firmware_protection.rs
new file mode 100644
index 0000000..de08246
index 000000000..de0824646
--- /dev/null
+++ b/kernel/src/hil/firmware_protection.rs
@@ -0,0 +1,48 @@
@@ -412,7 +412,7 @@ index 0000000..de08246
+ fn set_protection(&self, level: ProtectionLevel) -> ReturnCode;
+}
diff --git a/kernel/src/hil/mod.rs b/kernel/src/hil/mod.rs
index 4f42afa..83e7702 100644
index 4f42afa02..83e7702ab 100644
--- a/kernel/src/hil/mod.rs
+++ b/kernel/src/hil/mod.rs
@@ -8,6 +8,7 @@ pub mod dac;
@@ -423,4 +423,3 @@ index 4f42afa..83e7702 100644
pub mod flash;
pub mod gpio;
pub mod gpio_async;