Skip to content

Commit ddd9708

Browse files
committed
Add PrgData and DevDscr linker sections + data
1 parent 9ecb6bd commit ddd9708

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

link.x

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ SECTIONS {
3535
. = ALIGN(4);
3636
}
3737

38+
/* Section for data, specified by flashloader standard. */
39+
PrgData : {
40+
/*
41+
* We're explicitly putting a single object here (PRGDATA_Start in main.c) as this is required by some tools.
42+
* It is not used by this algorithm
43+
*/
44+
KEEP(*(PrgData))
45+
46+
. = ALIGN(4);
47+
}
48+
49+
/* Description of the flash algorithm */
50+
DevDscr . : {
51+
/* The device data content is only for external tools,
52+
* and usually not referenced by the code.
53+
* All rules have exceptions: device data is used by this flash algo.
54+
*
55+
* The KEEP statement ensures it's not removed by accident.
56+
*/
57+
KEEP(*(DeviceData))
58+
59+
. = ALIGN(4);
60+
}
61+
3862
/DISCARD/ : {
3963
/* Unused exception related info that only wastes space */
4064
*(.ARM.exidx);

src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,13 @@ impl Drop for RP2040Algo {
105105
(self.funcs.flash_enter_cmd_xip)();
106106
}
107107
}
108+
109+
/// Some tools (eg Segger's debugger) require the PrgData section to exist in the target binary
110+
///
111+
/// They scan the flashloader binary for this symbol to determine the section location
112+
/// If they cannot find it, the tool exits. This variable serves no other purpose
113+
#[allow(non_upper_case_globals)]
114+
#[no_mangle]
115+
#[used]
116+
#[link_section = "PrgData"]
117+
pub static mut PRGDATA_Start: usize = 0;

0 commit comments

Comments
 (0)