Browse Source

Merge remote-tracking branch 'origin/master' into dzkuvx-pid-target-overrides

master
Pawel Spychalski (DzikuVx) 3 years ago
parent
commit
fe40661263
  1. 2
      .gitignore
  2. 9
      board/f4fc.cfg
  3. 9
      board/f7fc.cfg
  4. 9
      board/h7fc.cfg
  5. 10
      docs/Settings.md
  6. 53
      docs/Wireless Connections (BLE, TCP and UDP).md
  7. 271
      docs/development/Hardware Debugging in VSC on Windows 10 or 11 with WSL.md
  8. 5
      install-toolchain.sh
  9. 3
      src/main/cms/cms_menu_misc.c
  10. 24
      src/main/fc/cli.c
  11. 3
      src/main/fc/config.c
  12. 3
      src/main/fc/config.h
  13. 22
      src/main/fc/fc_msp.c
  14. 6
      src/main/fc/settings.yaml
  15. 5
      src/main/flight/mixer.c
  16. 7
      src/main/io/osd.c
  17. 4
      src/main/io/osd.h
  18. 1
      src/main/msp/msp_protocol_v2_inav.h
  19. 12
      src/main/navigation/navigation.c
  20. 2
      src/main/target/common.h

2
.gitignore

@ -19,6 +19,8 @@ cov-int*
/patches/
/tools/
/downloads/
/debug/
/release/
# script-generated files
docs/Manual.pdf

9
board/f4fc.cfg

@ -0,0 +1,9 @@
# Boardconfig for ST-Link/V2 with F4-FC
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32f4x.cfg]
reset_config none separate

9
board/f7fc.cfg

@ -0,0 +1,9 @@
# Boardconfig for ST-Link/V2 with F7-FC
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32f7x.cfg]
reset_config none separate

9
board/h7fc.cfg

@ -0,0 +1,9 @@
# Boardconfig for ST-Link/V2 with H7-FC
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32h7x_dual_bank.cfg]
reset_config none separate

10
docs/Settings.md

@ -1502,6 +1502,16 @@ Enable use of Galileo satellites. This is at the expense of other regional const
---
### ground_test_mode
For developer ground test use. Disables motors, sets heading status = Trusted on FW.
| Default | Min | Max |
| --- | --- | --- |
| OFF | OFF | ON |
---
### gyro_anti_aliasing_lpf_hz
Gyro processing anti-aliasing filter cutoff frequency. In normal operation this filter setting should never be changed. In Hz

53
docs/Wireless Connections (BLE, TCP and UDP).md

@ -0,0 +1,53 @@
# Wireless connections
From iNav 5 onwards, the Configurator supports wireless connections via Bluetooth Low Energy (BLE) and Wifi (UDP and TCP).
## BLE
The following adapters are supported:
- CC2541 based modules (HM1X, HC08/09)
- Nordic Semiconductor NRF5340 (Adafruit BLE Shield)
- SpeedyBee adapter
Flightcontrollers with BLE should also work, if you have an adapter/FC that doesn't work, open an issue here on Github and we will add it.
### Configuring the BLE modules
Activate MSP in iNav on a free UART port and set the Bluetooth module to the appropriate baud rate.
Example for a HM-10 module:
Connect the module to a USB/UART adapter (remember: RX to TX, TX to RX), and connect it to a serial terminal (e.g. from the Arduino IDE),
Standard baud rate is 115200 baud, CR+LF
```
AT+BAUD4
AT+NAMEiNav
```
The baud rate values:
| Value | Baud |
|------|------|
| 1 | 9600 |
| 2 | 19200 |
| 3 | 38400 |
| 4 | 115200 |
There are many counterfeits of the HC08/09 modules on the market, which work unreliably at high baud rates.
However, it is recommended to avoid these modules and to use an original HM-10.
### SpeedyBee adapter
Just connect it to the USB port, no further configuration needed.
## TCP and UDP
Allows connections via Wifi.
Hardware:
- DIY, ESP8266 based:
This project can be used to make iNav Wifi enabled: https://github.com/Scavanger/MSPWifiBridge
A small ESP01S module should still fit anywhere.
- ExpressLRS Wifi:
Should work (via TCP, port 5761), but untested due to lack of hardware from the developer. CLI and presets do not work here, problem in ELRS, not in iNav.

271
docs/development/Hardware Debugging in VSC on Windows 10 or 11 with WSL.md

