@@ -77,95 +77,36 @@ from `/tmp` directory (on Windows `%TEMP%`) to launch OpenOCD similar as describ
77
77
78
78
Alright. Now, let's build the starter code and flash it into the microcontroller.
79
79
80
- To avoid passing the ` --target thumbv7em-none-eabihf ` flag to every Cargo invocation we
81
- have added ` [build] ` with a default target, ` target = "thumbv7em-none-eabihf" ` , to .cargo/config.
82
- Now if ` --target ` is not specified ` cargo ` will assume that the target is ` thumbv7em-none-eabihf ` .
83
-
84
- ```
85
- [target.thumbv7em-none-eabihf]
86
- runner = "arm-none-eabi-gdb -q -x openocd.gdb"
87
- rustflags = [
88
- "-C", "link-arg=-Tlink.x",
89
- ]
90
-
91
- [build]
92
- target = "thumbv7em-none-eabihf"
93
- ```
94
-
95
- In addition, our ` opendocd.gdb ` has some additional lines. Compared to the previous
96
- section ` set ` 's and initialize ` monitor ` ing so ` iprint! ` and ` iprintln! `
97
- macros work and output is visible on a console. Below the contents with comments:
98
-
99
- ``` console
100
- $ cat openocd.gdb
101
- # Connect to gdb remote server
102
- target remote :3333
103
-
104
- # Load will flash the code
105
- load
106
-
107
- # Enable demangling asm names on disassembly
108
- set print asm-demangle on
109
-
110
- # Enable pretty printing
111
- set print pretty on
112
-
113
- # Disable style sources as the default colors can be hard to read
114
- set style sources off
115
-
116
- # Have the tpiu send the data to a file itm.txt
117
- monitor tpiu config internal itm.txt uart off 8000000
118
-
119
- # Turn on the itm port
120
- monitor itm port 0 on
121
-
122
- # Set a breakpoint at main
123
- break main
124
-
125
- # Continue running and we' ll hit the main breakpoint
126
- continue
127
- ```
128
-
129
- We will now run the application and single step through it. Since we've added
130
- the ` monitor ` commands in ` openocd.gdb ` OpenOCD will redirect the ITM output to
131
- itm.txt and ` itmdump ` will write it to its terminal window.
80
+ We will now build and run the application, ` cargo run ` . And step through it using ` next ` .
81
+ Since ` openocd.gdb ` contains the ` monitor ` commands in ` openocd.gdb ` OpenOCD will redirect
82
+ the ITM output to itm.txt and ` itmdump ` will write it to its terminal window. Also, it setup
83
+ break points and stepped through the trampoline we are at the first executable
84
+ statement in ` fn main() ` :
132
85
133
86
``` console
87
+ ~/embedded-discovery/src/06-hello-world
134
88
$ cargo run
135
89
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
136
- Running `arm-none-eabi-gdb -q -x openocd.gdb ~/prgs/rust/tutorial/embedded-discovery/target/thumbv7em-none-eabihf/debug/hello-world`
137
- Reading symbols from ~/prgs/rust/tutorial/embedded-discovery/target/thumbv7em-none-eabihf/debug/hello-world...
138
- 0x00000000 in ?? ()
90
+ Running `arm-none-eabi-gdb -q -x ../openocd.gdb ~/embedded-discovery/target/thumbv7em-none-eabihf/debug/hello-world`
91
+ Reading symbols from ~/embedded-discovery/target/thumbv7em-none-eabihf/debug/hello-world...
92
+ hello_world::__cortex_m_rt_main () at ~/embedded-discovery/src/06-hello-world/src/main.rs:14
93
+ 14 loop {}
139
94
Loading section .vector_table, size 0x194 lma 0x8000000
140
- Loading section .text, size 0x28d8 lma 0x8000194
141
- Loading section .rodata, size 0x6b8 lma 0x8002a6c
142
- Start address 0x08000194, load size 12580
143
- Transfer rate: 18 KB/sec, 4193 bytes/write.
144
- Breakpoint 1 at 0x80001f0: file src/06-hello-world/src/main.rs, line 8.
95
+ Loading section .text, size 0x2828 lma 0x8000194
96
+ Loading section .rodata, size 0x638 lma 0x80029bc
97
+ Start address 0x08000194, load size 12276
98
+ Transfer rate: 18 KB/sec, 4092 bytes/write.
99
+ Breakpoint 1 at 0x80001f0: file ~/embedded-discovery/ src/06-hello-world/src/main.rs, line 8.
145
100
Note: automatically using hardware breakpoints for read-only addresses.
101
+ Breakpoint 2 at 0x800092a: file /home/wink/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.6.13/src/lib.rs, line 570.
102
+ Breakpoint 3 at 0x80029a8: file /home/wink/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.6.13/src/lib.rs, line 560.
146
103
147
- Breakpoint 1, hello_world::__cortex_m_rt_main_trampoline () at src/06-hello-world/src/main.rs:8
104
+ Breakpoint 1, hello_world::__cortex_m_rt_main_trampoline () at ~/embedded-discovery/ src/06-hello-world/src/main.rs:8
148
105
8 #[entry]
149
- ```
150
-
151
- We are now stopped at ` #[entry] ` and since, as before, it's a trampoline:
106
+ hello_world::__cortex_m_rt_main () at ~/embedded-discovery/src/06-hello-world/src/main.rs:10
107
+ 10 let mut itm = aux6::init();
152
108
153
- ``` console
154
- (gdb) disassemble /m
155
- Dump of assembler code for function main:
156
- 8 #[entry]
157
- 0x080001ec <+0>: push {r7, lr}
158
- 0x080001ee <+2>: mov r7, sp
159
- => 0x080001f0 <+4>: bl 0x80001f6 <hello_world::__cortex_m_rt_main>
160
- 0x080001f4 <+8>: udf #254 ; 0xfe
161
- ```
162
-
163
- We need to initially ` step ` into the main function which will position us at line 10:
164
-
165
- ``` text
166
- (gdb) step
167
- hello_world::__cortex_m_rt_main () at src/06-hello-world/src/main.rs:10
168
- 10 let mut itm = aux6::init();
109
+ (gdb)
169
110
```
170
111
171
112
Now issue a ` next ` command which will exectue ` aux6::init() ` and
0 commit comments