ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Make more features configurable

Open peterbarker opened this issue 3 years ago • 4 comments

Cleanup request

Our new build server (https://custom.ardupilot.org) allows users to make their own firmwares by selecting and de-selecting features.

Sometimes the amount of code required to run a feature exceeds the flash space available on boards.

The more things we allow users to remove from the compilation the more likely they are to get a firmware that does everything they want.

A good example of this is scripting - users of 1MB boards would love to have it, but it is a large chunk of code and excluded from the 1MB builds by default.

note - each of these libraries can and should be done as a separate Pull Request!

There are many places in the code that we could allow users to exclude chunks of code on a piece-by-piece basis, for example:

  • DONE GPS backends (@Hwurzburg is currently looking at these)
  • rangefinder library
  • DONE rangefinder backends
  • precision landing library
  • compass backends
  • DONE airspeed backends
  • AP_MSP backends
  • DONE AP_Mount backends
  • DONE battery monitor backends
  • visual odometry backends
  • AP_Winch
  • AP_Winch backends
  • DONE optical flow library
  • DONE optical flow backends
  • INPROGRESS RCInput backends (e.g. srxl)
  • FRSky library
  • FRSky backends
  • AC_Avoid

The larger the amount of code excised the more useful the change is. nm can be used to show the largest symbols in the compiled code:

pbarker@bluebottle:~/rc/ardupilot(pr/sitl-on-hw)$ arm-none-eabi-nm --demangle --size-sort --print-size build/NucleoH743/bin/ardurover | tail -20
3000de30 00001200 B NavEKF_core_common::nextP
080e58ac 00001264 T NavEKF3_core::FuseDragForces()
3000a484 000013c8 b xsimstate
080e4454 0000144c T NavEKF3_core::FuseSideslip()
080880c8 00001540 T SoloGimbalEKF::predictCovariance()
0810a8cc 0000163c T NavEKF2_core::FuseSideslip()
300183d0 00001658 b supported_frames
30011e20 000017e4 b icm40609
3001be50 000018a0 B SDU1
08111918 00001e78 t __static_initialization_and_destruction_0(int, int)
0810d548 00001f5c T NavEKF2_core::FuseOptFlow()
081330b0 00002014 T AP_Param::param_defaults_data
080e80fc 000022f8 T NavEKF3_core::FuseOptFlow(NavEKF3_core::of_elements const&, bool)
080d4e08 00002814 T NavEKF2_core::FuseMagnetometer()
0805ff8c 000029ee T NavEKF3_core::FuseBodyVel()
081460a4 00002ddb t ap_romfs_0
0805597c 00002edc T NavEKF3_core::FuseMagnetometer()
080df5ac 00004d0c T NavEKF2_core::CovariancePrediction()
0806626c 00005e70 T NavEKF3_core::CovariancePrediction(Vector3<double>*)
30002518 00006740 B rover
pbarker@bluebottle:~/rc/ardupilot(pr/sitl-on-hw)$ 

There are also some large wins available by filling out AP_NavEKF3_features.h with more options. This work will be much more complicated, but the ability to, for example, exclude magnetometers from the EKF's calculations would save a very large amount of code. ~~(see https://github.com/ArduPilot/ardupilot/issues/19070 however)~~

The pattern we use is AP_<foo>_ENABLED. An example of this is AP_QUADPLANE_ENABLED. Typically the main library header will contain:

#ifndef AP_GPS_NOVA_ENABLED
#define AP_GPS_NOVA_ENABLED 1
#endif

The new option should also be added to the custom build server configuration: https://github.com/ArduPilot/ardupilot/blob/master/Tools/scripts/build_options.py

The code must be tested for compilation and working-ness with and without the option set.

Platform [ X ] All [ ] AntennaTracker [ ] Copter [ ] Plane [ ] Rover [ ] Submarine

peterbarker avatar Oct 28 '21 22:10 peterbarker

Those looking to work on this issue, please note that the options for custom build server are now in ArduPilot repository at https://github.com/ArduPilot/ardupilot/blob/master/Tools/scripts/build_options.py instead of https://github.com/ardupilot/CustomBuild/blob/main/app.py

nkruzan avatar Jan 08 '22 18:01 nkruzan

GPSes done #19731

Hwurzburg avatar Jan 08 '22 19:01 Hwurzburg

@peterbarker @nkruzan Hi, I am pretty new to open source and I would love to work on this issue. I tried going through the issue description and the mentioned PR but still cannot get my head through it. Could you please help me with the issue more?

Its-Maniaco avatar Jan 31 '22 14:01 Its-Maniaco

@Its-Maniaco Checkout this PR: https://github.com/ArduPilot/ardupilot/pull/19960

That PR uses #ifdef so that the SMBus and fuel flow monitors can be selected to not be built by our custom build server. This saves users flash space that is quite limited on some harware.

The general idea to find all uses of the class AP_BattMonitor_SMBus and remove or include via a compile time option. Some libraries are easier then others to do this for...

Basically, if you have done it right running the following command returns nothing. Add if you haven't done it right the program will likely not compile (that isn't 100% true) or you the objects will still be found.

https://github.com/ArduPilot/ardupilot/pull/19960#pullrequestreview-869741896

hendjoshsr71 avatar Feb 01 '22 19:02 hendjoshsr71

I posted a PR to exclude the precision landing library

gmazzucchi avatar Feb 28 '23 16:02 gmazzucchi

I was looking into this issue, I think its not updated most of the points have been completed. I have understood the code of custom build and its features so I can work on the newer issues/features if required

adityaomar3 avatar Oct 01 '23 09:10 adityaomar3

Also there are some features which are still not added in the list of features in build options.py Please review this PR https://github.com/ArduPilot/ardupilot/pull/25159

I have added to some precland features in list, I have been reading it thoroughly so I will add other left out features shortly

adityaomar3 avatar Oct 01 '23 21:10 adityaomar3