Skip to content

Commit 6b7542b

Browse files
committed
Fix picow demo to work again
It broke when embassy deps were updated without being tested. NUM_LISTENERS has been reduced to 2 pending debugging issues with larger arena allocations. "nightly" embassy-executor works OK with NUM_LISTENERS=4 (or perhaps more). Fixes: e769b8a ("Use embassy from crates not git patch")
1 parent 05a7bfb commit 6b7542b

File tree

16 files changed

+187
-131
lines changed

16 files changed

+187
-131
lines changed

Cargo.lock

Lines changed: 32 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ embedded-io = { version = "0.6", optional = true }
5858
# for debug printing
5959
pretty-hex = { version = "0.4", default-features = false }
6060

61-
# for non_async
62-
futures = { version = "0.3", default-features = false }
63-
6461
[features]
6562
std = ["snafu/std", "snafu/backtrace", "ssh-key/alloc", "larger"]
6663
rsa = ["dep:rsa", "ssh-key/rsa"]
@@ -85,6 +82,18 @@ simplelog = { version = "0.12", features = ["test"] }
8582
#ed25519-dalek = { git = "https://github.com/mkj/curve25519-dalek", branch = "sunset" }
8683
#x25519-dalek = { git = "https://github.com/mkj/curve25519-dalek", branch = "sunset" }
8784

85+
# [patch.crates-io]
86+
# cyw43 = { path = "/home/matt/3rd/rs/embassy-stable-sunset/cyw43" }
87+
# embassy-time = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-time" }
88+
# embassy-time-driver = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-time-driver" }
89+
# embassy-time-queue-driver = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-time-queue-driver" }
90+
# embassy-sync = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-sync" }
91+
# embassy-net = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-net" }
92+
# embassy-net-driver = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-net-driver" }
93+
# embassy-net-driver-channel = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-net-driver-channel" }
94+
# embassy-executor = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-executor" }
95+
# embassy-executor-macros = { path = "/home/matt/3rd/rs/embassy-stable-sunset/embassy-executor-macros" }
96+
8897
# these are mostly applicable to picow, but can't hurt generally
8998
[profile.dev]
9099
debug = 2
@@ -97,9 +106,10 @@ codegen-units = 1
97106
debug = 2
98107
debug-assertions = false
99108
incremental = false
100-
lto = 'fat'
109+
lto = "fat"
101110
opt-level = 'z'
102111
overflow-checks = false
112+
panic = "abort"
103113

104114
# do not optimize proc-macro crates = faster builds from scratch
105115
[profile.dev.build-override]

embassy/demos/common/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(not(any(feature = "std", test)), no_std)]
1+
#![no_std]
22

33
// avoid warning about Send for the time being
44
#[allow(async_fn_in_trait)]

embassy/demos/common/src/server.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ pub async fn listener<D: Driver, S: DemoServer>(stack: &'static Stack<D>,
2828
let mut rx_buffer = [0; 1550];
2929
let mut tx_buffer = [0; 1550];
3030

31+
let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer);
32+
// socket.set_nagle_enabled(false);
3133
loop {
32-
let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer);
33-
// socket.set_nagle_enabled(false);
3434

