aboutsummaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorsummivox <summivox@gmail.com>2023-08-20 23:13:59 -0700
committerIan McIntyre <ianpmcintyre@gmail.com>2023-09-08 19:18:34 -0400
commitc6d3bcfb11800c58339037be58fa9935f816f1bb (patch)
tree4e8b0d6cdae543e0443f4a8d4cf969f4def7a1f3 /board
parente1fddd5b3b678c43ee59835d7b57bbc063a22d28 (diff)
Add optional DCD section in linker script
Users can define their device configuration data (DCD), and place the data in the .dcd section. If the .dcd section has content, the entry in the IVT points at the user's DCD. This plays well with imxrt-dcd.
Diffstat (limited to 'board')
-rw-r--r--board/Cargo.toml5
-rw-r--r--board/src/teensy4.rs15
2 files changed, 20 insertions, 0 deletions
diff --git a/board/Cargo.toml b/board/Cargo.toml
index 21defd4..9072274 100644
--- a/board/Cargo.toml
+++ b/board/Cargo.toml
@@ -45,3 +45,8 @@ imxrt1170evk-cm7 = [
"dep:rtt-target",
"dep:panic-rtt-target",
]
+
+# Dummy boards for testing DCD linking.
+# Don't try running these on hardware; they might not work.
+__dcd = ["teensy4"]
+__dcd_missize = ["teensy4"]
diff --git a/board/src/teensy4.rs b/board/src/teensy4.rs
index 28587cd..2aaee82 100644
--- a/board/src/teensy4.rs
+++ b/board/src/teensy4.rs
@@ -35,3 +35,18 @@ pub fn prepare(timer_delay_microseconds: u32) -> Option<crate::Resources> {
pit,
})
}
+
+/// Dummy DCD section containing a single NOP command (for testing linker scripts).
+#[cfg(feature = "__dcd")]
+#[link_section = ".dcd"]
+#[no_mangle]
+#[used]
+pub static DEVICE_CONFIGURATION_DATA: [u8; 8] = [0xD2, 0x00, 0x08, 0x41, 0xC0, 0x00, 0x04, 0x00];
+
+/// Ditto but incorrect size (not a multiple of 4 bytes). The linker script should catch this error
+/// and fail the build.
+#[cfg(feature = "__dcd_missize")]
+#[link_section = ".dcd"]
+#[no_mangle]
+#[used]
+pub static DEVICE_CONFIGURATION_DATA: [u8; 7] = [0xD2, 0x00, 0x08, 0x41, 0xC0, 0x00, 0x04];