[mavlink] KConfig for minimal functionality (flash savings)
Added the KConfig option MAVLINK_MINIMAL and MAVLINK_MSG_SELECT. Using MAVLINK_MSG_SELECT requires specifying KConfig options MAVLINK_<message_name> to enable the mavlink message in the streams_list. This follows the same pattern as the uavcannode for including message streams. The MAVLINK_MINIMAL option disables the message handlers for incoming mavlink data and thus disables functionalities that rely on bidirectional communication. This "minimal" version of the mavlink module simply sends out mavlink messages.
Problem being solved The mavlink module is pretty heavy, and a lot of the flash usage comes from the message handlers for sending and receiving. The ARK Flow has a UART on the debug connection that we can use to send mavlink OPTICAL_FLOW_RAD messages to systems that don't have CAN (e.g voxl2).
See new build target
make ark_can-flow_serial
TODO
- [ ] Figure out a better way to specify the streaming message set rather than the "mode". The pre-defined modes (normal, config, etc) are restrictive and don't give the flexibility to specify the messages or their rates.
Tested successfully https://github.com/dakejahl/mavlink-cpp/blob/master/examples/listener/listener.cpp#L36-L38
Before
Memory region Used Size Region Size %age Used
flash: 534457 B 448 KB 116.50%
sram: 16604 B 192 KB 8.45%
After
[4/7] Linking CXX executable ark_can-flow_default.elf
Memory region Used Size Region Size %age Used
flash: 441109 B 448 KB 96.15%
sram: 15804 B 192 KB 8.04%
- CONFIG_MAVLINK_MINIMAL -- 58.4KB savings
- CONFIG_MAVLINK_MSG_SELECT && CONFIG_MAVLINK_OPTICAL_FLOW_RAD -- 35.8KB savings
By simply adding this to the default.px4board
CONFIG_MODULES_MAVLINK=y
CONFIG_MAVLINK_MINIMAL=y
CONFIG_MAVLINK_MSG_SELECT=y
CONFIG_MAVLINK_OPTICAL_FLOW_RAD=y
Getting about 97% usage on my ark flow:
Memory region Used Size Region Size %age Used flash: 446365 B 448 KB 97.30% sram: 15844 B 192 KB 8.06%
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:
https://discuss.px4.io/t/px4-sync-q-a-may-15-2024/38773/1