aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 1f05befaae62ad3dd4091d5765d5be8b47e6f75f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
This repository contains [flash programming algorithms][fpa] for i.MX RT MCUs.
The algorithms are designed for use in [probe-rs]. They're written in Rust and
support a variety of MCUs and flash parts.

These flash programming algorithms compete with NXP's flash programming
algorithms, which are distributed in device family packs (DFPs). NXP's
algorithms also work with probe-rs, so prefer those if you want something
official.

I've found these algorithms can program flash 2x to 3x faster than NXP's
offerings. These algorithms definitely support page crossings; meaning, if the
debug probe wants to program 4KiB into flash, the algorithm will automatically
chunk it into pages of 256 bytes. This trick reduces I/O overhead between host
and debug probe. (Admittedly, NXP's algorithms might support this, but I never
tried. It's fun writing these algorithms!)

Supported boards include

- IMXRT1010EVK
- IMXRT1040EVK
- IMXRT1160EVK
- IMXRT1170EVK

You'll find the algorithms in their respective top-level directories. These
four boards sport four different MCUs, which you'll also find in the top-level
directories. Furthermore, those four boards have three different flash parts;
the flash part implementation is in `src/` as part of the core package.

Before attempting to generate the flash programming algorithms for [probe-rs],
install the `target-gen` tool. It's available in the probe-rs repository. [My
fork][probe-rs-fork] has some `target-gen` patches that might be useful.

Use `target-gen test` to test each algorithm on its EVK. For convenience,
there are dedicated Cargo configurations you can use. For example, to test the
algorithm on a 1010EVK, run

```
cargo --config .cargo/1010evk.toml run --release --package=imxrt1010evk
```

To test on a different EVK, change the Cargo configuration and the package.

Here's how to generate the algorithm, represented as YAML, for the 1010EVK:

```
cargo --config .cargo/flash_algo.toml run --release --package=imxrt1010evk
```

To generate the algorithm for a different EVK, change the `--package` selection.

[fpa]: https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/flashAlgorithm.html
[probe-rs]: https://probe.rs
[probe-rs-fork]: https://github.com/mciantyre/probe-rs

Eventually, I might try to define a universal flash programming algorithm,
one that works across different flash parts. But for now, they're separate by
manufacturer.

FlexSPI pin muxing assumes you're using the boot ROM's primary FlexSPI1
interface. In fact, all algorithms assume you're using FlexSPI1! If your board
is doing something different, then you'll need to manually change the pin muxing
/ FlexSPI instance. There's no board-by-board configuration.

License: APACHE-2.0