Skip to content

Unclear how to use #[interrupt] macro without deprecated --reexport-interrupt flag #830

Open

Description

@qwandor

According to the documentation of svd2rust, the --reexport-interrupt flag is deprecated. However according to the documentation of cortex-m-rt, the #[interrupt] macro should only be used via the svd2rust reexport, and indeed it fails to compile when used directly, with a confusing error.

How is the interrupt macro supposed to be used without the --reexport-interrupt flag passed to svd2rust? This should at least be documented clearly in the svd2rust documentation.

Activity

  1. burrbull commented on Mar 26, 2024

    @burrbull
    Member

    There have been planned some changes in cortex-m-rt 0.8 like moving interrupt in independent crate. But it is not done yet.
    Ask @adamgreig.

  2. robamu commented on Jun 25, 2024

    @robamu
    Contributor

    I also stumbled into the issue, wondering why I could not use the interrupt macro, and I had to rebuild with the --reexport-interrupt flag.

  3. royb3 commented on Aug 14, 2024

    @royb3

    You can use it without the flag. But you have to import your PAC's Interrupt enum as interrupt.

    use hal::pac::Interrupt as interrupt;
    use cortex_m_rt::interrupt;

    That's basically what the --reexport-interrupt flag does as well. Not sure if there's any value in doing this over using the deprecated flag for now.

  4. Bnyro commented on Apr 13, 2026

    @Bnyro

    To save any future reader time with debugging:

    If you are trying to use this with rtic and come across some linker errors regarding the interrupt vector table, e.g. link.x:49: symbol not found: DefaultHandler_:

    Make sure to include the import to use cortex_m_rt::interrupt;. I thought rtic would do that by itself, but apparently it doesn't.

    E.g., this would look like

    Details
    use your_pac as _;
    use cortex_m_rt::interrupt;
    

    #[rtic::app(
    device = your_pac,
    dispatchers = [UARTE0],
    )]
    mod app {}

    For reference, that's what --reexport-interrupt does:

    #[cfg(feature = "rt")]
    pub use self::Interrupt as interrupt;
    #[cfg(feature = "rt")]
    pub use cortex_m_rt::interrupt;

    Sorry if this looks obvious to most of you, but understanding this earlier would have probably saved me hours :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions