Merge branch 'master' into aaguid
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,9 +1,9 @@
|
||||
1003863864e06553e730eec6df4bf8d30c99f697ef9380efdc35eba679b4db78 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840dk.bin
|
||||
6b0a7402c38a37fc729644a4a92bfba8bc4431ad21f3a16d1527f2258e2231d1 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
|
||||
b35ac62a490c62d4b23dddf1d8e6946badb32b5b35b40bbd75587815530094c9 target/nrf52840_dongle_merged.hex
|
||||
d2373ac9df2ba8feff88f19e67ec87a58e635b94f0a0f759b6fcf4c750b256c9 target/nrf52840_dongle_merged.hex
|
||||
908d7f4f40936d968b91ab6e19b2406612fe8c2c273d9c0b71ef1f55116780e0 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_dongle_dfu.bin
|
||||
1adb9f71697947109020b25ad2b3fb3b03e6a07945dee14351ad67341241205e target/nrf52840_dongle_dfu_merged.hex
|
||||
3c6f18ad1e1ceedeb622f39cd00ae3328ea5ad1557a9042c1b4bf831d5e1fb0d target/nrf52840_dongle_dfu_merged.hex
|
||||
34ecbecaebf1188277f2310fe769c8c60310d8576493242712854deb4ba1036e third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_mdk_dfu.bin
|
||||
1661fb4da7cbaf01529e593600f47c4613446a37f400cb0b238249d100a3d9f1 target/nrf52840_mdk_dfu_merged.hex
|
||||
529ac9aef3941b45e7e480810ae4e821da433985b149028aa6a33f33e0dc1685 target/tab/ctap2.tab
|
||||
d1320adfcec35099ade04988111a947c05d14c43851fc5800d17d7a83bdba033 target/nrf52840_mdk_dfu_merged.hex
|
||||
c2cbcc28b835934be4c3d3e3c5bdaba642a5811d760c1d2cb73d26b6474e4219 target/tab/ctap2.tab
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
c182bb4902fff51b2f56810fc2a27df3646cd66ba21359162354d53445623ab8 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840dk.bin
|
||||
bebc884aa49b79359b22916ca3d20eca3cddc3d4283ff6d0da1f0d46e1b6a1fb 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
|
||||
1bf5219f7b096b4ade330e9b02544b09d10972ddf253c7fdfbd6241b03e98f31 target/nrf52840_dongle_merged.hex
|
||||
c9349bd480b30e28214bb8d58d10938889050b92d34fbeb70e3110919b3a2601 target/nrf52840_dongle_merged.hex
|
||||
e3acf15d5ae3a22aecff6cc58db5fc311f538f47328d348b7ad7db7f9ab5e72c third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_dongle_dfu.bin
|
||||
b83edda1b2588e3eff019fc8b2e16097e159f8a43fa5fc62a6e23497882c8dca target/nrf52840_dongle_dfu_merged.hex
|
||||
08f3ca1bb79e13e83149324244929b68f8d7583630d9a62a8ffdedb710c95d8b target/nrf52840_dongle_dfu_merged.hex
|
||||
cae312a26a513ada6c198fdc59b2bba3860c51726b817a9fd17a4331ee12c882 third_party/tock/target/thumbv7em-none-eabi/release/nrf52840_mdk_dfu.bin
|
||||
d376cb19e672ab80b9dd25e9df40af7ac833d03ede32f4a2ae21fdfd4e31d365 target/nrf52840_mdk_dfu_merged.hex
|
||||
ba0e11a0036f167a56864de43db3602a8a855b38be8a53afc3a97fcaa40f2201 target/tab/ctap2.tab
|
||||
849c67c811da8d359d4e55d81d2587b3efa2f6065d72e4db09c3e571af8fef94 target/nrf52840_mdk_dfu_merged.hex
|
||||
40b413a8b645b4b47fae62a4311acb12cb0c57faff2757e45c18d9e5d441e52d target/tab/ctap2.tab
|
||||
|
||||
@@ -5,8 +5,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171876 (0x29f64) bytes.
|
||||
Adding .stack section. Offset: 172004 (0x29fe4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175636 (0x2ae14) bytes.
|
||||
Adding .stack section. Offset: 175764 (0x2ae94). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
@@ -24,8 +24,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171876 (0x29f64) bytes.
|
||||
Adding .stack section. Offset: 172004 (0x29fe4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175636 (0x2ae14) bytes.
|
||||
Adding .stack section. Offset: 175764 (0x2ae94). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
@@ -43,8 +43,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171876 (0x29f64) bytes.
|
||||
Adding .stack section. Offset: 172004 (0x29fe4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175636 (0x2ae14) bytes.
|
||||
Adding .stack section. Offset: 175764 (0x2ae94). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
@@ -62,8 +62,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171876 (0x29f64) bytes.
|
||||
Adding .stack section. Offset: 172004 (0x29fe4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175636 (0x2ae14) bytes.
|
||||
Adding .stack section. Offset: 175764 (0x2ae94). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
|
||||
@@ -5,8 +5,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171316 (0x29d34) bytes.
|
||||
Adding .stack section. Offset: 171444 (0x29db4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175252 (0x2ac94) bytes.
|
||||
Adding .stack section. Offset: 175380 (0x2ad14). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
@@ -24,8 +24,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171316 (0x29d34) bytes.
|
||||
Adding .stack section. Offset: 171444 (0x29db4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175252 (0x2ac94) bytes.
|
||||
Adding .stack section. Offset: 175380 (0x2ad14). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
@@ -43,8 +43,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171316 (0x29d34) bytes.
|
||||
Adding .stack section. Offset: 171444 (0x29db4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175252 (0x2ac94) bytes.
|
||||
Adding .stack section. Offset: 175380 (0x2ad14). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
@@ -62,8 +62,8 @@ Min RAM size from sections in ELF: 16 bytes
|
||||
Number of writeable flash regions: 0
|
||||
Adding .crt0_header section. Offset: 64 (0x40). Length: 64 (0x40) bytes.
|
||||
Entry point is in .text section
|
||||
Adding .text section. Offset: 128 (0x80). Length: 171316 (0x29d34) bytes.
|
||||
Adding .stack section. Offset: 171444 (0x29db4). Length: 16384 (0x4000) bytes.
|
||||
Adding .text section. Offset: 128 (0x80). Length: 175252 (0x2ac94) bytes.
|
||||
Adding .stack section. Offset: 175380 (0x2ad14). Length: 16384 (0x4000) bytes.
|
||||
Searching for .rel.X sections to add.
|
||||
TBF Header:
|
||||
version: 2 0x2
|
||||
|
||||
Reference in New Issue
Block a user