Skip to content

Configurable vector end addr #23

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
May 18, 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
8 changes: 8 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build]
# Only one target to support for all chips!
target = "msp430-none-elf"

[unstable]
# MSP430 doesn't come with libcore compiled already. But when it does, this
# key can be removed.
build-std = ["core"]
8 changes: 6 additions & 2 deletions link.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ EXTERN(__RESET_VECTOR);
object file that's passed to the linker *before* this crate */
EXTERN(__INTERRUPTS);

/* Provide a default for __VECTORS_END_ADDR. Can be overriden in the user memory.x file */
PROVIDE(__VECTORS_END_ADDR = 0x10000);

/* # Pre-initialization function */
/* If the user overrides this using the `pre_init!` macro or by creating a `__pre_init` function,
then the function this points to will be called before the RAM is initialized. */
Expand Down Expand Up @@ -78,17 +81,18 @@ SECTIONS
}

/* Do not exceed this mark in the error messages below | */
ASSERT(ORIGIN(VECTORS) + LENGTH(VECTORS) == 0x10000, "
ASSERT(ORIGIN(VECTORS) + LENGTH(VECTORS) == __VECTORS_END_ADDR, "
ERROR(msp430-rt): The VECTORS memory region must end at address 0x10000. Check memory.x");

ASSERT(ADDR(.vector_table) + SIZEOF(.vector_table) == 0x10000, "
ASSERT(ADDR(.vector_table) + SIZEOF(.vector_table) == __VECTORS_END_ADDR, "
ERROR(msp430-rt): .vector_table is shorter than expected.
Possible solutions, from most likely to less likely:
- Link to a svd2rust generated pac crate, if you are not
- Fix _sinterrupts in memory.x; it doesn't match the number of interrupts provided by the
pac crate
- Disable the 'device' feature of msp430-rt to build a generic application; a dependency
may be enabling it
- Override __VECTORS_END_ADDR if your vector table is not placed at the regular vector location
");

ASSERT(_sgot == _egot, "
Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2025-04-29"
components = ["rust-src"]
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
//! }
//! ```
//!
//! By default, the linker will check that the address after the vector table is 0x10000 to
//! ensure that the vector table is placed correctly. For special cases like bootloader
//! setups, you might want to place the vector table somewhere else. For theses cases,
//! you can re-configure the expected end address by setting `__VECTORS_END_ADDR` in your
//! `memory.x` file.
//!
//! # An example
//!
//! This section presents a minimal application built on top of `msp430-rt`.
Expand Down
Loading