Skip to content

Commit 13a8404

Browse files
committed
[build] Add common Python embedded tools
2 parents d21e991 + 7f494fd commit 13a8404

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2508
-1391
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.

examples/nucleo_f103rb/hard_fault/main.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ main()
5454
if (FaultReporter::hasReport())
5555
{
5656
MODM_LOG_ERROR << "\n\nHardFault! Copy the data into a 'coredump.txt' file, ";
57-
MODM_LOG_ERROR << "then execute\n\n\tscons postmortem firmware=" << modm::hex;
57+
MODM_LOG_ERROR << "then execute\n\n\tscons debug-coredump ";
58+
#ifdef MODM_DEBUG_BUILD
59+
MODM_LOG_ERROR << "profile=debug ";
60+
#endif
61+
MODM_LOG_ERROR << "firmware=" << modm::hex;
5862
for (const auto data : FaultReporter::buildId()) MODM_LOG_ERROR << data;
5963
MODM_LOG_ERROR << "\n\n";
6064
for (const auto data : FaultReporter())

examples/stm32f469_discovery/hard_fault/main.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ main()
5454
if (FaultReporter::hasReport())
5555
{
5656
MODM_LOG_ERROR << "\n\nHardFault! Copy the data into a 'coredump.txt' file, ";
57-
MODM_LOG_ERROR << "then execute\n\n\tscons postmortem firmware=" << modm::hex;
57+
MODM_LOG_ERROR << "then execute\n\n\tscons debug-coredump ";
58+
#ifdef MODM_DEBUG_BUILD
59+
MODM_LOG_ERROR << "profile=debug ";
60+
#endif
61+
MODM_LOG_ERROR << "firmware=" << modm::hex;
5862
for (const auto data : FaultReporter::buildId()) MODM_LOG_ERROR << data;
5963
MODM_LOG_ERROR << "\n\n";
6064
for (const auto data : FaultReporter())

src/modm/platform/core/cortex/module.lb

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ def build(env):
273273
env.copy("delay.hpp")
274274

275275
# GNU Build ID
276+
env.collect(":build:linkflags", "-Wl,--build-id=sha1")
276277
if env.has_module(":architecture:build_id"):
277278
env.copy("build_id.cpp")
278-
env.collect(":build:linkflags", "-Wl,--build-id=sha1")
279279

280280
if env.has_module(":architecture:clock"):
281281
# modm-test implements the clock methods itself

src/unittest/controller.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ namespace unittest
5858
void
5959
nextTestSuite(modm::accessor::Flash<char> name) const;
6060

61+
/// Run the generated unittest
62+
static int
63+
run(Reporter reporter);
64+
6165
private:
6266
Controller();
6367

test/config/al-avreb-can.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:al-avreb-can</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/al-avreb-can/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/avr.cpp.in</option>
76
<!-- <option name="modm:build:avrdude.programmer">avrispmkII</option> -->
87
<option name="modm:build:avrdude.programmer">usbasp-clone</option>
98
<option name="modm:build:scons:info.git">Disabled</option>

test/config/arduino-nano.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:arduino-nano</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/arduino-nano/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/avr.cpp.in</option>
76
<option name="modm:build:scons:info.git">Disabled</option>
87
<option name="modm:build:avrdude.port">/dev/tty.usbserial-1410</option>
98
<option name="modm:io:with_float">True</option>

test/config/arduino-uno.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:arduino-uno</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/arduino-uno/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/avr.cpp.in</option>
76
<option name="modm:build:scons:info.git">Disabled</option>
87
<option name="modm:build:avrdude.port">/dev/tty.usbserial-1410</option>
98
<option name="modm:io:with_float">True</option>

test/config/hosted.xml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<library>
33
<options>
44
<option name="modm:build:scons:unittest.source">../../build/unittest/hosted/modm-test</option>
5-
<option name="modm:build:scons:unittest.runner">../runner/hosted.cpp.in</option>
65
</options>
76
<modules>
87
<module>modm:platform:core</module>

test/config/nucleo-f103.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:nucleo-f103rb</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/nucleo-f103/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/stm32.cpp.in</option>
76
</options>
87
<modules>
98
<module>modm:platform:heap</module>

test/config/nucleo-f401.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:nucleo-f401re</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/nucleo-f401/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/stm32.cpp.in</option>
76
</options>
87
<modules>
98
<module>modm:platform:heap</module>

test/config/nucleo-f411.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:nucleo-f411re</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/nucleo-f411/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/stm32.cpp.in</option>
76
</options>
87
<modules>
98
<module>modm:platform:heap</module>

test/config/nucleo-f446.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:nucleo-f446re</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/nucleo-f446/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/stm32.cpp.in</option>
76
</options>
87
<modules>
98
<module>modm:platform:heap</module>

test/config/nucleo-l432.xml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<extends>modm:nucleo-l432kc</extends>
44
<options>
55
<option name="modm:build:scons:unittest.source">../../build/unittest/nucleo-l432/modm-test</option>
6-
<option name="modm:build:scons:unittest.runner">../runner/stm32.cpp.in</option>
76
</options>
87
<modules>
98
<module>modm:platform:heap</module>

test/module.lb

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ def prepare(module, options):
2222

2323
def build(env):
2424
env.collect("modm:build:path.include", "modm-test/src")
25+
env.outbasepath = "."
26+
env.copy("runner/{}.cpp".format(env[":target"].identifier.platform),
27+
"main.cpp")

test/runner/avr.cpp.in test/runner/avr.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@
1313
// ----------------------------------------------------------------------------
1414

1515
#include <modm/board.hpp>
16-
17-
#include <unittest/reporter.hpp>
1816
#include <unittest/controller.hpp>
1917

2018
using namespace modm::platform;
2119

22-
${includes}
23-
24-
${names}
25-
2620
extern Board::LoggerDevice loggerDevice;
2721

2822
int
@@ -34,15 +28,9 @@ main()
3428

3529
loggerDevice.write("Unittests (" __DATE__ ", " __TIME__")\n");
3630

37-
unittest::Reporter reporter(loggerDevice);
38-
unittest::Controller::instance().setReporter(reporter);
39-
4031
Board::Leds::write(0b110);
4132

42-
// run tests
43-
${tests}
44-
45-
unittest::Controller::instance().getReporter().printSummary();
33+
unittest::Controller::run(loggerDevice);
4634

4735
Board::Leds::write(0b111);
4836
for (;;) {}

test/runner/hosted.cpp.in test/runner/hosted.cpp

+2-14
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
// ----------------------------------------------------------------------------
1515

16-
#include <unittest/reporter.hpp>
1716
#include <unittest/controller.hpp>
1817

1918
#include <modm/debug/logger.hpp>
@@ -41,16 +40,8 @@ modm::log::StyleWrapper< modm::log::Prefix< char[10] > > loggerDeviceError( \
4140
modm::log::Prefix< char[10] >("Error : ", outputDevice ));
4241
modm::log::Logger modm::log::error(loggerDeviceError);
4342

44-
${includes}
45-
46-
${names}
47-
48-
int
49-
main()
43+
int main()
5044
{
51-
unittest::Reporter reporter(outputDevice);
52-
unittest::Controller::instance().setReporter(reporter);
53-
5445
MODM_LOG_INFO << "Machine: " << MODM_BUILD_MACHINE << modm::endl;
5546
MODM_LOG_INFO << "User: " << MODM_BUILD_USER << modm::endl;
5647
MODM_LOG_INFO << "Os: " << MODM_BUILD_OS << modm::endl;
@@ -81,8 +72,5 @@ main()
8172
MODM_LOG_INFO << "Copied: " << MODM_GIT_COPIED << modm::endl;
8273
MODM_LOG_INFO << "Untracked: " << MODM_GIT_UNTRACKED << modm::endl;
8374

84-
// run tests
85-
${tests}
86-
87-
return unittest::Controller::instance().getReporter().printSummary();
75+
return unittest::Controller::run(outputDevice);
8876
}

test/runner/stm32.cpp.in test/runner/stm32.cpp

+1-12
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@
1515
#include <modm/board.hpp>
1616
#include <modm/debug/logger.hpp>
1717

18-
#include <unittest/reporter.hpp>
1918
#include <unittest/controller.hpp>
2019

2120
#include <info_git.h>
2221
#include <info_build.h>
2322

24-
${includes}
25-
26-
${names}
27-
2823
using namespace modm::platform;
2924

3025
// Reuse logger from board
@@ -69,15 +64,9 @@ main()
6964
MODM_LOG_INFO << "Copied: " << MODM_GIT_COPIED << modm::endl;
7065
MODM_LOG_INFO << "Untracked: " << MODM_GIT_UNTRACKED << modm::endl << modm::endl;
7166

72-
unittest::Reporter reporter(loggerDevice);
73-
unittest::Controller::instance().setReporter(reporter);
74-
7567
Board::Leds::write(0b110);
7668

77-
// run tests
78-
${tests}
79-
80-
unittest::Controller::instance().getReporter().printSummary();
69+
unittest::Controller::run(loggerDevice);
8170

8271
Board::Leds::write(0b111);
8372
for (;;) {}

tools/build_script_generator/cmake/module.lb

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ def post_build(env):
6767
})
6868
if subs["platform"] == "avr":
6969
subs.update(env.query("::avrdude_options"))
70+
if subs["core"].startswith("cortex-m"):
71+
# get memory information
72+
subs["memories"] = env.query("::memories")
73+
else:
74+
subs["memories"] = []
7075
# Set these substitutions for all templates
7176
env.substitutions = subs
7277

0 commit comments

Comments
 (0)