Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 18c7259

Browse files
committedDec 26, 2020
Default to externally powered RPis
Addresses issues in #86
1 parent dad68ab commit 18c7259

File tree

19 files changed

+269
-237
lines changed

19 files changed

+269
-237
lines changed
 

‎06_drivers_gpio_uart/README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@ init_uart_clock=48000000
4949
- [bootcode.bin](https://github.com/raspberrypi/firmware/raw/master/boot/bootcode.bin)
5050
- [fixup.dat](https://github.com/raspberrypi/firmware/raw/master/boot/fixup.dat)
5151
- [start.elf](https://github.com/raspberrypi/firmware/raw/master/boot/start.elf)
52-
4. Run `make` and copy the [kernel8.img](kernel8.img) onto the SD card.
52+
4. Run `make`.
5353

5454
### Pi 4
5555

5656
3. Copy the following files from the [Raspberry Pi firmware repo](https://github.com/raspberrypi/firmware/tree/master/boot) onto the SD card:
5757
- [fixup4.dat](https://github.com/raspberrypi/firmware/raw/master/boot/fixup4.dat)
5858
- [start4.elf](https://github.com/raspberrypi/firmware/raw/master/boot/start4.elf)
5959
- [bcm2711-rpi-4-b.dtb](https://github.com/raspberrypi/firmware/raw/master/boot/bcm2711-rpi-4-b.dtb)
60-
4. Run `BSP=rpi4 make` and copy the [kernel8.img](kernel8.img) onto the SD card.
60+
4. Run `BSP=rpi4 make`.
61+
6162

6263
_**Note**: Should it not work on your RPi4, try renaming `start4.elf` to `start.elf` (without the 4)
6364
on the SD card._
6465

6566
### Common again
6667

67-
5. Insert the SD card into the RPi and connect the USB serial to your host PC.
68-
- Wiring diagram at [top-level README](../README.md#usb-serial).
68+
5. Copy the `kernel8.img` onto the SD card and insert it back into the RPi.
6969
6. Run the `miniterm` target, which opens the UART device on the host:
7070

7171
```console
@@ -81,14 +81,16 @@ $ make miniterm
8181
$ DEV_SERIAL=/dev/tty.usbserial-0001 make miniterm
8282
```
8383

84-
7. Hit <kbd>Enter</kbd> after seeing "`Connected`" to kick off the kernel boot process and observe
85-
the output:
84+
7. Connect the USB serial to your host PC.
85+
- Wiring diagram at [top-level README](../README.md#-usb-serial-output).
86+
- Make sure that you **DID NOT** connect the power pin of the USB serial. Only RX/TX and GND.
87+
8. Connect the RPi to the (USB) power cable and observe the output:
8688

8789
```console
8890
Miniterm 1.0
8991

90-
91-
[MT] ✅ Connected
92+
[MT] ⏳ Waiting for /dev/ttyUSB0
93+
[MT] ✅ Serial connected
9294
[0] Booting on: Raspberry Pi 3
9395
[1] Drivers loaded:
9496
1. BCM GPIO
@@ -1212,7 +1214,7 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
12121214
mod memory;
12131215
mod panic_wait;
12141216
mod print;
1215-
@@ -116,16 +126,53 @@
1217+
@@ -116,16 +126,46 @@
12161218
/// # Safety
12171219
///
12181220
/// - 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
12391241
+ use console::interface::All;
12401242
+ use driver::interface::DriverManager;
12411243
+
1242-
+ // Wait for user to hit Enter.
1243-
+ loop {
1244-
+ if bsp::console::console().read_char() == '\n' {
1245-
+ break;
1246-
+ }
1247-
+ }
1248-
+
12491244
+ println!("[0] Booting on: {}", bsp::board_name());
12501245
+
12511246
+ println!("[1] Drivers loaded:");

‎06_drivers_gpio_uart/src/main.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,6 @@ fn kernel_main() -> ! {
147147
use console::interface::All;
148148
use driver::interface::DriverManager;
149149

150-
// Wait for user to hit Enter.
151-
loop {
152-
if bsp::console::console().read_char() == '\n' {
153-
break;
154-
}
155-
}
156-
157150
println!("[0] Booting on: {}", bsp::board_name());
158151

159152
println!("[1] Drivers loaded:");

‎07_uart_chainloader/README.md

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ Our chainloader is called `MiniLoad` and is inspired by [raspbootin].
2525

2626
You can try it with this tutorial already:
2727
1. Depending on your target hardware:`make` or `BSP=rpi4 make`.
28-
2. Copy `kernel8.img` to the SD card.
29-
3. Execute `make chainboot` or `BSP=rpi4 make chainboot`.
30-
4. Now plug in the USB Serial.
31-
5. Observe the loader fetching a kernel over `UART`:
28+
1. Copy `kernel8.img` to the SD card.
29+
1. Execute `make chainboot` or `BSP=rpi4 make chainboot`.
30+
1. Connect the USB serial to your host PC.
31+
- Wiring diagram at [top-level README](../README.md#-usb-serial-output).
32+
- Make sure that you **DID NOT** connect the power pin of the USB serial. Only RX/TX and GND.
33+
1. Connect the RPi to the (USB) power cable.
34+
1. Observe the loader fetching a kernel over `UART`:
3235

3336
> **NOTE**: By default, `make chainboot` tries to connect to `/dev/ttyUSB0`.
3437
> Should the USB serial on your system have a different name, you have to provide it explicitly. For
@@ -44,7 +47,8 @@ $ make chainboot
4447
Minipush 1.0
4548

4649
[MP] ⏳ Waiting for /dev/ttyUSB0
47-
[MP] ✅ Connected
50+
[MP] ✅ Serial connected
51+
[MP] 🔌 Please power the target now
4852
__ __ _ _ _ _
4953
| \/ (_)_ _ (_) | ___ __ _ __| |
5054
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -53,7 +57,7 @@ Minipush 1.0
5357
Raspberry Pi 3
5458

5559
[ML] Requesting binary
56-
[MP] ⏩ Pushing 7 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
60+
[MP] ⏩ Pushing 6 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
5761
[ML] Loaded! Executing the payload now
5862

5963
[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
429433
mod runtime_init;
430434
mod synchronization;
431435

432-
@@ -144,35 +148,52 @@
436+
@@ -144,28 +148,52 @@
433437

434438
/// The main function running after the early init.
435439
fn kernel_main() -> ! {
436440
+ use bsp::console::console;
437441
use console::interface::All;
438442
- use driver::interface::DriverManager;
443+
-
444+
- println!("[0] Booting on: {}", bsp::board_name());
439445

440-
- // Wait for user to hit Enter.
441-
- loop {
442-
- if bsp::console::console().read_char() == '\n' {
443-
- break;
446+
- println!("[1] Drivers loaded:");
447+
- for (i, driver) in bsp::driver::driver_manager()
448+
- .all_device_drivers()
449+
- .iter()
450+
- .enumerate()
451+
- {
452+
- println!(" {}. {}", i + 1, driver.compatible());
444453
+ println!(" __ __ _ _ _ _ ");
445454
+ println!("| \\/ (_)_ _ (_) | ___ __ _ __| |");
446455
+ println!("| |\\/| | | ' \\| | |__/ _ \\/ _` / _` |");
@@ -458,8 +467,17 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
458467
+ // Notify `Minipush` to send the binary.
459468
+ for _ in 0..3 {
460469
+ console().write_char(3 as char);
461-
+ }
462-
+
470+
}
471+
472+
- println!(
473+
- "[2] Chars written: {}",
474+
- bsp::console::console().chars_written()
475+
- );
476+
- println!("[3] Echoing input now");
477+
-
478+
- loop {
479+
- let c = bsp::console::console().read_char();
480+
- bsp::console::console().write_char(c);
463481
+ // Read the binary's size.
464482
+ let mut size: u32 = u32::from(console().read_char() as u8);
465483
+ 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
475493
+ // Read the kernel byte by byte.
476494
+ for i in 0..size {
477495
+ core::ptr::write_volatile(kernel_addr.offset(i as isize), console().read_char() as u8)
478-
}
496+
+ }
479497
}
480-
481-
- println!("[0] Booting on: {}", bsp::board_name());
498+
+
482499
+ println!("[ML] Loaded! Executing the payload now\n");
483500
+ console().flush();
484-
485-
- println!("[1] Drivers loaded:");
486-
- for (i, driver) in bsp::driver::driver_manager()
487-
- .all_device_drivers()
488-
- .iter()
489-
- .enumerate()
490-
- {
491-
- println!(" {}. {}", i + 1, driver.compatible());
492-
- }
501+
+
493502
+ // Use black magic to get a function pointer.
494503
+ let kernel: fn() -> ! = unsafe { core::mem::transmute(kernel_addr) };
495-
496-
- println!(
497-
- "[2] Chars written: {}",
498-
- bsp::console::console().chars_written()
499-
- );
500-
- println!("[3] Echoing input now");
501-
-
502-
- loop {
503-
- let c = bsp::console::console().read_char();
504-
- bsp::console::console().write_char(c);
505-
- }
504+
+
506505
+ // Jump to loaded kernel!
507506
+ kernel()
508507
}
@@ -583,4 +582,18 @@ diff -uNr 06_drivers_gpio_uart/src/runtime_init.rs 07_uart_chainloader/src/runti
583582
pub unsafe fn runtime_init() -> ! {
584583
zero_bss();
585584

585+
586+
diff -uNr 06_drivers_gpio_uart/update.sh 07_uart_chainloader/update.sh
587+
--- 06_drivers_gpio_uart/update.sh
588+
+++ 07_uart_chainloader/update.sh
589+
@@ -0,0 +1,8 @@
590+
+#!/usr/bin/env bash
591+
+
592+
+cd ../06_drivers_gpio_uart
593+
+BSP=rpi4 make
594+
+cp kernel8.img ../07_uart_chainloader/demo_payload_rpi4.img
595+
+make
596+
+cp kernel8.img ../07_uart_chainloader/demo_payload_rpi3.img
597+
+rm kernel8.img
598+
586599
```
-672 Bytes
Binary file not shown.
-648 Bytes
Binary file not shown.

‎07_uart_chainloader/update.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
cd ../06_drivers_gpio_uart
4+
BSP=rpi4 make
5+
cp kernel8.img ../07_uart_chainloader/demo_payload_rpi4.img
6+
make
7+
cp kernel8.img ../07_uart_chainloader/demo_payload_rpi3.img
8+
rm kernel8.img

‎08_timestamps/README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ $ make chainboot
1515
Minipush 1.0
1616

1717
[MP] ⏳ Waiting for /dev/ttyUSB0
18-
[MP] ✅ Connected
18+
[MP] ✅ Serial connected
19+
[MP] 🔌 Please power the target now
1920
__ __ _ _ _ _
2021
| \/ (_)_ _ (_) | ___ __ _ __| |
2122
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -24,19 +25,18 @@ Minipush 1.0
2425
Raspberry Pi 3
2526

2627
[ML] Requesting binary
27-
[MP] ⏩ Pushing 12 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
28+
[MP] ⏩ Pushing 11 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
2829
[ML] Loaded! Executing the payload now
2930

30-
[ 0.586140] Booting on: Raspberry Pi 3
31-
[ 0.587227] Architectural timer resolution: 52 ns
32-
[ 0.589530] Drivers loaded:
33-
[ 0.590876] 1. BCM GPIO
34-
[ 0.592309] 2. BCM PL011 UART
35-
[W 0.594005] Spin duration smaller than architecturally supported, skipping
36-
[ 0.597392] Spinning for 1 second
37-
[ 1.599001] Spinning for 1 second
38-
[ 2.599872] Spinning for 1 second
39-
31+
[ 0.543941] Booting on: Raspberry Pi 3
32+
[ 0.545059] Architectural timer resolution: 52 ns
33+
[ 0.547358] Drivers loaded:
34+
[ 0.548703] 1. BCM GPIO
35+
[ 0.550135] 2. BCM PL011 UART
36+
[W 0.551828] Spin duration smaller than architecturally supported, skipping
37+
[ 0.555212] Spinning for 1 second
38+
[ 1.556818] Spinning for 1 second
39+
[ 2.557690] Spinning for 1 second
4040
```
4141

4242
## Diff to previous
@@ -754,4 +754,17 @@ diff -uNr 07_uart_chainloader/src/time.rs 08_timestamps/src/time.rs
754754
+ }
755755
+}
756756

757+
diff -uNr 07_uart_chainloader/update.sh 08_timestamps/update.sh
758+
--- 07_uart_chainloader/update.sh
759+
+++ 08_timestamps/update.sh
760+
@@ -1,8 +0,0 @@
761+
-#!/usr/bin/env bash
762+
-
763+
-cd ../06_drivers_gpio_uart
764+
-BSP=rpi4 make
765+
-cp kernel8.img ../07_uart_chainloader/demo_payload_rpi4.img
766+
-make
767+
-cp kernel8.img ../07_uart_chainloader/demo_payload_rpi3.img
768+
-rm kernel8.img
769+
757770
```

‎09_hw_debug_JTAG/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ $ make jtagboot
157157
Minipush 1.0
158158

159159
[MP] ⏳ Waiting for /dev/ttyUSB0
160-
[MP] ✅ Connected
160+
[MP] ✅ Serial connected
161+
[MP] 🔌 Please power the target now
161162
__ __ _ _ _ _
162163
| \/ (_)_ _ (_) | ___ __ _ __| |
163164
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -166,10 +167,10 @@ Minipush 1.0
166167
Raspberry Pi 3
167168

168169
[ML] Requesting binary
169-
[MP] ⏩ Pushing 8 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
170+
[MP] ⏩ Pushing 7 KiB ==========================================🦀 100% 0 KiB/s Time: 00:00:00
170171
[ML] Loaded! Executing the payload now
171172

172-
[ 0.372110] Parking CPU core. Please connect over JTAG now.
173+
[ 0.394532] Parking CPU core. Please connect over JTAG now.
173174
```
174175

175176
It is important to keep the USB serial connected and the terminal with the `jtagboot` open and

‎10_privilege_level/README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ $ make chainboot
192192
Minipush 1.0
193193

194194
[MP] ⏳ Waiting for /dev/ttyUSB0
195-
[MP] ✅ Connected
195+
[MP] ✅ Serial connected
196+
[MP] 🔌 Please power the target now
196197
__ __ _ _ _ _
197198
| \/ (_)_ _ (_) | ___ __ _ __| |
198199
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -201,22 +202,22 @@ Minipush 1.0
201202
Raspberry Pi 3
202203

203204
[ML] Requesting binary
204-
[MP] ⏩ Pushing 15 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
205+
[MP] ⏩ Pushing 13 KiB =========================================🦀 100% 0 KiB/s Time: 00:00:00
205206
[ML] Loaded! Executing the payload now
206207

207-
[ 0.703812] Booting on: Raspberry Pi 3
208-
[ 0.704900] Current privilege level: EL1
209-
[ 0.706811] Exception handling state:
210-
[ 0.708592] Debug: Masked
211-
[ 0.710156] SError: Masked
212-
[ 0.711719] IRQ: Masked
213-
[ 0.713283] FIQ: Masked
214-
[ 0.714848] Architectural timer resolution: 52 ns
215-
[ 0.717149] Drivers loaded:
216-
[ 0.718496] 1. BCM GPIO
217-
[ 0.719929] 2. BCM PL011 UART
218-
[ 0.721623] Timer test, spinning for 1 second
219-
[ 1.723753] Echoing input now
208+
[ 0.637617] Booting on: Raspberry Pi 3
209+
[ 0.638737] Current privilege level: EL1
210+
[ 0.640645] Exception handling state:
211+
[ 0.642424] Debug: Masked
212+
[ 0.643986] SError: Masked
213+
[ 0.645548] IRQ: Masked
214+
[ 0.647110] FIQ: Masked
215+
[ 0.648672] Architectural timer resolution: 52 ns
216+
[ 0.650971] Drivers loaded:
217+
[ 0.652316] 1. BCM GPIO
218+
[ 0.653748] 2. BCM PL011 UART
219+
[ 0.655440] Timer test, spinning for 1 second
220+
[ 1.657567] Echoing input now
220221
```
221222

222223
## Diff to previous

‎11_virtual_mem_part1_identity_mapping/README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ $ make chainboot
264264
Minipush 1.0
265265

266266
[MP] ⏳ Waiting for /dev/ttyUSB0
267-
[MP] ✅ Connected
267+
[MP] ✅ Serial connected
268+
[MP] 🔌 Please power the target now
268269
__ __ _ _ _ _
269270
| \/ (_)_ _ (_) | ___ __ _ __| |
270271
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -276,24 +277,24 @@ Minipush 1.0
276277
[MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02
277278
[ML] Loaded! Executing the payload now
278279

279-
[ 3.085343] Booting on: Raspberry Pi 3
280-
[ 3.086427] MMU online. Special regions:
281-
[ 3.088339] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
282-
[ 3.092422] 0x1fff0000 - 0x1fffffff | 64 KiB | Dev RW PXN | Remapped Device MMIO
283-
[ 3.096375] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
284-
[ 3.099937] Current privilege level: EL1
285-
[ 3.101848] Exception handling state:
286-
[ 3.103629] Debug: Masked
287-
[ 3.105192] SError: Masked
288-
[ 3.106756] IRQ: Masked
289-
[ 3.108320] FIQ: Masked
290-
[ 3.109884] Architectural timer resolution: 52 ns
291-
[ 3.112186] Drivers loaded:
292-
[ 3.113532] 1. BCM GPIO
293-
[ 3.114966] 2. BCM PL011 UART
294-
[ 3.116660] Timer test, spinning for 1 second
280+
[ 3.175017] Booting on: Raspberry Pi 3
281+
[ 3.176100] MMU online. Special regions:
282+
[ 3.178009] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
283+
[ 3.182088] 0x1fff0000 - 0x1fffffff | 64 KiB | Dev RW PXN | Remapped Device MMIO
284+
[ 3.186036] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
285+
[ 3.189594] Current privilege level: EL1
286+
[ 3.191502] Exception handling state:
287+
[ 3.193281] Debug: Masked
288+
[ 3.194843] SError: Masked
289+
[ 3.196405] IRQ: Masked
290+
[ 3.197967] FIQ: Masked
291+
[ 3.199529] Architectural timer resolution: 52 ns
292+
[ 3.201828] Drivers loaded:
293+
[ 3.203173] 1. BCM GPIO
294+
[ 3.204605] 2. BCM PL011 UART
295+
[ 3.206297] Timer test, spinning for 1 second
295296
[ !!! ] Writing through the remapped UART at 0x1FFF_1000
296-
[ 4.120828] Echoing input now
297+
[ 4.210458] Echoing input now
297298
```
298299

299300
## Diff to previous

‎12_exceptions_part1_groundwork/README.md

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ $ make chainboot
399399
Minipush 1.0
400400

401401
[MP] ⏳ Waiting for /dev/ttyUSB0
402-
[MP] ✅ Connected
402+
[MP] ✅ Serial connected
403+
[MP] 🔌 Please power the target now
403404
__ __ _ _ _ _
404405
| \/ (_)_ _ (_) | ___ __ _ __| |
405406
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -411,29 +412,29 @@ Minipush 1.0
411412
[MP] ⏩ Pushing 64 KiB ========================================🦀 100% 32 KiB/s Time: 00:00:02
412413
[ML] Loaded! Executing the payload now
413414

414-
[ 3.006343] Booting on: Raspberry Pi 3
415-
[ 3.007428] MMU online. Special regions:
416-
[ 3.009339] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
417-
[ 3.013422] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
418-
[ 3.016985] Current privilege level: EL1
419-
[ 3.018895] Exception handling state:
420-
[ 3.020676] Debug: Masked
421-
[ 3.022240] SError: Masked
422-
[ 3.023804] IRQ: Masked
423-
[ 3.025368] FIQ: Masked
424-
[ 3.026931] Architectural timer resolution: 52 ns
425-
[ 3.029234] Drivers loaded:
426-
[ 3.030580] 1. BCM GPIO
427-
[ 3.032014] 2. BCM PL011 UART
428-
[ 3.033708] Timer test, spinning for 1 second
429-
[ 4.035837]
430-
[ 4.035841] Trying to write to address 8 GiB...
431-
[ 4.038006] ************************************************
432-
[ 4.040785] Whoa! We recovered from a synchronous exception!
433-
[ 4.043565] ************************************************
434-
[ 4.046345]
435-
[ 4.047040] Let's try again
436-
[ 4.048387] Trying to write to address 9 GiB...
415+
[ 3.090618] Booting on: Raspberry Pi 3
416+
[ 3.091701] MMU online. Special regions:
417+
[ 3.093610] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
418+
[ 3.097688] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
419+
[ 3.101246] Current privilege level: EL1
420+
[ 3.103155] Exception handling state:
421+
[ 3.104934] Debug: Masked
422+
[ 3.106496] SError: Masked
423+
[ 3.108058] IRQ: Masked
424+
[ 3.109619] FIQ: Masked
425+
[ 3.111181] Architectural timer resolution: 52 ns
426+
[ 3.113481] Drivers loaded:
427+
[ 3.114826] 1. BCM GPIO
428+
[ 3.116257] 2. BCM PL011 UART
429+
[ 3.117950] Timer test, spinning for 1 second
430+
[ 4.120076]
431+
[ 4.120079] Trying to write to address 8 GiB...
432+
[ 4.122242] ************************************************
433+
[ 4.125018] Whoa! We recovered from a synchronous exception!
434+
[ 4.127795] ************************************************
435+
[ 4.130571]
436+
[ 4.131266] Let's try again
437+
[ 4.132611] Trying to write to address 9 GiB...
437438

438439
Kernel panic:
439440

@@ -442,7 +443,7 @@ FAR_EL1: 0x0000000240000000
442443
ESR_EL1: 0x96000004
443444
Exception Class (EC) : 0x25 - Data Abort, current EL
444445
Instr Specific Syndrome (ISS): 0x4
445-
ELR_EL1: 0x0000000000080db4
446+
ELR_EL1: 0x0000000000081454
446447
SPSR_EL1: 0x600003c5
447448
Flags:
448449
Negative (N): Not set
@@ -457,22 +458,22 @@ SPSR_EL1: 0x600003c5
457458
Illegal Execution State (IL): Not set
458459

459460
General purpose register:
460-
x0 : 0x0000000000000000 x1 : 0x00000000000858f6
461-
x2 : 0x0000000000000026 x3 : 0x0000000000082a0c
462-
x4 : 0x000000000007fc7c x5 : 0x0000000000000003
463-
x6 : 0x0000000000000000 x7 : 0x7f91bc052b2b0208
464-
x8 : 0x0000000240000000 x9 : 0x00000000000858f6
465-
x10: 0x000000000000041d x11: 0x000000003f201000
466-
x12: 0x0000000000000019 x13: 0x000000000007fc7d
467-
x14: 0x000000000007fdc8 x15: 0x0000000000000040
468-
x16: 0x0000000000000000 x17: 0x0000000000000040
469-
x18: 0x9e06782800000028 x19: 0x000000003b9aca00
470-
x20: 0x00000000000003e8 x21: 0x0000000000082f58
471-
x22: 0x00000000000830cc x23: 0x0000000000090008
472-
x24: 0x00000000000f4240 x25: 0x0000000000085248
473-
x26: 0x00000000000856e0 x27: 0x00000000000857c0
474-
x28: 0x00000000000830cc x29: 0x0000000000085530
475-
lr : 0x0000000000080da8
461+
x0 : 0x0000000000000000 x1 : 0x0000000000085726
462+
x2 : 0x0000000000000026 x3 : 0x0000000000083bf0
463+
x4 : 0x0000000000000003 x5 : 0xfb4f101900000000
464+
x6 : 0x0000000000000000 x7 : 0x7e9198052b2b0200
465+
x8 : 0x0000000240000000 x9 : 0x000000003f201000
466+
x10: 0x0000000000000019 x11: 0x0000000000000000
467+
x12: 0x0000000000000006 x13: 0x0000000000000031
468+
x14: 0x000000000007fc2d x15: 0x0000000000000000
469+
x16: 0x0000000000000040 x17: 0xb557f006f276cfb6
470+
x18: 0x0000000000000003 x19: 0x0000000000090008
471+
x20: 0x0000000000085510 x21: 0x000000003b9aca00
472+
x22: 0x00000000000003e8 x23: 0x000000000008160c
473+
x24: 0x0000000000082264 x25: 0x00000000000f4240
474+
x26: 0xffffffffc4653600 x27: 0x00000000000855f0
475+
x28: 0x0000000000083f84 x29: 0x0000000000086810
476+
lr : 0x0000000000081448
476477
```
477478

478479
## Diff to previous

‎14_exceptions_part2_peripheral_IRQs/README.md

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,8 @@ $ make chainboot
665665
Minipush 1.0
666666

667667
[MP] ⏳ Waiting for /dev/ttyUSB0
668-
[MP] ✅ Connected
668+
[MP] ✅ Serial connected
669+
[MP] 🔌 Please power the target now
669670
__ __ _ _ _ _
670671
| \/ (_)_ _ (_) | ___ __ _ __| |
671672
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -677,25 +678,25 @@ Minipush 1.0
677678
[MP] ⏩ Pushing 66 KiB ========================================🦀 100% 33 KiB/s Time: 00:00:02
678679
[ML] Loaded! Executing the payload now
679680

680-
[ 3.134937] Booting on: Raspberry Pi 3
681-
[ 3.136023] MMU online. Special regions:
682-
[ 3.137934] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
683-
[ 3.142017] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
684-
[ 3.145579] Current privilege level: EL1
685-
[ 3.147490] Exception handling state:
686-
[ 3.149271] Debug: Masked
687-
[ 3.150835] SError: Masked
688-
[ 3.152398] IRQ: Unmasked
689-
[ 3.154049] FIQ: Masked
690-
[ 3.155613] Architectural timer resolution: 52 ns
691-
[ 3.157915] Drivers loaded:
692-
[ 3.159262] 1. BCM GPIO
693-
[ 3.160695] 2. BCM PL011 UART
694-
[ 3.162389] 3. BCM Interrupt Controller
695-
[ 3.164518] Registered IRQ handlers:
696-
[ 3.166255] Peripheral handler:
697-
[ 3.168038] 57. BCM PL011 UART
698-
[ 3.170078] Echoing input now
681+
[ 3.203172] Booting on: Raspberry Pi 3
682+
[ 3.204255] MMU online. Special regions:
683+
[ 3.206164] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
684+
[ 3.210242] 0x3f000000 - 0x4000ffff | 16 MiB | Dev RW PXN | Device MMIO
685+
[ 3.213800] Current privilege level: EL1
686+
[ 3.215709] Exception handling state:
687+
[ 3.217487] Debug: Masked
688+
[ 3.219049] SError: Masked
689+
[ 3.220611] IRQ: Unmasked
690+
[ 3.222260] FIQ: Masked
691+
[ 3.223822] Architectural timer resolution: 52 ns
692+
[ 3.226121] Drivers loaded:
693+
[ 3.227466] 1. BCM GPIO
694+
[ 3.228898] 2. BCM PL011 UART
695+
[ 3.230590] 3. BCM Interrupt Controller
696+
[ 3.232716] Registered IRQ handlers:
697+
[ 3.234451] Peripheral handler:
698+
[ 3.236232] 57. BCM PL011 UART
699+
[ 3.238269] Echoing input now
699700
```
700701

701702
Raspberry Pi 4:
@@ -706,7 +707,8 @@ $ BSP=rpi4 make chainboot
706707
Minipush 1.0
707708

708709
[MP] ⏳ Waiting for /dev/ttyUSB0
709-
[MP] ✅ Connected
710+
[MP] ✅ Serial connected
711+
[MP] 🔌 Please power the target now
710712
__ __ _ _ _ _
711713
| \/ (_)_ _ (_) | ___ __ _ __| |
712714
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -718,25 +720,25 @@ Minipush 1.0
718720
[MP] ⏩ Pushing 73 KiB ========================================🦀 100% 24 KiB/s Time: 00:00:03
719721
[ML] Loaded! Executing the payload now
720722

721-
[ 3.413865] Booting on: Raspberry Pi 4
722-
[ 3.414255] MMU online. Special regions:
723-
[ 3.416166] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
724-
[ 3.420249] 0xfe000000 - 0xff84ffff | 24 MiB | Dev RW PXN | Device MMIO
725-
[ 3.423811] Current privilege level: EL1
726-
[ 3.425722] Exception handling state:
727-
[ 3.427503] Debug: Masked
728-
[ 3.429067] SError: Masked
729-
[ 3.430630] IRQ: Unmasked
730-
[ 3.432281] FIQ: Masked
731-
[ 3.433845] Architectural timer resolution: 18 ns
732-
[ 3.436147] Drivers loaded:
733-
[ 3.437494] 1. BCM GPIO
734-
[ 3.438927] 2. BCM PL011 UART
735-
[ 3.440621] 3. GICv2 (ARM Generic Interrupt Controller v2)
736-
[ 3.443575] Registered IRQ handlers:
737-
[ 3.445312] Peripheral handler:
738-
[ 3.447096] 153. BCM PL011 UART
739-
[ 3.449136] Echoing input now
723+
[ 3.486234] Booting on: Raspberry Pi 4
724+
[ 3.486623] MMU online. Special regions:
725+
[ 3.488532] 0x00080000 - 0x0008ffff | 64 KiB | C RO PX | Kernel code and RO data
726+
[ 3.492610] 0xfe000000 - 0xff84ffff | 24 MiB | Dev RW PXN | Device MMIO
727+
[ 3.496167] Current privilege level: EL1
728+
[ 3.498076] Exception handling state:
729+
[ 3.499855] Debug: Masked
730+
[ 3.501417] SError: Masked
731+
[ 3.502979] IRQ: Unmasked
732+
[ 3.504628] FIQ: Masked
733+
[ 3.506189] Architectural timer resolution: 18 ns
734+
[ 3.508489] Drivers loaded:
735+
[ 3.509834] 1. BCM GPIO
736+
[ 3.511266] 2. BCM PL011 UART
737+
[ 3.512958] 3. GICv2 (ARM Generic Interrupt Controller v2)
738+
[ 3.515908] Registered IRQ handlers:
739+
[ 3.517643] Peripheral handler:
740+
[ 3.519425] 153. BCM PL011 UART
741+
[ 3.521463] Echoing input now
740742
```
741743

742744
## Diff to previous

‎15_virtual_mem_part2_mmio_remap/README.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ $ make chainboot
244244
Minipush 1.0
245245

246246
[MP] ⏳ Waiting for /dev/ttyUSB0
247-
[MP] ✅ Connected
247+
[MP] ✅ Serial connected
248+
[MP] 🔌 Please power the target now
248249
__ __ _ _ _ _
249250
| \/ (_)_ _ (_) | ___ __ _ __| |
250251
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -256,18 +257,18 @@ Minipush 1.0
256257
[MP] ⏩ Pushing 67 KiB ========================================🦀 100% 33 KiB/s Time: 00:00:02
257258
[ML] Loaded! Executing the payload now
258259

259-
[ 3.041355] Booting on: Raspberry Pi 3
260-
[ 3.042438] MMU online:
261-
[ 3.043609] -----------------------------------------------------------------------------------------------------------------
262-
[ 3.049466] Virtual Physical Size Attr Entity
263-
[ 3.055323] -----------------------------------------------------------------------------------------------------------------
264-
[ 3.061183] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack
265-
[ 3.066476] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data
266-
[ 3.071812] 0x000090000..0x0001AFFFF --> 0x000090000..0x0001AFFFF | 1 MiB | C RW XN | Kernel data and bss
267-
[ 3.076975] 0x1F0000000..0x1F000FFFF --> 0x03F200000..0x03F20FFFF | 64 KiB | Dev RW XN | BCM GPIO
268-
[ 3.081658] | BCM PL011 UART
269-
[ 3.086606] 0x1F0010000..0x1F001FFFF --> 0x03F000000..0x03F00FFFF | 64 KiB | Dev RW XN | BCM Peripheral Interrupt Controller
270-
[ 3.092462] -----------------------------------------------------------------------------------------------------------------
260+
[ 3.064756] Booting on: Raspberry Pi 3
261+
[ 3.065839] MMU online:
262+
[ 3.067010] -----------------------------------------------------------------------------------------------------------------
263+
[ 3.072868] Virtual Physical Size Attr Entity
264+
[ 3.078725] -----------------------------------------------------------------------------------------------------------------
265+
[ 3.084585] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack
266+
[ 3.089877] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data
267+
[ 3.095213] 0x000090000..0x0001BFFFF --> 0x000090000..0x0001BFFFF | 1 MiB | C RW XN | Kernel data and bss
268+
[ 3.100376] 0x1F0000000..0x1F000FFFF --> 0x03F200000..0x03F20FFFF | 64 KiB | Dev RW XN | BCM GPIO
269+
[ 3.105060] | BCM PL011 UART
270+
[ 3.110008] 0x1F0010000..0x1F001FFFF --> 0x03F000000..0x03F00FFFF | 64 KiB | Dev RW XN | BCM Peripheral Interrupt Controller
271+
[ 3.115863] -----------------------------------------------------------------------------------------------------------------
271272
```
272273

273274
Raspberry Pi 4:
@@ -278,7 +279,8 @@ $ BSP=rpi4 make chainboot
278279
Minipush 1.0
279280

280281
[MP] ⏳ Waiting for /dev/ttyUSB0
281-
[MP] ✅ Connected
282+
[MP] ✅ Serial connected
283+
[MP] 🔌 Please power the target now
282284
__ __ _ _ _ _
283285
| \/ (_)_ _ (_) | ___ __ _ __| |
284286
| |\/| | | ' \| | |__/ _ \/ _` / _` |
@@ -290,19 +292,19 @@ Minipush 1.0
290292
[MP] ⏩ Pushing 74 KiB ========================================🦀 100% 24 KiB/s Time: 00:00:03
291293
[ML] Loaded! Executing the payload now
292294

293-
[ 3.376642] Booting on: Raspberry Pi 4
294-
[ 3.377030] MMU online:
295-
[ 3.378202] -----------------------------------------------------------------------------------------------------------------
296-
[ 3.384059] Virtual Physical Size Attr Entity
297-
[ 3.389916] -----------------------------------------------------------------------------------------------------------------
298-
[ 3.395775] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack
299-
[ 3.401069] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data
300-
[ 3.406404] 0x000090000..0x0001AFFFF --> 0x000090000..0x0001AFFFF | 1 MiB | C RW XN | Kernel data and bss
301-
[ 3.411566] 0x1F0000000..0x1F000FFFF --> 0x0FE200000..0x0FE20FFFF | 64 KiB | Dev RW XN | BCM GPIO
302-
[ 3.416251] | BCM PL011 UART
303-
[ 3.421198] 0x1F0010000..0x1F001FFFF --> 0x0FF840000..0x0FF84FFFF | 64 KiB | Dev RW XN | GICD
304-
[ 3.425709] | GICC
305-
[ 3.430221] -----------------------------------------------------------------------------------------------------------------
295+
[ 3.379342] Booting on: Raspberry Pi 4
296+
[ 3.379731] MMU online:
297+
[ 3.380902] -----------------------------------------------------------------------------------------------------------------
298+
[ 3.386759] Virtual Physical Size Attr Entity
299+
[ 3.392616] -----------------------------------------------------------------------------------------------------------------
300+
[ 3.398475] 0x000070000..0x00007FFFF --> 0x000070000..0x00007FFFF | 64 KiB | C RW XN | Kernel boot-core stack
301+
[ 3.403768] 0x000080000..0x00008FFFF --> 0x000080000..0x00008FFFF | 64 KiB | C RO X | Kernel code and RO data
302+
[ 3.409104] 0x000090000..0x0001BFFFF --> 0x000090000..0x0001BFFFF | 1 MiB | C RW XN | Kernel data and bss
303+
[ 3.414267] 0x1F0000000..0x1F000FFFF --> 0x0FE200000..0x0FE20FFFF | 64 KiB | Dev RW XN | BCM GPIO
304+
[ 3.418951] | BCM PL011 UART
305+
[ 3.423898] 0x1F0010000..0x1F001FFFF --> 0x0FF840000..0x0FF84FFFF | 64 KiB | Dev RW XN | GICD
306+
[ 3.428409] | GICC
307+
[ 3.432921] -----------------------------------------------------------------------------------------------------------------
306308
```
307309

308310
## Diff to previous

‎README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,10 @@ provided container, please refer to the repository's [docker](docker) folder.
120120
## 📟 USB Serial Output
121121

122122
Since the kernel developed in the tutorials runs on the real hardware, it is highly recommended to
123-
get a USB serial debug cable to get the full experience. The cable also powers the Raspberry once
124-
you connect it, so you don't need extra power over the dedicated power-USB.
123+
get a USB serial cable to get the full experience.
125124

126125
- You can find USB-to-serial cables that should work right away at [\[1\]] [\[2\]].
127-
- You connect it to the GPIO pins `14/15` as shown below.
126+
- You connect it to `GND` and GPIO pins `14/15` as shown below.
128127
- [Tutorial 6](06_drivers_gpio_uart) is the first where you can use it. Check it out for
129128
instructions on how to prepare the SD card to boot your self-made kernel from it.
130129
- Starting with [tutorial 7](07_uart_chainloader), booting kernels on your Raspberry is getting

‎doc/wiring.fzz

59.8 KB
Binary file not shown.

‎doc/wiring.png

-19.3 KB
Loading

‎utils/devtool.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def make(bsp = nil)
146146
def make_xtra
147147
return if @user_has_supplied_crates
148148

149-
puts 'Make Xtra crates'.light_blue
149+
puts 'Make Xtra stuff'.light_blue
150+
system('cd 07_uart_chainloader && bash update.sh')
150151
system('cd X1_JTAG_boot && bash update.sh')
151152
end
152153

‎utils/minipush.rb

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MiniPush < MiniTerm
1717
def initialize(serial_name, binary_image_path)
1818
super(serial_name)
1919

20-
@name_short = 'MP'
20+
@name_short = 'MP' # override
2121
@binary_image_path = binary_image_path
2222
@binary_size = nil
2323
@binary_image = nil
@@ -28,11 +28,13 @@ def initialize(serial_name, binary_image_path)
2828
# The three characters signaling the request token are expected to arrive as the last three
2929
# characters _at the end_ of a character stream (e.g. after a header print from Miniload).
3030
def wait_for_binary_request
31-
Timeout.timeout(30) do
32-
loop do
33-
received = @target_serial.readpartial(4096)
31+
puts "[#{@name_short}] 🔌 Please power the target now"
3432

35-
raise ConnectionError if received.nil?
33+
# Timeout for the request token starts after the first sign of life was received.
34+
received = @target_serial.readpartial(4096)
35+
Timeout.timeout(10) do
36+
loop do
37+
raise ProtocolError if received.nil?
3638

3739
if received.chars.last(3) == ["\u{3}", "\u{3}", "\u{3}"]
3840
# Print the last chunk minus the request token.
@@ -41,6 +43,8 @@ def wait_for_binary_request
4143
end
4244

4345
print received
46+
47+
received = @target_serial.readpartial(4096)
4448
end
4549
end
4650
end
@@ -70,31 +74,30 @@ def send_binary
7074
end
7175
end
7276

73-
# When the serial is still powered.
74-
def handle_protocol_error
77+
# override
78+
def handle_reconnect
7579
connetion_reset
7680

7781
puts
7882
puts "[#{@name_short}] ⚡ " \
79-
"#{'Protocol Error: Remove and insert the USB serial again'.light_red}"
83+
"#{'Connection or protocol Error: '.light_red}" \
84+
"#{'Remove power and USB serial. Reinsert serial first, then power'.light_red}"
8085
sleep(1) while serial_connected?
8186
end
8287

8388
public
8489

90+
# override
8591
def run
8692
open_serial
8793
wait_for_binary_request
8894
load_binary
8995
send_size
9096
send_binary
9197
terminal
92-
rescue ConnectionError, EOFError, Errno::EIO
98+
rescue ConnectionError, EOFError, Errno::EIO, ProtocolError, Timeout::Error
9399
handle_reconnect
94100
retry
95-
rescue ProtocolError, Timeout::Error
96-
handle_protocol_error
97-
retry
98101
rescue StandardError => e
99102
handle_unexpected(e)
100103
ensure

‎utils/miniterm.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ def serial_connected?
2929
end
3030

3131
def wait_for_serial
32-
loop do
33-
break if serial_connected?
32+
return if serial_connected?
3433

35-
print "\r[#{@name_short}] ⏳ Waiting for #{@target_serial_name}"
34+
puts "[#{@name_short}] ⏳ Waiting for #{@target_serial_name}"
35+
loop do
3636
sleep(1)
37+
break if serial_connected?
3738
end
3839
end
3940

@@ -45,12 +46,10 @@ def open_serial
4546
# Ensure all output is immediately flushed to the device.
4647
@target_serial.sync = true
4748
rescue Errno::EACCES => e
48-
puts
4949
puts "[#{@name_short}] 🚫 #{e.message} - Maybe try with 'sudo'"
5050
exit
5151
else
52-
puts
53-
puts "[#{@name_short}] ✅ Connected"
52+
puts "[#{@name_short}] ✅ Serial connected"
5453
end
5554

5655
def terminal

0 commit comments

Comments
 (0)
Please sign in to comment.