Skip to content

Commit f212a64

Browse files
authored
Merge pull request #15 from Neotron-Compute/release/v0.2.0
Release/v0.2.0
2 parents 97e3f62 + ffa591f commit f212a64

File tree

24 files changed

+139
-128
lines changed

24 files changed

+139
-128
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
submodules: true
1616
fetch-depth: 0
@@ -23,7 +23,7 @@ jobs:
2323
rustup component add llvm-tools
2424
cargo install cargo-binutils
2525
26-
- name: Add targets
26+
- name: Add C tools
2727
run: |
2828
sudo apt-get -y install gcc-arm-none-eabi binutils-arm-none-eabi
2929
@@ -70,7 +70,7 @@ jobs:
7070
zip -r ./neotron-sdk-${{ env.slug }}.zip ./neotron-sdk-${{ env.slug }}
7171
7272
- name: Upload Artifacts
73-
uses: actions/upload-artifact@v3
73+
uses: actions/upload-artifact@v4
7474
if: ${{success()}}
7575
with:
7676
name: Artifacts

.github/workflows/clippy.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout Code
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
submodules: true
1616
fetch-depth: 0
1717

1818
- name: Install Rust
19-
uses: actions-rs/toolchain@v1
20-
with:
21-
toolchain: stable
22-
components: clippy
23-
target: thumbv6m-none-eabi
19+
run: |
20+
rustup component add clippy
21+
rustup target add thumbv6m-none-eabi
2422
2523
- name: Run Clippy
2624
uses: actions-rs/clippy-check@v1

.github/workflows/format.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout Code
10-
uses: actions/checkout@v3
10+
uses: actions/checkout@v4
1111
with:
1212
submodules: true
1313
fetch-depth: 0
1414

1515
- name: Install Rust
16-
uses: actions-rs/toolchain@v1
17-
with:
18-
toolchain: stable
19-
components: rustfmt
16+
run: rustup component add rustfmt
2017

2118
- name: Check Format
2219
run: cargo fmt -- --check

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
# Change Log
22

3-
## Unreleased changes ([Source](https://github.com/neotron-compute/neotron-sdk/tree/develop) | [Changes](https://github.com/neotron-compute/neotron-sdk/compare/v0.1.0...develop))
3+
## Unreleased changes ([Source](https://github.com/neotron-compute/neotron-sdk/tree/develop) | [Changes](https://github.com/neotron-compute/neotron-sdk/compare/v0.2.0...develop))
44

55
* None
66

7+
## v0.2.0 - 2024-05-19 ([Source](https://github.com/neotron-compute/neotron-sdk/tree/v0.2.0) | [Release](https://github.com/neotron-compute/neotron-sdk/releases/tag/v0.2.0))
8+
9+
* Adds a bare-metal target to docs.rs
10+
* Document the `init` function
11+
* Moved the Cortex-M linker script into the SDK so applications don't have to
12+
have a copy
13+
* Update GitHub Actions to avoid Node.js 16 warnings
14+
* Fixed the asmhello sample (it was crashing)
15+
* Added more docs to the linker script
16+
717
## v0.1.0 - 2024-05-19 ([Source](https://github.com/neotron-compute/neotron-sdk/tree/v0.1.0) | [Release](https://github.com/neotron-compute/neotron-sdk/releases/tag/v0.1.0))
818

9-
First version. Supports cross-platform terminal output and some basic file APIs.
19+
* First version. Supports cross-platform terminal output and some basic file APIs.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description = "SDK for writing applications for Neotron OS"
33
edition = "2021"
44
license = "MIT OR Apache-2.0"
55
name = "neotron-sdk"
6-
version = "0.1.0"
6+
version = "0.2.0"
77
authors = ["Jonathan 'theJPster' Pallant <neotron@thejpster.org.uk>"]
88

99
[dependencies]
@@ -19,3 +19,6 @@ crossterm = "0.26"
1919
[features]
2020
# Prints panic info. Costs you about 14K of code.
2121
fancy-panic = []
22+
23+
[package.metadata.docs.rs]
24+
targets = ["x86_64-unknown-linux-gnu", "thumbv6m-none-eabi"]

build.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//! Build script for the Neotron SDK
2+
//!
3+
//! Sets up Rust to link with a Cortex-M linker script if you are building for
4+
//! an Arm bare-metal target.
5+
6+
use std::io::prelude::*;
7+
8+
fn main() {
9+
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH variable");
10+
let os = std::env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS variable");
11+
match (arch.as_str(), os.as_str()) {
12+
("arm", "none") => {
13+
setup_cortexm_linker();
14+
}
15+
_ => {
16+
// no script required
17+
}
18+
}
19+
}
20+
21+
fn setup_cortexm_linker() {
22+
// Put `neotron-cortex-m.ld` in our output directory and ensure it's
23+
// on the linker search path.
24+
let out = &std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
25+
std::fs::File::create(out.join("neotron-cortex-m.ld"))
26+
.unwrap()
27+
.write_all(include_bytes!("./neotron-cortex-m.ld"))
28+
.unwrap();
29+
println!("cargo:rustc-link-search={}", out.display());
30+
31+
// By default, Cargo will re-run a build script whenever
32+
// any file in the project changes. By specifying `neotron-cortex-m.ld`
33+
// here, we ensure the build script is only re-run when
34+
// `neotron-cortex-m.ld` is changed.
35+
println!("cargo:rerun-if-changed=./neotron-cortex-m.ld");
36+
}
Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Based on the [Rust Embedded Cortex-M crate](https://github.com/rust-embedded/cortex-m).
55
*
66
* Copyright (c) 2016 Jorge Aparicio.
7-
* Copyright (c) 2023 Jonathan 'theJPster' Pallant and the Neotron Developers.
7+
* Copyright (c) 2024 Jonathan 'theJPster' Pallant and the Neotron Developers.
88
*/
99

1010
MEMORY
@@ -26,52 +26,67 @@ ENTRY(app_entry);
2626
/* # Sections */
2727
SECTIONS
2828
{
29-
/* ### .text */
29+
/* ## .text */
30+
/* All the executable code for our program */
3031
.text : ALIGN(4)
3132
{
3233
. = ALIGN(4);
3334
*(.text .text.*);
3435
. = ALIGN(4);
3536
} > RAM
3637

37-
/* ### .rodata */
38+
/* ## .rodata */
39+
/* All the read-only static data for our program */
3840
.rodata : ALIGN(4)
3941
{
4042
. = ALIGN(4);
4143
*(.rodata .rodata.*);
4244
. = ALIGN(4);
4345
} > RAM
4446

45-
/* ### .data */
47+
/* ## .data */
48+
/* All the read-write non-zero-initialised static data for our program */
4649
.data : ALIGN(4)
4750
{
4851
. = ALIGN(4);
4952
*(.data .data.*);
5053
. = ALIGN(4);
5154
} > RAM
5255

53-
/* ### .bss */
56+
/* ## .bss */
57+
/* All the read-write zero-initialised static data for our program */
5458
.bss : ALIGN(4)
5559
{
5660
. = ALIGN(4);
5761
*(.bss .bss.*);
5862
. = ALIGN(4);
5963
} > RAM
6064

61-
/* ### .uninit */
65+
/* ## .uninit */
66+
/* All the read-write uninitialised static data for our program */
6267
.uninit (NOLOAD) : ALIGN(4)
6368
{
6469
. = ALIGN(4);
6570
*(.uninit .uninit.*);
6671
. = ALIGN(4);
6772
} > RAM
6873

74+
/* ## Start of Heap */
75+
/* Newlib's `sbrk` syscall uses the `end` symbol to mark the start of heap
76+
memory. The `sbrk` syscall has a static variable tracking the edge of the
77+
heap (`heap_end`) and that value moves upwards as more heap memory is
78+
required. The `heap_end` value is initialised with the address of the `end`
79+
symbol on first allocation.
80+
81+
See https://github.com/bminor/newlib/blob/master/libgloss/libnosys/sbrk.c
82+
*/
6983
. = ALIGN(4);
7084
end = .;
7185

7286
/* ## .got */
73-
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in
74-
the input files and raise an error if relocatable code is found */
87+
/* Dynamic relocations are unsupported. This section is only used to detect
88+
relocatable code in the input files and raise an error if relocatable code
89+
is found */
7590
.got (NOLOAD) :
7691
{
7792
KEEP(*(.got .got.*));

samples/.cargo/config.toml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
[target.thumbv7em-none-eabihf]
2-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
2+
rustflags = [
3+
"-Clink-arg=-Tneotron-cortex-m.ld",
4+
"-Clink-arg=--nmagic"
5+
]
36

47
[target.thumbv7em-none-eabi]
5-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
8+
rustflags = [
9+
"-Clink-arg=-Tneotron-cortex-m.ld",
10+
"-Clink-arg=--nmagic"
11+
]
612

713
[target.thumbv7m-none-eabi]
8-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
14+
rustflags = [
15+
"-Clink-arg=-Tneotron-cortex-m.ld",
16+
"-Clink-arg=--nmagic"
17+
]
918

1019
[target.thumbv6m-none-eabi]
11-
rustflags = ["-C", "link-arg=-Tneotron-cortex-m.ld", "-C", "link-arg=--nmagic"]
20+
rustflags = [
21+
"-Clink-arg=-Tneotron-cortex-m.ld",
22+
"-Clink-arg=--nmagic"
23+
]

samples/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ members = [
88
]
99
resolver = "2"
1010

11+
[workspace.dependencies]
12+
neotron-sdk = { path = "..", version = "0.2" }
13+
1114
[profile.release]
1215
opt-level = "z"
1316
lto = "fat"

samples/asmhello/asmhello.S

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ app_entry:
2626
ldr r3, [r0, #8]
2727
// Set up file handle
2828
movs r0, #1
29-
// Set up data pointer
29+
// Get address of string
3030
ldr r1, =message
31-
// Set up data length
31+
// Get address of data length
3232
ldr r4, =message_len
33-
ldr r2, [r4]
33+
// Read data length (might not be aligned, as it follows the string, so only
34+
// read one byte)
35+
ldrb r2, [r4]
3436
// Call write function
3537
blx r3
3638
// Set return value
@@ -55,6 +57,6 @@ message:
5557
// Must come immediately after `message:`
5658
.type message_len,%object
5759
message_len:
58-
.long . - message
60+
.byte . - message
5961

6062
// End of file

0 commit comments

Comments
 (0)