8.1 KiB
Налагодження з Eclipse та J-Link
This topic explains how to setup and use MCU Eclipse with a Segger Jlink adapter to debug PX4 running on NuttX (e.g. Pixhawk series boards).
Необхідне обладнання
- J-Link EDU Mini
- Adapter to connect Segger JLink to Flight Controller SWD Debug Port (debug port).
- Мікро USB кабель
Встановлення
PX4
Налаштуйте PX4, дотримуючись звичайних вказівок:
- Setup the PX4 Developer Environment/Toolchain for your platform (e.g. for Linux see: Development Environment on Ubuntu LTS / Debian Linux).
- Download PX4 and optionally build it on the command line.
Eclipse
To install Eclipse:
- Download Eclipse CDT for C/C++ Developers (MCU GitHub).
- Розпакуйте папку Eclipse та скопіюйте її куди завгодно (немає потреби запускати будь-які сценарії установки).
- Run Eclipse and choose a location for your initial workbench.
Інструменти Segger Jlink
To install the Segger Jlink tools:
- Download and run the J-Link Software and Documentation Pack for your OS (Windows and Linux packages available).
- On Linux the tools are installed in /usr/bin.
For more information, see: https://gnu-mcu-eclipse.github.io/debug/jlink/install/.
Перше використання
-
Connect the Segger JLink to the host computer and the flight controller debug port (via an adapter).
-
Увімкніть модульний політний контролер.
-
Run Eclipse.
-
Add a source by choosing File > Import > C/C++ > Existing Code as Makefile Project and click Next.
-
Point it to the PX4-Autopilot folder and give it a name, then select ARM Cross GCC in the Toolchain for Indexer Settings and click Finish. Імпорт триває деякий час. Дочекайтеся його завершення.
-
Set the MCU settings: right-click on the top-level project in the Project Explorer, select Properties then under MCU choose SEGGER J-Link Path. Встановіть його, як показано на знімку екрану нижче.

-
Пакети з оновленнями:
:::

- The STM32Fxx devices are found in the Keil folder, install by right-clicking and then selecting install on the according device for F4 and F7.
-
Налаштування конфігурації налагодження для цілі:
- Right click project and open the Settings (menu: C/C++ Build > Settings)
- Choose the Devices Tab, Devices section (Not Boards).
- Знайдіть FMU чіп, який ви хочете налагодити.
-
Select debug configurations with the small drop-down next to the bug symbol:

-
Then select GDB SEGGER J-Link Debugging and then the New config button on the top left.

-
Налаштування конфігурації збірки:
-
Give it a name and set the C/C++ Application to the corresponding .elf file.
-
Choose Disable Auto build
::: info Remember that you must build the target from the command line before starting a debug session.
-
:::

-
The Debugger and Startup tabs shouldn’t need any modifications (just verify your settings with the screenshots below)
Відлагодження з урахуванням завдань SEGGER
Task-aware debugging (also known as thread-aware debugging) allows you to show the context of all running threads/tasks instead of just the stack current task. Це досить корисно, оскільки PX4 має тенденцію запускати виконання багато різних завдань.
Для активації цієї функції в Eclipse:
-
You first need to enable
CONFIG_DEBUG_TCBINFOin the NuttX configuration for your build (to expose the TCB offsets).-
Відкрийте термінал у кореневій теці вихідного коду PX4-Autopilot
-
In the terminal, open
menuconfigusing the appropriate make target for the build. Це виглядатиме приблизно так:make px4_fmu-v5_default boardguiconfig(See PX4 Menuconfig Setup for more information) on using the config tools).
-
Ensure that the Enable TCBinfo struct for debug is selected as shown:

-
-
Compile the jlink-nuttx.so library in the terminal by running the following command in the terminal:
make jlink-nuttx -
Modify Eclipse to use this library. In the J-Link GDB Server Setup configuration, update Other options to include
-rtos /home/<PX4 path>/Tools/jlink-nuttx.so, as shown in the image below. -
Під час запуску налагоджувача ви повинні побачити зараз декілька потоків замість одного:
Усунення проблем
Цільовий процесор відсутній в Package Manager
Якщо цільовий ЦП не відображається в package manager, вам може знадобитися ці крок для запуску відображення реєстру.
:::tip This should not generally happen (but anecdotally has been reported when connecting to an STM F7 controller). :::
Adding missing SVD files for the Peripheral View:
-
Find out where MCU Eclipse stores its packages (Preferences > C/C++ > MCU Packages):
-
Download missing packages from: https://www.keil.arm.com/devices/
-
Open downloaded pack with a decompression tool, and extract the .SVD files from: /CMSIS/SVD.
-
Select desired .SVD file in: Debug Options > GDB SEGGER JLink Debugging > SVD Path







