Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit c9bad32

Browse files
committed
v0.2.0
1 parent e90fd92 commit c9bad32

File tree

4 files changed

+40
-25
lines changed

4 files changed

+40
-25
lines changed

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v0.2.0] - 2017-04-27
11+
12+
### Changed
13+
14+
- [breaking-change] the `_stack_start` symbol is now required and must be
15+
provided in the `memory.x` file when using the "linker-script" feature. This
16+
symbol indicates where in memory the call stack will be allocated.
17+
1018
## [v0.1.3] - 2017-04-25
1119

1220
### Fixed
@@ -29,7 +37,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2937

3038
Initial release
3139

32-
[Unreleased]: https://github.com/japaric/cortex-m-rt/compare/v0.1.3...HEAD
40+
[Unreleased]: https://github.com/japaric/cortex-m-rt/compare/v0.2.0...HEAD
41+
[v0.2.0]: https://github.com/japaric/cortex-m-rt/compare/v0.1.3...v0.2.0
3342
[v0.1.3]: https://github.com/japaric/cortex-m-rt/compare/v0.1.2...v0.1.3
3443
[v0.1.2]: https://github.com/japaric/cortex-m-rt/compare/v0.1.1...v0.1.2
3544
[v0.1.1]: https://github.com/japaric/cortex-m-rt/compare/v0.1.0...v0.1.1

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ keywords = ["arm", "cortex-m", "runtime", "startup"]
66
license = "MIT OR Apache-2.0"
77
name = "cortex-m-rt"
88
repository = "https://github.com/japaric/cortex-m-rt"
9-
version = "0.1.3"
9+
version = "0.2.0"
1010

1111
[dependencies]
1212
r0 = "0.2.1"
1313

1414
[dependencies.cortex-m]
1515
optional = true
16-
version = "0.2.3"
16+
version = "0.2.4"
1717

1818
[dependencies.cortex-m-semihosting]
1919
optional = true

link.x

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SECTIONS
66
{
77
/* Vector table */
88
_VECTOR_TABLE = .;
9-
LONG(ORIGIN(RAM) + LENGTH(RAM));
9+
LONG(_stack_start);
1010

1111
KEEP(*(.rodata.reset_handler));
1212
KEEP(*(.rodata.exceptions));

src/lib.rs

+27-21
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,10 @@
1616
//!
1717
//! - An opt-in linker script (`"linker-script"` Cargo feature) that encodes
1818
//! the memory layout of a generic Cortex-M microcontroller. This linker
19-
//! script is missing the definition of the FLASH and RAM memory regions of
20-
//! the device. This missing information must be supplied through a `memory.x`
21-
//! linker script of the form:
22-
//!
23-
//! ``` text
24-
//! MEMORY
25-
//! {
26-
//! FLASH : ORIGIN = 0x08000000, LENGTH = 128K
27-
//! RAM : ORIGIN = 0x20000000, LENGTH = 8K
28-
//! }
29-
//! ```
19+
//! script is missing the definitions of the FLASH and RAM memory regions of
20+
//! the device and of the `_stack_start` symbol (address where the call stack
21+
//! is allocated). This missing information must be supplied through a
22+
//! `memory.x` file (see example below).
3023
//!
3124
//! - A default exception handler tailored for debugging and that provides
3225
//! access to the stacked registers under the debugger. By default, all
@@ -77,7 +70,7 @@
7770
//!
7871
//! $ cargo add cortex-m cortex-m-rt
7972
//!
80-
//! $ cat Xargo.toml
73+
//! $ edit Xargo.toml && cat $_
8174
//! ```
8275
//!
8376
//! ``` text
@@ -90,7 +83,7 @@
9083
//! ```
9184
//!
9285
//! ``` text
93-
//! $ cat memory.x
86+
//! $ edit memory.x && cat $_
9487
//! ```
9588
//!
9689
//! ``` text
@@ -99,10 +92,13 @@
9992
//! FLASH : ORIGIN = 0x08000000, LENGTH = 128K
10093
//! RAM : ORIGIN = 0x20000000, LENGTH = 8K
10194
//! }
95+
//!
96+
//! /* This is where the call stack will be allocated */
97+
//! _stack_start = ORIGIN(RAM) + LENGTH(RAM);
10298
//! ```
10399
//!
104100
//! ``` text
105-
//! $ cat src/main.rs
101+
//! $ edit src/main.rs && cat $_
106102
//! ```
107103
//!
108104
//! ``` ignore,no_run
@@ -113,31 +109,41 @@
113109
//! extern crate cortex_m;
114110
//! extern crate cortex_m_rt;
115111
//!
112+
//! use cortex_m::asm;
113+
//!
116114
//! fn main() {
117115
//! hprintln!("Hello, world!");
118116
//! }
119117
//!
118+
//! // As we are not using interrupts, we just register a dummy catch all handler
120119
//! #[allow(dead_code)]
121120
//! #[link_section = ".rodata.interrupts"]
122121
//! #[used]
123-
//! static INTERRUPTS: [u32; 240] = [0; 240];
122+
//! static INTERRUPTS: [extern "C" fn(); 240] = [default_handler; 240];
123+
//!
124+
//! extern "C" fn default_handler() {
125+
//! asm::bkpt();
126+
//! }
124127
//! ```
125128
//!
126129
//! ``` text
127-
//! $ xargo rustc --target thumbv7m-none-eabi -- -C link-args='-Tlink.x -nostartfiles'
130+
//! $ cargo install xargo
131+
//!
132+
//! $ xargo rustc --target thumbv7m-none-eabi -- \
133+
//! -C link-arg=-Tlink.x -C linker=arm-none-eabi-ld -Z linker-flavor=ld
128134
//!
129135
//! $ arm-none-eabi-objdump -Cd $(find target -name app) | less
130136
//! 08000000 <_VECTOR_TABLE>:
131137
//! 8000000: 20002000 .word 0x20002000
132138
//!
133139
//! 08000004 <cortex_m_rt::RESET_HANDLER>:
134-
//! 8000004: 08000671 q...
140+
//! 8000004: 0800065f _...
135141
//!
136142
//! 08000008 <cortex_m_rt::EXCEPTIONS>:
137-
//! 8000008: 080005a5 080005bd 08000569 08000599 ........i.......
138-
//! 8000018: 08000581 00000000 00000000 00000000 ................
139-
//! 8000028: 00000000 080005b1 00000000 00000000 ................
140-
//! 8000038: 0800058d 08000575 ....u...
143+
//! 8000008: 08000585 0800058f 080005a3 08000571 ............q...
144+
//! 8000018: 0800057b 00000000 00000000 00000000 {...............
145+
//! 8000028: 00000000 08000567 00000000 00000000 ....g...........
146+
//! 8000038: 080005ad 08000599 ........
141147
//! ```
142148
143149
#![deny(missing_docs)]

0 commit comments

Comments
 (0)