-
-
Notifications
You must be signed in to change notification settings - Fork 146
How board detection and firmware flashing works
MobiFlight supports a wide range of connected boards, both official (like Arudinos) and unofficial (like custom PCBs or the Raspberry Pi Pico). During startup MobiFlight goes through a process of identifying connected boards, determining whether they are supported, verifying the installed and MobiFlight firmware. This wiki explains how that process works.
Supported boards are defined using board.json definition files located in the Boards/ folder of the MobiFlight installation. Every supported board must have a corresponding board.json file to get detected by MobiFlight.
The board definition file includes a range of information about the board, including how to identify the board via USB VID/PID, how to flash it (if flashing is supported), the available pins, etc. The complete set of options is described in the mfboard.schema.json.
The list of supported boards is loaded by BoardDefintions.cs and the boards themselves are exposed via Board objects.
MobiFlight uses WMI to request all connected COM ports. It then iterates over each COM port and checks to see whether the VID/PID for the device connected to the port is listed in one or more board definition files. For a board to be considered at this point its VID/PID must match against a VID/PID in at least one board definition file. If it matches against more than one board definition file the first matching file is used (this happens to be alphabetically by board definition file name).
When this process is complete MobiFlight has a list of COM ports that have connected devices that are supported by MobiFlight and a corresponding board definition file for each of those connected COM ports.
This process is done in MobiFlightCache.cs:getSupportedPorts(). The function contains copious comments to explain in detail what is going on.
After matching against a board definition file MobiFlight attempts to communicate with the board to retrieve basic MobiFlight firmware information. This is done by executing a GetInfo command and checking to see if a response is received.
This check is done in MobiFlightCache.cs:LookupAllConnectedArduinoModulesAsync().
As part of the GetInfo command MobiFlight will do a second attempt at matching the connected device against the board definition files. It is possible that many boards share the same VID/PID but are actually different board types. For example, an Arduino Pro Micro will have the same VID/PID as a custom PCB that uses the ATmega32u4 chip. To determine the connected device type more specifically the MobiFlightType value returned from the firmware is tested against the board definition files. If a match is found, then the board definition originally detected in step 1 is replaced with the board definition that matched by MobiFlightType.
This second board lookup is done in MobiFlightModule.cs:GetInfo().
If step 2 failed to get a response to the GetInfo() command then MobiFlight assumes the board doesn't have the MobiFlight firmware installed on it. It then attempts to flash the firmware using the flash settings specified in the board definition file detected in step 1.
At the moment MobiFlight only supports flashing Arduino devices, however the code and board definition files are structured to allow flashing other devices types in the future.
The flash, based on settings in the board definition file, is done in MobiFlightFirmwareUpdater.cs:UpdateFirmware().
There are several situations where a connected board will have a VID/PID that matches multiple board definition files but will not have the MobiFlight firmwre installed yet. In those cases MobiFlight doesn't know how to flash the board and will just try the settings from the first matching board definition file. In many cases (e.g. an Arduino Uno that has the same VID/PID as an Arduino Mega) this will fail.
To resolve this MobiFlight offers the option of flashing devices from the MobiFlight Modules dialog as well, via a context menu that lists all matching board definitions. The user can select the appropriate one for their board and then those settings get used to flash the device.
The method that returns the list of matching board definitions is BoardDefinitions.cs:GetBoardsByHardwareId().
- MobiFlight Connector Installation
- Mobiflight Connector BETA version installation
- Modules
- MobiFlight Connector Files Structure
- MobiFlight Connector Uninstall
- Modules Reset to factory default
- Verifying the WASM module installation and locating the MSFS2020 community folder
- Verifying the WASM module installation and locating the MSFS2024 community folder
- Using a Winwing FCU with MobiFlight
- Using VKB controllers with MobiFlight
- Providing logs from MobiFlight
- MobiFlight Connector How does it work
- Mobiflight Connector Main Window
- Flash module with MobiFlight firmware
- Input and Output devices
- Joysticks
- Midi Boards
- Sim Variables (for Output)
- Input Actions
- Merging configuration files
- Disabling specific COM ports
- Examples Output LEDs
- Examples Input Switch
- Example 7 segment display
- Example Servo motor
- Controlling LEDs with an output shift register
- Adding lots of buttons with an input shift register
- Beginner's guide to input multiplexers
- Key Matrix with standard MobiFlight and Multiplexers
- Tutorial Easy Driver and x.27 or x.40 Stepper Motor
- Tutorial for Airbus VS display via 7-Segment LED Module
- Example Analog Input Potentiometer
- Baron G58 Tutorial Gear, Flaps, Mags, ELT Input Output Programming
- Using Mobiflight to control arduino-based 3rd party panels (RealSimGear GNS530)
- How to use a VNH2SP30 DC motor shield with MobiFlight
- Using 3D printer mainboards
- Playing sounds by sending keystrokes to AutoHotKey
- Using the selector knob on a Honeycomb Bravo
- Using an adjustable 12 position switch as a GA starter
- Brightness of LCD displays with I2C
- Using three-position switches
- Transponder with one Rotary
- Workflow for Creating Flight Simulation Panels ‐ Part 1
- MSFS2020 RPN Tips and Tricks
- MSFS2020 Using the Custom Input Code Box
- MSFS2020 Install WASM module and Event List
- MSFS2020 How to Create and Use User Defined Lvars
- MSFS2020 How to Create a Blinking LED configuration
- MSFS2020 User Defined WASM Module Events Best Practices
- MSFS2020 Developer Mode, Model Behavior dialog and Console window
- MSFS2020 PMDG 737‐700 List of Events that require use of FSUIPC7
-
MSFS2020 PMDG 737‐700 Calibrate throttle idle and reverse thrust using interpolation (Valkyrie)
- MSFS2020 PMDG 737-700 Chrono unit functions implemented in Mobiflight
- Configuring PMDG 737 Parking Brake Lever Auto-Release with a Servo in Mobiflight
- Using encoder to drive a value back and forth within a given range
- Adding a custom board to MobiFlight
- User guide - Community Board and Custom Devices
- Developing your own custom devices/boards