README.md
1# README
2
3## How to use
4
5This document is explaining how to use cmake with CMSIS-DSP.
6
7The example arm_variance_f32 in folder Examples/ARM/arm_variance_f32 has been modified to also
8support cmake and is used as an example in this document.
9
10### Generating the Makefiles
11
12To build example arm_variance_f32 with cmake, you need to create a build folder where the build will take place. Don't build in your source directory.
13
14You can create a build folder in Examples/ARM/arm_variance_f32
15
16Once you are in the build folder, you can use cmake to generate the Makefiles.
17
18The cmake command is requiring several arguments. For instance, to build for m7 with AC6 compiler:
19
20 cmake -DCMAKE_PREFIX_PATH="path to compiler (folder containing the bin folder)" \
21 -DCMAKE_TOOLCHAIN_FILE="../../../../armac6.cmake" \
22 -DARM_CPU="cortex-m7" \
23 -DROOT="../../../../../.." \
24 -DPLATFORM="FVP" \
25 -G "Unix Makefiles" ..
26
27DCMAKE_PREFIX_PATH is the path to the compiler toolchain. This folder should contain the bin folder where are the compiler executables.
28
29ROOT is pointing to the root CMSIS folder (the one containing CMSIS and Device).
30
31PLATFORM is used to select the boot code for the example. In example below, Fast Model (FVP) is selected and the boot code for fast model will be used.
32
33CMAKE_TOOLCHAIN_FILE is selecting the toolchain (ac6, ac5 or gcc). The files are in CMSIS/DSP.
34
35ARM_CPU is selecting the core. The syntax must be the one recognized by the compiler.
36(So for instance different between AC5 and AC6).
37
38The final .. is the path to the directory containing the CMakeLists.txt of the variance example.
39Since the build folder is assumed to be created in arm_variance_examples then the path to CMakeLists.txt from the build folder is ..
40
41To build for A5, you need to change DCMAKE_TOOLCHAIN_FILE and ARM_CPU:
42
43 -DCMAKE_TOOLCHAIN_FILE=../../../../armac5.cmake
44 -DARM_CPU="cortex-a5"
45
46To build for A5 with Neon acceleration, you need to add:
47
48 -DNEON=ON
49
50### Building
51
52Once cmake has generated the makefiles, you can use a GNU Make to build.
53
54 make VERBOSE=1
55
56### Running
57
58The generated executable can be run on a fast model.
59For instance, if you built for m7, you could just do:
60
61 FVP_MPS2_Cortex-M7.exe -a arm_variance_example
62
63The final executable has no extension in the filename.
64
65## Building only the CMSIS-DSP library
66
67If you want to build only the CMSIS-DSP library and don't link with any boot code then you'll need to write a specific cmake.
68
69Create a folder BuildCMSISOnly.
70
71Inside the folder, create a CMakeLists.txt with the following content:
72
73```cmake
74cmake_minimum_required (VERSION 3.6)
75
76# Define the project
77project (testcmsisdsp VERSION 0.1)
78
79# Define the path to CMSIS-DSP (ROOT is defined on command line when using cmake)
80set(DSP ${ROOT}/CMSIS/DSP)
81
82# Add DSP folder to module path
83list(APPEND CMAKE_MODULE_PATH ${DSP})
84
85###########
86#
87# CMSIS DSP
88#
89
90# Load CMSIS-DSP definitions. Libraries will be built in bin_dsp
91add_subdirectory(${DSP}/Source bin_dsp)
92```
93
94Create a build folder inside the BuildCMSISOnly folder.
95
96Inside the build folder, type following cmake command
97
98 cmake -DROOT="path to CMSIS Root" \
99 -DCMAKE_PREFIX_PATH="path to compiler (folder containing the bin folder)" \
100 -DCMAKE_TOOLCHAIN_FILE="../../CMSIS_ROOT/CMSIS/DSP/armac6.cmake" \
101 -DARM_CPU="cortex-m7" \
102 -G "Unix Makefiles" ..
103
104Now you can make:
105
106 make VERBOSE=1
107
108When the build has finished, you'll have a bin_dsp folder inside your build folder.
109Inside bin_dsp, you'll have a folder per CMSIS-DSP Folder : BasicMathFunctions ...
110
111Inside each of those folders, you'll have a library : libCMSISDSPBasicMath.a ...
112
113
114
115## Compilation symbols for tables
116
117Some new compilations symbols have been introduced to avoid including all the tables if they are not needed.
118
119If no new symbol is defined, everything will behave as usual. If ARM_DSP_CONFIG_TABLES is defined then the new symbols will be taken into account.
120
121Then you can select all FFT tables or all interpolation tables by defining following compilation symbols:
122
123* ARM_ALL_FFT_TABLES : All FFT tables are included
124* ARM_ALL_FAST_TABLES : All interpolation tables are included
125
126If more control is required, there are other symbols but it is not always easy to know which ones need to be enabled for a given use case.
127
128If you use cmake, it is easy since high level options are defined and they will select the right compilation symbols. If you don't use cmake, you can just look at fft.cmake to see which compilation symbols are needed.
129
130For instance, if you want to use the arm_rfft_fast_f32, in fft.cmake you'll see an option RFFT_FAST_F32_32.
131
132We see that following symbols need to be enabled :
133
134* ARM_TABLE_TWIDDLECOEF_F32_16
135* ARM_TABLE_BITREVIDX_FLT_16
136* ARM_TABLE_TWIDDLECOEF_RFFT_F32_32
137* ARM_TABLE_TWIDDLECOEF_F32_16
138
139In addition to that, ARM_DSP_CONFIG_TABLES must be enabled and finally ARM_FFT_ALLOW_TABLES must also be defined.
140
141This last symbol is required because if no transform functions are included in the build, then by default all flags related to FFT tables are ignored.
142
143
144
145