Skip to content

Commit 445c77d

Browse files
authored
Merge pull request #23 from Neotron-Compute/fix-versioning
Fix versioning
2 parents 8e73e25 + 94d0d24 commit 445c77d

File tree

9 files changed

+41
-47
lines changed

9 files changed

+41
-47
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
uses: actions/checkout@v3
1414
with:
1515
submodules: true
16+
fetch-depth: 0
1617

1718
- name: Install Rust
1819
uses: actions-rs/toolchain@v1
@@ -23,25 +24,8 @@ jobs:
2324
target: thumbv6m-none-eabi
2425

2526
- name: Build Code
26-
run: cargo build --release --verbose
27-
28-
- name: Get Branch Name
29-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
30-
id: branch_name
3127
run: |
32-
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
33-
34-
- name: Create Release
35-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
36-
id: create_release
37-
uses: actions/create-release@v1
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
with:
41-
tag_name: ${{ github.ref }}
42-
release_name: Release ${{ steps.branch_name.outputs.SOURCE_TAG }}
43-
draft: false
44-
prerelease: false
28+
cargo build --release --verbose
4529
4630
- name: Upload files to Release
4731
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')

.github/workflows/clippy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
steps:
1212
- name: Checkout Code
1313
uses: actions/checkout@v3
14+
with:
15+
submodules: true
16+
fetch-depth: 0
1417

1518
- name: Install Rust
1619
uses: actions-rs/toolchain@v1

.github/workflows/format.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
steps:
99
- name: Checkout Code
1010
uses: actions/checkout@v3
11+
with:
12+
submodules: true
13+
fetch-depth: 0
1114

1215
- name: Install Rust
1316
uses: actions-rs/toolchain@v1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ We use the "neotron-os-pico.ld" linker script to link it at `0x1002_0000`.
6161

6262
```console
6363
user@host ~/neotron-os $ cargo build --bin=flash1002 --release --target=thumbv6m-none-eabi
64-
user@host ~/neotron-os $ arm-none-eabi-objcopy -O binary ./target/thumbv6m-none-eabi/release/flash1002 ../neotron-pico-bios/src/flash1002.bin
64+
user@host ~/neotron-os $ arm-none-eabi-objcopy -O binary ./target/thumbv6m-none-eabi/release/flash1002 ../neotron-pico-bios/src/thumbv6m-none-eabi-flash1002-libneotron_os.bin
6565
```
6666

6767
6. Build and load the Neotron BIOS, and view the debug output stream, with `cargo run --release`:

build.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ fn main() {
2929
// `memory.x` is changed.
3030
println!("cargo:rerun-if-changed=memory.x");
3131

32-
// Get git version
33-
if let Ok(cmd_output) = std::process::Command::new("git")
34-
.arg("describe")
35-
.arg("--all")
36-
.arg("--dirty")
37-
.arg("--long")
32+
// Generate a file containing the firmware version
33+
let version_output = std::process::Command::new("git")
34+
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
35+
.args(["describe", "--long", "--dirty"])
3836
.output()
39-
{
40-
let git_version = std::str::from_utf8(&cmd_output.stdout).unwrap();
41-
println!(
42-
"cargo:rustc-env=BIOS_VERSION={} (git:{})",
43-
env!("CARGO_PKG_VERSION"),
44-
git_version.trim()
45-
);
46-
} else {
47-
println!("cargo:rustc-env=BIOS_VERSION={}", env!("CARGO_PKG_VERSION"));
48-
}
37+
.expect("running git-describe");
38+
assert!(version_output.status.success());
39+
40+
// Remove the trailing newline
41+
let mut output = version_output.stdout;
42+
output.pop();
43+
44+
// Add a null
45+
output.push(0);
46+
47+
// Write the file
48+
std::fs::write(out.join("version.txt"), output).expect("writing version file");
4949
}

src/flash1002.bin

-32 KB
Binary file not shown.

