Merge branch 'master' into authenticator-selection
This commit is contained in:
98
patches/libtock-rs/08-buffered-console.patch
Normal file
98
patches/libtock-rs/08-buffered-console.patch
Normal file
@@ -0,0 +1,98 @@
|
||||
diff --git a/src/console.rs b/src/console.rs
|
||||
index ecd7ad1..ae1b826 100644
|
||||
--- a/src/console.rs
|
||||
+++ b/src/console.rs
|
||||
@@ -16,33 +16,63 @@ mod allow_nr {
|
||||
pub const SHARE_BUFFER: usize = 1;
|
||||
}
|
||||
|
||||
+const BUFFER_SIZE: usize = 1024;
|
||||
+
|
||||
pub struct Console {
|
||||
- allow_buffer: [u8; 64],
|
||||
+ allow_buffer: [u8; BUFFER_SIZE],
|
||||
+ count_pending: usize,
|
||||
}
|
||||
|
||||
impl Console {
|
||||
pub fn new() -> Console {
|
||||
Console {
|
||||
- allow_buffer: [0; 64],
|
||||
+ allow_buffer: [0; BUFFER_SIZE],
|
||||
+ count_pending: 0,
|
||||
}
|
||||
}
|
||||
|
||||
+ fn is_empty(&self) -> bool {
|
||||
+ self.count_pending == 0
|
||||
+ }
|
||||
+
|
||||
+ fn is_full(&self) -> bool {
|
||||
+ self.allow_buffer.len() == self.count_pending
|
||||
+ }
|
||||
+
|
||||
+ fn available_len(&self) -> usize {
|
||||
+ self.allow_buffer.len() - self.count_pending
|
||||
+ }
|
||||
+
|
||||
pub fn write<S: AsRef<[u8]>>(&mut self, text: S) {
|
||||
let mut not_written_yet = text.as_ref();
|
||||
while !not_written_yet.is_empty() {
|
||||
- let num_bytes_to_print = self.allow_buffer.len().min(not_written_yet.len());
|
||||
- self.allow_buffer[..num_bytes_to_print]
|
||||
+ let num_bytes_to_print = self.available_len().min(not_written_yet.len());
|
||||
+ self.allow_buffer[self.count_pending..(self.count_pending + num_bytes_to_print)]
|
||||
.copy_from_slice(¬_written_yet[..num_bytes_to_print]);
|
||||
- self.flush(num_bytes_to_print);
|
||||
+ self.count_pending += num_bytes_to_print;
|
||||
+
|
||||
+ if self.is_full() {
|
||||
+ self.flush();
|
||||
+ }
|
||||
+
|
||||
not_written_yet = ¬_written_yet[num_bytes_to_print..];
|
||||
}
|
||||
}
|
||||
|
||||
- fn flush(&mut self, num_bytes_to_print: usize) {
|
||||
+ pub fn flush(&mut self) {
|
||||
+ if self.is_empty() {
|
||||
+ // Don't trigger any syscall if the buffer is empty.
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ let count = self.count_pending;
|
||||
+ // Clear the buffer even in case of error, to avoid an infinite loop.
|
||||
+ self.count_pending = 0;
|
||||
+
|
||||
let result = syscalls::allow(
|
||||
DRIVER_NUMBER,
|
||||
allow_nr::SHARE_BUFFER,
|
||||
- &mut self.allow_buffer[..num_bytes_to_print],
|
||||
+ &mut self.allow_buffer[..count],
|
||||
);
|
||||
if result.is_err() {
|
||||
return;
|
||||
@@ -59,8 +89,7 @@ impl Console {
|
||||
return;
|
||||
}
|
||||
|
||||
- let result_code =
|
||||
- unsafe { syscalls::command(DRIVER_NUMBER, command_nr::WRITE, num_bytes_to_print, 0) };
|
||||
+ let result_code = unsafe { syscalls::command(DRIVER_NUMBER, command_nr::WRITE, count, 0) };
|
||||
if result_code < 0 {
|
||||
return;
|
||||
}
|
||||
@@ -69,6 +98,12 @@ impl Console {
|
||||
}
|
||||
}
|
||||
|
||||
+impl Drop for Console {
|
||||
+ fn drop(&mut self) {
|
||||
+ self.flush();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
impl fmt::Write for Console {
|
||||
fn write_str(&mut self, string: &str) -> Result<(), fmt::Error> {
|
||||
self.write(string);
|
||||
13
patches/tock/05-backport-fix-1960.patch
Normal file
13
patches/tock/05-backport-fix-1960.patch
Normal file
@@ -0,0 +1,13 @@
|
||||
diff --git a/capsules/src/segger_rtt.rs b/capsules/src/segger_rtt.rs
|
||||
index 89a9ddbf..135e7b45 100644
|
||||
--- a/capsules/src/segger_rtt.rs
|
||||
+++ b/capsules/src/segger_rtt.rs
|
||||
@@ -240,7 +240,7 @@ impl<'a, A: hil::time::Alarm<'a>> uart::Transmit<'a> for SeggerRtt<'a, A> {
|
||||
|
||||
// Start a short timer so that we get a callback and
|
||||
// can issue the callback to the client.
|
||||
- let interval = (100 as u32) * <A::Frequency>::frequency() / 1000000;
|
||||
+ let interval = (1000 as u32) * <A::Frequency>::frequency() / 1000000;
|
||||
let tics = self.alarm.now().wrapping_add(interval);
|
||||
self.alarm.set_alarm(tics);
|
||||
})
|
||||
@@ -1,5 +1,5 @@
|
||||
1003863864e06553e730eec6df4bf8d30c99f697ef9380efdc35eba679b4db78 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840dk.bin
|
||||
93559510b03cd811bbdcf2963e5dd7e9acdc13cf47d2ad1b9e7bd2e210644a2b target/nrf52840dk_merged.hex
|
||||
0b54df6d548849e24d67b9b022ca09cb33c51f078ce85d0c9c4635ffc69902e1 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840dk.bin
|
||||
9ff63684ca08375e643f14f33dc6dc8131681bb562fb0df18f9c7f637e90cc73 target/nrf52840dk_merged.hex
|
||||
052eec0ae526038352b9f7573468d0cf7fb5ec331d4dc1a2df75fdbd514ea5ca third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_dongle.bin
|
||||
f976e2975d908567398456afd9996fd60639f0a5e55d0bd5a96768a7cb7797c2 target/nrf52840_dongle_merged.hex
|
||||
908d7f4f40936d968b91ab6e19b2406612fe8c2c273d9c0b71ef1f55116780e0 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_dongle_dfu.bin
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
c182bb4902fff51b2f56810fc2a27df3646cd66ba21359162354d53445623ab8 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840dk.bin
|
||||
5e49a0d46c9a122f847228784c0c0bfc8309be5ae56aea2241911bc9d61dce55 target/nrf52840dk_merged.hex
|
||||
29382e72d0f3c6a72ce9517211952ff29ea270193d7f0ddc48ca69009ee29925 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840dk.bin
|
||||
bb2fbf0d9dab2b489a49d1dc3db8923086ab109d14f1f1aa8296f086a03b75dd target/nrf52840dk_merged.hex
|
||||
30f239390ae9bef0825731e4c82d40470fc5e9bded2bf0d942e92dbb5d4faba1 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_dongle.bin
|
||||
e3e9dd3a633a0ceb4b971bcd82e3cd02dd37ccaca486e44f136ce79e4a5a407a target/nrf52840_dongle_merged.hex
|
||||
e3acf15d5ae3a22aecff6cc58db5fc311f538f47328d348b7ad7db7f9ab5e72c third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_dongle_dfu.bin
|
||||
|
||||
Reference in New Issue
Block a user