Skip to content
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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
nbuild = "run --manifest-path nbuild/Cargo.toml --"
14 changes: 14 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Clippy

on: [push, pull_request]

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup component add clippy
- run: cargo nbuild clippy

12 changes: 4 additions & 8 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ name: Format
on: [push, pull_request]

jobs:
run_cargo_fmt:
name: Run cargo fmt
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
submodules: true
- name: Add Tool
run: rustup component add rustfmt
- name: Check Format
run: cargo fmt -- --check
- run: rustup component add rustfmt
- run: cargo nbuild format --check
157 changes: 93 additions & 64 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,107 @@ name: Build
on: [push, pull_request]

jobs:
build:
name: Build (and Release)
embedded-binaries:
runs-on: ubuntu-latest
strategy:
matrix:
target: [thumbv6m-none-eabi, thumbv7em-none-eabi, thumbv8m.main-none-eabi]
start_address: [0x0802_0000, 0x1002_0000]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
submodules: true

- name: Check Syntax
run: |
cargo check

- name: Test
run: |
cargo test --lib

- name: Install Targets and Tools
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
rustup target add thumbv7em-none-eabi
rustup target add thumbv7m-none-eabi
rustup target add thumbv6m-none-eabi
rustup component add llvm-tools-preview
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV

- name: Install tools
uses: taiki-e/install-action@v2
- run: rustup target add ${{ matrix.target }}
- run: rustup component add llvm-tools-preview
- run: cargo nbuild binary --target=${{ matrix.target }} --start-address=${{ matrix.start_address }}
- uses: actions/upload-artifact@v4
if: ${{success()}}
with:
tool: cargo-binutils@0.3.6

- name: Install ROMFS tools
run: |
cargo install neotron-romfs-lsfs
cargo install neotron-romfs-mkfs

- name: Build
run: |
./build.sh --verbose

- name: Upload Artifacts
uses: actions/upload-artifact@v4
name: ${{ matrix.target }}-${{ matrix.start_address }}-binary
if-no-files-found: error
path: |
./target/${{ matrix.target }}/release/neotron-os
./target/${{ matrix.target }}/release/neotron-os.bin
./target/${{ matrix.target }}/release/romfs.bin
x64_64-unknown-linux-gnu-library:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: cargo nbuild library
- uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: Artifacts
name: x64_64-unknown-linux-gnu-library
if-no-files-found: error
path: |
./release/

