Modifying Nuttx Configuration File for Custom NuttX Applications

Hi all,

This is my first post on the PX4 forum - I’ve become a big fan of the PX4 Flight Controller and I am excited to be developing on it!

The problem I am having currently is adding custom and/or stock NuttX apps to a PX4 configuration. Here is the background on why I am not building the application using the standard method found in the Hello Sky tutorial:

  • The application I am developing will also be running on a standalone microcontroller running NuttX (not a px4 platform), I’d like to keep both the PX4 app and standalone NuttX app identical.
  • I need to add additional NuttX support (like networking) to PX4 platform that my application is dependent upon
  • I’d like to avoid porting my drivers that are already built for NuttX to the PX4 DriverFramework (probably unnecessary extra work).

It’s also worth mentioning that I have a fair amount of experience (I wouldn’t consider myself an expert) working with NuttX in isolation.

Where I am Now:
When modifying a NuttX configuration, it is necessary to modify the .config file (or defconfig in the board configuration) file in order to add applications to the NuttX configuration. The problem that I’ve run up against is that I am unable to modify the NuttX configuration for any nuttx-config (I’ve tried both px4fmu-v2 and crazyflie configs) without the following compiler error:

[ 11%] Building NuttX for crazyflie with nsh
make[4]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[4]: *** [arch/arm/src/board] Error 1
CMakeFiles/nuttx_export_crazyflie.dir/build.make:60: recipe for target 'crazyflie/NuttX/nuttx/nuttx-export/include/nuttx/config.h' failed
make[3]: *** [crazyflie/NuttX/nuttx/nuttx-export/include/nuttx/config.h] Error 2
CMakeFiles/Makefile2:835: recipe for target 'CMakeFiles/nuttx_export_crazyflie.dir/all' failed
make[2]: *** [CMakeFiles/nuttx_export_crazyflie.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make[1]: *** [all] Error 2
Makefile:148: recipe for target 'crazyflie_default' failed
make: *** [crazyflie_default] Error 2

The error above was generated by simply adding the example/hello application to the crazyflie configuration (defconfig) in the Firmware/nuttx-configs/crazyflie/nsh folder:


The compiler error has to do with crazyflie/NuttX/nuttx/nuttx-export/ which appears to be removed by `CMakeFiles/nuttx_export_crazyflie.dir/build.make’

Help Needed

  1. I don’t understand why modifying the NuttX configuration file causes this compiler error. I’d love to better understand how PX4 copies and compiles NuttX
  2. Any insight on the correct way modify NuttX configuration files and compile for px4fmu targets is greatly appreciated. I’d be willing to author a brief tutorial/best practices for the community on how to modify NuttX if you help me understand the the process.

Thank you,

The PX4 build system wraps the nuttx build and export. You could try the menuconfig helper target instead of modifying the config directly.

make menuconfig_${CONFIG}


Thanks for the feedback! I’ve successfully rebuilt the configuration and recompiled Nuttx file using your directions on the crazyflie (with a minor fix, see below). There were a couple minor issues I needed to work through when editing the configuration for that platform. I’ll document the issues after this thread is answered.

# Example of accessing the crazyflie's menuconfig 
# Execute from the top-level 'Firmware/' dir
make crazyflie_default menuconfig_crazyflie

Follow-up Question:
After adding the example/hello app via menuconfig, I was unable to run the hello command from NSH. I’ve verified that NuttX compiled the example/hello app successfully and the new binaries were uploaded to the crazyflie.

In other words, even though NuttX built the example/hello app, I cannot access the executable as a built-in app. It does not show up as a built-in app when running help from NSH or is it in the /bin folder after mounting the /bin via mount -t binfs /bin.

Again, I think I’m just unclear on how PX4 adds built-in applications to NuttX.

Hi Tony

I think you can add your hello app here: