Skip to content

[imxrt1050-evkb] Fix GPIO interrupts#2786

Merged
bors[bot] merged 1 commit into
tock:masterfrom
WyliodrinEmbeddedIoT:imxrt1052-evkb-fix
Aug 19, 2021
Merged

[imxrt1050-evkb] Fix GPIO interrupts#2786
bors[bot] merged 1 commit into
tock:masterfrom
WyliodrinEmbeddedIoT:imxrt1052-evkb-fix

Conversation

@valexandru

@valexandru valexandru commented Aug 17, 2021

Copy link
Copy Markdown
Contributor

Pull Request Overview

This pull request fixes gpio interrupts on the i.MX RT 1052 EVKB.

While I was testing the buttons example on the i.MX RT 1052 EVKB, I discovered that the interrupts are not enabled by default. However, if I set up a delay of 1000 ms so that a different interrupt is triggered before the gpio one, the gpio interrupts will work. Therefore, in order to prevent this, we have to specifically enable the interrupt in the nvic.

This seems to be a bug in the i.MX RT 1052 EVKB board and requires to manually enable the interrupts in the nvic.

Testing Strategy

This pull request was tested using an iMX. RT 1052 EVKB board.

TODO or Help Wanted

This pull request needs feedback.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

@valexandru valexandru mentioned this pull request Aug 17, 2021
23 tasks
hudson-ayers
hudson-ayers previously approved these changes Aug 17, 2021
bradjc
bradjc previously requested changes Aug 17, 2021

@bradjc bradjc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems bad. Why are the nvic interrupts not all enabled by default? Particularly why does the chip init look like:

pub unsafe fn init() {
cortexm7::nvic::disable_all();
cortexm7::nvic::clear_all_pending();
cortexm7::scb::set_vector_table_offset(
&BASE_VECTORS as *const [unsafe extern "C" fn(); 16] as *const (),
);
}

which does not enable all interrupts? Compare to the sam4l chip init:

pub unsafe fn init() {
cortexm4::nvic::disable_all();
cortexm4::nvic::clear_all_pending();
cortexm4::nvic::enable_all();
}

Tock assumes all interrupts are enabled at the interrupt controller level, and relies on individual peripherals to disable interrupts on a per-peripheral basis. That avoids all issues like this. Did we need to special case this chip for some reason?

@alexandruradovici

alexandruradovici commented Aug 19, 2021

Copy link
Copy Markdown
Contributor

I reversed the changes and enabled all interrupts. Please @valexandru test the gpio interrupt.

@valexandru

Copy link
Copy Markdown
Contributor Author

Yes, it works now, after enabling the interrupts in lib.rs. Thank you @alexandruradovici for making the changes while I was away.

@hudson-ayers hudson-ayers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bors r+

@bors

bors Bot commented Aug 19, 2021

Copy link
Copy Markdown
Contributor

This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried.

Additional information:

{"message":"1 review requesting changes and 1 approving review by reviewers with write access.","documentation_url":"https://docs.github.com/articles/about-protected-branches"}

@hudson-ayers

Copy link
Copy Markdown
Contributor

bors r+

@bors

bors Bot commented Aug 19, 2021

Copy link
Copy Markdown
Contributor

@bors bors Bot merged commit 7ceffd7 into tock:master Aug 19, 2021
sirchnik pushed a commit to sirchnik/tock that referenced this pull request May 12, 2026
2786: [imxrt1050-evkb] Fix GPIO interrupts r=hudson-ayers a=valexandru

### Pull Request Overview

This pull request fixes gpio interrupts on the i.MX RT 1052 EVKB.

While I was testing the buttons example on the i.MX RT 1052 EVKB, I discovered that the interrupts are not enabled by default. However, if I set up a delay of 1000 ms so that a different interrupt is triggered before the gpio one, the gpio interrupts will work. Therefore, in order to prevent this, we have to specifically enable the interrupt in the nvic. 

This seems to be a bug in the i.MX RT 1052 EVKB board and requires to manually enable the interrupts in the nvic.

### Testing Strategy

This pull request was tested using an iMX. RT 1052 EVKB board.


### TODO or Help Wanted

This pull request needs feedback.


### Documentation Updated

- [x] Updated the relevant files in `/docs`, or no updates are required.

### Formatting

- [x] Ran `make prepush`.


Co-authored-by: Alexandru Radovici <msg4alex@gmail.com>
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.

4 participants