cancel
Showing results for 
Search instead for 
Did you mean: 

Cookbook: enabling arm_math.h on STM32H7 (dual core M7/M4)

Hansel
Senior

I spent the time to learn how to get it up and running so that you don't have to. What I am explaining here was done on Win 10. My CubeIDE version was 1.6.1.

  1. Downloading and copying the files:
    1. At the time I installed it, STM32Cube_FW_H7_V1.9.0 was current. I downloaded it from here.
    2. After extracting the zip file, open a File Explorer window and go to the directory "<extractedFiles>\en.stm32cubeh7_v1-9-0_v1.9.0\STM32Cube_FW_H7_V1.9.0\Drivers\CMSIS\DSP"
    3. In the above directory, you will notice two folders: "Include" and "Lib". These two folders will have to be copied in your already existing project as explained next.
    4. Open another File Explorer window and go to the root directory of your project "<user>\STM32CubeIDE\<workspace>\<projectName>\Drivers\CMSIS". Here you need to create a new folder called "DSP". Once created, copy the to folders "Include" and "Lib" under folder "DSP".
    5. Unless your CubeIDE is already open, start it up. Unless the DSP folder isn't already visible, hit F5. Now it should look like this in the Project Explorer of CubeIDE ("Learning" is what I called my project here):0693W00000CzvUhQAJ.png
  2. Next we need to establishing the appropriate links in a number of places in CubeIDE.
    1. Note that you will have to do this job both in the CM4 as well as the CM7 project. In the Project Explorer of CubeIDE, right-click on one of the projects, like "Learning_CM4" or "Learning_CM7" as shown in my example above and click on "Properties (Alt+Enter)". Add the path highlighted in blue as shown below by clicking on the button encircled in red:0693W00000CzvVkQAJ.png
    2. Notice the selection at the top "Configuration: Debug [Active]". After hitting "Apply", make sure you repeat this for all your other configurations. The same goes for all the following steps, so don't forget to do it (it's a bit cumbersome).
    3. Next add the following symbol as shown below. If you have selected your project for CM4, enter "ARM_MATH_CM4". If you have selected your project for CM7, enter "ARM_MATH_CM7".0693W00000CzvXCQAZ.png
    4. Notice that you did the above for "MCU GCC Compiler -- Preprocessor". I repeated the same for "MCU G++ Compiler -- Preprocessor". You may want to do the same.
    5. Now comes the part that took me the longest to figure out. For CM4, add library "arm_cortexM4lf_math" if you are in the settings for your CM4 project; use "arm_cortexM7lfdp_math" for your CM7 project. In both cases, you will have to add the proper library search path as shown below. It should be written like follows: "${workspace_loc:/<projectName>/Drivers/CMSIS/DSP/Lib/GCC}". Unfortunately you cannot use "${workspace_loc:/${ProjName}..." as is possible in other places. I think this is a bug.0693W00000CzvWjQAJ.png
  3. Now add "#include arm_math.h" wherever you need it in your corresponding C files: in the CM4 project and/or in the CM7 project. Compile and link your project. If you encounter errors, check if you've forgotten a setting for the configuration you are using for compiling/linking.

I hope this helped you. If it did, consider giving my post a "Like". Thanks.

7 REPLIES 7
LBart.1
Associate

Many many thanks for sharing this information. I was desperatly trying to make the ARM DSP Lib working within CubeMX but it did not work at all.

So far I figured out: Inside the "Software Packs Component Selecor" select "STMicroelectronics.X-Cube-ALGOBUILD->DSP Library".

This makes the DSP Lib available in the CubeMX Project but the Code Generator does not copy the "libarm_cortexMxx_math.a" files. It only copies the "arm_math.h" file

plus it is a much older version (v.1.5.3 while offical release is at v1.9. already)

I guess this is some thin ST could really put some effort on making this process much more intuitive. I don't like fighting with tools, I rathe would like to fokus on my project.

So again, thanks you very much!

CubeMX 6.2.1

CubeIDE 1.7.0

Nucleo-H745Zi

Hansel
Senior

I am happy to read it helped. And, yes, I agree. Better documentation and a more streamlined interface would go a long way so that we can focus on what's important: put ST's µC to good use by writing code for it rather than fighting the system.

Hello @Stephan Hörold​ ,

the ARM_MATH_CM4 flag is obsolete since about 2019, in newer versions the Flag is not used, it will not cause problem if it set, but it also has no effect. If the flag is set for backward compatibility that makes sense, but it is not needed for the latest versions, but I can not tell you when it was changed exactly.

@Community member​ If you like to compile it from source, I added a pdf, I hope it helps.

Best Regards, Seppel

Hi @seppeltronics_v​, thanks for that information. So it essentially means the last step I showed above can be skipped.

Hello @Stephan Hörold​ ,

it depends on the version, if you are not sure, it may be better to set ARM_MATH_CM4 or ARM_MATH_CM7, depending on the core. I did not find the exact date of the change(I did not put too much effort in it) and I'm not sure ARM ever stated that they changed in the release, so it was obvious.

But maybe you can help me in finding the new binaries(*.a) of the Version 5.7.0 and 5.8.0? The repository, but that contains only code, as to be expected, but I have no idea where the *.a files are actually published by ARM.

Thanks a lot, Best Regards, Seppel

SuperMan96
Associate II

I am currently using STM32H747I-DISCO with Mac. This solution worked for me! Thank you :) 

Just make sure you don't blindly copy ${workspace_loc:/<projectName>/Drivers/CMSIS/DSP/Lib/GCC}.
replace <projectName> with your own projectName. A tedious mistake I overlooked.

E3ho
Associate

Thank you very much for your post, Hansel. It also worked for me, you made my day :raising_hands::raising_hands: