Full name: Common Microcontroller Software Interface Standard.
Definition
CMSIS (Common Microcontroller Software Interface Standard) is a family of software interfaces, libraries, tools and file formats that Arm publishes for microcontrollers §6.1 built on its Cortex processors. It is not one library: each part has its own name and job. CMSIS-Core gives C code standard access to the processor core; CMSIS-Driver defines peripheral driver interfaces; CMSIS-RTOS2 is the second version of the CMSIS interface to an RTOS (real-time operating system); and CMSIS-DSP provides DSP (digital signal processing) functions. Using one part does not imply using another.
The idea
Before CMSIS, each chip vendor wrote its own names and functions for parts that are identical on every chip with the same Arm processor core, such as the interrupt §6.11 controller and the system timer. Code that enabled an interrupt on one vendor’s Cortex-M4 §6.3 chip had to be rewritten for another vendor’s Cortex-M4 chip. CMSIS fixed one set of names for those common parts, and Arm later added further standard pieces around it: driver interfaces, an operating-system interface, math libraries, a packaging format and debugging aids. Arm first published it under the name Cortex Microcontroller Software Interface Standard; Arm now expands the C as Common.
The umbrella name is the trap. Saying that firmware “uses CMSIS” is like saying that a house uses standard parts: true, and useless until one says which parts. The parts carry different kinds of dependency. CMSIS-Core is mostly header files: names, constants and short inline functions that cost nothing until they are called. CMSIS-DSP is compiled code that runs and whose results obey a numerical contract. CMSIS-RTOS2 is an interface whose behavior comes entirely from the kernel behind it. A claim about one part says nothing about the others.
How it works
Arm’s documentation groups the parts as follows.
Base components, delivered together: CMSIS-Core, standard access to the processor core; CMSIS-Driver, generic peripheral driver interfaces for middleware such as network or file-system stacks; CMSIS-RTOS2, a common interface to real-time operating systems.
Extended components, delivered separately: CMSIS-DSP, optimized signal-processing and math functions; CMSIS-NN, neural-network (NN) computation kernels; CMSIS-View, event recording for debugging; CMSIS-Compiler, which redirects the input and output of the standard C library.
Tools, among them CMSIS-Toolbox, command-line build tools; CMSIS-DAP, firmware for debug probes that talk to a processor’s Debug Access Port (DAP); and CMSIS-Zone, a method to describe system resources and divide them up.
Specifications: CMSIS-Pack, a format for delivering software components and device support, and CMSIS-SVD, the System View Description (SVD) file that lists a device’s peripheral registers for debuggers.
CMSIS-Core is the part that most firmware touches. For each chip the vendor supplies a device header. It defines the chip’s interrupt numbers, as a C enumeration of names such as UART0_IRQn, and constants such as __NVIC_PRIO_BITS, the number of priority bits that the chip implements. The device header includes Arm’s core header for the processor, such as core_cm4.h for the Cortex-M4, which supplies:
structures that lay out the core’s registers at their fixed addresses, such as those of the NVIC §6.13 (Nested Vectored Interrupt Controller) and of the system timer, SysTick;
inline functions such as
NVIC_EnableIRQ(),NVIC_SetPriority()andSysTick_Config();intrinsics, functions that compile to a single special instruction, such as
__WFI(), wait for interrupt, and__DSB(), a data synchronization barrier.
The vendor also supplies start-up code and a system file whose function SystemInit() sets up the clocks and whose variable SystemCoreClock holds the processor’s clock frequency.
To tell which part a piece of code uses, look at the names it uses. Functions beginning with NVIC_ or SysTick_, and intrinsics such as __DSB(), belong to CMSIS-Core. Functions beginning with arm_ and ending in a number-format suffix such as _f32 or _q15, for example arm_mean_q15(), belong to CMSIS-DSP; CMSIS-NN also uses the arm_ prefix. Functions beginning with os, such as osThreadNew(), belong to CMSIS-RTOS2. Driver structures such as ARM_DRIVER_USART belong to CMSIS-Driver.
Worked example
CMSIS-Core: an interrupt priority. A chip implements 3 priority bits, so its device header sets __NVIC_PRIO_BITS to 3, and the chip has priority levels, from 0, the most urgent, to 7. Each interrupt has an 8-bit priority field of which only the top 3 bits exist. NVIC_SetPriority(irq, 5) shifts the value left by bits and keeps the low 8 bits of the result: , which is 0xA0, or 101 followed by five zeros in binary. The top 3 bits hold 5, as intended. The function does not check its argument. A call with priority 9 computes ; keeping the low 8 bits gives , whose top 3 bits hold 1. A programmer who asked for a level less urgent than 7 got the second most urgent one. CMSIS-Core standardizes how the register is written; staying within the chip’s range is the caller’s job.
CMSIS-DSP: a number format. The library’s Q15 functions take 16-bit integers that stand for fractions: the integer means , so the range runs from to just below 1. The samples 0.25, 0.5, and 0.75 are stored as , 16384, and 24576. Their sum is , larger than 32767, the largest 16-bit value, so a correct mean function adds them in a wider register. The mean is , which stands for ; indeed . The output 10240 is correct only for a caller who reads it as 0.3125; a caller who treats the numbers as plain integers has broken the format contract.
CMSIS-RTOS2: a delay. osDelay(10) asks the kernel behind the interface to suspend the calling thread for 10 kernel ticks, the kernel’s unit of time. With a kernel configured for 1000 ticks per second, that is 10 ms; with one configured for 100 ticks per second, it is 100 ms. The call is the same; the time comes from the kernel and its configuration, which osKernelGetTickFreq() reports.
Stated precisely
Identify a CMSIS dependency by four things: the component, its version, the implementation that provides it, and the target processor. Each component then has its own kind of contract.
CMSIS-Core: correct register access for the core named in the device header, provided that the vendor’s values, such as the interrupt numbers and
__NVIC_PRIO_BITS, match the chip, and that the caller passes values in range.CMSIS-DSP: a numerical result for inputs in the stated format, such as 32-bit floating point or the fixed-point formats Q7, Q15 and Q31, with the function’s documented rounding and saturation; saturation means that a result beyond the format’s range is replaced by the nearest value the format can hold. Speed depends on the processor: the library uses the SIMD (single-instruction, multiple-data) instructions of cores that have them, such as the Cortex-M4.
CMSIS-RTOS2: the interface fixes the meaning of each call, such as what a mutex §9.5 or a delay does; scheduling, timing and memory use come from the kernel behind it.
CMSIS-Driver: the interface fixes the function signatures and the events; behavior and timing come from the vendor’s implementation.
Limits and common mistakes
“Uses CMSIS” is not a claim about security, speed or correctness. Each such claim needs the component that supports it, and that component’s contract.
CMSIS-Core standardizes names; the vendor’s device header supplies the values. A wrong interrupt number or priority-bit count in that header makes standard code do the wrong thing.
Versions differ. CMSIS 6 moved CMSIS-DSP and CMSIS-NN out of the main package into packs of their own, and Arm states that the CMSIS-Core headers for Cortex-M devices changed in version 6.0.0 in ways incompatible with earlier versions.
CMSIS covers processors of Arm’s Cortex families. Code written against CMSIS-Core does not carry over to processors of other architectures.
An operating-system interface does not make timing portable. The same CMSIS-RTOS2 call takes whatever time the kernel behind it takes.
Zephyr §6.33 includes CMSIS-Core for its Arm Cortex-M targets and offers an optional CMSIS-RTOS2 layer over its own kernel. A Zephyr application that calls Zephyr’s own kernel functions does not use CMSIS-RTOS2 at all.
Questions answered
Which CMSIS component is actually relevant: core headers, DSP, RTOS interface, or another layer?
The relevant CMSIS component is the one whose names the code actually uses, and it must be found from the code, not from the umbrella name. CMSIS (Common Microcontroller Software Interface Standard) is Arm’s family of separate standard parts for microcontrollers built on Cortex processors. Look at the included files and the calls:
core headers such as
core_cm4.h, functions beginning withNVIC_orSysTick_, and intrinsics such as__DSB(): CMSIS-Core, standard access to the processor core, which costs nothing until called and works correctly only if the vendor’s device header matches the chip;functions such as
arm_mean_q15()orarm_fir_f32(): CMSIS-DSP, the DSP (digital signal processing) library, compiled code whose results depend on the number format of its inputs;functions beginning with
os, such asosThreadNew(): CMSIS-RTOS2, the interface to an RTOS (real-time operating system), whose timing comes from the kernel behind it;structures such as
ARM_DRIVER_USART: CMSIS-Driver. Pack description files belong to CMSIS-Pack, register description files read by a debugger to CMSIS-SVD, and debug probe firmware to CMSIS-DAP.
Then judge the code by that component’s own contract and version. Using CMSIS-Core says nothing about threads or signal processing. Much firmware, including most Zephyr applications on Cortex-M chips, uses CMSIS-Core and none of the other parts.
Related entries: NVIC (§6.13), Hardware abstraction layer (HAL) (§6.42), Firmware build profile (§6.44), Arm Cortex-M4 (§6.3). Further reading: [94, 175].