@@ -11,7 +11,7 @@ Onto the actual flashing. First thing we need is to do is launch OpenOCD. We did
1111previous section but this time we'll run the command inside a temporary directory (` /tmp ` on \* nix;
1212` %TEMP% ` on Windows).
1313
14- Make sure the F3 is connected to your computer and run the following commands on a ** new terminal** .
14+ Make sure the F3 is connected to your computer and run the following commands in a ** new terminal** .
1515
1616## For * nix & MacOS:
1717``` console
@@ -85,7 +85,7 @@ I mentioned that OpenOCD provides a GDB server so let's connect to that right no
8585
8686## Execute GDB
8787
88- First we need to determine what version of GDB you have that is capable of debugging ARM binaries.
88+ First, we need to determine what version of ` gdb ` you have that is capable of debugging ARM binaries.
8989
9090This could be any one of the commands below, try each one:
9191``` console
@@ -140,74 +140,87 @@ In both failing and successful cases you should see new output in the **OpenOCD
140140By default OpenOCD's GDB server listens on TCP port 3333 (localhost). This command is connecting to
141141that port.
142142
143- ## Update .cargo/config
143+ ## Update ../. cargo/config.toml
144144
145145Now 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.
146+ we need to change ` ../cargo/config.toml ` so that ` cargo run ` command will succeed.
147+ Note: ` cargo ` is the rust package manager and you can read about it
148+ [ here] ( https://doc.rust-lang.org/cargo/ ) .
147149
148- Get back to the terminal prompt and looking at ` .cargo/config ` :
150+ Get back to the terminal prompt and look at ` ../ cargo/config.toml ` :
149151``` console
150- $ cat .cargo/config
152+ ~/embedded-discovery/src/05-led-roulette
153+ $ cat ../.cargo/config.toml
151154[target.thumbv7em-none-eabihf]
152155runner = "arm-none-eabi-gdb -q"
156+ # runner = " gdb-multiarch -q"
157+ # runner = " gdb -q"
153158rustflags = [
154159 "-C", "link-arg=-Tlink.x",
155160]
156161
162+ [build]
163+ target = "thumbv7em-none-eabihf"
164+
157165```
158- Use your favorite editor to edit ` .cargo/config ` so that the
159- runner line contains the name of that debugger:
166+ Use your favorite editor to edit ` ../. cargo/config.toml ` so that the
167+ ` runner ` line contains the correct name of that debugger:
160168``` console
161- nano .cargo/config
169+ nano ../. cargo/config.toml
162170```
163171For 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:
172+ editing the ` git diff ` should be:
174173``` 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 @@
174+ $ git diff ../. cargo/config.toml
175+ diff --git a/src/.cargo/config.toml b/src/.cargo/config.toml
176+ index ddff17f..8512cfe 100644
177+ --- a/src/.cargo/config.toml
178+ +++ b/src/.cargo/config.toml
179+ @@ -1,6 +1,6 @@
181180 [target.thumbv7em-none-eabihf]
182181- runner = "arm-none-eabi-gdb -q"
182+ - # runner = "gdb-multiarch -q"
183+ + # runner = "arm-none-eabi-gdb -q"
183184+ runner = "gdb-multiarch -q"
185+ # runner = "gdb -q"
184186 rustflags = [
185187 "-C", "link-arg=-Tlink.x",
186- ]
187188```
188189
189- Now that you have ` .cargo/config ` setup to let's test it and use ` cargo run ` to
190- start the debug session:
190+ Now that you have ` ../.cargo/config.toml ` setup let's test it using ` cargo run ` to
191+ start the debug session.
192+
193+ > Note the ` --target thumbv7em-none-eabihf ` defines which architecture
194+ > to build and run. In our ` ../.cargo/config.toml ` file we have
195+ > ` target = "thumbv7em-none-eabihf" ` so it is actually not necessary
196+ > to specify ` --target ` we do it here just so you know that parameters on
197+ > the command line can be used and they override those in ` config.toml ` files
198+
199+ ```
200+ cargo run --target thumbv7em-none-eabihf
201+ ```
202+ Results in:
191203```
192204~/embedded-discovery/src/05-led-roulette
193205$ cargo run --target thumbv7em-none-eabihf
194206 Finished dev [unoptimized + debuginfo] target(s) in 0.01s
195207 Running `arm-none-eabi-gdb -q ~/embedded-discovery/target/thumbv7em-none-eabihf/debug/led-roulette`
196208Reading symbols from ~/embedded-discovery/target/thumbv7em-none-eabihf/debug/led-roulette...
209+ ```
197210
211+ Now issue the ` target remote :3333 ` to connect to the OpenOCD server
212+ and connect to the F3:
213+ ```
198214(gdb) target remote :3333
199215Remote debugging using :3333
2002160x00000000 in ?? ()
201-
202- (gdb)
203217```
204218
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 ` !
219+ Bravo, we will be modifying ` ../.cargo/config.toml ` in future. ** But** , since
220+ this file is shared with all of the chapters those changes should be made with
221+ that in mind. If you want or we need to make changes that only pertain to
222+ a particular chapter then create a ` .cargo/config.toml ` local to that chapter
223+ directory.
211224
212225## Flash the device
213226
0 commit comments