Skip to content

Commit befe684

Browse files
bors[bot]neilpate
andauthored
Merge #323
323: Updated instructions for running first Hardware example r=eldruin a=neilpate The code in the example had changed but the instructions and debug output had not. As such, someone experimenting with the example may get confused when there is a mismatch. Co-authored-by: Neil Pate <[email protected]>
2 parents 6ca3b52 + 5794166 commit befe684

File tree

1 file changed

+28
-50
lines changed

1 file changed

+28
-50
lines changed

src/start/hardware.md

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ Now proceed to *flash* (load) the program onto the microcontroller using the
197197
``` console
198198
(gdb) load
199199
Loading section .vector_table, size 0x400 lma 0x8000000
200-
Loading section .text, size 0x1e70 lma 0x8000400
201-
Loading section .rodata, size 0x61c lma 0x8002270
202-
Start address 0x800144e, load size 10380
203-
Transfer rate: 17 KB/sec, 3460 bytes/write.
200+
Loading section .text, size 0x1518 lma 0x8000400
201+
Loading section .rodata, size 0x414 lma 0x8001918
202+
Start address 0x08000400, load size 7468
203+
Transfer rate: 13 KB/sec, 2489 bytes/write.
204204
```
205205

206206
The program is now loaded. This program uses semihosting so before we do any
@@ -219,78 +219,56 @@ Like before we can skip all the way to `main` using a breakpoint and the
219219

220220
``` console
221221
(gdb) break main
222-
Breakpoint 1 at 0x8000d18: file examples/hello.rs, line 15.
222+
Breakpoint 1 at 0x8000490: file examples/hello.rs, line 11.
223+
Note: automatically using hardware breakpoints for read-only addresses.
223224

224225
(gdb) continue
225226
Continuing.
226-
Note: automatically using hardware breakpoints for read-only addresses.
227227

228-
Breakpoint 1, main () at examples/hello.rs:15
229-
15 let mut stdout = hio::hstdout().unwrap();
228+
Breakpoint 1, hello::__cortex_m_rt_main_trampoline () at examples/hello.rs:11
229+
11 #[entry]
230230
```
231231

232232
> **NOTE** If GDB blocks the terminal instead of hitting the breakpoint after
233233
> you issue the `continue` command above, you might want to double check that
234234
> the memory region information in the `memory.x` file is correctly set up
235235
> for your device (both the starts *and* lengths).
236236
237-
Advancing the program with `next` should produce the same results as before.
237+
Step into the main function with `step`.
238238

239239
``` console
240-
(gdb) next
241-
16 writeln!(stdout, "Hello, world!").unwrap();
242-
243-
(gdb) next
244-
19 debug::exit(debug::EXIT_SUCCESS);
240+
(gdb) step
241+
halted: PC: 0x08000496
242+
hello::__cortex_m_rt_main () at examples/hello.rs:13
243+
13 hprintln!("Hello, world!").unwrap();
245244
```
246245

247-
At this point you should see "Hello, world!" printed on the OpenOCD console,
246+
After advancing the program with `next` you should see "Hello, world!" printed on the OpenOCD console,
248247
among other stuff.
249248

250-
``` text
251-
$ openocd
252-
(..)
253-
Info : halted: PC: 0x08000e6c
254-
Hello, world!
255-
Info : halted: PC: 0x08000d62
256-
Info : halted: PC: 0x08000d64
257-
Info : halted: PC: 0x08000d66
258-
Info : halted: PC: 0x08000d6a
259-
Info : halted: PC: 0x08000a0c
260-
Info : halted: PC: 0x08000d70
261-
Info : halted: PC: 0x08000d72
262-
```
263-
264-
Issuing another `next` will make the processor execute `debug::exit`. This acts
265-
as a breakpoint and halts the process:
266-
267249
``` console
268-
(gdb) next
269-
270-
Program received signal SIGTRAP, Trace/breakpoint trap.
271-
0x0800141a in __syscall ()
272-
```
273-
274-
It also causes this to be printed to the OpenOCD console:
275-
276-
``` text
277250
$ openocd
278251
(..)
279-
Info : halted: PC: 0x08001188
280-
semihosting: *** application exited ***
281-
Warn : target not halted
282-
Warn : target not halted
283-
target halted due to breakpoint, current mode: Thread
284-
xPSR: 0x21000000 pc: 0x08000d76 msp: 0x20009fc0, semihosting
252+
Info : halted: PC: 0x08000502
253+
Hello, world!
254+
Info : halted: PC: 0x080004ac
255+
Info : halted: PC: 0x080004ae
256+
Info : halted: PC: 0x080004b0
257+
Info : halted: PC: 0x080004b4
258+
Info : halted: PC: 0x080004b8
259+
Info : halted: PC: 0x080004bc
285260
```
286-
287-
However, the process running on the microcontroller has not terminated and you
288-
can resume it using `continue` or a similar command.
261+
The message is only displayed once as the program is about to enter the infinite loop defined in line 19: `loop {}`
289262

290263
You can now exit GDB using the `quit` command.
291264

292265
``` console
293266
(gdb) quit
267+
A debugging session is active.
268+
269+
Inferior 1 [Remote target] will be detached.
270+
271+
Quit anyway? (y or n)
294272
```
295273

296274
Debugging now requires a few more steps so we have packed all those steps into a

0 commit comments

Comments
 (0)