Error link external C library

4 visualizzazioni (ultimi 30 giorni)
Mirko Mirabella
Mirko Mirabella il 16 Dic 2021
Risposto: arushi il 13 Feb 2024
Good morning,
I would like to ask for support in solving a problem that arises when updating a simulink model in which I would like to import external libraries written in C code for STM32 microcontrollers.
After having done all the includes, I can insert the functions in the library using C Caller (I see all the functions), but during the compilation phase I get an error that I report in the attached figure.
Thank you

Risposte (1)

arushi
arushi il 13 Feb 2024
Hi Mirko,
The errors you're encountering during the compilation phase in Simulink when trying to integrate external C libraries for STM32 microcontrollers suggest that there's a mismatch between the assembly code generated and what the assembler expects. This could be due to various reasons, including incorrect compiler settings, incompatible assembly syntax, or issues with the C code being compiled.
Here are some steps you can take to troubleshoot and resolve the issue:
  1. Check Compiler Compatibility: Ensure that you're using a compiler that is compatible with the STM32 microcontroller and that it understands the assembly instructions being used. The STM32 typically uses ARM Cortex processors.
  2. Review Custom Code Settings: In Simulink, make sure that the custom code settings, such as include paths, source files, and defines, are correctly specified. Also, ensure that the settings are compatible with the compiler you're using.
  3. Inline Assembly Syntax: If the C code contains inline assembly, ensure that the syntax is correct for the compiler you're using. Different compilers may have different syntax requirements for inline assembly.
  4. Assembly File Generation: The errors seem to be coming from an assembly file (*.s). Check whether the assembly file is generated by the compiler or provided as part of the library. If it's generated by the compiler, there might be an issue with the compiler's configuration or the C code itself.
  5. Simulink Model Configuration: Verify the Simulink model configuration parameters, specifically the hardware implementation settings. Make sure that you have selected the correct target hardware and that the toolchain settings align with your compiler.
  6. Update Libraries and Toolchain: Ensure that all libraries and the toolchain are up to date. Sometimes, compatibility issues can be resolved by updating to the latest versions.
By following these steps, you should be able to identify the source of the compilation errors.
Please refer to the below MathWorks documentation of working with STM32 controllers - https://www.mathworks.com/help/ecoder/stmicroelectronicsstm32f4discovery/ug/Getting-started-stm32cubemx.html
Hope this helps.

Prodotti


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by