forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 16
Project Setup: Command Line
Jamie Smith edited this page Jun 3, 2024
·
9 revisions
This page will show you how to take an existing Mbed CE project, build it, and debug it using command line tools.
- Open a terminal in the project directory.
- Create and enter a build directory:
mkdir build && cd build
- Run CMake:
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Develop -DMBED_TARGET=<your mbed target>
- Valid options for the MBED_TARGET option are any supported Mbed OS board target, such as
LPC1768
orNUCLEO_F429ZI
- The Develop build type is recommended for normal development work, but there is also the Debug build type which disables optimizations, and the Release build type which disables debug information.
- Valid options for the MBED_TARGET option are any supported Mbed OS board target, such as
- Build the project by running
ninja
- If the project has an executable which can be flashed, run
ninja flash-<executable>
to upload it to a connected device.
Suppose you want to debug an executable by the name of MyProgram.
- First, if you haven't already, you will need to make sure the project is configured to use an upload method that supports debugging. Read about upload methods on the Upload Methods page, and select a method to use using the
-DUPLOAD_METHOD=<method>
flag to CMake. - Now, plug in your target and start a GDB server for it by running
ninja gdbserver
in the build directory. - Finally, open another terminal in the build directory and run
ninja debug-MyProgram
. You should be dropped into a GDB session connected to your target!