Skip to content

Commit f0c8515

Browse files
committed
Remove all features; select chip with an enum
We used mutually-exclusive chip features to change the values of certain enums at build time. However, const evaluation also lets us express those differences, as long as we know the target chip. This breaking change removes all features. APIs that need to know the target chip now require an Imxrt variant in their const fn. I used the existing tests to inform the refactor, so all those tests should be unchanged.
1 parent 3bdd818 commit f0c8515

File tree

28 files changed

+507
-429
lines changed

28 files changed

+507
-429
lines changed

.github/workflows/rust.yml

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,25 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
strategy:
8-
matrix:
9-
feature: ["imxrt1010", "imxrt1020", "imxrt1040", "imxrt1050", "imxrt1060", "imxrt1064", "imxrt1160", "imxrt1170", "imxrt1180"]
10-
117
runs-on: ubuntu-latest
128

139
steps:
1410
- uses: actions/checkout@v4
15-
- run: rustup toolchain install stable --no-self-update --profile minimal
16-
- name: Build (${{ matrix.feature }})
17-
run: cargo build --package=imxrt-boot-gen --features=${{ matrix.feature }}
18-
- name: Run tests (${{ matrix.feature }})
19-
run: cargo test --package=imxrt-boot-gen --features=${{ matrix.feature }}
11+
- run: rustup toolchain install stable --no-self-update --profile minimal --target thumbv7em-none-eabihf
12+
- name: Build everything for the host
13+
run: cargo build --workspace
14+
- name: Run all tests on the host
15+
run: cargo test --workspace
16+
- name: Build everything for some embedded target
17+
run: cargo build --workspace --target=thumbv7em-none-eabihf
2018

2119
clippy:
22-
strategy:
23-
matrix:
24-
feature: ["imxrt1010", "imxrt1020", "imxrt1040", "imxrt1050", "imxrt1060", "imxrt1160", "imxrt1170", "imxrt1180"]
25-
2620
runs-on: ubuntu-latest
2721

2822
steps:
2923
- uses: actions/checkout@v4
30-
- run: rustup toolchain install stable --no-self-update --profile minimal --component clippy
31-
- run: cargo clippy --package=imxrt-boot-gen --features=${{ matrix.feature }} -- -D warnings
24+
- run: rustup toolchain install stable --no-self-update --profile minimal --component clippy --target thumbv7em-none-eabihf
25+
- run: cargo clippy --workspace --target=thumbv7em-none-eabihf -- -D warnings
3226

3327
format:
3428
runs-on: ubuntu-latest
@@ -37,18 +31,3 @@ jobs:
3731
- run: rustup toolchain install stable --no-self-update --profile minimal --component rustfmt
3832
- name: Run cargo fmt
3933
run: cargo fmt --all -- --check
40-
41-
fcbs:
42-
strategy:
43-
matrix:
44-
fcb: ["imxrt1010evk-fcb", "imxrt1060evk-fcb", "imxrt1170evk-fcb", "imxrt1180evk-fcb", "vmu-rt1170-fcb"]
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: actions/checkout@v4
48-
- run: rustup toolchain install stable --no-self-update --profile minimal --target thumbv7em-none-eabihf --component clippy
49-
- name: Build for an embedded target
50-
run: cargo build --package=${{ matrix.fcb }} --verbose --target=thumbv7em-none-eabihf
51-
- name: Build and run tests on the host
52-
run: cargo test --package=${{ matrix.fcb }} --verbose
53-
- name: Lint the package
54-
run: cargo clippy --package=${{ matrix.fcb }} --target=thumbv7em-none-eabihf -- -D warnings

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ packages maintained within this repository.
77

88
**BREAKING** All packages use the Rust 2024 edition.
99

10+
**BREAKING** Remove all feature flags. The compile time API now relies
11+
on enums to describe chips. Invalid configurations produce a compile-time
12+
panic.
13+
14+
If you were using this package with a 1064 MCU, then you may continue
15+
using the package as if it were a 1060 MCU variant.
16+
1017
## [0.3.4] 2025-03-01
1118

1219
Add support for new MCUS:

Cargo.toml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,7 @@ keywords = [
2727
"nxp",
2828
]
2929

30-
[features]
31-
imxrt1010 = []
32-
imxrt1020 = []
33-
imxrt1040 = []
34-
imxrt1050 = []
35-
imxrt1060 = []
36-
imxrt1064 = []
37-
imxrt1160 = []
38-
imxrt1170 = []
39-
imxrt1180 = []
40-
4130
[package.metadata.docs.rs]
42-
features = ["imxrt1060"]
4331
default-target = "thumbv7em-none-eabihf"
4432

4533
[workspace]

build.rs

Lines changed: 0 additions & 39 deletions
This file was deleted.

fcbs/imxrt1010evk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ description = "FlexSPI configuration block for NXP's IMXRT1010EVK"
1111
[dependencies.imxrt-boot-gen]
1212
version = "0.4.0"
1313
path = "../.."
14-
features = ["imxrt1010"]
1514

1615
[lib]
1716
path = "lib.rs"

fcbs/imxrt1010evk/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
pub use nor::ConfigurationBlock;
88

9+
use imxrt_boot_gen::Imxrt;
910
use imxrt_boot_gen::flexspi::{self, opcodes::sdr::*, *};
1011
use imxrt_boot_gen::serial_flash::*;
1112

13+
const CHIP: Imxrt = Imxrt::Imxrt1010;
14+
1215
const DENSITY_BITS: u32 = 128 * 1024 * 1024;
1316
const DENSITY_BYTES: u32 = DENSITY_BITS / 8;
1417

