Embedded system development @ BNU-HKBU UIC RoboMaster
You can follow the instructions below to set up the necessary environments for building the source code and flashing the embedded chips.
-
Go to the official download page for ARM Toolchain.
-
Download the pre-built toolchain according to your operating system.
-
Decompress it to some directory and find an absolute path to the
bin
directory.In my case:
/Users/yry0008/gcc-arm-none-eabi-10.3-2021.10/bin
. -
For Windows users, add the following line (replace
<path>
with the actual binary path found in step 3) toPATH
environment variable.For Linux / Mac users, add the following line (replace
<path>
with the actual binary path found in step 3) to~/.bashrc
for bash users or~/.zshrc
for zsh users.export PATH=<path>:$PATH
-
Go to the official download page for OpenOCD.
-
Download the pre-built toolchain according to your operating system.
-
Decompress it to some directory and find an absolute path to the
bin
directory.In my case:
/Users/yry0008/openocd-0.11.0-2021.10/bin
. -
For Windows users, add the following line (replace
<path>
with the actual binary path found in step 3) toPATH
environment variable. For Linux / Mac users, add the following line (replace<path>
with the actual binary path found in step 3) to~/.bashrc
for bash users or~/.zshrc
for zsh users.export PATH=<path>:$PATH
- Go to the official download page for CMake.
If you are using Clion, this step is not required.
- Go to the official download page
You can directly open the project in CLion and build it. You need to set the path of the embedded toolchain in the CLion settings.
In Windows, you should open `Settings`, `Build, Execution, Deployment`, `CMake`, then set the `Generator` to Ninja.
-
Go to your project root directory in a terminal.
-
Run the following command to build the entire project.
mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release .. make -j
In Windows, you should add the option to let cmake use ninja to build.
cmake -DCMAKE_BUILD_TYPE=Release ... -G "Ninja"
Using ninja to build.
ninja -j
Change build type to
Debug
orRelWithDebInfo
in order to debug withgdb
. Note thatDebug
build could be much slower than the other two due to lack of compiler optimizations.
Choose the target you want to flash and click the Run
button.
The default configuration is for CMSIS-DAP debugger. If you are using ST-LINK, you need to change the configuration in the CLion settings.
TODO
You will need Doxygen.
- For Mac users,
brew install doxygen
could be a shortcut. - For Ubuntu users,
sudo apt install doxygen
could be a shortcut. - For Arch users,
sudo pacman -S doxygen
could be a shortcut. - For Linux users, either use prebuilt binaries, or build from source following their compile manual.
To generate documentations after compiling the project.
- Run
make doc
in thebuild/
directory - In windows, you need to run
ninja doc
in thebuild/
directory
To view the generated document:
- Run
firefox docs/html/index.html
, or - Open
docs/html/index.html
in your browser.
Use the following guide when making contributions to this repo.
You can use any editor you like, but we recommend using CLion.
The continuous integration system will check the source code against a specific coding style. If the code does not follow the style, the formatting check will fail and the code will not be merged. All codes are required to be formatted correctly before merging. There are several integrated build commands that can help you automatically format your changes.
Prerequisite: install clang-format
- Linux's users can simply install it using
sudo apt install clang-format-10
. - Mac and Windows users need to download prebuilt binaries from here.
With clang-format
installed, you can run the following commands inside build/
to automatically format your changes.
make check-format
: Checkdiff
between current source and formatted source (without modifying any source file)make format
: Format all source files (Modifies file in place)
To debug embedded systems on a host machine, we would need a remote gdb server. There are 2 choices for such server, with tradeoffs of their own.
Clion Debugger
This is the easiest way to debug. Choose the target and Directly click the Debug
button in CLion.
OpenOCD
Thought directly using openocd
is possible, but it is only recommended for advanced users.