Skip to content

Commit 8b36b38

Browse files
committed
adjust docu, rustfmt
1 parent 6b842fd commit 8b36b38

File tree

7 files changed

+35
-27
lines changed

7 files changed

+35
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- ### :bulb: Features
44
- add some console log statements in the panic handler that gives a clue of the panic when at least
55
the console could be setup properly before panicing the first time :)
6-
- use Raspberry Mailbox to retrieve clock speed to initialize miniUart with
6+
- use Raspberry Pi Mailbox to retrieve clock speed to initialize miniUart with
77
- ### :detective: Fixes
88
- Fix the path created by the build script pointing to the linker script file. It should not contain a '\\\\'.
99
In addition the examples for the build script to be implementend on consumer side was updated.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ ruspiro-interrupt = { path = "../interrupt", version = "0.3" }
3939
ruspiro_pi3 = [
4040
"ruspiro-mailbox/ruspiro_pi3",
4141
"ruspiro-uart/ruspiro_pi3",
42-
"ruspiro-timer/ruspiro_pi3"
42+
"ruspiro-timer/ruspiro_pi3",
43+
"ruspiro-interrupt/ruspiro_pi3"
4344
]
4445
singlecore = []
4546
with_panic = []

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ This crate provides basic boot code that - when build into a kernel crate - will
88
[![License](https://img.shields.io/crates/l/ruspiro-boot.svg)](https://github.com/RusPiRo/ruspiro-boot#license)
99

1010
## Hint
11-
1211
The usage of this crate does only make sense when building a Raspberry Pi 3 bare metal kernel. The
1312
baremetal bootstrapping provided by this crate can be build for either Aarch32 or Aarch64 target
1413
architectures. It has been verified to cross compile from a Windows host machine successfully for
1514
both architectures and the execution is tested on a Raspberry Pi 3 B+.
1615

16+
## Features
17+
Feature | Purpose
18+
-------------------|--------------------------
19+
``with_panic`` | Implement a default panic handler
20+
``singlecore`` | Keep all cores except one in a "parked" state so the runtime only uses a single core.
21+
``ruspiro_pi3`` | This is passed to the dependend crates to ensure they will be build properly for this target device.
22+
1723
## Usage
1824
To use this crate simply add the following lines to your ``Cargo.toml`` file:
1925
(hint: git dependency as long as the crate is not registered at crates.io)
@@ -29,13 +35,6 @@ extern crate ruspiro_boot;
2935
The usage of `extern crate` is mandatory to ensure the boot strapping is properly linked into the
3036
final binary.
3137

32-
## Features
33-
Feature | Purpose
34-
-------------------|--------------------------
35-
``with_panic`` | Implement a default panic handler
36-
``singlecore`` | Keep all cores except one in a "parked" state so the runtime only uses a single core.
37-
``ruspiro_pi3`` | This is passed to the dependend crates to ensure they will be build properly for this target device.
38-
3938
To successfully build a bare metal binary using this crate for the boot strapping part it is **highly recomended** to use the linker script provided by this crate. Based on the target architecture to be built it is either [link32.ld](link32.ld) or [link64.ld](link64.ld).
4039
To conviniently refer to the linker scripts contained in this crate it's recommended to use a specific build script in your project that copies the required file to your current project folder and could then be referred to with the ``RUSTFLAG`` ``-C link-arg=-T./link<aarch>.ld``.
4140
The build script is a simple ``build.rs`` rust file in your project root with the following contents:

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ fn main() {
4343
.compile("excvector");
4444
// print the linker file location of the boot crate to the env-variables
4545
println!("cargo:linkerscript={}/link64.ld", script_location.display());
46-
46+
4747
println!("cargo:rerun-if-changed=link64.ld");
4848
println!("cargo:rerun-if-changed=src/asm/aarch64/bootstrap.S");
4949
println!("cargo:rerun-if-changed=src/asm/aarch64/exceptionvector.S");
5050
}
51-
}
51+
}
5252
}

makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,31 @@ all32: export RUSTFLAGS = -C linker=arm-eabi-gcc.exe -C target-cpu=cortex-a53 -C
1414
all32: export CC = arm-eabi-gcc.exe
1515
all32: export AR = arm-eabi-ar.exe
1616
all32:
17-
cargo xbuild --target armv7-unknown-linux-gnueabihf --release --lib --target-dir ./target/ --features ruspiro_pi3
17+
cargo xbuild --target armv7-unknown-linux-gnueabihf --release --lib --features ruspiro_pi3
1818

1919

2020
all64: export CFLAGS = -march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53
2121
all64: export RUSTFLAGS = -C linker=aarch64-elf-gcc.exe -C target-cpu=cortex-a53 -C target-feature=+strict-align,+a53,+fp-armv8,+neon -C link-arg=-nostartfiles -C opt-level=3 -C debuginfo=0 -C link-arg=-T./link64.ld
2222
all64: export CC = aarch64-elf-gcc.exe
2323
all64: export AR = aarch64-elf-ar.exe
2424
all64:
25-
cargo xbuild --target aarch64-unknown-linux-gnu --release --lib --target-dir ./target/ --features ruspiro_pi3
25+
cargo xbuild --target aarch64-unknown-linux-gnu --release --lib --features ruspiro_pi3
2626

2727

2828
doc: export CFLAGS = -march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53
2929
doc: export RUSTFLAGS = -C linker=aarch64-elf-gcc.exe -C target-cpu=cortex-a53 -C target-feature=+strict-align,+a53,+fp-armv8,+neon -C link-arg=-nostartfiles -C opt-level=3 -C debuginfo=0
3030
doc: export CC = aarch64-elf-gcc.exe
3131
doc: export AR = aarch64-elf-ar.exe
3232
doc:
33-
cargo doc --no-deps --target aarch64-unknown-linux-gnu --release --open
33+
cargo doc --no-deps --target aarch64-unknown-linux-gnu --features ruspiro_pi3,with_panic --release --open
3434

3535
clippy: export CFLAGS = -march=armv8-a -Wall -O3 -nostdlib -nostartfiles -ffreestanding -mtune=cortex-a53
3636
clippy: export RUSTFLAGS = -C linker=aarch64-elf-gcc.exe -C target-cpu=cortex-a53 -C target-feature=+strict-align,+a53,+fp-armv8,+neon -C link-arg=-nostartfiles -C opt-level=3 -C debuginfo=0
3737
clippy: export CC = aarch64-elf-gcc.exe
3838
clippy: export AR = aarch64-elf-ar.exe
3939
clippy:
4040
# run clippy for this crate using custom target
41-
cargo xclippy --target aarch64-unknown-linux-gnu --features ruspiro_pi3
41+
cargo xclippy --target aarch64-unknown-linux-gnu --release --features ruspiro_pi3
4242

4343
clean:
4444
cargo clean

src/lib.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,17 @@
4343
//!
4444
//! # Features
4545
//!
46-
//! - `with_panic` will ensure that a default panic handler is implemented.
47-
//! - `singlecore` enforces the compilation of the single core boot sequence. Only the main core 0 is then running.
48-
//! - `ruspiro_pi3` is passed to dependent crates to properly build them for the desired Raspberry Pi version
46+
//! Feature | Description
47+
//! ----------------|------------------------------------------------------------------------------
48+
//! ``ruspiro_pi3`` | Passed to dependent crates to ensure proper MMIO base memory address for Raspberry Pi 3 when accessing the peripherals
49+
//! ``singlecore`` | Enforces the compilation of the single core boot sequence. Only the main core 0 is then running.
50+
//! ``with_panic`` | Compiles a default simple panic handler into the crate. This will hang the core that paniced. No unwinding is performed
4951
//!
50-
//! To successfully build a bare metal binary using this crate for the boot strapping part it is
51-
//! **highly recomended** to use the linker script provided by this crate. Based on the target
52-
//! architecture to be built it is either [link32.ld](link32.ld) or [link64.ld](link64.ld). To
53-
//! conviniently refer to the linker scripts contained in this crate it's recommended to use a
52+
//! ## Hint:
53+
//! To successfully build a bare metal binary/kernel that depends on this one to perform the boot
54+
//! strapping part it is **highly recomended** to use the linker script provided by this crate. Based
55+
//! on the target architecture to be built it is either [link32.ld](link32.ld) or [link64.ld](link64.ld).
56+
//! To conviniently refer to the linker scripts contained in this crate it's recommended to use a
5457
//! specific build script in your project that copies the required file to your current project
5558
//! folder and could then be referred to with the `RUSTFLAG` parameter `-C link-arg=-T./link<aarch>.ld`.
5659
//! The build script is a simple `build.rs` rust file in your project root with the following
@@ -96,10 +99,10 @@ mod stubs;
9699
use ruspiro_cache as cache;
97100

98101
use ruspiro_console::*;
102+
use ruspiro_interrupt::IRQ_MANAGER;
99103
use ruspiro_mailbox::*;
100104
use ruspiro_timer as timer;
101105
use ruspiro_uart::Uart1;
102-
use ruspiro_interrupt::IRQ_MANAGER;
103106

104107
extern "C" {
105108
fn __kernel_startup(core: u32);
@@ -141,7 +144,7 @@ fn __rust_entry(core: u32) -> ! {
141144
// do some arbitrary sleep here to let the uart send the initial greetings before running
142145
// the kernel, which may initialize the UART for it's own purpose and this would break
143146
// this transfer...
144-
timer::sleep(10000);
147+
timer::sleep(timer::Useconds(10000));
145148

146149
// configure interrupt manager for further usage
147150
IRQ_MANAGER.take_for(|mgr| mgr.initialize());

src/panic.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@ fn panic(info: &PanicInfo) -> ! {
1818
// Panicing is undefined behaviour so we are unable to recover from one into a valid state.
1919
// Halt the panicing core and safely do nothing!
2020
if let Some(location) = info.location() {
21-
ruspiro_console::error!("PANIC at {:?}, {}:{}", location.file(), location.line(), location.column());
21+
ruspiro_console::error!(
22+
"PANIC at {:?}, {}:{}",
23+
location.file(),
24+
location.line(),
25+
location.column()
26+
);
2227
} else {
2328
ruspiro_console::error!("PANIC somewhere!");
2429
}
25-
30+
2631
loop {}
2732
}
2833

0 commit comments

Comments
 (0)