@@ -55,14 +58,16 @@ const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock =
5558
.device_mode_configuration(DeviceModeConfiguration::Disabled)
5659
.wait_time_cfg_commands(WaitTimeConfigurationCommands::disable())
5760
.flash_size(SerialFlashRegion::A1, DENSITY_BYTES)
58-
.serial_clk_freq(SerialClockFrequency::MHz120)
61+
.serial_clk_freq(CHIP.serial_clock_frequency(SerialClockOption::MHz120))
5962
.serial_flash_pad_type(FlashPadType::Quad);
6063

6164
pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
62-
nor::ConfigurationBlock::new(COMMON_CONFIGURATION_BLOCK)
65+
nor::ConfigurationBlock::new(CHIP, COMMON_CONFIGURATION_BLOCK)
6366
.page_size(256)
6467
.sector_size(4096)
65-
.ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30);
68+
.ip_cmd_serial_clk_freq(Some(
69+
CHIP.ip_serial_clock_frequency(SerialClockOption::MHz30),
70+
));
6671

6772
#[unsafe(no_mangle)]
6873
#[cfg_attr(

fcbs/imxrt1060evk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ description = "FlexSPI configuration block for NXP's IMXRT1060EVK"
1111
[dependencies.imxrt-boot-gen]
1212
version = "0.4.0"
1313
path = "../.."
14-
features = ["imxrt1060"]
1514

1615
[lib]
1716
path = "lib.rs"

fcbs/imxrt1060evk/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
pub use nor::ConfigurationBlock;
88

9+
use imxrt_boot_gen::Imxrt;
910
use imxrt_boot_gen::flexspi::{self, opcodes::sdr::*, *};
10-
use imxrt_boot_gen::flexspi::{
11-
FlashPadType, ReadSampleClockSource, SerialClockFrequency, SerialFlashRegion,
12-
};
11+
use imxrt_boot_gen::flexspi::{FlashPadType, ReadSampleClockSource, SerialFlashRegion};
1312
use imxrt_boot_gen::serial_flash::*;
1413

14+
const CHIP: Imxrt = Imxrt::Imxrt1060;
15+
1516
const SEQ_READ: Sequence = SequenceBuilder::new()
1617
.instr(Instr::new(CMD, Pads::One, 0xEB))
1718
.instr(Instr::new(RADDR, Pads::Four, 0x18))
@@ -54,14 +55,16 @@ const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock =
5455
.cs_setup_time(3)
5556
.controller_misc_options(0x10)
5657
.serial_flash_pad_type(FlashPadType::Quad)
57-
.serial_clk_freq(SerialClockFrequency::MHz133)
58+
.serial_clk_freq(CHIP.serial_clock_frequency(SerialClockOption::MHz133))
5859
.flash_size(SerialFlashRegion::A1, 8 * 1024 * 1024);
5960

6061
pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
61-
nor::ConfigurationBlock::new(COMMON_CONFIGURATION_BLOCK)
62+
nor::ConfigurationBlock::new(CHIP, COMMON_CONFIGURATION_BLOCK)
6263
.page_size(256)
6364
.sector_size(4096)
64-
.ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30);
65+
.ip_cmd_serial_clk_freq(Some(
66+
CHIP.ip_serial_clock_frequency(SerialClockOption::MHz30),
67+
));
6568

6669
#[unsafe(no_mangle)]
6770
#[cfg_attr(

fcbs/imxrt1170evk/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ description = "FlexSPI configuration block for NXP's IMXRT1170EVK"
1111
[dependencies.imxrt-boot-gen]
1212
version = "0.4.0"
1313
path = "../.."
14-
features = ["imxrt1170"]
1514

1615
[lib]
1716
path = "lib.rs"

fcbs/imxrt1170evk/lib.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
pub use nor::ConfigurationBlock;
88

9+
use imxrt_boot_gen::Imxrt;
910
use imxrt_boot_gen::flexspi::{self, opcodes::sdr::*, *};
10-
use imxrt_boot_gen::flexspi::{
11-
FlashPadType, ReadSampleClockSource, SerialClockFrequency, SerialFlashRegion,
12-
};
11+
use imxrt_boot_gen::flexspi::{FlashPadType, ReadSampleClockSource, SerialFlashRegion};
1312
use imxrt_boot_gen::serial_flash::*;
1413

14+
const CHIP: Imxrt = Imxrt::Imxrt1170;
15+
1516
const SEQ_READ: Sequence = SequenceBuilder::new()
1617
.instr(Instr::new(CMD, Pads::One, 0xEB))
1718
.instr(Instr::new(RADDR, Pads::Four, 0x18))
@@ -54,15 +55,19 @@ const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock =
5455
.cs_setup_time(3)
5556
.controller_misc_options(0x10)
5657
.serial_flash_pad_type(FlashPadType::Quad)
57-
.serial_clk_freq(SerialClockFrequency::MHz133)
58+
.serial_clk_freq(CHIP.serial_clock_frequency(SerialClockOption::MHz133))
5859
.flash_size(SerialFlashRegion::A1, 16 * 1024 * 1024);
5960

60-
pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
61-
nor::ConfigurationBlock::new(COMMON_CONFIGURATION_BLOCK)
61+
pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock = {
62+
let mut cb = nor::ConfigurationBlock::new(CHIP, COMMON_CONFIGURATION_BLOCK)
6263
.page_size(256)
6364
.sector_size(4 * 1024)
64-
.ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30)
65-
.block_size(64 * 1024);
65+
.ip_cmd_serial_clk_freq(Some(
66+
CHIP.ip_serial_clock_frequency(SerialClockOption::MHz30),
67+
));
68+
cb.extras(CHIP).unwrap().block_size(64 * 1024);
69+
cb
70+
};
6671

6772
#[unsafe(no_mangle)]
6873
#[cfg_attr(

0 commit comments

Comments
 (0)