Skip to content

Commit 31cb240

Browse files
Re-arranged into three binaries.
Each binary gets a unique linker argument in build.rs.
1 parent 70ed28d commit 31cb240

9 files changed

Lines changed: 88 additions & 37 deletions

File tree

.cargo/config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
[target.thumbv7em-none-eabihf]
2-
runner = 'arm-none-eabi-gdb --command=gdb.cfg -w'
3-
41
[build]
5-
target = "thumbv7em-none-eabihf"
2+
target = "thumbv6m-none-eabi"

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"rust-analyzer.checkOnSave.allTargets": false,
3+
"rust-analyzer.cargo.target": "thumbv6m-none-eabi"
4+
}

Cargo.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "neotron_os"
2+
name = "neotron-os"
33
version = "0.1.0"
44
authors = ["Jonathan 'theJPster' Pallant <github@thejpster.org.uk>"]
55
edition = "2018"
@@ -9,7 +9,17 @@ readme = "README.md"
99
repository = "https://github.com/neotron-compute/Neotron-OS"
1010

1111
[[bin]]
12-
name = "neotron_os"
12+
name = "flash1002"
13+
test = false
14+
bench = false
15+
16+
[[bin]]
17+
name = "flash0802"
18+
test = false
19+
bench = false
20+
21+
[[bin]]
22+
name = "flash0002"
1323
test = false
1424
bench = false
1525

README.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,34 @@ This OS is a work in progress. We intend to support:
1919

2020
## Build instructions
2121

22-
Your board will need an appropriate Neotron BIOS installed, and you need to
23-
have OpenOCD (or other programming tool) running for your particular board.
24-
You may also need to set the linker arguments so you link the binary to suit
25-
the memory available on your system.
22+
Your board will need an appropriate Neotron BIOS installed, and you need to have
23+
OpenOCD or some other programming tool running for your particular board. See
24+
your BIOS instructions for more details.
2625

27-
### Build Instructions for the Neotron Pico (and other systems with Flash at `0x1000_0000`)
26+
We compile one version of Neotron OS, but we link it three times to produce
27+
three binaries:
2828

29-
```
30-
$ git clone https://github.com/neotron-compute/Neotron-OS.git
31-
$ cd Neotron-OS
32-
$ git submodule update --init
33-
$ RUSTFLAGS="-C link-arg=-Tneotron-flash-1000.ld" cargo build --release --target=thumbv6m-none-eabi
34-
```
35-
36-
### Build Instructions for the STM32 (and other systems with Flash at `0x0800_0000`)
29+
* `flash0002` - is linked to run from address `0x0002_0000`
30+
* `flash1002` - is linked to run from address `0x1002_0000`
31+
* `flash0802` - is linked to run from address `0x0802_0000`
3732

3833
```
3934
$ git clone https://github.com/neotron-compute/Neotron-OS.git
4035
$ cd Neotron-OS
4136
$ git submodule update --init
42-
$ RUSTFLAGS="-C link-arg=-Tneotron-flash-0800.ld" cargo build --release --target=thumbv6m-none-eabi
37+
$ cargo build --release
38+
$ ls ./target/thumbv6m-none-eabi/release/flash{10,08,00}02
39+
./target/thumbv6m-none-eabi/release/flash0002 ./target/thumbv6m-none-eabi/release/flash0802 ./target/thumbv6m-none-eabi/release/flash1002
4340
```
4441

45-
### Build Instructions for other systems (with Flash at `0x0000_0000`)
46-
47-
```
48-
$ git clone https://github.com/neotron-compute/Neotron-OS.git
49-
$ cd Neotron-OS
50-
$ git submodule update --init
51-
$ RUSTFLAGS="-C link-arg=-Tneotron-flash-0000.ld" cargo run --release
52-
```
42+
Your BIOS should tell you which one you want and how to load it onto your system.
5343

5444
## Changelog
5545

5646
### Unreleased Changes ([Source](https://github.com/neotron-compute/Neotron-OS/tree/master))
5747

5848
* Basic `println!` to the text buffer.
49+
* Re-arranged linker script setup
5950

6051
## Licence
6152

build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
println!("cargo:rustc-link-arg-bin=flash1002=-Tneotron-flash-1000.ld");
3+
println!("cargo:rustc-link-arg-bin=flash0802=-Tneotron-flash-0800.ld");
4+
println!("cargo:rustc-link-arg-bin=flash0002=-Tneotron-flash-0000.ld");
5+
}

src/bin/flash0002.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Binary Neotron OS Image
2+
//!
3+
//! This is for Flash Addresses that start at `0x0002_0000`.
4+
//!
5+
//! Copyright (c) The Neotron Developers, 2022
6+
//!
7+
//! Licence: GPL v3 or higher (see ../LICENCE.md)
8+
9+
#![no_std]
10+
#![no_main]
11+
12+
/// This tells the BIOS how to start the OS. This must be the first four bytes
13+
/// of our portion of Flash.
14+
#[link_section = ".entry_point"]
15+
#[used]
16+
pub static ENTRY_POINT_ADDR: extern "C" fn(&'static neotron_common_bios::Api) -> ! =
17+
neotron_os::main;

src/bin/flash0802.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Binary Neotron OS Image
2+
//!
3+
//! This is for Flash Addresses that start at `0x0802_0000`.
4+
//!
5+
//! Copyright (c) The Neotron Developers, 2022
6+
//!
7+
//! Licence: GPL v3 or higher (see ../LICENCE.md)
8+
9+
#![no_std]
10+
#![no_main]
11+
12+
/// This tells the BIOS how to start the OS. This must be the first four bytes
13+
/// of our portion of Flash.
14+
#[link_section = ".entry_point"]
15+
#[used]
16+
pub static ENTRY_POINT_ADDR: extern "C" fn(&'static neotron_common_bios::Api) -> ! =
17+
neotron_os::main;

src/bin/flash1002.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Binary Neotron OS Image
2+
//!
3+
//! This is for Flash Addresses that start at `0x1002_0000`.
4+
//!
5+
//! Copyright (c) The Neotron Developers, 2022
6+
//!
7+
//! Licence: GPL v3 or higher (see ../LICENCE.md)
8+
9+
#![no_std]
10+
#![no_main]
11+
12+
/// This tells the BIOS how to start the OS. This must be the first four bytes
13+
/// of our portion of Flash.
14+
#[link_section = ".entry_point"]
15+
#[used]
16+
pub static ENTRY_POINT_ADDR: extern "C" fn(&'static neotron_common_bios::Api) -> ! =
17+
neotron_os::main;

src/main.rs renamed to src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
//!
33
//! This OS is intended to be loaded by a Neotron BIOS.
44
//!
5-
//! Copyright (c) The Neotron Developers, 2020
5+
//! Copyright (c) The Neotron Developers, 2022
66
//!
77
//! Licence: GPL v3 or higher (see ../LICENCE.md)
88
99
#![no_std]
10-
#![no_main]
1110

1211
// Imports
1312
use core::fmt::Write;
@@ -18,12 +17,6 @@ use serde::{Deserialize, Serialize};
1817
// Global Variables
1918
// ===========================================================================
2019

21-
/// This tells the BIOS how to start the OS. This must be the first four bytes
22-
/// of our portion of Flash.
23-
#[link_section = ".entry_point"]
24-
#[used]
25-
pub static ENTRY_POINT_ADDR: extern "C" fn(&'static bios::Api) -> ! = main;
26-
2720
/// The OS version string
2821
const OS_VERSION: &str = concat!("Neotron OS, version ", env!("CARGO_PKG_VERSION"), "-2");
2922

@@ -282,7 +275,7 @@ unsafe fn start_up_init() {
282275

283276
/// This is the function the BIOS calls. This is because we store the address
284277
/// of this function in the ENTRY_POINT_ADDR variable.
285-
extern "C" fn main(api: &'static bios::Api) -> ! {
278+
pub extern "C" fn main(api: &'static bios::Api) -> ! {
286279
unsafe {
287280
start_up_init();
288281
API = Some(api);

0 commit comments

Comments
 (0)