This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Host compilations of code which include the CMSIS headers

Hi folks,

In my current project, I am implementing (in C) a HAL for the CAN controller on my vendor board. All the register structures and associated enums for the board are defined in a single mega-header board.h. This header then includes the CMSIS Core header for the Cortex-M4, which includes the CMSIS GCC header.

I am developing this HAL on an Intel based laptop and the git repo is on Gitlab. I need to be able to unit test and analyse the code on the laptop, and using Gitlab CI.

My problem begins with the fact that the CMSIS headers for the Cortex-M4 and for GCC both define - not declare - a load of functions. It is especially tricky with the GCC header, whose functions are aliases for ARM assembly instructions. When I compile my project, the Intel compiler of course does not recognise the ARM assembly instructions.

The vendor megaheader not only includes the Cortex header (which relies on vendor types, e.g. a interrupt-number enumeration), but utilises macros/preprocessor constants defined in the Cortex header. It's tempting to blame the board vendor for including a header which defines functions, but it seems bizarre to me that ARM would define them in the CMSIS header.

This causes the unit testing problem firstly. I could, of course, copy all the types and #defs I need out of the vendor and CMSIS headers and dump them in a test-only alternative header, but that is a maintenance issue.

But the problem doesn't stop there. Basic compiler checks are also part of our quality assurance, so I want to be able to compile all my own sources with maximum pedantry, on the laptop, without having to rig up the development board and startup sources, which are themselves owned by a supplier.

Is there a way to generate CMSIS without the function definitions in source files? Maybe I'm still junior in the embedded world, but to me it is a sin worthy of the Inquisition to define functions in a header.

How do other people get round this difficulty?

Thanks!