@ -0,0 +1,271 @@
# Hardware Debugging in Visual Studio Code and WSL
Real debugging makes life easier, here is a configuration for VSCode with WSL for Windows 10/11.
## Hardware:
For the basics, please read [Hardware Debugging.md](Hardware%20Debugging.md) up to the section "Compilation options", everything after that is outdated.
In contrast to the instructions above, I had to connect the Target VCC pin of my original ST-Link/V2 to the 3.3V of the FC, otherwise I got an error message that the voltage of the target was too low. The FC is not supplied with voltage via this pin, only the voltage of the target is measured to ensure signal compatibility. (See ST-Link/V2 manual, table 4).
Check with "STM32 ST-LINK Utility" if the connection to the FC is working.
## Software:
Read [IDE - Visual Studio Code with Windows 10.md](IDE%20-%20Visual%20Studio%20Code%20with%20Windows%2010.md) and set up VSCode like this.
I recommend to use WSL2 and to work in the Linux file system (e.g. `~/git/inav`), access to the files in the Linux FS you get
in Windows 10 via `\\wsl$` in the address line of the explorer, in Windows 11 via the new entry "Linux" in the explorer.
"Cortex Debug" is also required as an additional extension for VSCode.
## OpenOCD
Now we come to the sticking point:
Unfortunately, WSL cannot pass the ST link (or only via tools such as usbipd-win, see the instructions here: [Windows 11 - VS Code - WSL2 - Hardware Debugging.md](Windows%2011%20-%20VS%20Code%20-%20WSL2%20-%20Hardware%20Debugging.md)), so OpenOCD must run on the Windows side, which is no problem since gdb and OpenOCD communicate with each other via TCP.
Tip:
Only for OpenOCD you don't need to install xpm and node.js, just download the archive at https://github.com/xpack-dev-tools/openocd-xpack/releases and unpack it into a folder of your choice.
Now OpenOCD needs board definition files for the FC, the files generated by the makefile do not work for me.
Copy the following files to `scripts\board` in the OpenOCD folder:
f4fc.cfg:
```
# Boardconfig for ST-Link/V2 with F4-FC
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32f4x.cfg]
reset_config none separate
```
f7fc.cfg
```
# Boardconfig for ST-Link/V2 with F7-FC
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32f7x.cfg]
reset_config none separate
```
h7fc.cfg
```
# Boardconfig for ST-Link/V2 with H7-FC
source [find interface/stlink.cfg]
transport select hla_swd
source [find target/stm32h7x_dual_bank.cfg]
reset_config none separate
```
In order for GDB and OpenOCD to be able to communicate with each other, the host (Windows) IP address is required, the easiest and most convenient way is to have this done automatically by the linux bash to do this automatically, add the following line to the `~/.bashrc` file:
`export WSL_HOST_IP=$(cat /etc/resolv.conf | sed -rn 's|nameserver (.*)|\1|p')`
Actually, the trick is quite simple:
In launch.json set `servertype` to `external` and `gdbTarget` to `windows-host-ip:3333`, the .cfg file must of course be passed when starting openOCD in windows and the connection must be bound to 0.0.0.0.
## VSCode configuration files
For convenience, I have created a set of VSCode configuration files, that do all the magic.
And before anyone asks: Yes, WSL can launch applications on the host.
launch.json
```
{
"configurations": [
{
"name": "Debug",
"type": "cortex-debug",
"request": "launch",
"servertype": "external",
"cwd": "${workspaceRoot}/debug",
//"runToEntryPoint": "main",
"executable": "${workspaceRoot}/debug/bin/${config:inav.debug.target}.elf",
"gdbTarget": "${config:openocd.host}:3333",
"svdFile": "${workspaceRoot}/dev/svd/${config:inav.debug.svdFile}",
"preLaunchTask": "Debug",
"showDevDebugOutput": "parsed"
},
],
}
```
tasks.json
```
{
"version": "2.0.0",
"tasks": [
{
"label": "Launch OpenOCD",
"command": "${config:openocd.path}",
"args": [
"-f",
"\"board/${config:inav.debug.board}\"",
"-c",
"\"bindto 0.0.0.0\""
],
"type": "shell",
"isBackground": false,
"group": "none",
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
},
{
"label": "CMAKE Release",
"type": "shell",
"command": "mkdir -p release && cd release && cmake -DCMAKE_BUILD_TYPE=Release ..",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "CMAKE Debug",
"type": "shell",
"command": "mkdir -p debug && cd debug && cmake -DCMAKE_BUILD_TYPE=Debug ..",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "CMAKE Build",
"type": "shell",
"command": "mkdir -p build && cd build && cmake ..",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Compile autogenerated docs",
"type": "shell",
"command": "python3 src/utils/update_cli_docs.py",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Debug",
"type": "shell",
"command": "make ${config:inav.debug.target}",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/debug"
}
},
{
"label": "Release",
"type": "shell",
"command": "make ${config:inav.release.target}",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/release"
}
},
{
"label": "Build",
"type": "shell",
"command": "make ${config:inav.release.Target}",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/build"
}
},
{
"label": "Clean Debug",
"type": "shell",
"command": "make clean",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/debug"
}
},
{
"label": "Clean Build",
"type": "shell",
"command": "make clean",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/build"
}
},
{
"label": "Clean Release",
"type": "shell",
"command": "make clean",
"group": "build",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/release"
}
},
]
}
```
settings.json
```
{
"cortex-debug.armToolchainPath": "${workspaceRoot}/tools/gcc-arm-none-eabi-10-2020-q4-major/bin",
"openocd.host": "${env:WSL_HOST_IP}",
"openocd.path": "/mnt/path/to/openocd/bin/openocd.exe",
"inav.debug.svdFile": "STM32F405.svd",
"inav.debug.target": "OMNIBUSF4SD",
"inav.release.target": "MATEKF722SE",
"inav.debug.board": "f4fc.cfg"
}
```
Only the settings.json needs to be modified:
| Option | Explanation |
|--------|-------------|
| cortex-debug.armToolchainPath | path to ARM toolchain, e.g. `${workspaceRoot}/tools/gcc-arm-none-eabi-10-2020-q4-major/bin` |
| openocd.host | IP address of the Windows host, if the environment variable was set as above, do not change anything here, otherwise manually enter the IP of the Windows host. |
| openocd.path | Path to OpenOCD in Windows, format `/mnt/[windows-drive-letter]/path/to/openocd.exe`, for example `/mnt/c/openocd-0.11.0-1/bin/openocd.exe`. |
| inav.debug.svdFile | SVD file, accroding to the processor on your board, see `/dev/svd`, for example `STM32F405.svd`. |
| inav.debug.target | Debug target, for example `OMNIBUSF4SD` |
| inav.release.target | Release target, for example `MATEKF722SE` |
| inav.debug.board | cfg file for OpenOCD, matching the processor of the board, e.g. `f4fc.cfg`, see above |
### Tasks
The following tasks are available
| Task | Description |
|------|-------------|
| Launch OpenOCD | Must be started manually once per session, starts OpenOCD with the correct options. |
| CMAKE Release | Creates a new folder "release", and configures the buildsystem for a real release build in it. |
| CMAKE Debug | Creates a new folder "debug", and configures the buildsystem for a real debug build in it. |
| CMAKE Build | Creates a new folder "build" and configures the buildsystem for the standard build. |
| Compile autogenerated docs | Rebuilds the CLI documentation |
| Debug | Compiles a new debug build for the target specified in inav.debug.target |
| Release | Compiles a new release build for the target specified in inav.release.target. |
| Build | Compiles a new standard build for the target specified in inav.release.target. |
| Clean Debug | Cleans up the debug folder |
| Clean Release | Cleans up the release folder |
| Clean Build | Cleans up the build folder |
With `F5`, a new debug session can be started normally (recompiling if necessary), with `CTRL+SHIFT+B` a build task can be started.
## Problem solving
If OpenOCD reports an error `Couldn't bind to ...`, it may be that Hyper-V is blocking these ports, see this thread on stackoverflow for solutions:
https://stackoverflow.com/questions/48478869/cannot-bind-to-some-ports-due-to-permission-denied

