Skip to content

riscv-rt: include device in link.x #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions riscv-rt/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- New `device` feature to include `device.x` in `link.x`. This feature is based
on the current implementation of `cortex-m-rt`.

### Changed

- Linker file now refers to standard exceptions and interrupts only when the
Expand Down
1 change: 1 addition & 0 deletions riscv-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ v-trap = ["riscv-rt-macros/v-trap"]
u-boot = ["riscv-rt-macros/u-boot", "single-hart"]
no-interrupts = []
no-exceptions = []
device = []
5 changes: 5 additions & 0 deletions riscv-rt/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ fn add_linker_script(arch_width: u32) -> io::Result<()> {
let interrupts_content = fs::read_to_string("interrupts.x")?;
include_content.push_str(&(interrupts_content + "\n"));
}
// If device is enabled, include the device.x file (usually, provided by PACs)
if env::var_os("CARGO_FEATURE_DEVICE").is_some() {
include_content.push_str("/* Device-specific exception and interrupt handlers */\n");
include_content.push_str("INCLUDE device.x\n");
}

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

Expand Down