Simulink build errors while building with custom code for target device - Cannot find standard library header files in custom code.
Show older comments
Background
I am trying to use Simulink in hardware mode to connect to a power board. For this I am building a model to a (Raspberry Pi using the Simulink Support Package for Raspberry Pi Hardware - 20.2.2) with custom c code driver files supplied with the power board which should allow communication over USB from the Pi to the board. A C-Caller block is being used currently in the simulink model which should just send a reset command to the board as a test of the model compiling and running on the Pi. I have been able to run simple tests to ensure that a model using the support package, and simple C programs can be run on the Pi.

Problem
When using the C_Caller block I must include the main header file, to access the needed functions, and all source files for the driver in Configuration Parameters -> Simulation Target.

The toolchain used to compile is the default for the Pi Support package, GNU GCC Raspberry Pi:

When testing by running Moniter & Tune, the build error occurs:
Error(s) encountered while building custom code simulation target for model 'test_model'. Fix the errors in your custom code or disable 'Import custom code' if your custom code has incompatibilities.
Caused by:
- c:\filepath\ComPort\ComPort.c:4:21: fatal error: termios.h: No such file or directory #include <termios.h> ^ compilation terminated.
I think that this means that the compiler does not have access to a certain standard library that contains this file. The file termios.h is included in the GNU C Library (glibc), and therefore I believe this problem could be resolved by ensuring this library is included in the compiler, but I am completely unsure how to do this, and getting further out of my depth!
Advice very welcome.
1 Comment
Nathan Wenban
on 23 Feb 2021
Accepted Answer
More Answers (0)
Categories
Find more on Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!