Hi @Thai Hoa,
Thank you for sharing your challenge regarding compilation of Simulink-generated code for the PX4 FMU V6X. Although I do not currently have direct access to Simulink myself, I have carefully analyzed your error logs alongside the MathWorks UAV Toolbox documentation and PX4 developer guides. Below I provide a structured analysis of your comments in chronological order, followed by a step-by-step corrective workflow that aligns with the official references.
1. Your Comment
“ I am building Simulink code for PX4 6x. However I got this issue… UNC paths are not supported. Defaulting to Windows directory. bash: line 1: /opt/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-g++: No such file or directory.”
Analysis of Issues
1. UNC Path Limitation
- The PX4 build system is being invoked from a UNC path (`\\wsl.localhost\ubuntu-22.04\…`).
- WSL does not support UNC paths as valid working directories; this forces the shell to fall back to Windows defaults, breaking the toolchain call.
2. Missing ARM GCC Toolchain
- The compiler `arm-none-eabi-g++` was not found at `/opt/gcc-arm-none-eabi-9-2020-q2-update/bin`. This indicates the GNU Arm Embedded toolchain is either not installed in WSL or not accessible at the expected location.
3. Workflow Context
- Your Simulink model (`waypoint_following`) generates C++ code via Embedded Coder, integrates it as a PX4 module (`px4_simulink_app`), and relies on PX4’s CMake/NuttX build system. So, for this workflow to succeed, the PX4 build must run fully inside WSL, with the proper toolchain installed.
Corrective Workflow (Synthesized from MathWorks Documentation)
1. Run Build from a Native WSL Path
cd /home/thaibahoa2024/PX4-Autopilot
Avoid UNC paths (`\\wsl.localhost\…`). Always invoke the PX4 build directly inside WSL.
2. Install the PX4 Toolchain in WSL
PX4 provides a setup script that installs the correct ARM GCC cross-compiler and dependencies:
cd ~/PX4-Autopilot/Tools/setup bash ubuntu.sh
This will install the GNU Arm Embedded toolchain (e.g., GCC 9-2020-q2), Ninja, CMake, and required libraries.
3. Verify Toolchain Availability
which arm-none-eabi-g++ arm-none-eabi-g++ --version
Confirm that a valid path and version string are returned.
4. Configure Simulink PX4 Support Package
In Simulink (via the UAV Toolbox Support Package for PX4 Autopilots), set *Hardware Implementation → Target Hardware = Pixhawk PX4.
- The support package will automatically locate the installed toolchain in WSL
- if MATLAB is properly configured. [MathWorks – PX4 Support Package Overview]( https://. www.mathworks.com/help/uav/px4-spkg.html)
5. Generate and Integrate Code
* Use Simulink Embedded Coder to generate C++ source.
* The PX4 support package places generated code under `src/modules/ px4_simulink_app/` within your PX4 workspace.
* CMake automatically includes this module in the PX4 firmware build.
6. Rebuild PX4 Firmware with Your Module
make px4_fmu-v6x_default
This command should now successfully compile your Simulink module alongside the PX4 firmware.
7. Flash Firmware to the Board (Optional)
make px4_fmu-v6x_default upload
References
MathWorks UAV Toolbox Support Package for PX4 Autopilots [ https://www.mathworks.com/help/uav/px4-spkg.html ]
PX4 Developer Guide – Setting up the PX4 Toolchain in WSL2 [ https://docs.px4.io/main/en/dev%5C_setup/dev%5C_env%5C_windows%5C_wsl.html ]
MathWorks – Setup and Configuration for PX4 in WSL [ https://www.mathworks.com/help/uav/setup-and-configuration-px4.html ]
In summary, your build failure arises from two root causes:
1. Running PX4 compilation from an unsupported UNC path. 2. Lack of a properly installed ARM embedded toolchain in WSL.
By (a) running the build directly from native WSL paths, (b) installing the toolchain with PX4’s setup script, and (c) ensuring Simulink’s PX4 support package points to this toolchain, you should be able to compile and deploy your Simulink-generated PX4 application reliably.
Please let me know the outcome after you follow these steps.