Skip to content

Commit d7bcdcb

Browse files
committed
Add compile/flash section in ReadMe
1 parent bd520e5 commit d7bcdcb

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ An [overview](https://wiki.netz39.de/projects:2022:stepper_locking_system) (Germ
77

88
On the basis of stepper motor and its driver, the hall encoder and connected switches, the firmware implements a error-tolerant and robust state maschine with overwatchings of current state. At non-planned events like step losses it tries to recover from this.
99

10+
## How to Compile and Flash
11+
The process of compiling project and flash the binary to microcontroller is described in [compile_flash.md](compile_flash.md).
12+
1013
## Animations
1114
For visualization of current state the system controls two **[LED-rings with integrated crossbar](https://github.com/netz39/LED-ring-with-crossbar)**. Each unit has 42 LEDs. Both rings are visible from inside and outside respectively.
1215

compile_flash.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# How to Compile and Flash
2+
3+
## Toolchain
4+
To compile the project we need a cross-compiler for ARM embedded systems (`arm-none-eabi`). It requires at minimum a version that supports C++17. You should, however, stick to the latest version if possible.
5+
6+
Depending of current Ubuntu version it is not recommended to
7+
install the toolchain via apt from the Ubuntu archives or a PPA, as these sources usually provide very outdated versions.
8+
In that case it is better to download and install the toolchain manually:
9+
10+
1. Goto the [download site](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads) and download the `arm-none-eabi` tarball for Linux hosts (for e.g. `arm-gnu-toolchain-x.x.x-x86_64-arm-none-eabi.tar.xz`)
11+
2. Extract the files to the target install directory of your choice, e.g. by `~/toolchains/`
12+
3. Create symbolic links in `/usr/bin` to make our toolchain callable system wide by using the following command: `sudo ln -s ~/toolchains/[your arm-none-eabi toolchain]/bin/arm-none-eabi-* /usr/bin`
13+
4. Verify the output of `arm-none-eabi-gcc --version`
14+
15+
## Cmake
16+
17+
Without IDE the simplest approach to generate cmake files in `build` directory is to use this command in root of project:
18+
19+
```
20+
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/arm-none-eabi-gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/arm-none-eabi-g++ -B build
21+
```
22+
Then go into the build directory and now you can compile with `make`.
23+
24+
## VS Code
25+
Using an IDE will make your life easier. In this case the setup in VS Code will described here.
26+
27+
0. Install VS Code of course. (e.g. `sudo snap install code --classic`)
28+
1. Install those extensions in VS Code:
29+
* CMake
30+
* CMake Tools
31+
* Cortex-Debug
32+
33+
2. Open the project directory `File > Open Folder...`
34+
3. Select kit with currently used toolchain. This should prompted by opening a list from top. If not you can select the kit in the bottom bar where `Not kit selected` is labeled.
35+
4. Then you can hit the `Build` button in the bottom bar to compile.
36+
37+
## Flash
38+
39+
It is recommend to do flashing with VS Code because it is simply and you can attach/debug to the running firmware after flashing.
40+
41+
For flashing we use J-Link debugger from Segger like [J-Link EDU Mini](https://www.segger.com/products/debug-probes/j-link/models/j-link-edu-mini/).
42+
So at first we need to [download](https://www.segger.com/downloads/jlink/) the software from Segger for our J-Link.
43+
44+
45+
46+
After we install J-Link software, compile the project and connect the target:
47+
48+
1. go to Tab `Run and debug` on left
49+
2. at the top right beside the play button you can select the debug profile. Select `Debug (J-Link, RTOS-aware)`. This ensures you target will be flashed with new firmware and after that you can debug with aware-ness of RTOS (like showing tasks list).
50+
3. Hit F5 or press the play button
51+
52+
You firmware is flashed!
53+
54+
Note: If you want only attach to the running firmware without resetting them, select the debug profile `Attach (J-Link, RTOS-aware)`.

0 commit comments

Comments
 (0)