FreeRTOS debugging documentation (#446)

This commit is contained in:
Joe Campbell 2022-04-14 01:58:11 +01:00 committed by GitHub
parent 35323817ee
commit e7bf95bf20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions

View File

@ -1,5 +1,16 @@
# Building
This project uses [PlatformIO](https://platformio.org/) to simplify development. The easiest way to get started is to install [VSCode](https://code.visualstudio.com/) and the [PlatformIO VSCode plugin](https://marketplace.visualstudio.com/items?itemName=platformio.platformio-ide) (simple instructions [here](https://platformio.org/install/ide?install=vscode)).
Once you have opened this project, building and uploading the project to your ESP32 board is as easy as clicking on the Build and Upload buttons.
![PlatformIO Build/Upload Buttons](https://docs.platformio.org/en/latest/_images/platformio-ide-vscode-build-project.png)
## Changing PlatformIO project environment
Project environments are used for different board configurations and are stored in ```platformio.ini```
Platforms can be changed by:
- Selecting the PlatformIO icon from the left bar in VSCode
- Selecting the desired build target under project tasks
![PlatformIO Env](https://community.platformio.org/uploads/default/original/2X/4/4d87f4672f1892ce54852fed3b8e3cf21b8aed4f.png)

46
DEBUGGING_FREERTOS.md Normal file
View File

@ -0,0 +1,46 @@
# Debugging FreeRTOS Stacks
PlatformIOs built in tools for debugging the FreeRTOS stack are limited.
NXP have a free FreeRTOS debug plugin for Eclipse which will give more detailed debug information regarding stack usage.
### Requirements
- [**MCUXpresso IDE**](https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-integrated-development-environment-ide:MCUXpresso-IDE) - This requires a free NXP account to access the download link. Any Eclipse install will work but if using another install, the FreeRTOS plugin will need to be installed separately.
- **JTAG Debugger** - Any debugger compatible with OpenOCD should work. This below steps were tested with a Segger J-Link
- **PlatformIO**
- **OpenOCD** - Changing the PlatformIO project environment to an environment set to use ```upload_protocol = jlink``` will automatically download the ```tool-openocd-esp32``` package.
### Setup the MCUXpresso debugger
1. Open MCUXpresso - any workspace can be used
2. Select Run > Debug Configurations
3. Double click on ``` GDB Hardware Debugging``` to create a new configuration
4. On the *Main* tab -
a. **Project** - Can be left blank, or point to project code.
b. **C/C++ Application** - Point to the ```firmware.elf``` file. If built from PlatformIO will be in the ```ESPresense/.pio/build/<env name>``` directory.
c. **Build** - Disable auto build
5. On the *Debugger* tab -
a. **GDB Command** - Path to ```xtensa-esp32-elf-gdb.exe```, if using defaults in PlatformIO will be ```~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb.exe```
b. **Remote Target** - Check Use remote target, JTAG Device - ```OpenOCD (via socket)```, GDB Connection String ```localhost:3333```
6. On the *Startup* tab -
a. **Initialisation commands**:
- ```set mem inaccessible-by-default off```
- ```mon reset halt```
- ```flushregs```
- ```set remote hardware-watchpoint-limit 2```
b. **Load Symbols** - Use project binary
c. Uncheck all boxes except ```Load Symbols``` and ```Resume```
7. Apply Changes
### Running the debug tool
1. Program the ESP32 with the target build and connect the ESP32 to the debug probe.
2. Start the OpenOCD Server:
```bash
cd ~\.platformio\packages\tool-openocd-esp32
.\bin\openocd.exe -f .\share\openocd\scripts\interface\J-Link.cfg -f .\share\openocd\scripts\board\esp-wroom-32.cfg -c "adapter_khz 4000"
```
3. Start the debug tool in MCDExpresso with the debug symbol on the taskbar. **Note**: I have found the first connection to the debug session often fails with a warning ```failed to execute MI Command
--exec-continue```. Canceling this and selecting the debug symbol again correctly starts the debugger.
4. FreeRTOS information can be viewed from the RTOS > Task List from the top menu. This will refresh after pausing the debugger or reaching a breakpoint.
### References
https://mcuoneclipse.com/2019/09/22/eclipse-jtag-debugging-the-esp32-with-a-segger-j-link/