oxidecomputer / oxidecomputer/hubris

SPI driver seems to hang at high clock frequencies

Open
#2,133 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cosmo hardware stm32
Dominant language
Rust
Stars
3.6k
Forks
239
Avg merge
1d 12h
Merged PRs (30d)
23

Description

When testing SPI at a DIV2 clock divider (50 MHz, see https://github.com/oxidecomputer/hardware-cosmo/issues/766#issuecomment-3050259583), we noticed what looks like a hang in the SPI driver. Normally, cosmo_seq takes a tiny amount of time to configure FPGA2 over SPI3, but in this test it never finished:

➜  hubris git:(master) ✗ humility tasks
humility: attached via ST-Link V3
system time = 43495
ID TASK                       GEN PRI STATE
 0 jefe                         0   0 recv, notif: fault timer(T+5)
 1 net                          0   5 notif: jefe-state-change
 2 sys                          0   1 recv, notif: exti-wildcard-irq(irq6/irq7/irq8/irq9/irq10/irq23/irq40)
 3 spi2_driver                  0   3 recv
 4 spi3_driver                  0   3 notif: spi-irq(irq51)
 5 i2c_driver                   0   3 recv
 6 packrat                      0   1 recv
 7 thermal                      0   8 wait: send to cosmo_seq/gen0
 8 power                        0   8 wait: send to cosmo_seq/gen0
 9 hiffy                        0   7 notif: bit31(T+15)
10 cosmo_seq                    0   7 wait: reply from spi3_driver/gen0
11 ignition_flash               0   7 recv
12 spartan7_loader              0   4 recv
13 hash_driver                  0   2 recv
14 hf                           0   6 recv, notif: timer
15 update_server                0   3 recv
16 sensor                       0   4 recv
17 host_sp_comms                0   9 recv, notif: jefe-state-change usart-irq(irq71) multitimer control-plane-agent
18 udpecho                      0   6 wait: send to net/gen0
19 udpbroadcast                 0   6 wait: send to net/gen0
20 control_plane_agent          0   8 wait: send to net/gen0
21 sprot                        0   4 recv
22 validate                     0   5 recv
23 vpd                          0   4 recv
24 user_leds                    0   2 recv, notif: timer
25 dump_agent                   0   6 wait: send to net/gen0
26 sbrmi                        0   4 recv
27 spd                          0   7 notif: jefe-state-change
28 auxflash                     0   3 recv
29 idle                         0  15 RUNNING
30 udprpc                       0   6 wait: send to net/gen0
31 fmc_demo                     0   6 recv, notif: socket
humility tasks -sl spi3_driver
humility: attached via ST-Link V3
system time = 183694
ID TASK                       GEN PRI STATE
 4 spi3_driver                  0   3 notif: spi-irq(irq51)
   |
   +--->  0x24068290 0x0804c178 userlib::sys_recv_stub
                     @ /hubris/sys/userlib/src/lib.rs:368
          0x24068368 0x0804aa8a userlib::sys_recv
                     @ /hubris/sys/userlib/src/lib.rs:296
          0x24068368 0x0804aa8a userlib::sys_recv_notification
                     @ /hubris/sys/userlib/src/lib.rs:340
          0x24068368 0x0804a8f2 <drv_stm32h7_spi_server::ServerImpl as drv_stm32h7_spi_server::InOrderSpiImpl>::write
                     @ /hubris/drv/stm32h7-spi-server/src/main.rs:73
          0x24068368 0x0804a886 drv_stm32h7_spi_server::<impl idol_runtime::Server<drv_stm32h7_spi_server::SpiOperation> for (core::marker::PhantomData<drv_stm32h7_spi_server::SpiOperation>,&mut S)>::handle
                     @ /hubris/target/thumbv7em-none-eabihf/release/build/drv-stm32h7-spi-server-d0f0d84fec042ad1/out/server_stub.rs:243
          0x24068368 0x0804a63e idol_runtime::dispatch
                     @ /git/idolatry-1ebf1c2fd2f30300/6c54f3b/runtime/src/lib.rs:228
          0x24068368 0x0804aa9a main
                     @ /hubris/drv/stm32h7-spi-server/src/main.rs:33

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in drv/stm32h7-spi-server/src/main.rs, especially InOrderSpiImpl::write at line 73, and inspect the stack shown for sys_recv_notification. Reproduce the DIV2, 50 MHz configuration test and use humility tasks to observe spi3_driver and cosmo_seq. Done means SPI3 configuration completes without leaving cosmo_seq waiting indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.