rust-embedded / rust-embedded/cortex-m
Convenience function to get all read-only linker sections located in Flash
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 202
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 2
Description
If you would like to perform a checksum validation of all Flash memory you would need to know where all used Flash memory starts and ends.
Today, this can (partially) be done using the _stext, __etext, etc. symbols + slice::from_raw_parts but these symbols are not part of the public, stable ABI (iirc) and this approach requires writing unsafe code.
We could add a function that returns an iterator (or slice) over the read-only linker sections .
// the elements of the returned slices are the sectinos `.vector_table`, `.text`, `.rodata`, etc.
pub fn read_only_flash_sections() -> &[&u8] { /* .. */ }
I think this should be sound because these sections are read only so it should be OK to return a shared reference to the entire linker section.
On the other hand, a section dedicated to writeable Flash should not be returned from this function.
The slice should also contain the chunk of memory that corresponds to the initial values of mutable static variables (corresponds to LOADADDR(.data) in the linker script), see below.
static X: AtomicU32 = AtomicU32::new(42);
// ^^ this value is stored in Flash but it's not in .rodata
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the linker script sections and the existing _stext, __etext, and LOADADDR(.data) symbols mentioned in the issue. Determine the public API and soundness requirements before implementing anything; done means a stable read-only Flash view includes the initial mutable-static values while excluding writable Flash sections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100