Skip to content

Commit 7f494fd

Browse files
committed
[docs] Update with modm_tools docs
1 parent 78e6e03 commit 7f494fd

File tree

7 files changed

+422
-217
lines changed

7 files changed

+422
-217
lines changed

docs/src/guide/installation.md

+44-16
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ This is the required software for generating, compiling and programming projects
44
with modm:
55

66
- [Python 3](http://www.python.org/)
7-
- [Software Construct](http://www.scons.org/)
7+
- [Software Construct][scons] or [CMake][]
88
- [Library Builder][lbuild]
99
- AVR toolchain: [avr-gcc][] and [avrdude][]
1010
- ARM toolchain: [gcc-arm-toolchain][] and [OpenOCD][].
11-
- [Doxygen](http://www.doxygen.nl)
11+
- Optional: [Doxygen][] or [Doxypress][]
12+
- Optional: [gdbgui][] for IDE-independent debugging
1213

1314
Note that the modm examples use the SCons build system by default, however,
1415
you are not *required* to use it. See [the reference manual](../../reference/build-systems) for
@@ -48,11 +49,17 @@ well:
4849
brew install arm-gcc-bin
4950
brew install openocd --HEAD
5051

51-
scons now works with Python 3. Unfortunately, macOS still defaults to Python 2.
52+
We recommend the use of a graphical frontend for GDB called [gdbgui][]:
53+
54+
pip3 install gdbgui
55+
56+
SCons now works with Python 3. Unfortunately, macOS still defaults to Python 2.
5257
For a less intrusive way to run all scons scripts with Python 3 add this to your
5358
`.bashrc` or `.zshrc`:
5459

5560
alias scons="/usr/bin/env python3 $(which scons)"
61+
# or if your using scons elsewhere too:
62+
alias scons3="/usr/bin/env python3 $(which scons)"
5663

5764
To compile modm *for macOS* (and not the embedded target) you need to install
5865
some of these libraries as well, depending on what modm modules you use:
@@ -81,12 +88,16 @@ Install the AVR toochain:
8188
!!! bug "avr-gcc on Ubuntu"
8289
Ubuntu does not provide an up-to-date version of avr-gcc that supports C++17.
8390
For our CI we've created a [precompiled version of avr-gcc for Ubuntu][avr-gcc-latest].
84-
Use at your own risk.
91+
Unfortunately its path is hardcoded to `/work/avr-gcc`.
8592

8693
Install the ARM toochain by downloading [the pre-built version][gcc-arm-toolchain]
8794
for 64-bit Linux and adding its `/bin` directory to your path.
88-
Even though your distribution may ship their own ARM toolchain, we *very strongly
89-
recommend* using the official toolchain, since all of modm is tested with it.
95+
**Even though your distribution may ship their own ARM toolchain, we very strongly
96+
recommend using the official toolchain, since all of modm is tested with it.**
97+
98+
We recommend the use of a graphical frontend for GDB called [gdbgui][]:
99+
100+
pip3 install gdbgui
90101

91102
To compile modm *for Linux* (and not the embedded target) you need to install
92103
some of these libraries as well, depending on what modm modules you use:
@@ -96,32 +107,49 @@ some of these libraries as well, depending on what modm modules you use:
96107

97108
## Windows
98109

99-
We will use [Anaconda](https://www.anaconda.com/) ([Miniconda](http://conda.pydata.org/miniconda.html) [Windows installation](https://docs.conda.io/en/latest/miniconda.html#windows-installers) is sufficient) to create a new Python 3 environment and install all
100-
necessary packages:
110+
We will use [Anaconda][] ([Miniconda Windows installation][miniconda] is
111+
sufficient) to create a new Python 3 environment and install all necessary
112+
packages:
101113

102114
conda create --name modm python=3 pip
103115
activate modm
104116
conda install -c conda-forge git
105-
pip install jinja2 scons future pyelftools lbuild
117+
pip install jinja2 scons future pyelftools lbuild gdbgui
106118

107119
For ARM development install the Windows 32-bit build of the [GNU Arm Embedded
108120
Toolchain][gcc-arm-toolchain]. For programming and debugging ARM Cortex-M
109-
devices install the pre-build [OpenOCD binaries](http://gnutoolchains.com/arm-eabi/openocd/).
121+
devices install the pre-build [OpenOCD binaries][openocd_binaries].
110122
You'll need to add both `/bin` paths to your `PATH` variable manually.
111123

112124
!!! warning "For non-English speakers"
113-
For now project and build paths containing non-ASCII characters are not parsed correctly.
125+
For now project and build paths containing non-ASCII characters are not
126+
parsed correctly.
127+
128+
!!! warning "Windows paths"
129+
Windows created maximal incompatibility with it's `\` path separator.
130+
Even though we try hard to not hardcode the path separator, there may still
131+
be issues related to this. [Please open an issue][newissue] in that case.
114132

115133
!!! info "Dear Windows users"
116-
We don't regularly use Windows with modm, so we rely on YOU to keep these install instructions
117-
working and up-to-date. Please [open a PR with improvements][contribute].
134+
We don't regularly use Windows with modm, so we rely on YOU to keep these
135+
install instructions working and up-to-date. Please [open a PR with
136+
improvements][contribute].
118137

119138

120139
[contribute]: https://github.com/modm-io/modm/blob/develop/CONTRIBUTING.md
140+
[newissue]: https://github.com/modm-io/modm/issues/new
121141
[examples]: https://github.com/modm-io/modm/tree/develop/examples
122142
[gcc-arm-toolchain]: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm
123143
[openocd]: http://openocd.org
124-
[avr-gcc]: http://www.nongnu.org/avr-libc
125-
[avrdude]: http://www.nongnu.org/avrdude
144+
[avr-gcc]: https://www.nongnu.org/avr-libc
145+
[avrdude]: https://www.nongnu.org/avrdude
126146
[lbuild]: https://github.com/modm-io/lbuild
127-
[avr-gcc-latest]: https://github.com/salkinium/docker-avr-gcc/releases
147+
[scons]: https://www.scons.org
148+
[cmake]: https://www.cmake.org
149+
[anaconda]: https://www.anaconda.com
150+
[miniconda]: https://docs.conda.io/en/latest/miniconda.html#windows-installers
151+
[avr-gcc-latest]: https://github.com/modm-ext/docker-avr-gcc/releases
152+
[openocd_binaries]: https://gnutoolchains.com/arm-eabi/openocd
153+
[doxygen]: http://www.doxygen.nl
154+
[doxypress]: https://www.copperspice.com/documentation-doxypress.html
155+
[gdbgui]: https://www.gdbgui.com

docs/src/reference/documentation.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ The generated Doxypress/Doxygen documentation contains the original module docum
8383
lbuild options to changes in the generated source code.
8484

8585

86-
### Online API documentation
86+
## Online API Docs
8787

88-
API documentation is available at https://docs.modm.io/ for a large and representative
89-
number of targets with all modules enabled.
88+
API documentation is available at [docs.modm.io](https://docs.modm.io/) for a
89+
large and representative number of targets with all modules enabled.

tools/build_script_generator/cmake/module.md

+94-24
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,33 @@ Generates the CMake build folders and initializes the build system.
4141
If you forget to call this first, the build will fail with this error message:
4242

4343
```
44-
$ make build-release
44+
$ make build
4545
Error: build/cmake-build-release is not a directory
4646
make: *** [build-release] Error 1
4747
```
4848

4949

50-
#### make build-release
51-
#### make build-debug
50+
#### make clean
51+
52+
Removes the CMake build artifacts.
53+
54+
55+
#### make cleanall
56+
57+
Removes the entire build folder. You must then first call `make cmake` before
58+
being able to build again.
59+
60+
61+
#### make build
62+
63+
```
64+
make build profile={debug|release}
65+
```
5266

5367
Compiles your application into an executable using the release or debug profile.
5468

5569
```
56-
$ make build-release
70+
$ make build profile=release
5771
Scanning dependencies of target blink_cmake
5872
[ 3%] Building C object CMakeFiles/blink_cmake.dir/modm/ext/cmsis/device/peripherals.c.o
5973
[ 7%] Building CXX object CMakeFiles/blink_cmake.dir/modm/src/modm/architecture/driver/atomic/flag.cpp.o
@@ -69,16 +83,41 @@ Scanning dependencies of target blink_cmake
6983
```
7084

7185

72-
#### make upload-release
73-
#### make upload-debug
86+
#### make size
87+
88+
```
89+
make size profile={debug|release}
90+
```
91+
92+
Displays the static Flash and RAM consumption of your target.
93+
94+
Example for the Blue Pill target:
95+
96+
```
97+
$ make size
98+
99+
Program: 1.4 KiB (2.2% used)
100+
(.build_id + .fastcode + .fastdata + .hardware_init + .rodata +
101+
.table.copy.intern + .table.heap + .table.zero.intern + .text + .vector_rom)
102+
103+
Data: 3.0 KiB (15.1% used) = 20 B static (0.1%) + 3072 B stack (15.0%)
104+
(.bss + .fastdata + .stack)
105+
106+
Heap: 17.0 KiB (84.9% available)
107+
(.heap1)
108+
```
109+
110+
111+
#### make program
112+
113+
```
114+
make program profile={debug|release} [port={serial-port}]
115+
```
74116

75117
Writes the executable onto your target via AvrDude or OpenOCD.
76-
This is a convenience wrapper around the programming options and methods
77-
defined in the `modm:build` module.
78-
(\* *only AVR and ARM Cortex-M targets*)
79118

80119
```
81-
$ make upload-release
120+
$ make program
82121
[100%] Built target blink_cmake
83122
[100%] Built target blink_cmake.bin
84123
[100%] Built target blink_cmake.hex
@@ -102,33 +141,64 @@ verified 1652 bytes in 0.104584s (15.426 KiB/s)
102141
shutdown command invoked
103142
```
104143

144+
#### make program-bmp
105145

106-
#### make gdb
107-
#### make gdb-release
146+
```
147+
make program-bmp profile={debug|release} [port={serial-port}]
148+
```
108149

109-
Launches GDB with the debug or release executable.
110-
This is just a convenience wrapper for the debug functionality defined in the
111-
`modm:build` module.
150+
Writes the executable onto your target via Black Magic Probe.
112151
(\* *only ARM Cortex-M targets*)
113152

114-
**OpenOCD must already be running in the background**. Launch it by manually
115-
calling `make openocd` in another terminal.
116153

154+
#### make debug
117155

118-
#### make openocd
156+
```
157+
make debug profile={debug|release} ui={tui|web}
158+
```
119159

120-
Starts OpenOCD with the modm specific configuration.
160+
Launches OpenOCD in the background, then launches GDB in foreground with the
161+
correct executable with text-based or [web-based gdbgui](gdbgui) UI. When GDB
162+
exits, it stops the OpenOCD process.
163+
(\* *only ARM Cortex-M targets*)
121164

165+
To use gdbgui you must have it installed via `pip install gdbgui`.
122166

123-
#### make clean
167+
!!! tip "Choose the correct profile"
168+
When debugging, make sure to select the correct compilation profile. The
169+
firmware and the executable given to GDB have to be the some or you'll see
170+
GDB translate the program counter to the wrong code locations. When you
171+
suspect a bug in your firmware, consider that it was most likely compiled
172+
with the release profile, since that's the default. First try to
173+
`make debug profile=release`, and if that doesn't help, compile and
174+
`make program profile=debug` and try `make debug profile=debug` again.
124175

125-
Removes the CMake build artifacts.
126176

177+
#### make debug-coredump
127178

128-
#### make cleanall
179+
```
180+
make debug-coredump profile={debug|release} ui={tui|web}
181+
```
129182

130-
Removes the entire build folder. You must then first call `make cmake` before
131-
being able to build again.
183+
Launches GDB for post-mortem debugging with the using the data in the
184+
`coredump.txt` argument.
185+
(\* *only ARM Cortex-M targets*)
186+
187+
See the `:platform:fault` module for details how to receive the coredump data.
188+
189+
190+
#### make log-itm
191+
192+
```
193+
make log-itm fcpu={HCLK in Hz}
194+
```
195+
196+
Configures OpenOCD in tracing mode to output ITM channel 0 on SWO pin and
197+
displays the serial output stream.
198+
199+
See the `:platform:itm` module for details how to use the ITM as a logging
200+
output.
132201

133202

134203
[cmake]: http://cmake.org
204+
[gdbgui]: https://www.gdbgui.com

tools/build_script_generator/module.lb

+27-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,41 @@
1010
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
1111
# -----------------------------------------------------------------------------
1212

13-
import os
13+
import os, sys
14+
from pathlib import Path
1415

1516
# import all common code
1617
with open(localpath("common.py")) as common:
1718
exec(common.read())
1819

20+
class BuildModuleDocs:
21+
def __init__(self):
22+
self._content = None
23+
24+
def __str__(self):
25+
if self._content is None:
26+
self._content = Path(localpath("module.md")).read_text().strip()
27+
tools = ["avrdude", "openocd", "bmp", "gdb", "size",
28+
"unittest", "log", "build_id", "bitmap"]
29+
30+
for tool in tools:
31+
tpath = Path(repopath("tools/modm_tools/{}.py".format(tool)))
32+
doc = None
33+
if tpath.with_suffix(".md").exists():
34+
doc = tpath.with_suffix(".md").read_text()
35+
elif tpath.exists():
36+
co = compile(tpath.read_bytes(), tpath, 'exec')
37+
if co.co_consts and isinstance(co.co_consts[0], str):
38+
doc = co.co_consts[0]
39+
if doc is not None:
40+
self._content += "\n\n\n" + doc.strip()
41+
42+
return self._content
1943

44+
# -----------------------------------------------------------------------------
2045
def init(module):
2146
module.name = ":build"
22-
module.description = FileReader("module.md")
47+
module.description = BuildModuleDocs()
2348

2449

2550
def prepare(module, options):

0 commit comments

Comments
 (0)