CMSIS-Driver Validation  
Driver Validation
Setup

Step 1: Create an MDK project for your target microcontroller device

Step 2: Add the required software components

For proper operation, add the following software components in the Manage Run-Time Environment window:

  • CMSIS Driver Validation: Framework
  • CMSIS Driver Validation: driver, driver interfaces to be tested
  • CMSIS Driver: driver, driver implementations to be tested
  • CMSIS: RTOS2 (API): Keil RTX5
  • Compiler: I/O: STDOUT, variant ITM (if your hardware does not support ITM select EVR to use Event Recorder instead of ITM)
  • Resolve any unresolved component dependencies

Step 3: Add the application's main file (main.c)

Right-click Source Group 1... and select Add New Item to Group, select User Code Template and choose the CMSIS-RTOS2 'main' function file from CMSIS: RTOS2:Keil RTX5.

Add this include:

#include "cmsis_dv.h"

In the app_main function, create the cmsis_dv thread, before endless for loop:

osThreadNew(cmsis_dv, NULL, NULL);
void cmsis_dv(void *argument)
This is the entry point of the test framework.
Definition: DV_Framework.c:77

to run all the tests that you have chosen in the next step.

Step 4: Configure the CMSIS-Driver Validation framework in DV_Config.h file

Open DV_Config.h under the CMSIS Driver Validation group in the Project window.

In the configuration file DV_Config.h select Plain Text as the Report Format.

Step 5: Configure the interface settings and tests in related DV_interface_Config.h files

Each interface has a related DV_interface_Config.h file, where interface represents interface's acronym or abbreviation.
For example for Serial Peripheral Interface (SPI) related config file name is DV_SPI_Config.h.

For details on interface specific configuration and test selection please check the Configuration section in the Reference of the related interface.

Step 6: Configure the Heap memory

Depending on the buffer sizes used for data transfer tests the heap size has to be adjusted to provide enough memory for these buffers to be allocated.
Depending on how heap is configured in your system, open your startup_<device>.s or startup_<device>.c file from the Device group in the Project window or use a linker script to adjust the heap size.
Set the heap size to minimum of 16384 bytes.

For details on heap requirements please refer to the Heap Memory requirements documentation.

Step 7: Configure the CMSIS-RTOS2 (Keil RTX5)

Open RTX_Config.h and set:

  • System Configuration: Global Dynamic Memory size [bytes] to 16384
  • Thread configuration: Default Thread stack size [bytes] to 3072

For details on CMSIS-RTOS2 requirements please refer to the CMSIS-RTOS2 requirements documentation.

Step 8: Configure the Device

Depending on your device, you might have different pin/hardware configuration options. Usually, you can configure the device using the RTE_Device.h file from the Device group or with a vendor provided pin configuration tool. Enable all interfaces you wish to test and make all necessary pin-out changes required by your actual board layout (consult the board schematics).
You can check the provided examples as a reference point.

For a robust test with good coverage, implement various targets with different settings:

  • Use non-DMA (IRQ) and DMA configurations if they are available on the driver
  • Use different compiler optimization levels in the C/C++ tab of the Options for Target dialog

Step 9: Setup the required hardware

For the interfaces that support loopback testing: Ethernet, USART and SPI, connect the following pins on your target hardware together (refer to the hardware schematics):

  • Ethernet: RX+ and TX+, RX- and TX-
  • USART: RX and TX
  • SPI: MOSI and MISO

For the interfaces that support testing with dedicated server: WiFi and SPI, connect the related hardware as required by the related server:

  • WiFi: WiFi module has to be in close proximity to the Access Point which is in the same network as the required SockServer
  • SPI: MOSI, MISO, SCLK, SS, GND to the same lines on the SPI Server

Step 10: Download and Run the Project

In the Options for Target dialog, under debug settings, if you use ITM as standard output channel ensure that Trace and ITM port 0 are enabled and that the correct Core Clock frequency is set:

ITM Channel setting

Build, load and run the project. The output is displayed in the Debug (printf) Viewer window.
Example below shows output result of an SPI driver testing:

CMSIS-Driver_Validation v3.0.0 CMSIS-Driver SPI Test Report   March  30 2022   13:44:11

TEST 01: SPI_GetVersion
  DV_SPI.c (1023): [INFO] Driver API version 2.3, Driver version 2.15
                                          PASSED
