aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/host.rs58
-rw-r--r--src/host/imxrt-link.x14
-rw-r--r--src/target.rs7
3 files changed, 72 insertions, 7 deletions
diff --git a/src/host.rs b/src/host.rs
index 42d5e5e..b9809dd 100644
--- a/src/host.rs
+++ b/src/host.rs
@@ -824,6 +824,18 @@ impl RuntimeBuilder {
let link_x = include_bytes!("host/imxrt-link.x");
writer.write_all(link_x)?;
+ // ECC configurations, varying by user build settings, need to go at
+ // the back. We're using a linker script to figure out the spans of
+ // unused RAM regions for zeroing. We need the other sections placed
+ // before we do that.
+ write_ecc_config(
+ writer,
+ self.family,
+ &self.flexram_layout,
+ self.flexram_ecc,
+ self.mecc64,
+ )?;
+
Ok(())
}
@@ -937,18 +949,54 @@ fn write_ecc_config(
let itcm_count = layout_count_of(FlexRamKind::Itcm, flexram_layout);
let dtcm_count = layout_count_of(FlexRamKind::Dtcm, flexram_layout);
let ocram_count = layout_count_of(FlexRamKind::Ocram, flexram_layout);
+ let ocram = family.ocram_start_size(ocram_count, flexram_ecc, mecc64);
+
+ let itcm_ecc = itcm_count > 0 && flexram_ecc.is_enable();
+ let dtcm_ecc = dtcm_count > 0 && flexram_ecc.is_enable();
+ let ocram_ecc = ocram.size > 0 && (mecc64.is_enable() || flexram_ecc.is_enable());
+ let any_ecc_ram = itcm_ecc || dtcm_ecc || ocram_ecc;
+
+ if any_ecc_ram {
+ writeln!(output, "SECTIONS {{")?;
+ }
+ if itcm_ecc {
+ writeln!(
+ output,
+ " .unused.itcm (NOLOAD) : ALIGN(8) {{ . = ALIGN(8); __sitcm_unused = .; . = ORIGIN(ITCM) + LENGTH(ITCM); __eitcm_unused = .; }} > ITCM"
+ )?;
+ } else {
+ writeln!(output, "__sitcm_unused = 0; __eitcm_unused = 0;")?;
+ }
+ if dtcm_ecc {
+ writeln!(
+ output,
+ " .unused.dtcm (NOLOAD) : ALIGN(8) {{ . = ALIGN(8); __sdtcm_unused = .; . = ORIGIN(DTCM) + LENGTH(DTCM); __edtcm_unused = .; }} > DTCM"
+ )?;
+ } else {
+ writeln!(output, "__sdtcm_unused = 0; __edtcm_unused = 0;")?;
+ }
+ if ocram_ecc {
+ writeln!(
+ output,
+ " .unused.ocram (NOLOAD) : ALIGN(8) {{ . = ALIGN(8); __socram_unused = .; . = ORIGIN(OCRAM) + LENGTH(OCRAM); __eocram_unused = .; }} > OCRAM"
+ )?;
+ } else {
+ writeln!(output, "__socram_unused = 0; __eocram_unused = 0;")?;
+ }
+ if any_ecc_ram {
+ writeln!(output, "}}")?;
+ }
let mut ecc_ram_config = 0_u32;
- if itcm_count > 0 && flexram_ecc.is_enable() {
+ if itcm_ecc {
ecc_ram_config |= crate::ECC_ITCM_ACTIVE;
}
- if dtcm_count > 0 && flexram_ecc.is_enable() {
+ if dtcm_ecc {
ecc_ram_config |= crate::ECC_DTCM_ACTIVE;
}
- let ocram = family.ocram_start_size(ocram_count, flexram_ecc, mecc64);
- if ocram.size > 0 && (mecc64.is_enable() || flexram_ecc.is_enable()) {
+ if ocram_ecc {
ecc_ram_config |= crate::ECC_OCRAM_ACTIVE;
}
@@ -980,7 +1028,6 @@ fn write_flash_memory_map(
write_flexram_memories(output, family, flexram_layout, flexram_ecc, mecc64)?;
writeln!(output, "}}")?;
writeln!(output, "__fcb_offset = {:#X};", family.fcb_offset())?;
- write_ecc_config(output, family, flexram_layout, flexram_ecc, mecc64)?;
Ok(())
}
@@ -1002,7 +1049,6 @@ fn write_ram_memory_map(
writeln!(output, "MEMORY {{")?;
write_flexram_memories(output, family, flexram_layout, flexram_ecc, mecc64)?;
writeln!(output, "}}")?;
- write_ecc_config(output, family, flexram_layout, flexram_ecc, mecc64)?;
Ok(())
}
diff --git a/src/host/imxrt-link.x b/src/host/imxrt-link.x
index c04e3d4..48a792b 100644
--- a/src/host/imxrt-link.x
+++ b/src/host/imxrt-link.x
@@ -51,6 +51,13 @@ SECTIONS
_stack_start = __sstack;
} > REGION_STACK
+ .vector_table_pad (NOLOAD) : ALIGN(8)
+ {
+ __svector_table_pad = .;
+ . = ALIGN(1024);
+ __evector_table_pad = .;
+ } > REGION_VTABLE
+
.vector_table : ALIGN(1024)
{
FILL(0xff);
@@ -170,6 +177,9 @@ SECTIONS
ASSERT(__sstack % 8 == 0 && __estack % 8 == 0, "
BUG(imxrt-rt): .stack is not 8-byte aligned");
+ASSERT(__svector_table_pad % 8 == 0 && __evector_table_pad % 8 == 0, "
+BUG(imxrt-rt): .vector_table_pad is not 8-byte aligned");
+
ASSERT(__stext % 8 == 0 && __etext % 8 == 0, "
BUG(imxrt-rt): .text is not 8-byte aligned");
@@ -199,7 +209,9 @@ BUG(imxrt-rt): .heap is not 8-byte aligned");
/* # Position checks */
-/* ## .vector_table */
+ASSERT(__evector_table_pad == ADDR(.vector_table), "
+BUG(imxrt-rt): .vector_table_pad does not end at the vector table");
+
ASSERT(__reset_vector == ADDR(.vector_table) + 0x8, "
BUG(imxrt-rt): the reset vector is missing");
diff --git a/src/target.rs b/src/target.rs
index 95dc7b6..5e298e6 100644
--- a/src/target.rs
+++ b/src/target.rs
@@ -151,7 +151,10 @@ __pre_init:
# debugger, perhaps).
cmp r2, #0
beq 1000f
+
+ zero_section64 0x00 , 0x20
zero_section64 __estack , __sstack
+ zero_section64 __svector_table_pad , __evector_table_pad
maybe_zero_section64 __svector_table , __sivector_table , __evector_table
maybe_zero_section64 __stext , __sitext , __etext
maybe_zero_section64 __srodata , __sirodata , __erodata
@@ -160,6 +163,10 @@ __pre_init:
zero_section64 __suninit , __euninit
zero_section64 __sheap , __eheap
+ zero_section64 __sitcm_unused , __eitcm_unused
+ zero_section64 __sdtcm_unused , __edtcm_unused
+ zero_section64 __socram_unused , __eocram_unused
+
b 1000f
1180: