Default to externally powered RPis

Addresses issues in #86
pull/99/head
Andre Richter 3 years ago
parent dad68abdc6
commit 18c7259c60
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -49,7 +49,7 @@ init_uart_clock=48000000
- [bootcode.bin](https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin) - [bootcode.bin](https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin)
- [fixup.dat](https://github.com/raspberrypi/firmware/raw/master/boot/fixup.dat) - [fixup.dat](https://github.com/raspberrypi/firmware/raw/master/boot/fixup.dat)
- [start.elf](https://github.com/raspberrypi/firmware/raw/master/boot/start.elf) - [start.elf](https://github.com/raspberrypi/firmware/raw/master/boot/start.elf)
4. Run `make` and copy the [kernel8.img](kernel8.img) onto the SD card. 4. Run `make`.
### Pi 4 ### Pi 4
@ -57,15 +57,15 @@ init_uart_clock=48000000
- [fixup4.dat](https://github.com/raspberrypi/firmware/raw/master/boot/fixup4.dat) - [fixup4.dat](https://github.com/raspberrypi/firmware/raw/master/boot/fixup4.dat)
- [start4.elf](https://github.com/raspberrypi/firmware/raw/master/boot/start4.elf) - [start4.elf](https://github.com/raspberrypi/firmware/raw/master/boot/start4.elf)
- [bcm2711-rpi-4-b.dtb](https://github.com/raspberrypi/firmware/raw/master/boot/bcm2711-rpi-4-b.dtb) - [bcm2711-rpi-4-b.dtb](https://github.com/raspberrypi/firmware/raw/master/boot/bcm2711-rpi-4-b.dtb)
4. Run `BSP=rpi4 make` and copy the [kernel8.img](kernel8.img) onto the SD card. 4. Run `BSP=rpi4 make`.
_**Note**: Should it not work on your RPi4, try renaming `start4.elf` to `start.elf` (without the 4) _**Note**: Should it not work on your RPi4, try renaming `start4.elf` to `start.elf` (without the 4)
on the SD card._ on the SD card._
### Common again ### Common again
5. Insert the SD card into the RPi and connect the USB serial to your host PC. 5. Copy the `kernel8.img` onto the SD card and insert it back into the RPi.
- Wiring diagram at [top-level README](../README.md#usb-serial).
6. Run the `miniterm` target, which opens the UART device on the host: 6. Run the `miniterm` target, which opens the UART device on the host:
```console ```console
@ -81,14 +81,16 @@ $ make miniterm
$ DEV_SERIAL=/dev/tty.usbserial-0001 make miniterm $ DEV_SERIAL=/dev/tty.usbserial-0001 make miniterm
``` ```
7. Hit <kbd>Enter</kbd> after seeing "`Connected`" to kick off the kernel boot process and observe 7. Connect the USB serial to your host PC.
the output: - Wiring diagram at [top-level README](../README.md#-usb-serial-output).
- Make sure that you **DID NOT** connect the power pin of the USB serial. Only RX/TX and GND.
8. Connect the RPi to the (USB) power cable and observe the output:
```console ```console
Miniterm 1.0 Miniterm 1.0
[MT] ⏳ Waiting for /dev/ttyUSB0
[MT] ✅ Connected [MT] ✅ Serial connected
[0] Booting on: Raspberry Pi 3 [0] Booting on: Raspberry Pi 3
[1] Drivers loaded: [1] Drivers loaded:
1. BCM GPIO 1. BCM GPIO
@ -1212,7 +1214,7 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
mod memory; mod memory;
mod panic_wait; mod panic_wait;
mod print; mod print;
@@ -116,16 +126,53 @@ @@ -116,16 +126,46 @@
/// # Safety /// # Safety
/// ///
/// - Only a single core must be active and running this function. /// - Only a single core must be active and running this function.
@ -1239,13 +1241,6 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
+ use console::interface::All; + use console::interface::All;
+ use driver::interface::DriverManager; + use driver::interface::DriverManager;
+ +
+ // Wait for user to hit Enter.
+ loop {
+ if bsp::console::console().read_char() == '\n' {
+ break;
+ }
+ }
+
+ println!("[0] Booting on: {}", bsp::board_name()); + println!("[0] Booting on: {}", bsp::board_name());
+ +
+ println!("[1] Drivers loaded:"); + println!("[1] Drivers loaded:");

@ -147,13 +147,6 @@ fn kernel_main() -> ! {
use console::interface::All; use console::interface::All;
use driver::interface::DriverManager; use driver::interface::DriverManager;
// Wait for user to hit Enter.
loop {
if bsp::console::console().read_char() == '\n' {
break;
}
}
println!("[0] Booting on: {}", bsp::board_name()); println!("[0] Booting on: {}", bsp::board_name());
println!("[1] Drivers loaded:"); println!("[1] Drivers loaded:");

@ -25,10 +25,13 @@ Our chainloader is called `MiniLoad` and is inspired by [raspbootin].
You can try it with this tutorial already: You can try it with this tutorial already:
1. Depending on your target hardware:`make` or `BSP=rpi4 make`. 1. Depending on your target hardware:`make` or `BSP=rpi4 make`.
2. Copy `kernel8.img` to the SD card. 1. Copy `kernel8.img` to the SD card.
3. Execute `make chainboot` or `BSP=rpi4 make chainboot`. 1. Execute `make chainboot` or `BSP=rpi4 make chainboot`.
4. Now plug in the USB Serial. 1. Connect the USB serial to your host PC.
5. Observe the loader fetching a kernel over `UART`: - Wiring diagram at [top-level README](../README.md#-usb-serial-output).
- Make sure that you **DID NOT** connect the power pin of the USB serial. Only RX/TX and GND.
1. Connect the RPi to the (USB) power cable.
1. Observe the loader fetching a kernel over `UART`:
> ❗ **NOTE**: By default, `make chainboot` tries to connect to `/dev/ttyUSB0`. > ❗ **NOTE**: By default, `make chainboot` tries to connect to `/dev/ttyUSB0`.
> Should the USB serial on your system have a different name, you have to provide it explicitly. For > Should the USB serial on your system have a different name, you have to provide it explicitly. For
@ -44,7 +47,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -53,7 +57,7 @@ Minipush 1.0
Raspberry Pi 3 Raspberry Pi 3
[ML] Requesting binary [ML] Requesting binary
[MP] ⏩ Pushing 7 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00 [MP] ⏩ Pushing 6 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[0] Booting on: Raspberry Pi 3 [0] Booting on: Raspberry Pi 3
@ -429,18 +433,23 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
mod runtime_init; mod runtime_init;
mod synchronization; mod synchronization;
@@ -144,35 +148,52 @@ @@ -144,28 +148,52 @@
/// The main function running after the early init. /// The main function running after the early init.
fn kernel_main() -> ! { fn kernel_main() -> ! {
+ use bsp::console::console; + use bsp::console::console;
use console::interface::All; use console::interface::All;
- use driver::interface::DriverManager; - use driver::interface::DriverManager;
-
- println!("[0] Booting on: {}", bsp::board_name());
- // Wait for user to hit Enter. - println!("[1] Drivers loaded:");
- loop { - for (i, driver) in bsp::driver::driver_manager()
- if bsp::console::console().read_char() == '\n' { - .all_device_drivers()
- break; - .iter()
- .enumerate()
- {
- println!(" {}. {}", i + 1, driver.compatible());
+ println!(" __ __ _ _ _ _ "); + println!(" __ __ _ _ _ _ ");
+ println!("| \\/ (_)_ _ (_) | ___ __ _ __| |"); + println!("| \\/ (_)_ _ (_) | ___ __ _ __| |");
+ println!("| |\\/| | | ' \\| | |__/ _ \\/ _` / _` |"); + println!("| |\\/| | | ' \\| | |__/ _ \\/ _` / _` |");
@ -458,8 +467,17 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
+ // Notify `Minipush` to send the binary. + // Notify `Minipush` to send the binary.
+ for _ in 0..3 { + for _ in 0..3 {
+ console().write_char(3 as char); + console().write_char(3 as char);
+ } }
+
- println!(
- "[2] Chars written: {}",
- bsp::console::console().chars_written()
- );
- println!("[3] Echoing input now");
-
- loop {
- let c = bsp::console::console().read_char();
- bsp::console::console().write_char(c);
+ // Read the binary's size. + // Read the binary's size.
+ let mut size: u32 = u32::from(console().read_char() as u8); + let mut size: u32 = u32::from(console().read_char() as u8);
+ size |= u32::from(console().read_char() as u8) << 8; + size |= u32::from(console().read_char() as u8) << 8;
@ -475,34 +493,15 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
+ // Read the kernel byte by byte. + // Read the kernel byte by byte.
+ for i in 0..size { + for i in 0..size {
+ core::ptr::write_volatile(kernel_addr.offset(i as isize), console().read_char() as u8) + core::ptr::write_volatile(kernel_addr.offset(i as isize), console().read_char() as u8)
} + }
} }
+
- println!("[0] Booting on: {}", bsp::board_name());
+ println!("[ML] Loaded! Executing the payload now\n"); + println!("[ML] Loaded! Executing the payload now\n");
+ console().flush(); + console().flush();
+
- println!("[1] Drivers loaded:");
- for (i, driver) in bsp::driver::driver_manager()
- .all_device_drivers()
- .iter()
- .enumerate()
- {
- println!(" {}. {}", i + 1, driver.compatible());
- }
+ // Use black magic to get a function pointer. + // Use black magic to get a function pointer.
+ let kernel: fn() -> ! = unsafe { core::mem::transmute(kernel_addr) }; + let kernel: fn() -> ! = unsafe { core::mem::transmute(kernel_addr) };
+
- println!(
- "[2] Chars written: {}",
- bsp::console::console().chars_written()
- );
- println!("[3] Echoing input now");
-
- loop {
- let c = bsp::console::console().read_char();
- bsp::console::console().write_char(c);
- }
+ // Jump to loaded kernel! + // Jump to loaded kernel!
+ kernel() + kernel()
} }
@ -583,4 +582,18 @@ diff -uNr 06_drivers_gpio_uart/src/runtime_init.rs 07_uart_chainloader/src/runti
pub unsafe fn runtime_init() -> ! { pub unsafe fn runtime_init() -> ! {
zero_bss(); zero_bss();
diff -uNr 06_drivers_gpio_uart/update.sh 07_uart_chainloader/update.sh
--- 06_drivers_gpio_uart/update.sh
+++ 07_uart_chainloader/update.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+cd ../06_drivers_gpio_uart
+BSP=rpi4 make
+cp kernel8.img ../07_uart_chainloader/demo_payload_rpi4.img
+make
+cp kernel8.img ../07_uart_chainloader/demo_payload_rpi3.img
+rm kernel8.img
``` ```

@ -0,0 +1,8 @@
#!/usr/bin/env bash
cd ../06_drivers_gpio_uart
BSP=rpi4 make
cp kernel8.img ../07_uart_chainloader/demo_payload_rpi4.img
make
cp kernel8.img ../07_uart_chainloader/demo_payload_rpi3.img
rm kernel8.img

@ -15,7 +15,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -24,19 +25,18 @@ Minipush 1.0
Raspberry Pi 3 Raspberry Pi 3
[ML] Requesting binary [ML] Requesting binary
[MP] ⏩ Pushing 12 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00 [MP] ⏩ Pushing 11 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 0.586140] Booting on: Raspberry Pi 3 [ 0.543941] Booting on: Raspberry Pi 3
[ 0.587227] Architectural timer resolution: 52 ns [ 0.545059] Architectural timer resolution: 52 ns
[ 0.589530] Drivers loaded: [ 0.547358] Drivers loaded:
[ 0.590876] 1. BCM GPIO [ 0.548703] 1. BCM GPIO
[ 0.592309] 2. BCM PL011 UART [ 0.550135] 2. BCM PL011 UART
[W 0.594005] Spin duration smaller than architecturally supported, skipping [W 0.551828] Spin duration smaller than architecturally supported, skipping
[ 0.597392] Spinning for 1 second [ 0.555212] Spinning for 1 second
[ 1.599001] Spinning for 1 second [ 1.556818] Spinning for 1 second
[ 2.599872] Spinning for 1 second [ 2.557690] Spinning for 1 second
``` ```
## Diff to previous ## Diff to previous
@ -754,4 +754,17 @@ diff -uNr 07_uart_chainloader/src/time.rs 08_timestamps/src/time.rs
+ } + }
+} +}
diff -uNr 07_uart_chainloader/update.sh 08_timestamps/update.sh
--- 07_uart_chainloader/update.sh
+++ 08_timestamps/update.sh
@@ -1,8 +0,0 @@
-#!/usr/bin/env bash
-
-cd ../06_drivers_gpio_uart
-BSP=rpi4 make
-cp kernel8.img ../07_uart_chainloader/demo_payload_rpi4.img
-make
-cp kernel8.img ../07_uart_chainloader/demo_payload_rpi3.img
-rm kernel8.img
``` ```

@ -157,7 +157,8 @@ $ make jtagboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -166,10 +167,10 @@ Minipush 1.0
Raspberry Pi 3 Raspberry Pi 3
[ML] Requesting binary [ML] Requesting binary
[MP] ⏩ Pushing 8 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00 [MP] ⏩ Pushing 7 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 0.372110] Parking CPU core. Please connect over JTAG now. [ 0.394532] Parking CPU core. Please connect over JTAG now.
``` ```
It is important to keep the USB serial connected and the terminal with the `jtagboot` open and It is important to keep the USB serial connected and the terminal with the `jtagboot` open and

@ -192,7 +192,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -201,22 +202,22 @@ Minipush 1.0
Raspberry Pi 3 Raspberry Pi 3
[ML] Requesting binary [ML] Requesting binary
[MP] ⏩ Pushing 15 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00 [MP] ⏩ Pushing 13 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 0.703812] Booting on: Raspberry Pi 3 [ 0.637617] Booting on: Raspberry Pi 3
[ 0.704900] Current privilege level: EL1 [ 0.638737] Current privilege level: EL1
[ 0.706811] Exception handling state: [ 0.640645] Exception handling state:
[ 0.708592] Debug: Masked [ 0.642424] Debug: Masked
[ 0.710156] SError: Masked [ 0.643986] SError: Masked
[ 0.711719] IRQ: Masked [ 0.645548] IRQ: Masked
[ 0.713283] FIQ: Masked [ 0.647110] FIQ: Masked
[ 0.714848] Architectural timer resolution: 52 ns [ 0.648672] Architectural timer resolution: 52 ns
[ 0.717149] Drivers loaded: [ 0.650971] Drivers loaded:
[ 0.718496] 1. BCM GPIO [ 0.652316] 1. BCM GPIO
[ 0.719929] 2. BCM PL011 UART [ 0.653748] 2. BCM PL011 UART
[ 0.721623] Timer test, spinning for 1 second [ 0.655440] Timer test, spinning for 1 second
[ 1.723753] Echoing input now [ 1.657567] Echoing input now
``` ```
## Diff to previous ## Diff to previous

@ -264,7 +264,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -276,24 +277,24 @@ Minipush 1.0
[MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02 [MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 3.085343] Booting on: Raspberry Pi 3 [ 3.175017] Booting on: Raspberry Pi 3
[ 3.086427] MMU online. Special regions: [ 3.176100] MMU online. Special regions:
[ 3.088339] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data [ 3.178009] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
[ 3.092422] 0x1fff0000 - 0x1fffffff | 64 KiB | Dev RW PXN | Remapped Device MMIO [ 3.182088] 0x1fff0000 - 0x1fffffff | 64 KiB | Dev RW PXN | Remapped Device MMIO
[ 3.096375] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO [ 3.186036] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
[ 3.099937] Current privilege level: EL1 [ 3.189594] Current privilege level: EL1
[ 3.101848] Exception handling state: [ 3.191502] Exception handling state:
[ 3.103629] Debug: Masked [ 3.193281] Debug: Masked
[ 3.105192] SError: Masked [ 3.194843] SError: Masked
[ 3.106756] IRQ: Masked [ 3.196405] IRQ: Masked
[ 3.108320] FIQ: Masked [ 3.197967] FIQ: Masked
[ 3.109884] Architectural timer resolution: 52 ns [ 3.199529] Architectural timer resolution: 52 ns
[ 3.112186] Drivers loaded: [ 3.201828] Drivers loaded:
[ 3.113532] 1. BCM GPIO [ 3.203173] 1. BCM GPIO
[ 3.114966] 2. BCM PL011 UART [ 3.204605] 2. BCM PL011 UART
[ 3.116660] Timer test, spinning for 1 second [ 3.206297] Timer test, spinning for 1 second
[ !!! ] Writing through the remapped UART at 0x1FFF_1000 [ !!! ] Writing through the remapped UART at 0x1FFF_1000
[ 4.120828] Echoing input now [ 4.210458] Echoing input now
``` ```
## Diff to previous ## Diff to previous

@ -399,7 +399,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -411,29 +412,29 @@ Minipush 1.0
[MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02 [MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 3.006343] Booting on: Raspberry Pi 3 [ 3.090618] Booting on: Raspberry Pi 3
[ 3.007428] MMU online. Special regions: [ 3.091701] MMU online. Special regions:
[ 3.009339] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data [ 3.093610] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
[ 3.013422] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO [ 3.097688] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
[ 3.016985] Current privilege level: EL1 [ 3.101246] Current privilege level: EL1
[ 3.018895] Exception handling state: [ 3.103155] Exception handling state:
[ 3.020676] Debug: Masked [ 3.104934] Debug: Masked
[ 3.022240] SError: Masked [ 3.106496] SError: Masked
[ 3.023804] IRQ: Masked [ 3.108058] IRQ: Masked
[ 3.025368] FIQ: Masked [ 3.109619] FIQ: Masked
[ 3.026931] Architectural timer resolution: 52 ns [ 3.111181] Architectural timer resolution: 52 ns
[ 3.029234] Drivers loaded: [ 3.113481] Drivers loaded:
[ 3.030580] 1. BCM GPIO [ 3.114826] 1. BCM GPIO
[ 3.032014] 2. BCM PL011 UART [ 3.116257] 2. BCM PL011 UART
[ 3.033708] Timer test, spinning for 1 second [ 3.117950] Timer test, spinning for 1 second
[ 4.035837] [ 4.120076]
[ 4.035841] Trying to write to address 8 GiB... [ 4.120079] Trying to write to address 8 GiB...
[ 4.038006] ************************************************ [ 4.122242] ************************************************
[ 4.040785] Whoa! We recovered from a synchronous exception! [ 4.125018] Whoa! We recovered from a synchronous exception!
[ 4.043565] ************************************************ [ 4.127795] ************************************************
[ 4.046345] [ 4.130571]
[ 4.047040] Let's try again [ 4.131266] Let's try again
[ 4.048387] Trying to write to address 9 GiB... [ 4.132611] Trying to write to address 9 GiB...
Kernel panic: Kernel panic:
@ -442,7 +443,7 @@ FAR_EL1: 0x0000000240000000
ESR_EL1: 0x96000004 ESR_EL1: 0x96000004
Exception Class (EC) : 0x25 - Data Abort, current EL Exception Class (EC) : 0x25 - Data Abort, current EL
Instr Specific Syndrome (ISS): 0x4 Instr Specific Syndrome (ISS): 0x4
ELR_EL1: 0x0000000000080db4 ELR_EL1: 0x0000000000081454
SPSR_EL1: 0x600003c5 SPSR_EL1: 0x600003c5
Flags: Flags:
Negative (N): Not set Negative (N): Not set
@ -457,22 +458,22 @@ SPSR_EL1: 0x600003c5
Illegal Execution State (IL): Not set Illegal Execution State (IL): Not set
General purpose register: General purpose register:
x0 : 0x0000000000000000 x1 : 0x00000000000858f6 x0 : 0x0000000000000000 x1 : 0x0000000000085726
x2 : 0x0000000000000026 x3 : 0x0000000000082a0c x2 : 0x0000000000000026 x3 : 0x0000000000083bf0
x4 : 0x000000000007fc7c x5 : 0x0000000000000003 x4 : 0x0000000000000003 x5 : 0xfb4f101900000000
x6 : 0x0000000000000000 x7 : 0x7f91bc052b2b0208 x6 : 0x0000000000000000 x7 : 0x7e9198052b2b0200
x8 : 0x0000000240000000 x9 : 0x00000000000858f6 x8 : 0x0000000240000000 x9 : 0x000000003f201000
x10: 0x000000000000041d x11: 0x000000003f201000 x10: 0x0000000000000019 x11: 0x0000000000000000
x12: 0x0000000000000019 x13: 0x000000000007fc7d x12: 0x0000000000000006 x13: 0x0000000000000031
x14: 0x000000000007fdc8 x15: 0x0000000000000040 x14: 0x000000000007fc2d x15: 0x0000000000000000
x16: 0x0000000000000000 x17: 0x0000000000000040 x16: 0x0000000000000040 x17: 0xb557f006f276cfb6
x18: 0x9e06782800000028 x19: 0x000000003b9aca00 x18: 0x0000000000000003 x19: 0x0000000000090008
x20: 0x00000000000003e8 x21: 0x0000000000082f58 x20: 0x0000000000085510 x21: 0x000000003b9aca00
x22: 0x00000000000830cc x23: 0x0000000000090008 x22: 0x00000000000003e8 x23: 0x000000000008160c
x24: 0x00000000000f4240 x25: 0x0000000000085248 x24: 0x0000000000082264 x25: 0x00000000000f4240
x26: 0x00000000000856e0 x27: 0x00000000000857c0 x26: 0xffffffffc4653600 x27: 0x00000000000855f0
x28: 0x00000000000830cc x29: 0x0000000000085530 x28: 0x0000000000083f84 x29: 0x0000000000086810
lr : 0x0000000000080da8 lr : 0x0000000000081448
``` ```
## Diff to previous ## Diff to previous

@ -665,7 +665,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -677,25 +678,25 @@ Minipush 1.0
[MP] ⏩ Pushing 66 KiB ========================================🦀 100% 33 KiB/s Time: 00:00:02 [MP] ⏩ Pushing 66 KiB ========================================🦀 100% 33 KiB/s Time: 00:00:02
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 3.134937] Booting on: Raspberry Pi 3 [ 3.203172] Booting on: Raspberry Pi 3
[ 3.136023] MMU online. Special regions: [ 3.204255] MMU online. Special regions:
[ 3.137934] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data [ 3.206164] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
[ 3.142017] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO [ 3.210242] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
[ 3.145579] Current privilege level: EL1 [ 3.213800] Current privilege level: EL1
[ 3.147490] Exception handling state: [ 3.215709] Exception handling state:
[ 3.149271] Debug: Masked [ 3.217487] Debug: Masked
[ 3.150835] SError: Masked [ 3.219049] SError: Masked
[ 3.152398] IRQ: Unmasked [ 3.220611] IRQ: Unmasked
[ 3.154049] FIQ: Masked [ 3.222260] FIQ: Masked
[ 3.155613] Architectural timer resolution: 52 ns [ 3.223822] Architectural timer resolution: 52 ns
[ 3.157915] Drivers loaded: [ 3.226121] Drivers loaded:
[ 3.159262] 1. BCM GPIO [ 3.227466] 1. BCM GPIO
[ 3.160695] 2. BCM PL011 UART [ 3.228898] 2. BCM PL011 UART
[ 3.162389] 3. BCM Interrupt Controller [ 3.230590] 3. BCM Interrupt Controller
[ 3.164518] Registered IRQ handlers: [ 3.232716] Registered IRQ handlers:
[ 3.166255] Peripheral handler: [ 3.234451] Peripheral handler:
[ 3.168038] 57. BCM PL011 UART [ 3.236232] 57. BCM PL011 UART
[ 3.170078] Echoing input now [ 3.238269] Echoing input now
``` ```
Raspberry Pi 4: Raspberry Pi 4:
@ -706,7 +707,8 @@ $ BSP=rpi4 make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -718,25 +720,25 @@ Minipush 1.0
[MP] ⏩ Pushing 73 KiB ========================================🦀 100% 24 KiB/s Time: 00:00:03 [MP] ⏩ Pushing 73 KiB ========================================🦀 100% 24 KiB/s Time: 00:00:03
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 3.413865] Booting on: Raspberry Pi 4 [ 3.486234] Booting on: Raspberry Pi 4
[ 3.414255] MMU online. Special regions: [ 3.486623] MMU online. Special regions:
[ 3.416166] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data [ 3.488532] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
[ 3.420249] 0xfe000000 - 0xff84ffff | 24 MiB | Dev RW PXN | Device MMIO [ 3.492610] 0xfe000000 - 0xff84ffff | 24 MiB | Dev RW PXN | Device MMIO
[ 3.423811] Current privilege level: EL1 [ 3.496167] Current privilege level: EL1
[ 3.425722] Exception handling state: [ 3.498076] Exception handling state:
[ 3.427503] Debug: Masked [ 3.499855] Debug: Masked
[ 3.429067] SError: Masked [ 3.501417] SError: Masked
[ 3.430630] IRQ: Unmasked [ 3.502979] IRQ: Unmasked
[ 3.432281] FIQ: Masked [ 3.504628] FIQ: Masked
[ 3.433845] Architectural timer resolution: 18 ns [ 3.506189] Architectural timer resolution: 18 ns
[ 3.436147] Drivers loaded: [ 3.508489] Drivers loaded:
[ 3.437494] 1. BCM GPIO [ 3.509834] 1. BCM GPIO
[ 3.438927] 2. BCM PL011 UART [ 3.511266] 2. BCM PL011 UART
[ 3.440621] 3. GICv2 (ARM Generic Interrupt Controller v2) [ 3.512958] 3. GICv2 (ARM Generic Interrupt Controller v2)
[ 3.443575] Registered IRQ handlers: [ 3.515908] Registered IRQ handlers:
[ 3.445312] Peripheral handler: [ 3.517643] Peripheral handler:
[ 3.447096] 153. BCM PL011 UART [ 3.519425] 153. BCM PL011 UART
[ 3.449136] Echoing input now [ 3.521463] Echoing input now
``` ```
## Diff to previous ## Diff to previous

@ -244,7 +244,8 @@ $ make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -256,18 +257,18 @@ Minipush 1.0
[MP] ⏩ Pushing 67 KiB ========================================🦀 100% 33 KiB/s Time: 00:00:02 [MP] ⏩ Pushing 67 KiB ========================================🦀 100% 33 KiB/s Time: 00:00:02
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 3.041355] Booting on: Raspberry Pi 3 [ 3.064756] Booting on: Raspberry Pi 3
[ 3.042438] MMU online: [ 3.065839] MMU online:
[ 3.043609] ----------------------------------------------------------------------------------------------------------------- [ 3.067010] -----------------------------------------------------------------------------------------------------------------
[ 3.049466] Virtual Physical Size Attr Entity [ 3.072868] Virtual Physical Size Attr Entity
[ 3.055323] ----------------------------------------------------------------------------------------------------------------- [ 3.078725] -----------------------------------------------------------------------------------------------------------------
[ 3.061183] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack [ 3.084585] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack
[ 3.066476] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data [ 3.089877] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data
[ 3.071812] 0x000090000..0x0001AFFFF --> 0x000090000..0x0001AFFFF | 1 MiB | C RW XN | Kernel data and bss [ 3.095213] 0x000090000..0x0001BFFFF --> 0x000090000..0x0001BFFFF | 1 MiB | C RW XN | Kernel data and bss
[ 3.076975] 0x1F0000000..0x1F000FFFF --> 0x03F200000..0x03F20FFFF | 64 KiB | Dev RW XN | BCM GPIO [ 3.100376] 0x1F0000000..0x1F000FFFF --> 0x03F200000..0x03F20FFFF | 64 KiB | Dev RW XN | BCM GPIO
[ 3.081658] | BCM PL011 UART [ 3.105060] | BCM PL011 UART
[ 3.086606] 0x1F0010000..0x1F001FFFF --> 0x03F000000..0x03F00FFFF | 64 KiB | Dev RW XN | BCM Peripheral Interrupt Controller [ 3.110008] 0x1F0010000..0x1F001FFFF --> 0x03F000000..0x03F00FFFF | 64 KiB | Dev RW XN | BCM Peripheral Interrupt Controller
[ 3.092462] ----------------------------------------------------------------------------------------------------------------- [ 3.115863] -----------------------------------------------------------------------------------------------------------------
``` ```
Raspberry Pi 4: Raspberry Pi 4:
@ -278,7 +279,8 @@ $ BSP=rpi4 make chainboot
Minipush 1.0 Minipush 1.0
[MP] ⏳ Waiting for /dev/ttyUSB0 [MP] ⏳ Waiting for /dev/ttyUSB0
[MP] ✅ Connected [MP] ✅ Serial connected
[MP] 🔌 Please power the target now
__ __ _ _ _ _ __ __ _ _ _ _
| \/ (_)_ _ (_) | ___ __ _ __| | | \/ (_)_ _ (_) | ___ __ _ __| |
| |\/| | | ' \| | |__/ _ \/ _` / _` | | |\/| | | ' \| | |__/ _ \/ _` / _` |
@ -290,19 +292,19 @@ Minipush 1.0
[MP] ⏩ Pushing 74 KiB ========================================🦀 100% 24 KiB/s Time: 00:00:03 [MP] ⏩ Pushing 74 KiB ========================================🦀 100% 24 KiB/s Time: 00:00:03
[ML] Loaded! Executing the payload now [ML] Loaded! Executing the payload now
[ 3.376642] Booting on: Raspberry Pi 4 [ 3.379342] Booting on: Raspberry Pi 4
[ 3.377030] MMU online: [ 3.379731] MMU online:
[ 3.378202] ----------------------------------------------------------------------------------------------------------------- [ 3.380902] -----------------------------------------------------------------------------------------------------------------
[ 3.384059] Virtual Physical Size Attr Entity [ 3.386759] Virtual Physical Size Attr Entity
[ 3.389916] ----------------------------------------------------------------------------------------------------------------- [ 3.392616] -----------------------------------------------------------------------------------------------------------------
[ 3.395775] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack [ 3.398475] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack
[ 3.401069] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data [ 3.403768] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data
[ 3.406404] 0x000090000..0x0001AFFFF --> 0x000090000..0x0001AFFFF | 1 MiB | C RW XN | Kernel data and bss [ 3.409104] 0x000090000..0x0001BFFFF --> 0x000090000..0x0001BFFFF | 1 MiB | C RW XN | Kernel data and bss
[ 3.411566] 0x1F0000000..0x1F000FFFF --> 0x0FE200000..0x0FE20FFFF | 64 KiB | Dev RW XN | BCM GPIO [ 3.414267] 0x1F0000000..0x1F000FFFF --> 0x0FE200000..0x0FE20FFFF | 64 KiB | Dev RW XN | BCM GPIO
[ 3.416251] | BCM PL011 UART [ 3.418951] | BCM PL011 UART
[ 3.421198] 0x1F0010000..0x1F001FFFF --> 0x0FF840000..0x0FF84FFFF | 64 KiB | Dev RW XN | GICD [ 3.423898] 0x1F0010000..0x1F001FFFF --> 0x0FF840000..0x0FF84FFFF | 64 KiB | Dev RW XN | GICD
[ 3.425709] | GICC [ 3.428409] | GICC
[ 3.430221] ----------------------------------------------------------------------------------------------------------------- [ 3.432921] -----------------------------------------------------------------------------------------------------------------
``` ```
## Diff to previous ## Diff to previous

@ -120,11 +120,10 @@ provided container, please refer to the repository's [docker](docker) folder.
## 📟 USB Serial Output ## 📟 USB Serial Output
Since the kernel developed in the tutorials runs on the real hardware, it is highly recommended to Since the kernel developed in the tutorials runs on the real hardware, it is highly recommended to
get a USB serial debug cable to get the full experience. The cable also powers the Raspberry once get a USB serial cable to get the full experience.
you connect it, so you don't need extra power over the dedicated power-USB.
- You can find USB-to-serial cables that should work right away at [\[1\]] [\[2\]]. - You can find USB-to-serial cables that should work right away at [\[1\]] [\[2\]].
- You connect it to the GPIO pins `14/15` as shown below. - You connect it to `GND` and GPIO pins `14/15` as shown below.
- [Tutorial 6](06_drivers_gpio_uart) is the first where you can use it. Check it out for - [Tutorial 6](06_drivers_gpio_uart) is the first where you can use it. Check it out for
instructions on how to prepare the SD card to boot your self-made kernel from it. instructions on how to prepare the SD card to boot your self-made kernel from it.
- Starting with [tutorial 7](07_uart_chainloader), booting kernels on your Raspberry is getting - Starting with [tutorial 7](07_uart_chainloader), booting kernels on your Raspberry is getting

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 79 KiB

@ -146,7 +146,8 @@ class DevTool
def make_xtra def make_xtra
return if @user_has_supplied_crates return if @user_has_supplied_crates
puts 'Make Xtra crates'.light_blue puts 'Make Xtra stuff'.light_blue
system('cd 07_uart_chainloader && bash update.sh')
system('cd X1_JTAG_boot && bash update.sh') system('cd X1_JTAG_boot && bash update.sh')
end end

@ -17,7 +17,7 @@ class MiniPush < MiniTerm
def initialize(serial_name, binary_image_path) def initialize(serial_name, binary_image_path)
super(serial_name) super(serial_name)
@name_short = 'MP' @name_short = 'MP' # override
@binary_image_path = binary_image_path @binary_image_path = binary_image_path
@binary_size = nil @binary_size = nil
@binary_image = nil @binary_image = nil
@ -28,11 +28,13 @@ class MiniPush < MiniTerm
# The three characters signaling the request token are expected to arrive as the last three # The three characters signaling the request token are expected to arrive as the last three
# characters _at the end_ of a character stream (e.g. after a header print from Miniload). # characters _at the end_ of a character stream (e.g. after a header print from Miniload).
def wait_for_binary_request def wait_for_binary_request
Timeout.timeout(30) do puts "[#{@name_short}] 🔌 Please power the target now"
loop do
received = @target_serial.readpartial(4096)
raise ConnectionError if received.nil? # Timeout for the request token starts after the first sign of life was received.
received = @target_serial.readpartial(4096)
Timeout.timeout(10) do
loop do
raise ProtocolError if received.nil?
if received.chars.last(3) == ["\u{3}", "\u{3}", "\u{3}"] if received.chars.last(3) == ["\u{3}", "\u{3}", "\u{3}"]
# Print the last chunk minus the request token. # Print the last chunk minus the request token.
@ -41,6 +43,8 @@ class MiniPush < MiniTerm
end end
print received print received
received = @target_serial.readpartial(4096)
end end
end end
end end
@ -70,18 +74,20 @@ class MiniPush < MiniTerm
end end
end end
# When the serial is still powered. # override
def handle_protocol_error def handle_reconnect
connetion_reset connetion_reset
puts puts
puts "[#{@name_short}] ⚡ " \ puts "[#{@name_short}] ⚡ " \
"#{'Protocol Error: Remove and insert the USB serial again'.light_red}" "#{'Connection or protocol Error: '.light_red}" \
"#{'Remove power and USB serial. Reinsert serial first, then power'.light_red}"
sleep(1) while serial_connected? sleep(1) while serial_connected?
end end
public public
# override
def run def run
open_serial open_serial
wait_for_binary_request wait_for_binary_request
@ -89,12 +95,9 @@ class MiniPush < MiniTerm
send_size send_size
send_binary send_binary
terminal terminal
rescue ConnectionError, EOFError, Errno::EIO rescue ConnectionError, EOFError, Errno::EIO, ProtocolError, Timeout::Error
handle_reconnect handle_reconnect
retry retry
rescue ProtocolError, Timeout::Error
handle_protocol_error
retry
rescue StandardError => e rescue StandardError => e
handle_unexpected(e) handle_unexpected(e)
ensure ensure

@ -29,11 +29,12 @@ class MiniTerm
end end
def wait_for_serial def wait_for_serial
loop do return if serial_connected?
break if serial_connected?
print "\r[#{@name_short}] ⏳ Waiting for #{@target_serial_name}" puts "[#{@name_short}] ⏳ Waiting for #{@target_serial_name}"
loop do
sleep(1) sleep(1)
break if serial_connected?
end end
end end
@ -45,12 +46,10 @@ class MiniTerm
# Ensure all output is immediately flushed to the device. # Ensure all output is immediately flushed to the device.
@target_serial.sync = true @target_serial.sync = true
rescue Errno::EACCES => e rescue Errno::EACCES => e
puts
puts "[#{@name_short}] 🚫 #{e.message} - Maybe try with 'sudo'" puts "[#{@name_short}] 🚫 #{e.message} - Maybe try with 'sudo'"
exit exit
else else
puts puts "[#{@name_short}] ✅ Serial connected"
puts "[#{@name_short}] ✅ Connected"
end end
def terminal def terminal

Loading…
Cancel
Save