Skip to content

Commit 67dd556

Browse files
committed
Remove OS from build.
Also update instructions so user flashes OS separately.
1 parent 8ff598e commit 67dd556

File tree

4 files changed

+58
-77
lines changed

4 files changed

+58
-77
lines changed

README.md

Lines changed: 37 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -82,65 +82,56 @@ Currently the BIOS uses Core 0 for running the Neotron OS (and application code)
8282

8383
The Neotron BIOS uses the [defmt](https://crates.io/crates/defmt) crate to provide structured logging over the SWD interface. The easiest way to flash and debug your Neotron Pico BIOS is with a second Raspberry Pi Pico, or the official Raspberry Pi Debug Probe.
8484

85-
1. If your BMC has not been programmed, do that first.
85+
1. If your BMC has not been programmed, [do that first](https://github.com/Neotron-Compute/Neotron-BMC/blob/v0.5.2/neotron-bmc-pico/README.md).
8686

87-
2. Connect your *Debugger* Pico to the three *DEBUG* pins on the *Neotron* Pico, following the instructions for your particular debugging device or firmware.
87+
1. Connect your *Debug Probe* to the three *DEBUG* pins on the *Raspberry Pi Pico* fitted to your Neotron Pico, following the instructions for your particular debugging device or firmware.
8888

89-
3. If your *Debugger* Pico was a bare Pi Pico (and not a Debug Probe) then flash it with <https://github.com/raspberrypi/picoprobe> or <https://github.com/majbthrd/DapperMime> firmware (e.g. by copying the UF2 file to the USB Mass Storage device)
89+
1. On your PC, install the [*probe-rs*](https://github.com/probe-rs), a microcontroller flashing tool. See website for instructions.
9090

91-
4. On your PC, install [*probe-rs*](https://github.com/probe-rs), a microcontroller flashing tool.
91+
1. Power on your Neotron Pico into bootloader mode by applying 12V, holding down
92+
the "BOOTSEL" button on the Raspberry Pi Pico and then and tapping the On/Off
93+
button on the Neotron.
9294

93-
```sh
94-
cargo install probe-rs --features=cli
95-
```
95+
If you don't put the Raspberry Pi Pico into bootloader mode then when
96+
`probe-rs` resets the chip after programming, the firmware will detect it has
97+
had an incomplete reset and cause a full reset. This makes the video output
98+
more reliable, but the full reset will immediately disconnect `probe-rs` so
99+
you won't see any log messages. Booting the RP2040 in USB bootloader mode
100+
avoids this issue by making the `probe-rs` triggered reset look more like a
101+
full reset.
96102

97-
5. Build the Neotron OS:
98-
We use the "neotron-flash-1002.ld" linker script to link it at `0x1002_0000`.
103+
1. Flash the BIOS.
99104

100-
```console
101-
user@host ~/neotron-os $ cargo build --bin=flash1002 --release --target=thumbv6m-none-eabi
102-
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
103-
```
105+
1. You can compile from source and flash all-in-one:
104106

105-
6. Power on your Neotron Pico into bootloader mode by applying 12V, holding down
106-
the "BOOTSEL" button on the Raspberry Pi Pico and then and tapping the On/Off
107-
button on the Neotron.
107+
```bash
108+
cargo run --release
109+
```
108110

109-
If you don't put the RP2040 into bootloader mode then when `probe-rs` resets
110-
the chip after programming, the firmware will detect it has had an incomplete
111-
reset and cause a full reset. This makes the video output more reliable, but
112-
the full reset will immediately disconnect `probe-rs` so you won't see any
113-
log messages. Booting the RP2040 in USB bootloader mode avoids this issue by
114-
making the `probe-rs` triggered reset look more like a full reset.
115-
116-
7. Build and load the Neotron BIOS, and view the debug output stream, with `cargo run --release`.
117-
118-
```console
119-
user@host ~/neotron-pico-bios $ DEFMT_LOG=debug cargo run --release
120-
Compiling neotron-pico-bios v0.1.0 (/home/jonathan/Documents/neotron/neotron-pico-bios)
121-
Finished release [optimized + debuginfo] target(s) in 0.76s
122-
Running `probe-rs run --chip RP2040 target/thumbv6m-none-eabi/release/neotron-pico-bios`
123-
(HOST) INFO flashing program (7.30 KiB)
124-
(HOST) INFO success!
125-
────────────────────────────────────────────────────────────────────────────────
126-
INFO Neotron BIOS starting...
127-
└─ neotron_pico_bios::__cortex_m_rt_main @ src/main.rs:79
128-
INFO Clocks OK
129-
└─ neotron_pico_bios::__cortex_m_rt_main @ src/main.rs:102
130-
INFO Pins OK
131-
└─ neotron_pico_bios::__cortex_m_rt_main @ src/main.rs:121
132-
DEBUG Loop...
133-
└─ neotron_pico_bios::__cortex_m_rt_main @ src/main.rs:128
134-
```
135-
136-
You should see your Neotron Pico boot, both over RTT in the `probe-rs` output, and also on the VGA output.
111+
1. You can download the `neotron-pico-bios.elf` file from [Github
112+
Releases](https://github.com/Neotron-Compute/Neotron-Pico-BIOS/releases) and
113+
flash with `probe-rs`:
114+
115+
```bash
116+
probe-rs run --chip RP2040 ~/Downloads/neotron-pico-bios
117+
```
118+
119+
1. You can download the `neotron-pico-bios.uf2` file from [Github
120+
Releases](https://github.com/Neotron-Compute/Neotron-Pico-BIOS/releases) and
121+
flash by copying to the RP2040 bootloader's fake USB Mass Storage Device. You will need to connect a USB cable to the Raspberry Pi Pico's external USB micro-AB port, and ensure that the USB Host Power jumper near the 12V input is NOT fitted.
122+
123+
1. Now when you reset your board, you will see the BIOS splash screen on any
124+
connected VGA display and some start-up tones on any connected PC Speaker. No
125+
OS will be booted, as we haven't flashed the OS yet. Grab a compatible OS
126+
release from <https://github.com/Neotron-Compute/Neotron-OS/releases>. You
127+
need the `flash1002` variant for the Neotron Pico, because the BIOS expects
128+
the OS to live in flash at address `0x1002_0000`.
137129
138130
## Multiple Probes
139131
140132
If you have multiple `probe-rs` compatible probes attached to your computer,
141133
you will receive an error message.
142134
143-
144135
You will need to check what probes are available and edit `.cargo/config.toml` to add the appropriate `--probe VID:PID` argument.
145136
146137
```console
@@ -165,7 +156,7 @@ See [CHANGELOG.md](./CHANGELOG.md)
165156
## Licence
166157
167158
```text
168-
Neotron-Pico-BIOS Copyright (c) Jonathan 'theJPster' Pallant and the Neotron Developers, 2023
159+
Neotron-Pico-BIOS Copyright (c) Jonathan 'theJPster' Pallant and the Neotron Developers, 2024
169160
170161
This program is free software: you can redistribute it and/or modify
171162
it under the terms of the GNU General Public License as published by

src/main.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// -----------------------------------------------------------------------------
1515
// Licence Statement
1616
// -----------------------------------------------------------------------------
17-
// Copyright (c) Jonathan 'theJPster' Pallant and the Neotron Developers, 2023
17+
// Copyright (c) Jonathan 'theJPster' Pallant and the Neotron Developers, 2024
1818
//
1919
// This program is free software: you can redistribute it and/or modify it under
2020
// the terms of the GNU General Public License as published by the Free Software
@@ -64,6 +64,7 @@ use core::{
6464
fmt::Write,
6565
ptr::{addr_of, addr_of_mut},
6666
sync::atomic::{AtomicBool, AtomicU32, Ordering},
67+
u32,
6768
};
6869

6970
// Third Party Stuff
@@ -256,17 +257,6 @@ static HARDWARE: NeoMutex<Option<Hardware>> = NeoMutex::new(None);
256257
/// The pin we use for external interrupt input
257258
static IRQ_PIN: NeoMutex<Option<IrqPin>> = NeoMutex::new(None);
258259

259-
/// This is our Operating System. It must be compiled separately.
260-
///
261-
/// The RP2040 requires an OS linked at `0x1002_0000` and compiled for the
262-
/// `thumbv6m-none-eabi` target. You should therefore use the binary
263-
/// `thumbv6m-none-eabi-flash1002-libneotron_os.bin` from
264-
/// <https://github.com/Neotron-Compute/Neotron-OS/releases>
265-
#[link_section = ".flash_os"]
266-
#[used]
267-
pub static OS_IMAGE: [u8; include_bytes!("thumbv6m-none-eabi-flash1002-libneotron_os.bin").len()] =
268-
*include_bytes!("thumbv6m-none-eabi-flash1002-libneotron_os.bin");
269-
270260
/// Tracks if we have had an IO interrupt.
271261
///
272262
/// Set by the GPIO interrupt routine to reflect the level state of the IRQ input
@@ -526,8 +516,22 @@ fn main() -> ! {
526516
sign_on();
527517

528518
// Now jump to the OS
529-
let code: &common::OsStartFn = unsafe { ::core::mem::transmute(&_flash_os_start) };
530-
code(&API_CALLS);
519+
unsafe {
520+
let entry_fn_addr: *const usize = addr_of!(_flash_os_start) as *const usize;
521+
info!("entry_fn_addr = 0x{:08x}", entry_fn_addr);
522+
let entry_fn = entry_fn_addr.read_volatile();
523+
info!("entry_fn = 0x{:08x}", entry_fn);
524+
if entry_fn != 0xFFFF_FFFF && entry_fn != 0x0000_0000 {
525+
// looks like it's not blank at least - let's jump to it
526+
let code: common::OsStartFn = core::mem::transmute(entry_fn);
527+
code(&API_CALLS);
528+
} else {
529+
// flash looks blank - sit at the splash screen
530+
loop {
531+
cortex_m::asm::wfe();
532+
}
533+
}
534+
}
531535
}
532536

533537
/// Check if the rest of the system appears to be running already.
@@ -583,7 +587,7 @@ fn sign_on() {
583587
static LOGO_ANSI_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/logo.bytes"));
584588
static COPYRIGHT_TEXT: &str = "\
585589
\n\
586-
Copyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2023\n\
590+
Copyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2024\n\
587591
This program is free software under GPL v3 (or later)\n\
588592
You are entitled to the Complete and Corresponding Source for this BIOS\n\
589593
\n\
@@ -702,6 +706,8 @@ fn sign_on() {
702706
countdown -= 1;
703707
}
704708
}
709+
710+
write!(&tc, "Now starting OS (if present)...").unwrap();
705711
}
706712

707713
/// Paint the Core 0 and Core 1 stacks
-117 KB
Binary file not shown.

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)