aboutsummaryrefslogtreecommitdiff
path: root/examples/mimxrt1011/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mimxrt1011/src/lib.rs')
-rw-r--r--examples/mimxrt1011/src/lib.rs75
1 files changed, 75 insertions, 0 deletions
diff --git a/examples/mimxrt1011/src/lib.rs b/examples/mimxrt1011/src/lib.rs
new file mode 100644
index 000000000..f0391ef57
--- /dev/null
+++ b/examples/mimxrt1011/src/lib.rs
@@ -0,0 +1,75 @@
1//! FlexSPI configuration block (FCB) for iMXRT1011 boards.
2//!
3//! This is a generic FCB that should work with most QSPI flash.
4
5#![no_std]
6
7use imxrt_boot_gen::flexspi;
8use imxrt_boot_gen::flexspi::opcodes::sdr::*;
9use imxrt_boot_gen::flexspi::{
10 ColumnAddressWidth, Command, DeviceModeConfiguration, FlashPadType, Instr, LookupTable, Pads,
11 ReadSampleClockSource, Sequence, SequenceBuilder, SerialClockFrequency, SerialFlashRegion,
12 WaitTimeConfigurationCommands,
13};
14use imxrt_boot_gen::serial_flash::nor;
15
16/// While the IMXRT1010-EVK and Makerdiary iMX RT1011 Nano Kit have 128MBit of flash we limit to 64Mbit
17/// to allow the Metro M7 boards to use the same FCB configuration.
18const DENSITY_BITS: u32 = 64 * 1024 * 1024;
19const DENSITY_BYTES: u32 = DENSITY_BITS / 8;
20
21const SEQ_READ: Sequence = SequenceBuilder::new()
22 .instr(Instr::new(CMD, Pads::One, 0xEB))
23 .instr(Instr::new(RADDR, Pads::Four, 0x18))
24 .instr(Instr::new(DUMMY, Pads::Four, 0x06))
25 .instr(Instr::new(READ, Pads::Four, 0x04))
26 .build();
27
28const SEQ_READ_STATUS: Sequence = SequenceBuilder::new()
29 .instr(Instr::new(CMD, Pads::One, 0x05))
30 .instr(Instr::new(READ, Pads::One, 0x01))
31 .build();
32
33const SEQ_WRITE_ENABLE: Sequence = SequenceBuilder::new().instr(Instr::new(CMD, Pads::One, 0x06)).build();
34
35const SEQ_ERASE_SECTOR: Sequence = SequenceBuilder::new()
36 .instr(Instr::new(CMD, Pads::One, 0x20))
37 .instr(Instr::new(RADDR, Pads::One, 0x18))
38 .build();
39
40const SEQ_PAGE_PROGRAM: Sequence = SequenceBuilder::new()
41 .instr(Instr::new(CMD, Pads::One, 0x02))
42 .instr(Instr::new(RADDR, Pads::One, 0x18))
43 .instr(Instr::new(WRITE, Pads::One, 0x04))
44 .build();
45
46const SEQ_CHIP_ERASE: Sequence = SequenceBuilder::new().instr(Instr::new(CMD, Pads::One, 0x60)).build();
47
48const LUT: LookupTable = LookupTable::new()
49 .command(Command::Read, SEQ_READ)
50 .command(Command::ReadStatus, SEQ_READ_STATUS)
51 .command(Command::WriteEnable, SEQ_WRITE_ENABLE)
52 .command(Command::EraseSector, SEQ_ERASE_SECTOR)
53 .command(Command::PageProgram, SEQ_PAGE_PROGRAM)
54 .command(Command::ChipErase, SEQ_CHIP_ERASE);
55
56const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock = flexspi::ConfigurationBlock::new(LUT)
57 .read_sample_clk_src(ReadSampleClockSource::LoopbackFromDQSPad)
58 .cs_hold_time(0x03)
59 .cs_setup_time(0x03)
60 .column_address_width(ColumnAddressWidth::OtherDevices)
61 .device_mode_configuration(DeviceModeConfiguration::Disabled)
62 .wait_time_cfg_commands(WaitTimeConfigurationCommands::disable())
63 .flash_size(SerialFlashRegion::A1, DENSITY_BYTES)
64 .serial_clk_freq(SerialClockFrequency::MHz120)
65 .serial_flash_pad_type(FlashPadType::Quad);
66
67pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
68 nor::ConfigurationBlock::new(COMMON_CONFIGURATION_BLOCK)
69 .page_size(256)
70 .sector_size(4096)
71 .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30);
72
73#[unsafe(no_mangle)]
74#[cfg_attr(all(target_arch = "arm", target_os = "none"), link_section = ".fcb")]
75pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK;