-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use probe-rs as probe-run is deprecated #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,12 @@ categories = ["embedded", "hardware-support", "no-std"] | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
cortex-m = "0.7.5" | ||
cortex-m = { version = "0.7.5", features = ["critical-section-single-core"] } | ||
embedded-hal = "0.2.7" | ||
switch-hal = "0.4.0" | ||
stm32f4xx-hal = { version = "0.13.2", features = ["stm32f446"]} | ||
unwrap-infallible = "0.1.5" | ||
rtt-target = "0.5.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed for cargo embed for the example you added? If so, I think it's best to place it in the dev-dependencies as someone using the crate as a library has no need to add this as a dependency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'm going to remove the new examples so this will be removed. |
||
|
||
[dev-dependencies] | ||
cortex-m-rt = "0.7.1" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[default.general] | ||
chip = "STM32F446RETx" | ||
|
||
# By default use denable rtt if we use `cargo embed` | ||
[default.rtt] | ||
enabled = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Examples | ||
|
||
If you've installed `probe-rs` with `cargo install probe-rs --features cli` | ||
just use `cargo run --example <filename>` to build and run any of the | ||
examples. | ||
|
||
For `channels-3d-1u` you can use also use | ||
`cargo embed --example channels-3d-1u` which provides a nicer interface, | ||
a terminal with 3 tabs and you can switch between the tabe using | ||
F1, F2 and F3. | ||
|
||
In all cases Ctrl-C terminates the program. | ||
|
||
**TODO:** Document serial_*, inparticular how to setup the hardware! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#![deny(unsafe_code)] | ||
#![no_std] | ||
#![no_main] | ||
|
||
use cortex_m_rt::entry; | ||
use embedded_hal::blocking::delay::DelayMs; | ||
use nucleo_f446re::{led::LedDigital, Nucleo}; | ||
use panic_probe as _; | ||
|
||
|
||
use core::fmt::Write; | ||
use rtt_target::{rtt_init, ChannelMode::BlockIfFull}; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let mut nucleo = Nucleo::<LedDigital>::init().unwrap(); | ||
|
||
let channels = rtt_init! { | ||
up: { | ||
0: { | ||
size: 512, | ||
mode: BlockIfFull, | ||
name: "Up zero" | ||
} | ||
1: { | ||
size: 128, | ||
name: "Up one" | ||
} | ||
2: { | ||
size: 128, | ||
name: "Up two" | ||
} | ||
} | ||
down: { | ||
0: { | ||
size: 512, | ||
mode: BlockIfFull, | ||
name: "Down zero" | ||
} | ||
} | ||
}; | ||
|
||
let mut output2 = channels.up.1; | ||
writeln!( | ||
output2, | ||
"Hi! I will turn anything you type on channel 0 into upper case." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran this example but couldn't get it to work like I thought. On channel 0 I am able to get an uppercase'd echo and periodic logs on channel 2, but channel 1 (which has this message) doesn't do anything. I probably need to read up more on RTT to get what is going on here. It does feel similar to the comment I left on the other example, that I'm not sure this adds much to this nucleo crate (rather an example of RTT usage). But, it is a more involved example so I'm more inclined to include it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing for now |
||
) | ||
.ok(); | ||
|
||
let mut output = channels.up.0; | ||
let mut log = channels.up.2; | ||
let mut input = channels.down.0; | ||
let mut buf = [0u8; 512]; | ||
let mut count: u8 = 0; | ||
|
||
loop { | ||
writeln!(log, "Top of loop, invoking input.read").ok(); | ||
let bytes = loop { | ||
let bytes_read = input.read(&mut buf[..]); | ||
|
||
if bytes_read > 0 { | ||
break bytes_read; | ||
} | ||
|
||
writeln!(log, "No bytes read, sleeping").ok(); | ||
nucleo.delay.delay_ms(1000_u32); | ||
}; | ||
|
||
writeln!(log, "read {} bytes", bytes).ok(); | ||
if bytes > 0 { | ||
for c in buf.iter_mut() { | ||
c.make_ascii_uppercase(); | ||
} | ||
|
||
let mut p = 0; | ||
while p < bytes { | ||
p += output.write(&buf[p..bytes]); | ||
} | ||
} | ||
|
||
writeln!(log, "Messsge no. {}/{}", count, bytes).ok(); | ||
nucleo.user_led.toggle(); | ||
|
||
count += 1; | ||
|
||
nucleo.delay.delay_ms(10_u32); | ||
//for _ in 0..1_000_000 { | ||
// cortex_m::asm::nop(); | ||
//} | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be honest, I don't see much value in this example being included in this repository. It seems more like a demonstration of rtt features as otherwise the behavior is identical to the blinky example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that was important feature you can when using probe-rs so I added it. But to simplify this change I'm removing them. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#![deny(unsafe_code)] | ||
#![no_std] | ||
#![no_main] | ||
|
||
use cortex_m_rt::entry; | ||
use embedded_hal::blocking::delay::DelayMs; | ||
use nucleo_f446re::{led::LedDigital, Nucleo}; | ||
use panic_probe as _; | ||
use rtt_target; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let mut nucleo = Nucleo::<LedDigital>::init().unwrap(); | ||
// Can also use the LED default generic argument with <Nucleo>::init().unwrap(); | ||
|
||
rtt_target::rtt_init_print!(); | ||
loop { | ||
rtt_target::rprintln!("rprintln!(Hello, world!)"); | ||
rtt_target::debug_rprintln!("debug_rprintln!(Hello, world!)"); | ||
nucleo.user_led.toggle(); | ||
nucleo.delay.delay_ms(500_u32); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this feature needed for? I initially had a build error that I think is due to this feature being added in a later version of cortex-m.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before adding that I got errors that
_critical_section_1_0_release
and_critical_section_1_0_acquire
were undefined.I did a search for undefined _critical_section_1_0_release and found this so I added
critical-section-single-core
. Actually, I didn't find that ferrous post originally, but it pedantically explains why so used that one here :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I see what's going on now. I had an older lockfile initially, which only use 0.7.5, which does fail to build with the feature (because it was added in 0.7.6). But, newer versions of the dependencies use 0.7.7 which does have the feature, and requires it in this situation (as your link to the Ferrous Systems blog explains). At least it makes sense now.