-
Notifications
You must be signed in to change notification settings - Fork 35
Miscellaneous tools for FC management
Obsolete article Please check the [manual](https://stronnag.github.io/mwptools/) for more up-to-date information.
This documents a number of command line tools that are provided by mwptools. Note that not all these tools are built or installed by default; it may be necessary to enter a source directory and invoke make && sudo make install
or ninja
in situ, or copy a script to a directory on $PATH
.
Simple standalone uploader for iNav / MultiWii compatible mission files.
mwp-uploader
performs the upload (optionally save to eeprom) and validation of XML (mwp, ezgui, Mission Planner for iNav) and JSON (mwp) mission files to an iNav or MultiWii flight controller.
$ ./mwp-uploader --help Usage: mwp-uploader [OPTION?] - Mission UPloader Help Options: -h, --help Show help options Application Options: -b, --baud baud rate -d, --device device -m, --mission mission file -s, --save=false save to eeprom
By default, output is logger to STDERR and a result message written to STDOUT. The exit status is set to 0 if the upload was successful and 1 if not. If STDERR is redirected, then the output is redirected (appended) to the standard mwp log file, mwp_stderr_YYYY-MM-DD.txt
.
This may be used in scripts, for example:
RES=$(./mwp-uploader -m ~/Projects/quads/missions/jtest.mission -s 2> /dev/null) if [ $? = 0 ] ; then echo $RES else echo "Upload failed, please see log file mwp_stderr_$(date +%F).log" fi
If no device is given, mwp-uploader
will try to auto-detect the FC.
$ mwp-uploader -m nm_multi2.mission 2018-03-28T16:15:04+0100 No device given ... watching 2018-03-28T16:15:04+0100 Opening /dev/ttyUSB0 2018-03-28T16:15:05+0100 WP: 48 2018-03-28T16:15:05+0100 Mission validated 2018-03-28T16:15:05+0100 WP_GETINFO: 48/60/1 uploaded 48/60 WP, valid
fc-get
and fc-set
are tools to manage CLI settings:
-
fc-get
dump clidiff
settings to a file that can be replayed byfc-set
-
fc-set
replay a file of cli settings to the FC. Once the settings have been saved, a backup is made of the original file; the settings are then read from the FC and the original file updated.
$ fc-set --help Usage: fc-set [OPTION?] - fc diff manager Help Options: -h, --help Show help options Application Options: -b, --baud baud rate -d, --device device -n, --no-back no back
Note
|
fc-get and fc-set are essentially the same program, the function is defined by the name.
|
$ fc-get /tmp/dodo-test.txt 12:16:04 No device given ... watching 12:16:04 Opening /dev/ttyUSB0 12:16:04 Establishing CLI 12:16:05 Starting "diff all" 12:16:06 Exiting 12:16:06 Rebooting
Then, maybe after flashing the FC to a new version:
$ fc-set /tmp/dodo-test.txt 12:16:56 No device given ... watching 12:16:56 Opening /dev/ttyUSB0 12:16:56 Starting restore 12:16:56 Establishing CLI 12:16:58 [████████████████████████████████] 100% 12:16:58 Rebooting 12:17:01 Establishing CLI 12:17:03 Starting "diff all" 12:17:03 Exiting 12:17:03 Rebooting
And now we have a settings backup …
$ ls -l /tmp/dodo* -rw-r----- 1 jrh jrh 2115 Mar 28 12:17 /tmp/dodo-test.txt -rw-r----- 1 jrh jrh 2115 Mar 28 12:16 /tmp/dodo-test.txt.2018-03-28T12.17.01
A shell script to flash new firmware to an FC. See the comments in the script as to third party dependencies (stm32flash
, dfu-util
).
$ flash.sh inav_1.9.1_SPRACINGF3.hex # uses stm32flash / USB $ # ... $ flash.sh inav_1.9.1_MATEKF405.hex # uses dfu-util / VCP
see also https://github.com/fiam/msp-tool for another tool to simplify flashing.
flashdl
is a tool to download blackbox logs from on-board flash. If you’re doing this on a VCP board, it will download much faster then the apparent baud rate indicates. If you’re using a non-VCP board, then consider using flash_dump.rb
which can temporarily alter the baudrate to achieve faster rates using CLI (vice MSP) commands.
In the following example, I use test mode because the flash is empty. Normally you would not set TEST_USED
or use the -t
(test) flag.
$ TEST_USED=$((1024*1600)) flashdl -t 13:11:46 Opened /dev/ttyACM0 13:11:46 Entering test mode for 1.6MB 13:11:46 Data Flash 1638400 / 2097152 (78%) 13:11:46 Downloading to BBL_2018-03-28_131146.TXT [████████████████████████████████] 1.6MB/1.6MB 100% 0s 13:12:17 1638400 bytes in 31s, 52851 bytes/s $ $ # normally $ # flashdl $ # or $ # flashdl -e # erase after downloading
Note that the FC device is auto-detected.
Note also that the download speed is approximately 5 times greater than one would expect from the nominal baud rate (115200 ~= 10800 bytes/sec).
flash_dump.rb is another tool for downloading blackbox logs from on-board flash. Whereas flashdl uses MSP, flash_dump.rb uses CLI commands and is thus rather more fragile.
-
It allows the temporary use of higher baud rates on USB (e.g. 921600).
-
Requires the F3 or better FC
-
If it fails, you will have to reset the baud rate via the CLI, as the configurator will not connect > 115200 baud.
$ flash_dump.rb --help flash_dump.rb [options] file Download bb from flash -s, --serial-device=DEV -e, --erase -E, --erase-only -o, --output=FILE -b, --baud=RATE -B, --super-baud=RATE -?, --help Show this message
Unlike flashdl
which auto-detects serial ports, flash_dump.rb
tries /dev/ttyUSB0
and /dev/ttyACM0
, or the device given with -d
. The "super baud" rate must be specified to use a faster rate than the FC default:
$ flash_dump.rb -B 921600 /dev/ttyUSB0 Changing baud rate to 921600 Found "serial 0 1 115200 38400 115200 115200" setting serial 0 1 921600 38400 115200 115200 Reopened at 921600 Size = 1638400 read 1638400 / 1638400 100% 0s Got 1638400 bytes in 18.8s 87268.8 b/s Exiting
After the download has completed, the serial port is reset to the prior configured bayd rate (typically 115200). Note the very high speed of the download, 87268 bytes /sec; this is almost 9 times faster than the standard baud (and 9x the speed of using the configurator with a USB board).
Should the download fail and the board serial is not reset automatically, it will be necessary to manually reset UART1, possibly using cliterm
.
So, had the above failed, it could be rescued by pasting in the "Found" item above:
$ cliterm -b 921600 open /dev/ttyUSB0 Entering CLI Mode, type 'exit' to return, or 'help' # serial 0 1 115200 38400 115200 115200 # save Saving Rebooting
cliterm
is a simple terminal program for interacting with the iNav CLI. Unlike alternative tools (picocom
, minicom
etc.), it will auto-detect the FC serial device, uses 115200 as the baud rate and, by default, automatically enters the CLI.
$ cliterm --help Usage: cliterm [OPTION?] - cli tool Help Options: -h, --help Show help options Application Options: -b, --baud=115200 baud rate -d, --device device -n, --noinit=false noinit -f, --file file -m, --eolmode=[cr,lf,crlf,crcrlf] eol mode
The options -n
(don’t enter CLI automatically) and -m
may be useful when accessing other devices (for example a 3DR radio, HC-12 radio or ESP8266) in command mode.
cliterm
understands Ctrl-D as "quit CLI without saving". You should quit cliterm
with Ctrl-C, having first exited the CLI in the FC (save
, exit
, Ctrl-D).