Skip to content
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

sprot: turn ROT_IRQ into a real IRQ #1696

Merged
merged 14 commits into from
Apr 5, 2024
Merged

sprot: turn ROT_IRQ into a real IRQ #1696

merged 14 commits into from
Apr 5, 2024

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Mar 29, 2024

The ROT_IRQ line is used by the RoT to raise an interrupt to the SP.
Currently, the drv-stm32h7-sprot-server task waits for this IRQ by
polling the state of the GPIO in a loop, with a comment saying that once
we can receive EXTI IRQs, we should use EXTI instead.

Now that #1691 and #1693 have merged, we can actually use EXTI to
receive interrupts on GPIO pin state changes. So, this branch updates
the stm32h7-sprot-server task to use EXTI, instead. We now also use
the timer notification to implement the timeout while waiting for the
interrupt, which was previously implemented by counting the number of
loops.

I've tested this change using the sprot-e2e framework on a PSC, using
the SP image built from this branch and the RoT images built from
@lzrd's update-stage0 branch. If there's any additional testing I
ought to do, I'm happy to take suggestions.

In a follow-up change, I'd like to also implement the task configuration
for this pin, so that it's no longer hard-coded in the app.tomls.

@hawkw hawkw force-pushed the eliza/make-rot-irq-real branch from 1390c22 to 3ce610b Compare March 29, 2024 20:30
@hawkw
Copy link
Member Author

hawkw commented Mar 29, 2024

Build failure is because I haven't actually updated app.tomls for most targets yet, which...I could do, but would like to know if this works first.

@hawkw hawkw force-pushed the eliza/make-rot-irq-real branch from c29e5ef to 5694463 Compare April 4, 2024 16:49
@hawkw hawkw force-pushed the eliza/make-rot-irq-real branch from 5694463 to edab604 Compare April 4, 2024 16:56
@hawkw hawkw marked this pull request as ready for review April 4, 2024 20:09
@hawkw hawkw requested review from cbiffle and lzrd April 4, 2024 20:09
@hawkw hawkw enabled auto-merge (squash) April 4, 2024 21:03
drv/stm32h7-sprot-server/src/main.rs Outdated Show resolved Hide resolved
drv/stm32h7-sprot-server/src/main.rs Outdated Show resolved Hide resolved
@hawkw hawkw requested a review from lzrd April 5, 2024 21:20
@hawkw
Copy link
Member Author

hawkw commented Apr 5, 2024

@lzrd Okay, I've addressed all the review suggestions, going to re-run the e2e tests to make sure I didn't break anything.

Also, #1734 adds codegen which will allow us to replace the hard-coded pin sets with the pin sets defined in the IRQ config. Depending on which PR merges first, I'll either update this branch to use that, or that branch to change this code.

@hawkw hawkw merged commit 4a0ebad into master Apr 5, 2024
103 checks passed
hawkw added a commit that referenced this pull request Apr 7, 2024
In PR #1696, I broke the `drv-stm32h7-sprot-server` code for waiting for
`ROT_IRQ` to change state. The `ROT_IRQ` signal is active low (and in
the schematic it's called `ROT_TO_SP_IRQ_L`), but in the code, the pin
is just referred to as `ROT_IRQ`, so I configured edge sensitivity
backwards, meaning we missed the IRQ signal. Oops, my bad.

This commit changes the edge sensitivity to wait for the falling edge
when waiting for `ROT_IRQ` to be asserted, and to wait for the rising
edge when waiting for it to be deasserted, instead of the other way
around. Now, it actually works correctly.

```console
eliza@lurch ~ $ pfexec humility -t psc-sp flash && faux-mgs --interface axf1 --discovery-addr [fe80::aa40:25ff:fe06:103%3]:11111 state
humility: attaching with chip set to "STM32H753ZITx"
humility: attached to 0483:374e:0037001B5553500720393256 via ST-Link V3
humility: flash/archive mismatch; reflashing
humility: flashing done
Apr 07 18:07:31.725 INFO creating SP handle on interface axf1, component: faux-mgs
Apr 07 18:07:33.727 INFO initial discovery complete, addr: [fe80::aa40:25ff:fe06:103%3]:11111, interface: axf1, component: faux-mgs
Apr 07 18:07:33.733 INFO V2(SpStateV2 { hubris_archive_id: [53, 140, 208, 151, 27, 45, 232, 176], serial_number: [66, 82, 77, 52, 53, 50, 50, 48, 48, 48, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], model: [57, 49, 51, 45, 48, 48, 48, 48, 48, 48, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], revision: 8, base_mac_address: [168, 64, 37, 6, 1, 2], power_state: A2, rot: Ok(RotStateV2 { active: A, persistent_boot_preference: A, pending_persistent_boot_preference: None, transient_boot_preference: None, slot_a_sha3_256_digest: Some([175, 36, 236, 22, 163, 153, 65, 80, 159, 252, 36, 30, 77, 25, 52, 93, 158, 50, 246, 178, 139, 62, 218, 107, 9, 29, 129, 29, 100, 174, 133, 25]), slot_b_sha3_256_digest: Some([139, 130, 30, 66, 20, 39, 59, 105, 242, 21, 10, 7, 147, 124, 64, 253, 57, 156, 212, 176, 189, 255, 59, 243, 172, 9, 204, 75, 221, 250, 208, 53]) }) }), component: faux-mgs
hubris archive: 358cd0971b2de8b0
serial number: BRM45220003
model: 913-0000003
revision: 8
base MAC address: a8:40:25:06:01:02
power state: A2
RotStateV2 {
 active: A,
 persistent_boot_preference: A,
 pending_persistent_boot_preference: None,
 transient_boot_preference: None
 slot_a_sha3_256_digest: af24ec16a39941509ffc241e4d19345d9e32f6b28b3eda6b091d811d64ae8519,
 slot_b_sha3_256_digest: 8b821e4214273b69f2150a07937c40fd399cd4b0bdff3bf3ac09cc4bddfad035,
}
eliza@lurch ~ $ pfexec humility -t psc-sp ringbuf sprot_server
humility: attached to 0483:374e:0037001B5553500720393256 via ST-Link V3
humility: ring buffer drv_stm32h7_sprot_server::__RINGBUF in sprot:
 NDX LINE      GEN    COUNT PAYLOAD
   0  243        1        1 Sent(0xa)
   1  365        1        1 WaitRotIrq(true, 0x5)
   2  285        1        1 Received(0x51)
eliza@lurch ~ $
```
hawkw added a commit that referenced this pull request Apr 7, 2024
In PR #1696, I broke the `drv-stm32h7-sprot-server` code for waiting for
`ROT_IRQ` to change state. The `ROT_IRQ` signal is active low (and in
the schematic it's called `ROT_TO_SP_IRQ_L`), but in the code, the pin
is just referred to as `ROT_IRQ`, so I configured edge sensitivity
backwards, meaning we missed the IRQ signal. Oops, my bad.

This commit changes the edge sensitivity to wait for the falling edge
when waiting for `ROT_IRQ` to be asserted, and to wait for the rising
edge when waiting for it to be deasserted, instead of the other way
around. Now, it actually works correctly.

```console
eliza@lurch ~ $ pfexec humility -t psc-sp flash && faux-mgs --interface axf1 --discovery-addr [fe80::aa40:25ff:fe06:103%3]:11111 state
humility: attaching with chip set to "STM32H753ZITx"
humility: attached to 0483:374e:0037001B5553500720393256 via ST-Link V3
humility: flash/archive mismatch; reflashing
humility: flashing done
Apr 07 18:07:31.725 INFO creating SP handle on interface axf1, component: faux-mgs
Apr 07 18:07:33.727 INFO initial discovery complete, addr: [fe80::aa40:25ff:fe06:103%3]:11111, interface: axf1, component: faux-mgs
Apr 07 18:07:33.733 INFO V2(SpStateV2 { hubris_archive_id: [53, 140, 208, 151, 27, 45, 232, 176], serial_number: [66, 82, 77, 52, 53, 50, 50, 48, 48, 48, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], model: [57, 49, 51, 45, 48, 48, 48, 48, 48, 48, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], revision: 8, base_mac_address: [168, 64, 37, 6, 1, 2], power_state: A2, rot: Ok(RotStateV2 { active: A, persistent_boot_preference: A, pending_persistent_boot_preference: None, transient_boot_preference: None, slot_a_sha3_256_digest: Some([175, 36, 236, 22, 163, 153, 65, 80, 159, 252, 36, 30, 77, 25, 52, 93, 158, 50, 246, 178, 139, 62, 218, 107, 9, 29, 129, 29, 100, 174, 133, 25]), slot_b_sha3_256_digest: Some([139, 130, 30, 66, 20, 39, 59, 105, 242, 21, 10, 7, 147, 124, 64, 253, 57, 156, 212, 176, 189, 255, 59, 243, 172, 9, 204, 75, 221, 250, 208, 53]) }) }), component: faux-mgs
hubris archive: 358cd0971b2de8b0
serial number: BRM45220003
model: 913-0000003
revision: 8
base MAC address: a8:40:25:06:01:02
power state: A2
RotStateV2 {
 active: A,
 persistent_boot_preference: A,
 pending_persistent_boot_preference: None,
 transient_boot_preference: None
 slot_a_sha3_256_digest: af24ec16a39941509ffc241e4d19345d9e32f6b28b3eda6b091d811d64ae8519,
 slot_b_sha3_256_digest: 8b821e4214273b69f2150a07937c40fd399cd4b0bdff3bf3ac09cc4bddfad035,
}
eliza@lurch ~ $ pfexec humility -t psc-sp ringbuf sprot_server
humility: attached to 0483:374e:0037001B5553500720393256 via ST-Link V3
humility: ring buffer drv_stm32h7_sprot_server::__RINGBUF in sprot:
 NDX LINE      GEN    COUNT PAYLOAD
   0  243        1        1 Sent(0xa)
   1  365        1        1 WaitRotIrq(true, 0x5)
   2  285        1        1 Received(0x51)
eliza@lurch ~ $
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants