Skip to content

Commit 8087f7e

Browse files
committed
Add start of nbuild tool.
1 parent 4b45624 commit 8087f7e

File tree

11 files changed

+463
-45
lines changed

11 files changed

+463
-45
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias]
2+
nbuild = "run --manifest-path nbuild/Cargo.toml --"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/nbuild/target
12
/target
23
**/*.rs.bk
34
/release

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
22
"rust-analyzer.checkOnSave.allTargets": false,
3-
"rust-analyzer.cargo.target": "thumbv6m-none-eabi"
3+
"rust-analyzer.linkedProjects": [
4+
"./Cargo.toml",
5+
"./nbuild/Cargo.toml"
6+
]
47
}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ members = [
44
"utilities/flames",
55
]
66
resolver = "2"
7+
exclude = [
8+
"nbuild"
9+
]
710

811
[workspace.dependencies]
912
neotron-sdk = "0.2.0"

README.md

Lines changed: 16 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ This OS is a work in progress. We intend to support:
1414
* [x] Executing applications from RAM
1515
* [x] Applications can print to stdout
1616
* [x] Applications can read from stdin
17-
* [ ] Applications can open/close/read/write files
17+
* [x] Applications can open/close/read files
18+
* [ ] Applications can write to files
1819
* [x] MBR/FAT32 formatted block devices
1920
* [x] Read blocks
2021
* [x] Directory listing of /
2122
* [ ] Write to files
2223
* [ ] Delete files
2324
* [ ] Change directory
2425
* [x] Load ELF binaries from disk
26+
* [x] Load ELF binaries from ROM
2527
* [x] Changing text modes
2628
* [ ] Basic networking
2729
* [x] Music playback
@@ -35,50 +37,13 @@ Your board will need an appropriate Neotron BIOS installed, and you need to have
3537
OpenOCD or some other programming tool running for your particular board. See
3638
your BIOS instructions for more details.
3739

38-
We compile one version of Neotron OS, but we link it three times to produce
39-
three different binaries:
40+
Building Neotron OS is handled by the `nbuild` tool, in this repository.
4041

41-
* `flash0002` - is linked to run from address `0x0002_0000`
42-
* `flash1002` - is linked to run from address `0x1002_0000`
43-
* `flash0802` - is linked to run from address `0x0802_0000`
42+
Run `cargo nbuild help` for more information.
4443

45-
```console
46-
$ git clone https://github.com/neotron-compute/Neotron-OS.git
47-
$ cd Neotron-OS
48-
$ cargo build --target thumbv6m-none-eabi --release --bins
49-
$ ls ./target/thumbv6m-none-eabi/release/flash*02
50-
./target/thumbv6m-none-eabi/release/flash0002 ./target/thumbv6m-none-eabi/release/flash0802 ./target/thumbv6m-none-eabi/release/flash1002
51-
```
52-
53-
Your BIOS should tell you which one you want and how to load it onto your system.
44+
Your BIOS should tell you which options to pass, and how to load the resulting image onto your system.
5445

55-
You can also build a *shared object* to load into a Windows/Linux/macOS application.
56-
57-
```console
58-
$ cargo build --lib
59-
$ ls ./target/debug/*.so
60-
./target/debug/libneotron_os.so
61-
```
62-
63-
If you want to include a ROMFS, you need to:
64-
65-
```bash
66-
cargo install neotron-romfs-lsfs
67-
cargo install neotron-romfs-mkfs
68-
cargo install cargo-binutils
69-
```
70-
71-
A bunch of utilities are supplied in the [`utilities`](./utilities/) folder. Build them all, and make a ROMFS image, then build the OS with the `ROMFS_PATH` environment variable set.
72-
73-
```bash
74-
TGT=$(pwd)/target/thumbv6m-none-eabi/release
75-
cargo build --bin flames --target thumbv6m-none-eabi --release
76-
rust-strip ${TGT}/flames -o ${TGT}/flames.elf
77-
neotron-romfs-mkfs ${TGT}/flames.elf > ${TGT}/romfs.img
78-
ROMFS_PATH=${TGT}/romfs.img cargo build --bin flash1002 --target thumbv6m-none-eabi --release
79-
```
80-
81-
The OS will then include the ROMFS image, which you can access with the `rom` command.
46+
Programs in the ROMFS can be loaded with:
8247

8348
```text
8449
> rom
@@ -93,14 +58,22 @@ Loading 4908 bytes to 0x200022b4
9358

9459
A better UI for loading files from ROM is being planned (maybe we should have drive letters, and the ROM can be `R:`).
9560

61+
You can also build a *shared object* to load into a Windows/Linux/macOS application, like [Neotron Desktop BIOS](https://github.com/neotron-compute/neotron-desktop-bios):
62+
63+
```console
64+
$ cargo nbuild library
65+
$ ls ./target/debug/*.so
66+
./target/debug/libneotron_os.so
67+
```
68+
9669
## Changelog
9770

9871
See [`CHANGELOG.md`](./CHANGELOG.md)
9972

10073
## Licence
10174

10275
```text
103-
Neotron-OS Copyright (c) Jonathan 'theJPster' Pallant and The Neotron Developers, 2023
76+
Copyright (c) 2019-2024 Jonathan 'theJPster' Pallant and The Neotron Developers
10477
10578
This program is free software: you can redistribute it and/or modify
10679
it under the terms of the GNU General Public License as published by

nbuild/Cargo.lock

Lines changed: 237 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nbuild/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "nbuild"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = [
6+
"Jonathan 'theJPster' Pallant <github@thejpster.org.uk>",
7+
"The Neotron Developers"
8+
]
9+
description = "The Neotron Operating System Build System"
10+
license = "GPL-3.0-or-later"
11+
readme = "README.md"
12+
repository = "https://github.com/neotron-compute/Neotron-OS"
13+
14+
[dependencies]
15+
clap = { version = "4.5.23", features = ["derive"] }

nbuild/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# nbuild - the Neotron OS Build System
2+
3+
Building Neotron OS involves:
4+
5+
* Compiling the Neotron OS source code
6+
* Compiling and linking multiple Neotron OS utilities
7+
* Assembling the utilities into a ROMFS image
8+
* Linking the Neotron OS object code, including the ROMFS image
9+
10+
This utility automates that process.
11+
12+
Run `cargo nbuild --help` from the top level of the checkout for more information.

0 commit comments

Comments
 (0)