TEST 02: SPI_GetCapabilities              PASSED
TEST 03: SPI_Initialize_Uninitialize      PASSED
TEST 04: SPI_PowerControl
  DV_SPI.c (1314): [WARNING] PowerControl (ARM_POWER_LOW) is not supported
                                          PASSED
TEST 05: SPI_Mode_Master_SS_Unused        PASSED
TEST 06: SPI_Mode_Master_SS_Sw_Ctrl       PASSED
TEST 07: SPI_Mode_Master_SS_Hw_Ctrl_Out   PASSED
TEST 08: SPI_Mode_Master_SS_Hw_Mon_In     PASSED
TEST 09: SPI_Mode_Slave_SS_Hw_Mon         PASSED
TEST 10: SPI_Mode_Slave_SS_Sw_Ctrl        PASSED
TEST 11: SPI_Format_Clock_Pol0_Pha0       PASSED
TEST 12: SPI_Format_Clock_Pol0_Pha1       PASSED
TEST 13: SPI_Format_Clock_Pol1_Pha0       PASSED
TEST 14: SPI_Format_Clock_Pol1_Pha1       PASSED
TEST 15: SPI_Format_Frame_TI              PASSED
TEST 16: SPI_Format_Clock_Microwire       NOT EXECUTED
TEST 17: SPI_Data_Bits_1                  NOT EXECUTED
TEST 18: SPI_Data_Bits_2                  NOT EXECUTED
TEST 19: SPI_Data_Bits_3                  NOT EXECUTED
TEST 20: SPI_Data_Bits_4                  NOT EXECUTED
TEST 21: SPI_Data_Bits_5                  NOT EXECUTED
TEST 22: SPI_Data_Bits_6                  NOT EXECUTED
TEST 23: SPI_Data_Bits_7                  NOT EXECUTED
TEST 24: SPI_Data_Bits_8                  PASSED
TEST 25: SPI_Data_Bits_9                  NOT EXECUTED
TEST 26: SPI_Data_Bits_10                 NOT EXECUTED
TEST 27: SPI_Data_Bits_11                 NOT EXECUTED
TEST 28: SPI_Data_Bits_12                 NOT EXECUTED
TEST 29: SPI_Data_Bits_13                 NOT EXECUTED
TEST 30: SPI_Data_Bits_14                 NOT EXECUTED
TEST 31: SPI_Data_Bits_15                 NOT EXECUTED
TEST 32: SPI_Data_Bits_16                 PASSED
TEST 33: SPI_Data_Bits_17                 NOT EXECUTED
TEST 34: SPI_Data_Bits_18                 NOT EXECUTED
TEST 35: SPI_Data_Bits_19                 NOT EXECUTED
TEST 36: SPI_Data_Bits_20                 NOT EXECUTED
TEST 37: SPI_Data_Bits_21                 NOT EXECUTED
TEST 38: SPI_Data_Bits_22                 NOT EXECUTED
TEST 39: SPI_Data_Bits_23                 NOT EXECUTED
TEST 40: SPI_Data_Bits_24                 NOT EXECUTED
TEST 41: SPI_Data_Bits_25                 NOT EXECUTED
TEST 42: SPI_Data_Bits_26                 NOT EXECUTED
TEST 43: SPI_Data_Bits_27                 NOT EXECUTED
TEST 44: SPI_Data_Bits_28                 NOT EXECUTED
TEST 45: SPI_Data_Bits_29                 NOT EXECUTED
TEST 46: SPI_Data_Bits_30                 NOT EXECUTED
TEST 47: SPI_Data_Bits_31                 NOT EXECUTED
TEST 48: SPI_Data_Bits_32                 NOT EXECUTED
TEST 49: SPI_Bit_Order_MSB_LSB            PASSED
TEST 50: SPI_Bit_Order_LSB_MSB            PASSED
TEST 51: SPI_Bus_Speed_Min                PASSED
TEST 52: SPI_Bus_Speed_Max
  DV_SPI.c (3524): [WARNING] At requested bus speed of 10000000 bps, effective bus speed is 6477809 bps
                                          PASSED
TEST 53: SPI_Number_Of_Items              PASSED
TEST 54: SPI_Abort                        PASSED
TEST 55: SPI_DataLost                     PASSED
TEST 56: SPI_ModeFault                    PASSED

Test Summary: 56 Tests, 25 Passed, 0 Failed.
Test Result: PASSED