Skip to content

Commit b5832b6

Browse files
Merge pull request #275 from rust-embedded/include-device
Add memory feature
2 parents 3626b66 + e8b2625 commit b5832b6

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

riscv-rt/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- New `device` feature to include `device.x` in `link.x`. This feature is based
1313
on the current implementation of `cortex-m-rt`.
14+
- New `memory` feature to include `memory.x` in `link.x`. This feature is based
15+
on the current implementation of `cortex-m-rt`. However, in contrast with
16+
`cortex-m-rt`, including `memory.x` in the linker file is feature gated.
17+
The benefits of leaving this optional are backwards compatibility and
18+
allowing users to define less typical linker scripts that do not rely on a
19+
`device.x` or `memory.x` file.
1420

1521
### Changed
1622

riscv-rt/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ u-boot = ["riscv-rt-macros/u-boot", "single-hart"]
3838
no-interrupts = []
3939
no-exceptions = []
4040
device = []
41+
memory = []

riscv-rt/build.rs

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ fn add_linker_script(arch_width: u32) -> io::Result<()> {
2929
include_content.push_str("/* Device-specific exception and interrupt handlers */\n");
3030
include_content.push_str("INCLUDE device.x\n");
3131
}
32+
// If memory is enabled, include the memory.x file (usually, provided by BSPs)
33+
if env::var_os("CARGO_FEATURE_MEMORY").is_some() {
34+
include_content.push_str("/* Device-specific memory layout */\n");
35+
include_content.push_str("INCLUDE memory.x\n");
36+
}
3237

3338
content = content.replace("${INCLUDE_LINKER_FILES}", &include_content);
3439

0 commit comments

Comments
 (0)