@@ -140,10 +140,80 @@ In both failing and successful cases you should see new output in the **OpenOCD
140
140
By default OpenOCD's GDB server listens on TCP port 3333 (localhost). This command is connecting to
141
141
that port.
142
142
143
+ ## Update .cargo/config
144
+
145
+ Now that you've successfully determined which debugger you need to use
146
+ we need to change ` .cargo/config ` so that ` cargo run ` command can succeed.
147
+
148
+ Get back to the terminal prompt and looking at ` .cargo/config ` :
149
+ ``` console
150
+ $ cat .cargo/config
151
+ [target.thumbv7em-none-eabihf]
152
+ runner = "arm-none-eabi-gdb -q"
153
+ rustflags = [
154
+ "-C", "link-arg=-Tlink.x",
155
+ ]
156
+
157
+ ```
158
+ Use your favorite editor to edit ` .cargo/config ` so that the
159
+ runner line contains the name of that debugger:
160
+ ``` console
161
+ nano .cargo/config
162
+ ```
163
+ For example, if your debugger was ` gdb-multiarch ` then after
164
+ editing you should have:
165
+ ``` console
166
+ $ cat .cargo/config
167
+ [target.thumbv7em-none-eabihf]
168
+ runner = "gdb-mulitarch -q"
169
+ rustflags = [
170
+ "-C", "link-arg=-Tlink.x",
171
+ ]
172
+ ```
173
+ And ` git diff ` should be:
174
+ ``` diff
175
+ $ git diff .cargo/config
176
+ diff --git a/src/05-led-roulette/.cargo/config b/src/05-led-roulette/.cargo/config
177
+ index 01d25c8..c23dc80 100644
178
+ --- a/src/05-led-roulette/.cargo/config
179
+ +++ b/src/05-led-roulette/.cargo/config
180
+ @@ -1,5 +1,5 @@
181
+ [target.thumbv7em-none-eabihf]
182
+ - runner = "arm-none-eabi-gdb -q"
183
+ + runner = "gdb-multiarch -q"
184
+ rustflags = [
185
+ "-C", "link-arg=-Tlink.x",
186
+ ]
187
+ ```
188
+
189
+ Now that you have ` .cargo/config ` setup to let's test it and use ` cargo run ` to
190
+ start the debug session:
191
+ ```
192
+ ~/embedded-discovery/src/05-led-roulette
193
+ $ cargo run --target thumbv7em-none-eabihf
194
+ Finished dev [unoptimized + debuginfo] target(s) in 0.01s
195
+ Running `arm-none-eabi-gdb -q ~/embedded-discovery/target/thumbv7em-none-eabihf/debug/led-roulette`
196
+ Reading symbols from ~/embedded-discovery/target/thumbv7em-none-eabihf/debug/led-roulette...
197
+
198
+ (gdb) target remote :3333
199
+ Remote debugging using :3333
200
+ 0x00000000 in ?? ()
201
+
202
+ (gdb)
203
+ ```
204
+
205
+ Bravo, you'll be making additional changes to ` .cargo/config ` in future
206
+ sections to make building and debugging easier.
207
+
208
+ > ** Note** the default ` .cargo/config ` in every chapter assumes
209
+ > the debugger is ` arm-none-eabi-gdb ` . So the first thing you should
210
+ > do when you start a new chapter is edit ` .cargo/config ` !
211
+
143
212
## Flash the device
144
213
145
- Almost there. To flash the device, we'll use the ` load ` command inside the GDB shell:
214
+ Assuming you have gdb running, if not start it as suggested in the previous section.
146
215
216
+ Now use the ` load ` command in ` gdb ` to actually flash the program into the device:
147
217
```
148
218
(gdb) load
149
219
Loading section .vector_table, size 0x194 lma 0x8000000
0 commit comments