- name: Upload files to Release
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
./target/release/libneotron_os.so
x86_64-pc-windows-msvc-library:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: cargo nbuild library
- uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: x86_64-pc-windows-msvc-library
if-no-files-found: error
path: |
./target/release/neotron_os.dll
./target/release/neotron_os.dll.exp
./target/release/neotron_os.dll.lib
./target/release/neotron_os.pdb
aarch64-apple-darwin-library:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: cargo nbuild library
- uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: aarch64-apple-darwin-library
if-no-files-found: error
path: |
./target/release/libneotron_os.dylib
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: cargo nbuild test
preview-release:
runs-on: ubuntu-latest
needs: [embedded-binaries, x64_64-unknown-linux-gnu-library, x86_64-pc-windows-msvc-library, aarch64-apple-darwin-library, run-tests]
steps:
- run: mkdir ./release
- uses: actions/download-artifact@v4
with:
path: ./release-${{ github.ref_name }}
- run: ls -lR ./release-${{ github.ref_name }}
- run: zip -r ./release-${{ github.ref_name }}.zip ./release-${{ github.ref_name }}
- uses: actions/upload-artifact@v4
if: ${{success()}}
with:
name: release
if-no-files-found: error
path: |
./release-${{ github.ref_name }}.zip
release:
runs-on: ubuntu-latest
needs: [preview-release]
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
name: release
path: .
- uses: softprops/action-gh-release@v1
with:
files: |
./release/thumbv6m-none-eabi-flash0002-libneotron_os.bin
./release/thumbv6m-none-eabi-flash0002-libneotron_os.elf
./release/thumbv6m-none-eabi-flash0802-libneotron_os.bin
./release/thumbv6m-none-eabi-flash0802-libneotron_os.elf
./release/thumbv6m-none-eabi-flash1002-libneotron_os.bin
./release/thumbv6m-none-eabi-flash1002-libneotron_os.elf
./release/thumbv7em-none-eabi-flash0002-libneotron_os.bin
./release/thumbv7em-none-eabi-flash0002-libneotron_os.elf
./release/thumbv7em-none-eabi-flash0802-libneotron_os.bin
./release/thumbv7em-none-eabi-flash0802-libneotron_os.elf
./release/thumbv7em-none-eabi-flash1002-libneotron_os.bin
./release/thumbv7em-none-eabi-flash1002-libneotron_os.elf
./release/thumbv7m-none-eabi-flash0002-libneotron_os.bin
./release/thumbv7m-none-eabi-flash0002-libneotron_os.elf
./release/thumbv7m-none-eabi-flash0802-libneotron_os.bin
./release/thumbv7m-none-eabi-flash0802-libneotron_os.elf
./release/thumbv7m-none-eabi-flash1002-libneotron_os.bin
./release/thumbv7m-none-eabi-flash1002-libneotron_os.elf
./release/x86_64-unknown-linux-gnu-libneotron_os.so
./release-${{ github.ref_name }}.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/nbuild/target
/target
**/*.rs.bk
/release
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.cargo.target": "thumbv6m-none-eabi"
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./nbuild/Cargo.toml"
]
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ members = [
"utilities/flames",
]
resolver = "2"
exclude = [
"nbuild"
]

[workspace.dependencies]
neotron-sdk = "0.2.0"
Expand Down
68 changes: 27 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ This OS is a work in progress. We intend to support:
* [x] Executing applications from RAM
* [x] Applications can print to stdout
* [x] Applications can read from stdin
* [ ] Applications can open/close/read/write files
* [x] Applications can open/close/read files
* [ ] Applications can write to files
* [x] MBR/FAT32 formatted block devices
* [x] Read blocks
* [x] Directory listing of /
* [ ] Write to files
* [ ] Delete files
* [ ] Change directory
* [x] Load ELF binaries from disk
* [x] Load ELF binaries from ROM
* [x] Changing text modes
* [ ] Basic networking
* [x] Music playback
Expand All @@ -35,55 +37,30 @@ Your board will need an appropriate Neotron BIOS installed, and you need to have
OpenOCD or some other programming tool running for your particular board. See
your BIOS instructions for more details.

We compile one version of Neotron OS, but we link it three times to produce
three different binaries:
Building Neotron OS is handled by the `nbuild` tool, in this repository. Run `cargo nbuild help` for more information.

* `flash0002` - is linked to run from address `0x0002_0000`
* `flash1002` - is linked to run from address `0x1002_0000`
* `flash0802` - is linked to run from address `0x0802_0000`
To make an image for a board like the Neotron Pico, you want to run `cargo nbuild binary`. By default this will produce a `thumbv6m-none-eabi` image linked to run at address `0x1002_0000`, with a ROMFS containing various utilities, which is what you need on a Neotron Pico. Your BIOS should tell you if you need to change these options, and how to load the resulting image onto your system.

```console
$ git clone https://github.com/neotron-compute/Neotron-OS.git
$ cd Neotron-OS
$ cargo build --target thumbv6m-none-eabi --release --bins
$ ls ./target/thumbv6m-none-eabi/release/flash*02
./target/thumbv6m-none-eabi/release/flash0002 ./target/thumbv6m-none-eabi/release/flash0802 ./target/thumbv6m-none-eabi/release/flash1002
$ cargo nbuild binary
...
$ ls ./target/thumbv6m-none-eabi/release
build/ examples/ flames.d libflames.d libneotron_os.d neotron-os neotron-os.d
deps/ flames incremental/ libflames.rlib libneotron_os.rlib neotron-os.bin romfs.bin
```

Your BIOS should tell you which one you want and how to load it onto your system.
Here:

You can also build a *shared object* to load into a Windows/Linux/macOS application.
* `romfs.bin` is the raw ROMFS image
* `neotron-os` is an ELF file containing the OS and the ROMFS image
* `neotron-os.bin` is an raw binary copy of the contents of the ELF file

```console
$ cargo build --lib
$ ls ./target/debug/*.so
./target/debug/libneotron_os.so
```

If you want to include a ROMFS, you need to:

```bash
cargo install neotron-romfs-lsfs
cargo install neotron-romfs-mkfs
cargo install cargo-binutils
```

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.

```bash
TGT=$(pwd)/target/thumbv6m-none-eabi/release
cargo build --bin flames --target thumbv6m-none-eabi --release
rust-strip ${TGT}/flames -o ${TGT}/flames.elf
neotron-romfs-mkfs ${TGT}/flames.elf > ${TGT}/romfs.img
ROMFS_PATH=${TGT}/romfs.img cargo build --bin flash1002 --target thumbv6m-none-eabi --release
```

The OS will then include the ROMFS image, which you can access with the `rom` command.
When the OS is running, programs in the ROMFS can be loaded with:

```text
> rom
flames.elf (14212 bytes)
> rom flames.elf
flames (14212 bytes)
> rom flames
Loading 4256 bytes to 0x20001000
Loading 532 bytes to 0x200020a0
Loading 4908 bytes to 0x200022b4
Expand All @@ -93,14 +70,23 @@ Loading 4908 bytes to 0x200022b4

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

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):

```console
$ cargo nbuild library
...
$ ls ./target/debug/*.so
./target/debug/libneotron_os.so
```

## Changelog

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

## Licence

```text
Neotron-OS Copyright (c) Jonathan 'theJPster' Pallant and The Neotron Developers, 2023
Copyright (c) 2019-2024 Jonathan 'theJPster' Pallant and The Neotron Developers

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
39 changes: 0 additions & 39 deletions build.sh

This file was deleted.

Loading
Loading