A library for generating an iMXRT106X Firmware Configuration Block (FCB)
from Rust. Intended to be used in build.rs
build scripts to generate
FCBs for iMXRT106x-based systems.
Rationale
The iMXRT106x Firmware Configuration Block (FCB) is an array that describes how the processor should initiate a boot. It's expected to be placed in a certain region of FLASH, with values that describe how a peripheral should interact with NAND- / NOR-based FLASH memory. The FCB has a lot of magic numbers, and it would be nice to have an API to generate the FCB.
The imxrt1062-fcb-gen
crate provides an API for generating the FCB. As of this
writing, it supports only the generation of an FCB for reading NOR Flash via
FlexSPI. Other configurations, such as NAND Flash and / or the SEMC interface,
may be added later.
Usage
Add imxrt1062-fcb-gen
to your build dependencies:
[]
= { = "../imxrt1062-fcb-gen" }
Then, instantiate a Builder
in your build.rs
build script. Unless a
member of the Builder
implements Default
, it's probably required and
it requires your input. See the iMXRT1062
reference manual for details
that may be missing from this library.
Once the builder is built, write the FCB instance from your build script, and
include it using the include!
macro in your crate. See the teensy4-fcb
crate for an example.
ABI
The output is a single u8
array, called FIRMWARE_CONFIGURATION_BLOCK
.
The name is not mangled. It may be referenced in a linker script by its section, ".fcb"
.
Examples
The example below demonstrates how we might define the FCB for a Teensy 4.
use *;
// We're using serial NOR flash.
let nor_cb = ConfigurationBlock ;
// Load the lookup table with our magic numbers. Numbers
// that are not specifed are set to `0`.
let lookup_table = ;
// Define the FCB
let builder = Builder ;
// Build the FCB
let fcb = builder.build.unwrap;
// Write it to a string. It could also be written to
// a file, or to an `std::io::Writer`.
let fcb_string = format!;
// The string will resemble something like the following...
//
// #[link_section = ".fcb"]
// #[no_mangle]
// pub static FIRMWARE_CONFIGURATION_BLOCK: [u8; 512] = [
// 0x46, // 0x000 Tag 'FCFB'
// 0x43, // 0x001
// 0x46, // 0x002
// 0x42, // 0x003
// 0x00, // 0x004 Version 'bugfix'
// 0x00, // 0x005 Version 'minor'
// 0x01, // 0x006 Version 'major
// 0x56, // 0x007 Version 'V'
// 0x00, // 0x008 RESERVED
// 0x00, // 0x009 RESERVED
// 0x00, // 0x00A RESERVED
// 0x00, // 0x00B RESERVED
// 0x01, // 0x00C readSampleClkSrc
// 0x01, // 0x00D csHoldTime
// 0x02, // 0x00E csSetupTime
// 0x00, // 0x00F columnAddressWidth
// 0x00, // 0x010 deviceModeCfgEnable
// 0x00, // 0x011 RESERVED
// 0x00, // 0x012
// 0x00, // 0x013 waitTimeCfgCommands
// 0x00, // 0x014 deviceModeSeq
// // Rest elided for clarity...
// ];