Skip to content

Conscript TIM5 for early boot#2571

Open
jamesmunns wants to merge 11 commits into
masterfrom
james/tim5-boot
Open

Conscript TIM5 for early boot#2571
jamesmunns wants to merge 11 commits into
masterfrom
james/tim5-boot

Conversation

@jamesmunns

Copy link
Copy Markdown
Contributor

This change implements a very simple hardware timer using the 32-bit TIM5.

I'm open to better ideas of how to test this, but using the HUBRIS_MEASUREMENT_RESULT as a signal:

# Current `master`, measured on a grapefruit
$ humility -d ./hubris.core.0 readvar HUBRIS_MEASUREMENT_RESULT
humility: attached to dump
HUBRIS_MEASUREMENT_RESULT (0x24000404) = Some(Valid {
        count: Some(0x7)
    })

# This change, as-is (20x200ms delays)
$ humility -d ./hubris.core.1 readvar HUBRIS_MEASUREMENT_RESULT
humility: attached to dump
HUBRIS_MEASUREMENT_RESULT (0x24000404) = Some(Valid {
        count: Some(0xd)
    })

# This change, but with `DELAY_MICROS` set to `1_000 * 1_000`, or 20x1s delays
$ humility -d ./hubris.core.2 readvar HUBRIS_MEASUREMENT_RESULT
humility: attached to dump
HUBRIS_MEASUREMENT_RESULT (0x24000404) = Some(Valid {
        count: Some(0x3)
    })

This PR is intended as a lay-up to #2506, though for that future use we would need to:

  1. Re-configure and re-enable the timer for the increased APB1L frequency (100MHz, instead of 64MHz)
  2. Implement a "get current rolling time" free function, provide that to the kernel
  3. Find a way to tell the kernel the range and frequency of the rolling timer (e.g. 32-bit, 1MHz)
  4. Implement the embassy-time "rolling timer extension" algorithm described in Consider requiring a higher resolution platform-specific timer #2506
  5. (optional) add a "get micros since boot -> u64" syscall for use in userspace

Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs
Comment thread drv/stm32h7-startup/src/lib.rs Outdated

@labbott labbott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll confess to initially being skeptical of using timers but this looks really nice. I'll take a closer look later this week.

Comment thread drv/stm32h7-startup/src/lib.rs
Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs Outdated

@labbott labbott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to do at least one boot/check on a gimlet for the revision strap pins since debugging that was awful.

Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs Outdated
Comment thread drv/stm32h7-startup/src/lib.rs Outdated
@jamesmunns

Copy link
Copy Markdown
Contributor Author

It would be good to do at least one boot/check on a gimlet for the revision strap pins since debugging that was awful.

I've now tested this on:

  • gimlet-d
  • sidecar-b
  • psc-c

Using both power-off resets (using niles' power control), and with soft resets (humility reset). I wasn't able to test a minibar, but it seems to use the same delay timing as sidecar.

Let me know if you'd like me to chase down a minibar as well, or if this is close enough for comfort. Either way, I might hack together a test on Monday to toggle a pin using the timer and watch it with a saleae, just to make sure that it really is ticking at 64MHz as I expect.

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.

3 participants