Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit ef36141

Browse files
committed
korken69's J-Link fix behind a feature flag
1 parent 64b7c7e commit ef36141

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ version = "0.3.4"
1414

1515
[features]
1616
inline-asm = []
17+
jlink-quirks = []
1718

1819
[dependencies]
1920
cortex-m = ">= 0.5.8, < 0.7"

src/hio.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ fn write_all(fd: usize, mut buffer: &[u8]) -> Result<(), ()> {
7474
slice::from_raw_parts(buffer.as_ptr().offset(offset), n)
7575
}
7676
}
77+
#[cfg(feature = "jlink-quirks")]
78+
// Error (-1) - should be an error but JLink can return -1, -2, -3,...
79+
// For good measure, we allow up to negative 15.
80+
n if n > 0xfffffff0 => return Ok(()),
7781
// Error
7882
_ => return Err(()),
7983
}

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@
133133
//! When this feature is disabled semihosting is implemented using FFI calls into an external
134134
//! assembly file and compiling this crate works on stable and beta.
135135
//!
136+
//! ## `jlink-quirks`
137+
//!
138+
//! When this feature is enabled, return values above `0xfffffff0` from semihosting operation
139+
//! `SYS_WRITE` (0x05) are interpreted as if the entire buffer had been written. The current
140+
//! latest version 6.48b of J-Link exhibits such behaviour, causing a panic if this feature
141+
//! is not enabled.
142+
//!
136143
//! # Reference
137144
//!
138145
//! For documentation about the semihosting operations, check:

0 commit comments

Comments
 (0)