src/main.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ struct Pins {
154154
// Static and Const Data
155155
// -----------------------------------------------------------------------------
156156

157-
/// The BIOS version string
158-
static BIOS_VERSION: &str = concat!("Neotron Pico BIOS version ", env!("BIOS_VERSION"), "\0");
157+
/// Version string auto-generated by git.
158+
static VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/version.txt"));
159159

160160
/// Ensures we always send a unique read request
161161
static USE_ALT: UseAlt = UseAlt::new();
@@ -168,11 +168,14 @@ static HARDWARE: Mutex<core::cell::RefCell<Option<Hardware>>> =
168168

169169
/// This is our Operating System. It must be compiled separately.
170170
///
171-
/// The RP2040 requires an OS linked at `0x1002_0000`, which is the OS binary
172-
/// `flash1002`. Use `objdump` as per the README file to make a `flash1002.bin`.
171+
/// The RP2040 requires an OS linked at `0x1002_0000` and compiled for the
172+
/// `thumbv6m-none-eabi` target. You should therefore use the binary
173+
/// `thumbv6m-none-eabi-flash1002-libneotron_os.bin` from
174+
/// <https://github.com/Neotron-Compute/Neotron-OS/releases>
173175
#[link_section = ".flash_os"]
174176
#[used]
175-
pub static OS_IMAGE: [u8; include_bytes!("flash1002.bin").len()] = *include_bytes!("flash1002.bin");
177+
pub static OS_IMAGE: [u8; include_bytes!("thumbv6m-none-eabi-flash1002-libneotron_os.bin").len()] =
178+
*include_bytes!("thumbv6m-none-eabi-flash1002-libneotron_os.bin");
176179

177180
/// The table of API calls we provide the OS
178181
static API_CALLS: common::Api = common::Api {
@@ -258,8 +261,8 @@ fn main() -> ! {
258261
// Needed by the clock setup
259262
let mut watchdog = hal::watchdog::Watchdog::new(pp.WATCHDOG);
260263

261-
// BIOS_VERSION has a trailing `\0` as that is what the BIOS/OS API requires.
262-
info!("{} starting...", &BIOS_VERSION[0..BIOS_VERSION.len() - 1]);
264+
// VERSION has a trailing `\0` as that is what the BIOS/OS API requires.
265+
info!("Neotron BIOS {} starting...", VERSION.trim_matches('\0'));
263266

264267
// Run at 126 MHz SYS_PLL, 48 MHz, USB_PLL. This is important, we as clock
265268
// the PIO at ÷ 5, to give 25.2 MHz (which is close enough to the 25.175
@@ -824,7 +827,7 @@ fn sign_on() {
824827

825828
tc.move_to(0, 0);
826829

827-
writeln!(&tc, "{}", &BIOS_VERSION[0..BIOS_VERSION.len() - 1]).unwrap();
830+
writeln!(&tc, "Neotron Pico BIOS {}", VERSION.trim_matches('\0')).unwrap();
828831
write!(&tc, "{}", LICENCE_TEXT).unwrap();
829832

830833
let bmc_ver = critical_section::with(|cs| {
@@ -876,7 +879,7 @@ pub extern "C" fn api_version_get() -> common::Version {
876879
/// a Rust string. It is unspecified as to whether the string is located
877880
/// in Flash ROM or RAM (but it's likely to be Flash ROM).
878881
pub extern "C" fn bios_version_get() -> common::ApiString<'static> {
879-
common::ApiString::new(BIOS_VERSION)
882+
common::ApiString::new(VERSION)
880883
}
881884

882885
/// Get information about the Serial ports in the system.
33.6 KB
Binary file not shown.

src/flash1002.txt renamed to src/thumbv6m-none-eabi-flash1002-libneotron_os.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
This is Neotron OS version v0.1.0
2-
See https://github.com/neotron-compute/neotron-os
1+
This is Neotron OS version v0.2.0
2+
3+
Taken from https://github.com/Neotron-Compute/Neotron-OS/releases/tag/v0.2.0
34

45
This program is free software: you can redistribute it and/or modify
56
it under the terms of the GNU General Public License as published by
@@ -12,4 +13,4 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1213
GNU General Public License for more details.
1314

1415
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
along with this program. If not, see <https://www.gnu.org/licenses/>.

0 commit comments

Comments
 (0)