Skip to content

Commit

Permalink
Add PrgData and DevDscr linker sections + data
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Feb 12, 2024
1 parent 9ecb6bd commit ddd9708
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
24 changes: 24 additions & 0 deletions link.x
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ SECTIONS {
. = ALIGN(4);
}

/* Section for data, specified by flashloader standard. */
PrgData : {
/*
* We're explicitly putting a single object here (PRGDATA_Start in main.c) as this is required by some tools.
* It is not used by this algorithm
*/
KEEP(*(PrgData))

. = ALIGN(4);
}

/* Description of the flash algorithm */
DevDscr . : {
/* The device data content is only for external tools,
* and usually not referenced by the code.
* All rules have exceptions: device data is used by this flash algo.
*
* The KEEP statement ensures it's not removed by accident.
*/
KEEP(*(DeviceData))

. = ALIGN(4);
}

/DISCARD/ : {
/* Unused exception related info that only wastes space */
*(.ARM.exidx);
Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,13 @@ impl Drop for RP2040Algo {
(self.funcs.flash_enter_cmd_xip)();
}
}

/// Some tools (eg Segger's debugger) require the PrgData section to exist in the target binary
///
/// They scan the flashloader binary for this symbol to determine the section location
/// If they cannot find it, the tool exits. This variable serves no other purpose
#[allow(non_upper_case_globals)]
#[no_mangle]
#[used]
#[link_section = "PrgData"]
pub static mut PRGDATA_Start: usize = 0;

0 comments on commit ddd9708

Please sign in to comment.