Skip to content

Commit 5dfe760

Browse files
committed
renumbered chapters again
1 parent 6b5ee14 commit 5dfe760

37 files changed

+44
-53
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ resolver = "2"
33
members = [
44
"mdbook/src/03-setup",
55
"mdbook/src/05-hello-world",
6-
"mdbook/src/07-registers",
7-
"mdbook/src/05-led-roulette",
6+
"mdbook/src/06-registers",
7+
"mdbook/src/07-led-roulette",
88
"mdbook/src/09-uart",
99
"mdbook/src/10-i2c",
1010
"mdbook/src/11-led-compass",

mdbook/src/07-registers/README.md renamed to mdbook/src/06-registers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
It's time to explore what calling `display_pins.row1.set_high()` does under the hood.
44

5-
In a nutshell, it just writes to some special memory regions. Go into the `07-registers` directory
5+
In a nutshell, it just writes to some special memory regions. Go into the `06-registers` directory
66
and let's run the starter code statement by statement.
77

88
``` rust

mdbook/src/07-registers/bad-address.md renamed to mdbook/src/06-registers/bad-address.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ Target halted
1919
(gdb) continue
2020
Continuing.
2121

22-
Breakpoint 1, registers::__cortex_m_rt_main_trampoline () at src/07-registers/src/main.rs:9
22+
Breakpoint 1, registers::__cortex_m_rt_main_trampoline () at src/06-registers/src/main.rs:9
2323
9 #[entry]
2424
(gdb) continue
2525
Continuing.
2626

2727
Program received signal SIGINT, Interrupt.
28-
registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:10
28+
registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:10
2929
10 fn main() -> ! {
3030
(gdb) continue
3131
Continuing.
File renamed without changes.

mdbook/src/07-registers/rtrm.md renamed to mdbook/src/06-registers/rtrm.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ So here we go. Furst turn off the `inaccessible-by-default` flag, then set a cou
6363
```
6464
(gdb) set mem inaccessible-by-default off
6565
(gdb) break 16
66-
Breakpoint 1 at 0x172: file src/07-registers/src/main.rs, line 16.
66+
Breakpoint 1 at 0x172: file src/06-registers/src/main.rs, line 16.
6767
Note: automatically using hardware breakpoints for read-only addresses.
6868
(gdb) break 19
69-
Breakpoint 2 at 0x17c: file src/07-registers/src/main.rs, line 19.
69+
Breakpoint 2 at 0x17c: file src/06-registers/src/main.rs, line 19.
7070
(gdb) break 22
71-
Breakpoint 3 at 0x184: file src/07-registers/src/main.rs, line 22.
71+
Breakpoint 3 at 0x184: file src/06-registers/src/main.rs, line 22.
7272
(gdb) break 25
73-
Breakpoint 4 at 0x18c: file src/07-registers/src/main.rs, line 25.
73+
Breakpoint 4 at 0x18c: file src/06-registers/src/main.rs, line 25.
7474
(gdb) monitor reset halt
7575
Resetting and halting target
7676
Target halted
@@ -82,7 +82,7 @@ All right. Let's continue until the first breakpoint, right before line 16, and
8282
(gdb) c
8383
Continuing.
8484
85-
Breakpoint 1, registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:16
85+
Breakpoint 1, registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:16
8686
16 *(PORT_P0_OUT as *mut u32) |= 1 << 21;
8787
(gdb) x 0x50000504
8888
0x50000504: 0x00000000
@@ -97,12 +97,12 @@ Let's go on. This line consists of multiple instructions (reading, bitwise ORing
9797
Continuing.
9898
9999
Program received signal SIGINT, Interrupt.
100-
0x00000174 in registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:16
100+
0x00000174 in registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:16
101101
16 *(PORT_P0_OUT as *mut u32) |= 1 << 21;
102102
(gdb) c
103103
Continuing.
104104
105-
Breakpoint 2, registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:19
105+
Breakpoint 2, registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:19
106106
19 *(PORT_P0_OUT as *mut u32) |= 1 << 19;
107107
```
108108

@@ -126,12 +126,12 @@ Yeah, I was gonna say that. Now, hit 'c' another time to continue execution up t
126126

127127
```
128128
Program received signal SIGINT, Interrupt.
129-
0x0000017e in registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:19
129+
0x0000017e in registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:19
130130
19 *(PORT_P0_OUT as *mut u32) |= 1 << 19;
131131
(gdb) c
132132
Continuing.
133133
134-
Breakpoint 3, registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:22
134+
Breakpoint 3, registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:22
135135
22 *(PORT_P0_OUT as *mut u32) &= !(1 << 21);
136136
(gdb) x 0x50000504
137137
0x50000504: 0x00280000
@@ -150,26 +150,26 @@ Continue execution and check that the reported values of the `OUT` register matc
150150
Continuing.
151151
152152
Program received signal SIGINT, Interrupt.
153-
0x00000186 in registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:22
153+
0x00000186 in registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:22
154154
22 *(PORT_P0_OUT as *mut u32) &= !(1 << 21);
155155
(gdb) c
156156
Continuing.
157157
158-
Breakpoint 4, registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:25
158+
Breakpoint 4, registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:25
159159
25 *(PORT_P0_OUT as *mut u32) &= !(1 << 19);
160160
(gdb) x 0x50000504
161161
0x50000504: 0x00080000
162162
(gdb) c
163163
Continuing.
164164
165165
Program received signal SIGINT, Interrupt.
166-
0x0000018e in registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:25
166+
0x0000018e in registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:25
167167
25 *(PORT_P0_OUT as *mut u32) &= !(1 << 19);
168168
(gdb) c
169169
Continuing.
170170
^C
171171
Program received signal SIGINT, Interrupt.
172-
0x00000196 in registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:28
172+
0x00000196 in registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:28
173173
28 loop {}
174174
(gdb) x 0x50000504
175175
0x50000504: 0x00000000

mdbook/src/07-registers/type-safe-manipulation.md renamed to mdbook/src/06-registers/type-safe-manipulation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ cortex_m_rt::DefaultPreInit () at src/lib.rs:1058
6868
(gdb) continue
6969
Continuing.
7070
71-
Breakpoint 1, registers::__cortex_m_rt_main_trampoline () at src/07-registers/src/main.rs:7
71+
Breakpoint 1, registers::__cortex_m_rt_main_trampoline () at src/06-registers/src/main.rs:7
7272
7 #[entry]
7373
(gdb) continue
7474
Continuing.
7575
7676
Program received signal SIGINT, Interrupt.
77-
registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:8
77+
registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:8
7878
8 fn main() -> ! {
7979
(gdb) continue
8080
Continuing.
8181
82-
Breakpoint 4.2, registers::__cortex_m_rt_main () at src/07-registers/src/main.rs:12
82+
Breakpoint 4.2, registers::__cortex_m_rt_main () at src/06-registers/src/main.rs:12
8383
12 p0.out.modify(|_, w| w.pin21().set_bit());
8484
(gdb) print *p0 ; ⬅️ Printing `*p0` here!
8585
$1 = nrf52833_pac::p0::RegisterBlock {

mdbook/src/05-led-roulette/README.md renamed to mdbook/src/07-led-roulette/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The starter code is in the `src` directory of the book repository. Inside that d
1515
more directories named after each chapter of this book. Most of those directories are starter Cargo
1616
projects.
1717

18-
Now, jump into the `src/05-led-roulette` directory. Check the `examples/init.rs` file:
18+
Now, jump into the `src/07-led-roulette` directory. Check the `examples/init.rs` file:
1919

2020
``` rust
2121
{{#include examples/init.rs}}

mdbook/src/05-led-roulette/build-it.md renamed to mdbook/src/07-led-roulette/build-it.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ while [verifying your setup].
3939

4040

4141
With the `rust-std` component in place you can now cross compile the program using Cargo.
42-
Make sure you are in the `src/05-led-roulette` directory, then build. This initial code is an
42+
Make sure you are in the `src/07-led-roulette` directory, then build. This initial code is an
4343
example, so we compile it as such.
4444

4545
``` console

mdbook/src/05-led-roulette/debug-it.md renamed to mdbook/src/07-led-roulette/debug-it.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ setting a breakpoint there and then continuing program execution until we hit th
5454

5555
```
5656
(gdb) break main
57-
Breakpoint 1 at 0x104: file src/05-led-roulette/examples/init.rs, line 9.
57+
Breakpoint 1 at 0x104: file src/07-led-roulette/examples/init.rs, line 9.
5858
Note: automatically using hardware breakpoints for read-only addresses.
5959
(gdb) continue
6060
Continuing.
6161
62-
Breakpoint 1, init::__cortex_m_rt_main_trampoline () at src/05-led-roulette/examples/init.rs:9
62+
Breakpoint 1, init::__cortex_m_rt_main_trampoline () at src/07-led-roulette/examples/init.rs:9
6363
9 #[entry]
6464
```
6565

@@ -89,11 +89,11 @@ numbers. If we want to break in line 13 we can simply do:
8989

9090
```
9191
(gdb) break 13
92-
Breakpoint 2 at 0x110: file src/05-led-roulette/examples/init.rs, line 13.
92+
Breakpoint 2 at 0x110: file src/07-led-roulette/examples/init.rs, line 13.
9393
(gdb) continue
9494
Continuing.
9595
96-
Breakpoint 2, init::__cortex_m_rt_main () at src/05-led-roulette/examples/init.rs:13
96+
Breakpoint 2, init::__cortex_m_rt_main () at src/07-led-roulette/examples/init.rs:13
9797
(gdb)
9898
```
9999

@@ -201,7 +201,7 @@ One last trick before we move to something more interesting. Enter the following
201201
(gdb) c
202202
Continuing.
203203
204-
Breakpoint 1, init::__cortex_m_rt_main_trampoline () at src/05-led-roulette/src/main.rs:9
204+
Breakpoint 1, init::__cortex_m_rt_main_trampoline () at src/07-led-roulette/src/main.rs:9
205205
9 #[entry]
206206
(gdb)
207207
```

mdbook/src/SUMMARY.md

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,20 @@
1717
- [Timers](05-hello-world/timers.md)
1818
- [Portability](05-hello-world/portability.md)
1919
- [Board support crate](05-hello-world/board-support-crate.md)
20-
- [Registers](07-registers/README.md)
21-
- [RTRM](07-registers/rtrm.md)
22-
- [(mis)Optimization](07-registers/optimization.md)
23-
- [`0xBAAAAAAD` address](07-registers/bad-address.md)
24-
- [Spooky action at a distance](07-registers/spooky-action-at-a-distance.md)
25-
- [Type safe manipulation](07-registers/type-safe-manipulation.md)
26-
- [LED roulette](05-led-roulette/README.md)
27-
- [Build it](05-led-roulette/build-it.md)
28-
- [Flash it](05-led-roulette/flash-it.md)
29-
- [Debug it](05-led-roulette/debug-it.md)
30-
- [Light it up](05-led-roulette/light-it-up.md)
31-
- [It blinks](05-led-roulette/it-blinks.md)
32-
- [The challenge](05-led-roulette/the-challenge.md)
33-
- [My solution](05-led-roulette/my-solution.md)
34-
- [Clocks and timers](06-clocks-and-timers/README.md)
35-
- [`for` loop delays](06-clocks-and-timers/for-loop-delays.md)
36-
- [NOP](06-clocks-and-timers/nop.md)
37-
- [Registers](07-registers/README.md)
38-
- [RTRM](07-registers/rtrm.md)
39-
- [(mis)Optimization](07-registers/optimization.md)
40-
- [`0xBAAAAAAD` address](07-registers/bad-address.md)
41-
- [Spooky action at a distance](07-registers/spooky-action-at-a-distance.md)
42-
- [Type safe manipulation](07-registers/type-safe-manipulation.md)
20+
- [Registers](06-registers/README.md)
21+
- [RTRM](06-registers/rtrm.md)
22+
- [(mis)Optimization](06-registers/optimization.md)
23+
- [`0xBAAAAAAD` address](06-registers/bad-address.md)
24+
- [Spooky action at a distance](06-registers/spooky-action-at-a-distance.md)
25+
- [Type safe manipulation](06-registers/type-safe-manipulation.md)
26+
- [LED roulette](07-led-roulette/README.md)
27+
- [Build it](07-led-roulette/build-it.md)
28+
- [Flash it](07-led-roulette/flash-it.md)
29+
- [Debug it](07-led-roulette/debug-it.md)
30+
- [Light it up](07-led-roulette/light-it-up.md)
31+
- [It blinks](07-led-roulette/it-blinks.md)
32+
- [The challenge](07-led-roulette/the-challenge.md)
33+
- [My solution](07-led-roulette/my-solution.md)
4334
- [Serial communication](08-serial-communication/README.md)
4435
- [\*nix tooling](08-serial-communication/nix-tooling.md)
4536
- [Windows tooling](08-serial-communication/windows-tooling.md)

mdbook/src/appendix/2-how-to-use-gdb/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# How to use GDB
22

33
Below are some useful GDB commands that can help us debug our programs. This assumes you have
4-
[flashed a program](../../05-led-roulette/flash-it.md) onto your microcontroller and attached GDB to
4+
[flashed a program](../../07-led-roulette/flash-it.md) onto your microcontroller and attached GDB to
55
a `cargo-embed` session.
66

77
## General Debugging

rechapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def next_line(lines):
7878
if line is not None:
7979
print(line, file=ns)
8080
if ch - 1 != nch:
81-
print("chapter count mismatch: summary {ch - 1}, dir {nch}", file=sys.stderr)
81+
print(f"chapter count mismatch: summary {ch - 1}, dir {nch}", file=sys.stderr)
8282
exit(1)
8383

8484
sed_script = Path("rechapter.sed")

0 commit comments

Comments
 (0)