| Age | Commit message (Collapse) | Author |
|
Haven't tested the included examples on hardware. It's just here so I
can define an inspect_elf test. Out of tree, there's a basic example
on an 1170EVK.
|
|
If the CPU speculates into the RAM we haven't initialized, we can fault
when the ECC controller reports bad data. Didn't have that problem when
blasting all of RAM...
We can use the linker to help us figure out the range of these unused
regions. If we don't need to zero anything, the host emits 0 for the
start and end, skipping the zeroing.
I'm also zeroing the 32 byte reservation at the start of ITCM, along
with any padding introduced before the vector table. With this in place,
the rip_through_ram firmware does not report any exceptions.
|
|
A little firmware that you can run on your 11xx with ECC RAM active.
If I'm doing the preloading correctly and considering speculative reads
into unused memory, this test should pass. Right now, it definitely does
not pass, since the __pre_init only (maybe) zeros the program sections.
|
|
Just a refactor inside board. Activate the "ram" feature to target a
RAM-only for your given bord. I'm adding the 1170EVK RAM support.
|
|
Blasting all of RAM with zeros would wipe ourselves away if we were
executing from RAM. It also wipes out the HAB event log, which seems to
reside in the boot ROM reservation.
We now zero individual memory regions. Similar to the copy loops,
we'll skip the loop if the VMA and LMA are equal. It looks silly to
zero things like bss when we know cortex-m's reset handler will do it;
but, the usual loop doesn't use the 64 bit writes we'd need to preload
ciphers in ITCM and OCRAM.
Tested RAM loading with probe-rs, using an 1170EVK w/ ECC RAM active.
|
|
8 byte alignment means we can perform per-section ECC RAM preloading,
usually requiring 64-bit accesses.
|
|
Build the package for both the host and target before publishing.
|
|
Testing shows that we must blow fuses in order to activate either ECC
engine. Once the fuse is blown, NXP's boot ROM will enable the ECC
engine. So by the time the reset handler is running, ECC may already
be enabled.
The 32-bit copy loops won't work for initializing ITCM and OCRAM.
Since these bus widths are 64-bit and the ECC is computed over 64
bits, these 32 bit accesses result in a read-modify-write (RMW) on the
underlying interface. If these RAM regions aren't already initialized,
we'll fail an ECC check; the read in RMW compares bogus RAM contents
against a bogus ECC. This seems to dramatically slow down
initialization, or stall it (I've seen the CPU spinning in the boot
ROM).
If we listen to NXP and use 64-bit writes to preload ECC-protected RAM
regions, the 32-bit copy loops will work as expected. Note that we can
still issue 64-bit accesses towards DTCM; they're scattered across the
two 32-bit interfaces. There's an NXP whitepaper [1] describing that.
Once TCM ECC is enabled, we need to tell the TCM interfaces to RMW
smaller accesses. Otherwise, we won't generate correct ciphers. We
also might need to retry operations if there was a correction by the
RAM controller. We can perform these with predicated instructions.
Tested on an 1010EVK, where I used the debugger to show the control
registers weren't touched; and tested on the 1170EVK, with the same
approach showing the expected set bits.
[1]: https://www.nxp.com/docs/en/white-paper/CORTEXM7WP.pdf
[2]: https://www.nxp.com/docs/en/application-note/AN13204.pdf
|
|
As of this commit, the RuntimeBuilder only limits the available OCRAM
if either ECC controller is enabled. It's misleading; however, it gives
users a chance to evaluate their firmware builds with the restricted
RAM regions. I'll add and test the controller setups in a later commit.
Existing tests still pass. New unit tests demonstrate the restricted
RAM behavior.
|
|
No change in behavior. Follows the approach shown by ITCM in a prior
commit. Unit tests still pass, and existing ELF tests show that we
still generate valid linker script.
|
|
Gives us baseline coverage before we start adding ECC and affecting
OCRAM allocations. The approach is hacky, but I'll refactor the test
in the next commit.
|
|
The boot ROM is allowed to use allocations of OCRAM as scratch space. If
you interact with the boot ROM -- using it to interact with FlexSPI, for
instance -- then you cannot also use these OCRAM regions. See the system
boot chapter in the reference manual for more info.
The boot ROM typically reserves the start of OCRAM. The size varies by
chip. This commit describes a new section, .bootrom_reservation, at the
start of OCRAM. Users are encouraged to place a MaybeUninit buffer
that's sized for your ROM's requirements.
If users don't place anything in this section, then the new directive is
a no-op. On the other hand, the section is defined before other RAM
regions, so that it takes precedence over other sections users might
want to place in OCRAM.
Tested using the runtime's test suite. I'm testing with the Teensy 4
binary, since the test suite can support features in this build. The
updated test suite shows that the linker will place the boot ROM
reservation before placing the stack, suggesting that we're respecting
section priority.
|
|
cortex-m-rt v0.7.3 and earlier didn't document support for custom linker
scripts. Without that, I figured we were relying on an implementation
detail, and a patch version bump could break dependents. Pinning the
version avoided that possibility.
Now that there's documented support for custom scripts, we can relax
that.
|
|
To form a secondary image, use in_flash to position it in flash, then
override the default setting that disables the boot header.
With proper configuration, NXP's boot ROM can load a backup image. This
commit reconfigures the 1170EVK board for the experiment.
|
|
Alternate PAC designs might describe the device file with a custom / chip
specific name. This change lets users specify which linker script they're
using.
|
|
The vector tables exported by imxrt-ral are smaller than the default
cortex-m-rt vector table. The tests fail once we enable the rt / device
features. With this change, we expect the MCU-dependent vector table sizes.
|
|
The layout, or assignment of FlexRAM banks to memory regions, is more
precise than the count. When a user specifies the count, we still apply
the same layout as we always have. But now, by default, we prefer the
fuse layout for users who have made no choice.
This commit supports RAM loading with probe-rs. After probe-rs resets
the MCU and uses the fuse FlexRAM layout, firmware can perfectly match
that layout without disrupting the data already copied into RAM by the
debugger.
|
|
|
|
Just a proof-of-concept. The new inspect_elf test seems to show that
we're building the correct image. We need another commit in order to
help the program run in FlexRAM.
|
|
Missed in the previous hexification commit.
|
|
|
|
Make it easier to write loops for other sections. Since the macro
expands to the same instructions that we previously had, we can show
that a binary is equivalent before and after this change. Let's use the
binaries generated in this test suite.
Before this change, run the bash script below. Re-run this script with
this change, and show that the hashes for the binaries are the same.
cargo clean
cargo test inspect_elf -- --include-ignored --exact imxrt1010evk imxrt1170evk_cm7 imxrt1170evk_cm7_nonboot teensy4 teensy4_fake_dcd 2> /dev/null 1>/dev/null
for test_binary in imxrt1010evk imxrt1170evk-cm7 imxrt1170evk-cm7-nonboot teensy4 __dcd;
do
cat target/${test_binary}/thumbv7em-none-eabihf/debug/examples/blink-rtic | sha256sum -;
done
|
|
Makes it a little easier for me to manually inspect binaries and figure
out their targets.
|
|
Local numbered labels won't appear in the ELF file. This makes debugging
a little easier.
|
|
Attach the version information in a symbol that's generated by the host.
Then, expect the same symbol exists in the embedded target. If the
linker can't resolve this, then the host and target should be
incompatible. I'm overloading the __imxrt_family symbol for this.
|
|
I'm considering this a breaking change. I'll try to introduce new
sections that rely on the user's `unsafe` keyword for linker placement.
Rust 2024 has different opinions on format, and clippy has new thoughts.
Let's adopt them.
|
|
The runtime previously allowed function placement at address 0 in ITCM.
However, if you ever formed a pointer to the function placed there, it
would look like a null pointer. And you would never be able to call that
function if you relied on null pointer optimization. Also, most MCU
reference manuals (RM) recommend against this placement.
This commit reduces the total capacity of ITCM by 32 bytes, the smallest
possible size of a MPU region. Note that this is greater than the RM's
recommendation of a four byte reservation. It affects all supported
MCUs, except the 1180. If you're so inclined, your MPU could disallow
loads, stores, and execution from this reservation.
Revised unit tests should cover this change. Additionally, you can
manually verify that the ITCM region lengths are reduced by 32 bytes by
opening the linker scripts generated by the ELF test suite.
|
|
No changes here; we're testing an existing behavior. The next commit
changes how this math works.
|
|
|
|
|
|
Applications linked through this builder can be placed in a flash
reservation. You'll need some other software to launch these programs,
since they lack the boot header required by the NXP boot ROM.
|
|
We added the `.xip` section to ensure that the reset handler and
pre-init functions would be placed in flash. This commit lets users
place other content into that section.
`.xip` is intended for instructions. The runtime builder will place
these instructions into the same load region as `.text`. However,
there's no pre-`main` relocation.
Aligning the `.xip` and the `.text` section produces more predictable
behavior between GNU's ld and LLVM's lld.
|
|
|
|
Given the way this package abuses cortex-m-rt, it's not immediately
obvious how to register a Cortex-M exception handler with the
`#[exception]` macro. This commit documents and demonstrates the
workaround I use.
|
|
Implemented by following the reference manual, and tested on an
MIMXRT1160EVK. The target adopts all of the same limitations as the 1170
target.
|
|
I derived these values from the reference manual. Tested on an
MIMXRT1040EVK.
|
|
|
|
|
|
Follows the same approach taken in imxrt-hal, imxrt-ral, etc.
|
|
There's no requirement for 16 byte-aligned read-only data, and this is
the only assertion expecting that requirement. Reducing the requirement
lets the test pass when the image is built with a Rust 1.82 toolchain.
|
|
|
|
The 1180 family uses a different boot header than previous families. The
header is generated to support the default configuration where hash and
signature errors are ignored.
The XIP `__pre_init` strategy is still used, more for ease of getting
something running than because of any known problems with the boot ROM's
implementation of loading images to different memories.
The boot ROM for the 1180 does not appear to allow the entry point to
lie outside the (loaded or execute-in-place) image, so a new `.xip`
section is added after the vector table to put the address inside the
image while keeping VMA=LMA. This could cause problems for tools that
manipulate binaries based on section names.
|
|
|
|
|
|
If you define a runtime, you can call `stack_size_env_override` to
define an optional environment variable checked by the runtime builder.
Same goes for the heap. A user can set these environment variables to
override the runtime's stack / heap size. You can use this package's
examples to try it out; see the updated build script.
There's no default environment variable for either memory region. The
package that defines the runtime needs to opt-in to this feature.
|
|
|
|
Test with GNU's linker
|
|
Ensure that we can use GCC's linker to generate our Rust firmware. This
is useful for exploring mixed-language firmware builds.
|
|
GNU's LTO has a tendency to remove __pre_init, which is written in
inline assembly. It doesn't realize that the reset handler references
this symbol, because the reset handler is also written in inline
assembly. Not sure why LLVM's linker doesn't also optimize it away, but
this commit ensures that __pre_init remains in the output file.
|
|
Haven't fully dug into this one, but GNU ld and LLVM lld have slightly
different section positions when we cross from text to data. We can
relax the asserts to show ordering without strictly requiring an offset.
|