Skip to content

Commit 4930c27

Browse files
committed
docs: add CLion integration guide
1 parent ffb0be9 commit 4930c27

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

README.md

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,23 +234,56 @@ You can use the generated code by linking in your executable the targets:
234234
- `Harmony::SysInit`: the SYS_Initialize() function that does the clock init.
235235

236236
## Uploading code
237-
You can upload compiled `.elf` binaries using OpenOCD. Assuming a common
238-
development board (Atmel SAMV71 Xplained Ultra), OpenOCD can do this:
237+
You can upload compiled `.elf` binaries using [OpenOCD](https://openocd.org)
238+
and a suitable configuration file (e.g. `atmel_samv71_xplained_ultra.cfg` for
239+
the Atmel SAMV71 Xplained Ultra board) with the following command:
240+
239241
```shell
240242
openocd -f /path/to/cfg/file -c "program /path/to/compiled/binary.elf reset"
241243
```
242244

243245
## Attaching a debugger
244-
OpenOCD automatically opens a GDB debug server to which you can connect if
245-
needed, for complete control, as follows:
246+
OpenOCD automatically opens a debug server to which you can connect using
247+
GDB if needed, as follows:
246248
```shell
247249
arm-none-eabi-gdb /path/to/compiled/binary_with_symbols.elf
248250
```
249251
Within GDB, run the following command to connect:
250252
`target extended-remote localhost:3333`
251253

252254
## CLion integration
253-
TODO
255+
256+
Many developers in the team prefer using CLion for day-to-day coding. Conan
257+
generates CMake presets, which can be used for setting up CLion run
258+
configurations as follows:
259+
260+
1. Generate CMake toolchains for `Debug` and `Release` builds using:
261+
- `conan install . -pr=baremetal-samv71-armv7 -s build_type=Debug`
262+
- `conan install . -pr=baremetal-samv71-armv7 -s build_type=Release`
263+
This should have generated a `CMakeUserPresets.json` file in the project
264+
directory.
265+
266+
2. Start CLion and open the project directory (`Open` button).
267+
3. CLion should pop up a message in the lower right corner stating
268+
`Loaded XXXX CMake presets` and a window named `Open Project Wizard`.
269+
4. In the `Open Project Wizard`, disable the default `Debug` profile by
270+
unticking the `Enable profile` checkbox. Enable only the `conan-debug`
271+
and `conan-release` profiles.
272+
5. Click `OK`. You should now have two options for `conan-debug`
273+
and `conan-release`, so you can switch between them at will.
274+
6. Add an OpenOCD run configuration via `Run -> Edit Configurations`.
275+
Click the `+` button on the upper left corner and select
276+
`OpenOCD Download and Run` from the list.
277+
7. Set the `Executable binary` to your project's binary target,
278+
the `Debugger` to `arm-none-eabi-gdb` and the
279+
`Board config file` to OpenOCD's `cfg` file. Leave the rest of the
280+
settings at default.
281+
8. Click `OK`.
282+
283+
If everything went well, add a random breakpoint in your code (make sure
284+
it's actually reachable) and try running the debugger from the "bug" icon.
285+
CLion should build, upload and attach automatically, and when the breakpoint
286+
is hit CLion's debug interface will start up, letting you step as always.
254287

255288
# Appendix: Conan package description
256289
## Device Family Pack (DFP)
@@ -285,4 +318,4 @@ TODO
285318

286319
# Examples
287320
The repository includes example code under `examples/`. Refer to each example's
288-
README files for details on building.
321+
README files for details.

0 commit comments

Comments
 (0)