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

Fix System Pin Feature Gate #38

Merged

Conversation

martinmortsell
Copy link
Contributor

@martinmortsell martinmortsell commented Oct 7, 2022

This pull request addresses #37 .

Instead of allowing usage of system pins (which fails) without the reconfigurable-system-pins feature set, not having the feature set now removes the pins completely, and any peripheral that directly depend on them.

It would be nice to achieve compilation failures that are more descriptive than

error[E0609]: no field `pb4` on type `BankB`
  --> examples/blinky.rs:62:25
   | 
62 |         let pb4 = bankb.pb4.into_output(true);
   |                         ^^^ help: a field with a similar name exists: `pb0`

but I have no idea of how to achieve that.

CHANGELOG.md Outdated
@@ -19,6 +19,7 @@
### Fixed

- HAL build when targeting `sams70n19b`.
- reconfigurable-system-pins feature.
Copy link
Member

Choose a reason for hiding this comment

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

I suggest adding some details.

@@ -41,11 +41,13 @@ twi.write_read(0x0, &[0b1000_0000], &mut buffer).unwrap();
use crate::clocks::{Clock, Hertz, HostClock, PeripheralIdentifier};
use crate::ehal::blocking;
use crate::generics;
#[cfg(feature = "reconfigurable-system-pins")]
use crate::pac::TWIHS1;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this gated?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind. It's because the peripheral requires the system pins.

@@ -83,15 +83,17 @@ let _ = spi.read().unwrap();
pub use super::uart::{ChannelMode, ParityMode, UartConfiguration};
use crate::clocks::{Clock, Hertz, HostClock, Pck, Pck4, PeripheralIdentifier};
use crate::generics::{self, Token};
#[cfg(feature = "reconfigurable-system-pins")]
use crate::pac::USART1;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@tmplt
Copy link
Member

tmplt commented Oct 12, 2022

Looks logical from a cursory review. I'd double-check if we somehow break API here and lose any read-only features. Add some details to the CHANGELOG.md and see the commit history on how to format these; I'd like to keep them uniform. These changes can be squashed into a single commit.

Adding documentation that these peripherals are unavailable without the feature would also be good.

Twi and Usart Peripheral now both mention System Pins.
@martinmortsell martinmortsell mentioned this pull request Oct 13, 2022
@martinmortsell
Copy link
Contributor Author

Should the CI be updated to run both with and without the reconfigurable-system-pins feature?

@tmplt
Copy link
Member

tmplt commented Oct 13, 2022

Yes; a feature matrix may be applicable.

@michalfita
Copy link
Collaborator

@martinmortsell Please fix issues (merge back development shall help) and we can merge this and release 0.4.1.

@martinmortsell
Copy link
Contributor Author

My attempt to add a featrues matrix to the CI seems to have been unsuccesful, reattempting later.

@martinmortsell
Copy link
Contributor Author

CIFeatures
And there you have it.

@@ -12,7 +12,7 @@ jobs:
- id: boards
run: echo "::set-output name=board_matrix::$(ls ./boards --indicator-style=none | jq -ncR '[inputs]')"
- id: features
run: echo "::set-output name=feature_matrix::["reconfigurable-system-pins","usart-spi-host-without-select"]"
run: echo "::set-output name=feature_matrix::[\"reconfigurable-system-pins\",\"usart-spi-host-without-select\"]"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having the features hard coded like this isn't pretty, but I have no idea how to parse the actual list of features and not catch the internal-only features.

Copy link
Member

Choose a reason for hiding this comment

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

There is probably a better way to check different feature permutations (and maybe streamline the CI further), but we can delay that until we have more feature gates. Ideally they will be de-coupled, so we could just check with --all-features, but I don't know if we can separate the PACs from this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There a cargo extensions crate called cargo-hack that can do feature permutations.

Raised #42 about this.

Copy link
Member

@tmplt tmplt left a comment

Choose a reason for hiding this comment

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

Fixup the changelog and clean up the commit history and I'll approve. Thanks!

CHANGELOG.md Outdated
@@ -24,6 +24,8 @@
### Fixed

- HAL build when targeting `sams70n19b`.
- The special-on-reset pins `PB4/5/6/7/12` are now completely unavailable, if the `reconfigurable-system-pins` feature is not enabled.
- `Usart<Usart1>` and `Twi<TwiHS1>` are now only available if the `reconfigurable-system-pins` feature is enabled, as they cannot obtain a valid pin configuration without it.
Copy link
Member

Choose a reason for hiding this comment

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

Move these under Changed.

@@ -12,7 +12,7 @@ jobs:
- id: boards
run: echo "::set-output name=board_matrix::$(ls ./boards --indicator-style=none | jq -ncR '[inputs]')"
- id: features
run: echo "::set-output name=feature_matrix::["reconfigurable-system-pins","usart-spi-host-without-select"]"
run: echo "::set-output name=feature_matrix::[\"reconfigurable-system-pins\",\"usart-spi-host-without-select\"]"
Copy link
Member

Choose a reason for hiding this comment

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

There is probably a better way to check different feature permutations (and maybe streamline the CI further), but we can delay that until we have more feature gates. Ideally they will be de-coupled, so we could just check with --all-features, but I don't know if we can separate the PACs from this.

@michalfita
Copy link
Collaborator

@martinmortsell I can't push to this branch myself. You have to not only move the section to ## Changed but up to # Unreleased, as v0.4.0 has sailed already.

@tmplt
Copy link
Member

tmplt commented Oct 24, 2022

Changes LGTM. Squash into a single commit to keep the history tidy.

@martinmortsell
Copy link
Contributor Author

Changes LGTM. Squash into a single commit to keep the history tidy.

But is the squash not done as part of the merge?

@tmplt
Copy link
Member

tmplt commented Oct 24, 2022

But is the squash not done as part of the merge?

Yes, but I do not have merging rights, so I can only state my wishes.

@martinmortsell
Copy link
Contributor Author

Ok, fair.

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.

None yet

3 participants