5
install-toolchain.sh

@ -1,5 +0,0 @@
#!/bin/bash
if [ ! -d $PWD/gcc-arm-none-eabi-8-2018-q4-major/bin ] ; then
curl --retry 10 --retry-max-time 120 -L "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2" | tar xfj -
fi

3
src/main/cms/cms_menu_misc.c

@ -43,6 +43,9 @@ static const OSD_Entry menuMiscEntries[]=
OSD_LABEL_ENTRY("-- MISC --"),
OSD_SETTING_ENTRY("THR IDLE", SETTING_THROTTLE_IDLE),
#ifdef USE_DEV_TOOLS
OSD_SETTING_ENTRY("GROUND TEST MODE", SETTING_GROUND_TEST_MODE),
#endif
#ifdef USE_OSD
#ifdef USE_ADC
OSD_SETTING_ENTRY("OSD VOLT DECIMALS", SETTING_OSD_MAIN_VOLTAGE_DECIMALS),

24
src/main/fc/cli.c

@ -140,6 +140,7 @@ static uint8_t cliWriteBuffer[sizeof(*cliWriter) + 128];
static char cliBuffer[64];
static uint32_t bufferIndex = 0;
static uint16_t cliDelayMs = 0;
#if defined(USE_ASSERT)
static void cliAssert(char *cmdline);
@ -222,6 +223,9 @@ static void cliPrint(const char *str)
static void cliPrintLinefeed(void)
{
cliPrint("\r\n");
if (cliDelayMs) {
delay(cliDelayMs);
}
}
static void cliPrintLine(const char *str)
@ -1672,6 +1676,25 @@ static void cliModeColor(char *cmdline)
}
#endif
static void cliDelay(char* cmdLine) {
int ms = 0;
if (isEmpty(cmdLine)) {
cliDelayMs = 0;
cliPrintLine("CLI delay deactivated");
return;
}
ms = fastA2I(cmdLine);
if (ms) {
cliDelayMs = ms;
cliPrintLinef("CLI delay set to %d ms", ms);
} else {
cliShowParseError();
}
}
static void printServo(uint8_t dumpMask, const servoParam_t *servoParam, const servoParam_t *defaultServoParam)
{
// print out servo settings
@ -3856,6 +3879,7 @@ const clicmd_t cmdTable[] = {
CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor),
CLI_COMMAND_DEF("mode_color", "configure mode and special colors", NULL, cliModeColor),
#endif
CLI_COMMAND_DEF("cli_delay", "CLI Delay", "Delay in ms", cliDelay),
CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", NULL, cliDefaults),
CLI_COMMAND_DEF("dfu", "DFU mode on reboot", NULL, cliDfu),
CLI_COMMAND_DEF("diff", "list configuration changes from default",

3
src/main/fc/config.c

@ -113,6 +113,9 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
.current_profile_index = 0,
.current_battery_profile_index = 0,
.debug_mode = SETTING_DEBUG_MODE_DEFAULT,
#ifdef USE_DEV_TOOLS
.groundTestMode = SETTING_GROUND_TEST_MODE_DEFAULT, // disables motors, set heading trusted for FW (for dev use)
#endif
#ifdef USE_I2C
.i2c_speed = SETTING_I2C_SPEED_DEFAULT,
#endif

3
src/main/fc/config.h

@ -70,6 +70,9 @@ typedef struct systemConfig_s {
uint8_t current_profile_index;
uint8_t current_battery_profile_index;
uint8_t debug_mode;
#ifdef USE_DEV_TOOLS
bool groundTestMode; // Disables motor ouput, sets heading trusted on FW (for dev use)
#endif
#ifdef USE_I2C
uint8_t i2c_speed;
#endif

22
src/main/fc/fc_msp.c

@ -1548,6 +1548,23 @@ static mspResult_e mspFcSafeHomeOutCommand(sbuf_t *dst, sbuf_t *src)
}
}
static mspResult_e mspFcLogicConditionCommand(sbuf_t *dst, sbuf_t *src) {
const uint8_t idx = sbufReadU8(src);
if (idx < MAX_LOGIC_CONDITIONS) {
sbufWriteU8(dst, logicConditions(idx)->enabled);
sbufWriteU8(dst, logicConditions(idx)->activatorId);
sbufWriteU8(dst, logicConditions(idx)->operation);
sbufWriteU8(dst, logicConditions(idx)->operandA.type);
sbufWriteU32(dst, logicConditions(idx)->operandA.value);
sbufWriteU8(dst, logicConditions(idx)->operandB.type);
sbufWriteU32(dst, logicConditions(idx)->operandB.value);
sbufWriteU8(dst, logicConditions(idx)->flags);
return MSP_RESULT_ACK;
} else {
return MSP_RESULT_ERROR;
}
}
static void mspFcWaypointOutCommand(sbuf_t *dst, sbuf_t *src)
{
const uint8_t msp_wp_no = sbufReadU8(src); // get the wp number
@ -3226,6 +3243,11 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
break;
#endif
#ifdef USE_PROGRAMMING_FRAMEWORK
case MSP2_INAV_LOGIC_CONDITIONS_SINGLE:
*ret = mspFcLogicConditionCommand(dst, src);
break;
#endif
case MSP2_INAV_SAFEHOME:
*ret = mspFcSafeHomeOutCommand(dst, src);
break;

6
src/main/fc/settings.yaml

@ -3554,6 +3554,12 @@ groups:
description: "Defines debug values exposed in debug variables (developer / debugging setting)"
default_value: "NONE"
table: debug_modes
- name: ground_test_mode
description: "For developer ground test use. Disables motors, sets heading status = Trusted on FW."
condition: USE_DEV_TOOLS
default_value: OFF
field: groundTestMode
type: bool
- name: throttle_tilt_comp_str
description: "Can be used in ANGLE and HORIZON mode and will automatically boost throttle when banking. Setting is in percentage, 0=disabled."
default_value: 0

5
src/main/flight/mixer.c

@ -606,6 +606,11 @@ void FAST_CODE mixTable()
if (currentMotorStatus != MOTOR_RUNNING) {
motor[i] = motorValueWhenStopped;
}
#ifdef USE_DEV_TOOLS
if (systemConfig()->groundTestMode) {
motor[i] = motorZeroCommand;
}
#endif
}
} else {
for (int i = 0; i < motorCount; i++) {

7
src/main/io/osd.c

@ -4324,6 +4324,13 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
}
}
/* Messages that are shown regardless of Arming state */
#ifdef USE_DEV_TOOLS
if (systemConfig()->groundTestMode) {
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_GRD_TEST_MODE);
}
#endif
if (messageCount > 0) {
message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)];
if (message == failsafeInfoMessage) {

4
src/main/io/osd.h

@ -113,6 +113,10 @@
#define OSD_MSG_NAV_SOARING "(SOARING)"
#define OSD_MSG_UNABLE_ARM "UNABLE TO ARM"
#ifdef USE_DEV_TOOLS
#define OSD_MSG_GRD_TEST_MODE "GRD TEST > MOTORS DISABLED"
#endif
#if defined(USE_SAFE_HOME)
#define OSD_MSG_DIVERT_SAFEHOME "DIVERTING TO SAFEHOME"
#define OSD_MSG_LOITERING_SAFEHOME "LOITERING AROUND SAFEHOME"

1
src/main/msp/msp_protocol_v2_inav.h

@ -80,3 +80,4 @@
#define MSP2_INAV_SET_SAFEHOME 0x2039
#define MSP2_INAV_MISC2 0x203A
#define MSP2_INAV_LOGIC_CONDITIONS_SINGLE 0x203B

12
src/main/navigation/navigation.c

@ -2036,7 +2036,14 @@ void updateActualHeading(bool headingValid, int32_t newHeading)
/* Update heading. Check if we're acquiring a valid heading for the
* first time and update home heading accordingly.
*/
navigationEstimateStatus_e newEstHeading = headingValid ? EST_TRUSTED : EST_NONE;
#ifdef USE_DEV_TOOLS
if (systemConfig()->groundTestMode && STATE(AIRPLANE)) {
newEstHeading = EST_TRUSTED;
}
#endif
if (newEstHeading >= EST_USABLE && posControl.flags.estHeadingStatus < EST_USABLE &&
(posControl.rthState.homeFlags & (NAV_HOME_VALID_XY | NAV_HOME_VALID_Z)) &&
(posControl.rthState.homeFlags & NAV_HOME_VALID_HEADING) == 0) {
@ -2307,6 +2314,11 @@ void setHomePosition(const fpVector3_t * pos, int32_t yaw, navSetWaypointFlags_t
// Update target RTH altitude as a waypoint above home
updateDesiredRTHAltitude();
// Reset RTH sanity checker for new home position if RTH active
if (FLIGHT_MODE(NAV_RTH_MODE)) {
initializeRTHSanityChecker();
}
updateHomePositionCompatibility();
ENABLE_STATE(GPS_FIX_HOME);
}

2
src/main/target/common.h

@ -46,6 +46,8 @@
#define USE_SERIALRX_FPORT
#define USE_SERIALRX_FPORT2
//#define USE_DEV_TOOLS // tools for dev use only. Undefine for release builds.
#define COMMON_DEFAULT_FEATURES (FEATURE_TX_PROF_SEL)
#if defined(STM32F3)

Loading…
Cancel
Save