3535
info!("Listening on TCP:22...");
3636
if let Err(_) = socket.accept(22).await {
@@ -159,6 +159,7 @@ impl ServerApp {
159159
};
160160

161161
if p.check(password) {
162+
info!("Password login for {username}");
162163
a.allow()?
163164
}
164165
Ok(())
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2-
runner = "probe-run --chip RP2040"
2+
runner = "probe-rs run --chip RP2040 --speed 20000"
33

44
[build]
55
target = "thumbv6m-none-eabi"
6-
rustflags = "-Cllvm-args=--enable-machine-outliner=never"
76

8-
[env]
9-
DEFMT_LOG = "debug"

embassy/demos/picow/Cargo.toml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,33 @@ sunset = { path = "../../.." }
99
sunset-sshwire-derive = { path = "../../../sshwire-derive" }
1010
sunset-demo-embassy-common= { path = "../common" }
1111

12-
cyw43 = { version = "0.1.0", optional = true}
12+
cyw43 = { version = "0.1.0", optional = true, features = ["log", "firmware-logs"]}
1313
cyw43-pio = { version = "0.1.0", optional = true }
1414

1515
embassy-net-wiznet = { version = "0.1.0", optional = true }
1616

17-
embassy-executor = { version = "0.5", features = ["integrated-timers", "executor-thread", "arch-cortex-m"] }
17+
embassy-executor = { version = "0.5", features = [
18+
"integrated-timers", "executor-thread", "arch-cortex-m", "log",
19+
# Larger than around 120kB causes unknown failures. using "nightly" feature
20+
# instead works OK. Needs investigation. 96kB is sufficient for NUM_LISTENERS=2
21+
# https://github.com/embassy-rs/embassy/issues/3061
22+
"task-arena-size-98304"] }
1823
embassy-time = { version = "0.3", features = [] }
1924
embassy-rp = { version = "0.1", features = ["unstable-pac", "time-driver"] }
20-
embassy-net = { version = "0.4", features = ["tcp", "dhcpv4", "medium-ethernet"] }
25+
embassy-net = { version = "0.4", features = ["tcp", "dhcpv4", "medium-ethernet", "log"] }
2126
embassy-net-driver = { version = "0.2" }
2227
embassy-usb-driver = { version = "0.1" }
2328
embassy-sync = { version = "0.5" }
2429
embassy-futures = { version = "0.1" }
25-
embassy-usb = { version = "0.1" }
30+
embassy-usb = { version = "0.1", features = ["log"] }
2631
atomic-polyfill = "1.0"
2732
static_cell = { version = "1.0", features = [ "nightly" ] }
2833

29-
panic-probe = { version = "0.3", features = [] }
30-
pretty-hex = { version = "0.4", default-features = false }
3134
log = { version = "0.4" }
32-
futures = { version = "0.3", default-features = false }
35+
rtt-target = "0.3"
36+
rtt-logger = "0.2"
37+
38+
pretty-hex = { version = "0.4", default-features = false }
3339

3440
snafu = { version = "0.8", default-features = false, features = ["rust_1_65"] }
3541

@@ -61,8 +67,8 @@ cyw43 = ["dep:cyw43", "dep:cyw43-pio"]
6167
w5500 = ["dep:embassy-net-wiznet", "dep:embedded-hal-bus"]
6268

6369
# Use cyw43 firmware already on flash. This saves time when developing.
64-
# probe-rs-cli download firmware/43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
65-
# probe-rs-cli download firmware/43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000
70+
# probe-rs download firmware/43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
71+
# probe-rs download firmware/43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
6672
romfw = []
6773

6874
# Set default console to serial

embassy/demos/picow/memory.x

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MEMORY {
22
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
3-
FLASH : ORIGIN = 0x10000100, LENGTH = 1024K - 0x100
4-
RAM : ORIGIN = 0x20000000, LENGTH = 256K
5-
}
3+
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
4+
RAM : ORIGIN = 0x20000000, LENGTH = 264K
5+
}

embassy/demos/picow/src/flashconfig.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ struct FlashConfig<'a> {
3737
}
3838

3939
impl FlashConfig<'_> {
40-
const BUF_SIZE: usize = 1 + SSHConfig::BUF_SIZE + 32;
40+
const BUF_SIZE: usize = 4 + SSHConfig::BUF_SIZE + 32;
4141
}
42+
const _: () = assert!(FlashConfig::BUF_SIZE % 4 == 0, "flash reads must be a multiple of 4");
4243

4344
fn config_hash(config: &SSHConfig) -> Result<[u8; 32]> {
4445
let mut h = sha2::Sha256::new();
@@ -71,7 +72,10 @@ pub async fn create(flash: &mut Fl<'_>) -> Result<SSHConfig> {
7172
pub async fn load(flash: &mut Fl<'_>) -> Result<SSHConfig> {
7273
// let mut buf = [0u8; ERASE_SIZE];
7374
let mut buf = [0u8; FlashConfig::BUF_SIZE];
74-
flash.read(CONFIG_OFFSET, &mut buf).await.map_err(|_| Error::msg("flash error"))?;
75+
flash.read(CONFIG_OFFSET, &mut buf).await.map_err(|e| {
76+
debug!("flash read error 0x{CONFIG_OFFSET:x} {e:?}");
77+
Error::msg("flash error")
78+
})?;
7579

7680
// use pretty_hex::PrettyHex;
7781
// use core::fmt::Write;

0 commit comments

Comments
 (0)