cancel
Showing results for 
Search instead for 
Did you mean: 

ModusToolbox Blog

markgsaunders
Employee

Using the CMSIS-DSP Library in a ModusToolbox Project

Our friend, Matt Mielke at Dig-Key, just wrote a really good blog about using CMSIS-DSP on PSoC 6. It is one of those really good articles that just gets on with the job of describing the subject without a load of unnecessary, showy-offy acronyms and buzzwords. I really liked it and recommend you give it a read. Unless you really like slow math in your programs. Ok, then... good luck with that.

I liked that it methodically explains what the library does and how it helps, uses the CMSIS-PACK plug-in that ships with ModusToolbox to install the library, then adds it to the project and sets the include path up. In case you have never seen it, here is an image showing the Pack Manager after the library has been installed - it is a great way to install libraries and keep them up to date.

CMSIS Pack Manager installing CMSIS-DSP in ModusToolbox

I only thought of one thing I would add to the article. Matt explains the difference between hardfp and softfp libraries, and points out that you cannot mix-and-match them. But I'd also add that you need to remember that when choosing other middleware for your application. Here is a picture of the ModusToolbox Middleware Selector... notice the CapSense and Segger emWin entries that list a Hard FP and Soft FP implementation... you need to make sure all those match your DSP library selection.

Hard and Soft FP libraries in ModusToolbox Middleware Selector

Did you finish reading it yet? Good, wasn't it?

12 Comments
ArPa_4301556
Employee

Hi,

I was trying the same exercise on ModusToolbox 2.0, that is, using CMSIS and its packs and its DSP libs. I was unable to find the same CMSIS Pack support in 2.0 (compared to 1.1), was I looking in the wrong places or is my 2.0 install incomplete/outdated/somehow broken? Or is the CMSIS Pack support for 2.0 not there yet?

Thx a lot

Arndt

0 Likes
markgsaunders
Employee

Hello!

Unfortunately the CMSIS library manager that we were using in ModusToolbox 1.1 was removed in the 2.0 release. Users found it confusing because it provides a means of creating a project that is not supportable within ModusToolbox. We determined that this problem outweighed the convenience of adding software packs. You have two options with the 2.0 software. You could install the pack manager from the Eclipse marketplace and follow the instructions in the Matt Mielke blog again. Alternatively, you could simply go to GitHub and get the CMSIS-DSP sources from there. Here is the link: GitHub - ARM-software/CMSIS_5: CMSIS Version 5 Development Repository​. Simply putting the library in your project space is all that is typically required for the make-based build system to find, compile, and link the DSP sources.

Regards, Mark Saunders.

0 Likes
ArPa_4301556
Employee

Hi, Mark

Thanks for looking into this and your comments. Before we can take a look at the CMSIS DSP example build I was trying to do, I would like to see what’s going wrong when building the Hello_world example - here’s what I do:

- Installed ModusToolbox 2.0 (in a non-default location), using a CY8CPROTO-063-BLE kit

- Created a „New Application“, selected the Hello World app, fixed the CY_TOOLS_PATHS thingie in the makefile and build the application – works fine, build completes with no errors, I have an elf file …

- Trying to debug this, but there is no “hello world debug” or any other item in the “Launches” tab. Read a little more on the Getting Started doc, figured out that my BLE kit needs to be upgraded to Kit3. Did that and enabled the DAPlink, restarted ModusToolbox to see whether it would fill the “Launches” tab … no success so far.

ð Anything you could help me with? I don’t really know how to establish connectivity with the BLE kit, fw_loader worked fine, but I can’t debug.

Then, going on to the CMSIS DSP lib example:

- I can build, see above, so created another app using the empty PSoC6 app as a basis.

- I replaced the sources by the example sources from a fresh working copy of ARM’s CMSIS repo on github, cloned to some location outside of the actual empty PSoC6 app. So, arm_convolution_example_f32.c is my new main()

- I added the CY-specific HAL, BSP includes and compiled the whole thing. ARM_MATH_CMx needs to be defined as per compile error log. So, I wanted to add a respective –DARM_MATH_CM4 through the project properties, but I didn’t find a suitable field to do that. So, I did this in the makefile …

- Now the stuff compiles, but does not link … libarm_cortexM4l_math.a is missing from the linker command line. It sits in the CMSIS repo in ./CMSIS/DSP/Lib/GCC, but it does not seem to be part of the libs folder of the example project. The CMSIS header files like arm_math.h are, though …

- So, how should I add libarm_cortexM4l_math.a to this project? I tried a number of combinations in the makefile, e.g.

  1. Additional / custom libraries to link in to the application.

LDLIBS= -llibarm_cortexM4l_math.a

But this doesn’t really work, make complains with

make: *** No rule to make target '-llibarm_cortexM4l_math.a', needed by 'D:/Temp/mtw-2.0/Empty_PSoC6_App/build/CY8CPROTO-063-BLE/Debug/mtb-example-psoc6-empty-app.elf'. Stop.

So, I dropped the lib into the same location as the source files as you suggested and now it links fine, thx for the hint, however, I find this kind of counter-intuitive and weird to drop a lib into where the actual source code sits.

--> How do I tell the makefile to consider the lib’s original location, I don’t really want to drop/copy those kinds of external libs to the “project space”.

Again, thx for your help

Arndt

0 Likes
markgsaunders
Employee

I've not yet tried a non-standard install location so I am a little unsure of why the launch configurations are wrong. But it might be fixable by just regenerating them. In the Project Explorer, right-click on the project and select Build Targets... and then Create. In the dialog just write "eclipse" as the Target name.

pastedImage_0.png

Press OK and you will see a new folder in the project called Build Targets. There is a single item in that folder, called eclipse. Double-click that and the launch configurations will hopefully get re-created.

Note that you can also do this (rather quicker) from a modus-shell by running "make eclipse" in the project folder.

As for the root cause, I have an inkling that it is because you created the project and then changed the tools path in the makefile. This means that the launch configurations pre-date the path setup. The steps above would fix that if this is, indeed, the case. I would set the environment variable because then you can create new projects without having to run make eclipse.

Please let us know how you get on with this fix. As for the CMSIS stuff, I am not an Eclipse guru (actually i am just not a guru!) so I'll ask one of our support guys to follow up with you on that.

Mark.

0 Likes
ArPa_4301556
Employee

Hi, Mark

Thanks for your answer.

No, regenerating them didn’t work – the launch config dir and its content was indeed regenerated, but it didn’t show up in Eclipse, neither by closing/opening/refreshing/whatever either the project or Eclipse itself.

So, I deleted the project and recreated it from scratch, see log attached.

As per log, there seems to be a problem with CY_TOOLS_PATHS. It seems available, but not “understood”. So I closed the IDE and changed

set CY_TOOLS_PATHS=d:\ModusToolbox_2.0\tools_2.0

to

set CY_TOOLS_PATHS=d:/ModusToolbox_2.0/tools_2.0

in my DOS shell from which I start the Toolbox.

And, surprise: Restarting the IDE and creating a fresh Hello_World projects gives me 4 Launch configs. I’m still missing the Attach and Erase Launch config, but at least I have the “Debug” and the ”Program” config, both for Kit3 and JLink.

Ok, so one step forward …

Unfortunately, launching any of the available configs does not work, they all seem to suffer from path problems - see this:

Error in services launch sequence

Launching command failed.

Launching command failed.

Cannot run program "/undefined_path/JLinkGDBServerCL.exe": Launching failed

Kit3-based launch configs returned error messages which, to me, seem to indicate similar problems.

So, all in all:

- Installing the IDE in a non-default location seems, well, something that needs a second look. I’m not aware that my machine is special in any respect, the path I have installed it to is simple and short and has no whitespaces and …

- You are using Cygwin under the hood, but imho you seem to have a problem with properly handling slashes and backslashes inbetween native Win/DOS paths and those Cygwin-wanna-be-POSIX paths.

- Lots of time going by …

Cheers

Arndt

0 Likes
markgsaunders
Employee

Hello!

The attach and erase configurations still exist but we do not put them in the Quick Panel because it just gets too full. If you use the Run Configurations dialog, from the main Run menu you will see them. Once you use them the first time they will be in your history and you'll see them as choices in the Debug and Run buttons in the main button bar.

I did not see a response from our support guys. That's unusual. I'll follow up.

Regards, Mark.

0 Likes
DheerajK_81
Moderator
Moderator

Hello Arndt,

Addressing the issues you are facing:

Q1. I have installed ModusToolbox in a custom location. How do I make things work?

Ans. In ModusToolbox the build infrastructure is entirely using the Makefile. By default, ModusToolbox searches for the "tools_2.0" directory in the USERPROFILE path which is usually  "C:/Users/<username>" .

Where is this specified is the next question you are going to ask me.

In the Makefile, you will notice this line:

CY_WIN_HOME=$(subst \,/,$(USERPROFILE))

This line takes the USERPROFILE path and then substitutes "\" with "/". Make sure you use "/" for the paths because "/" is the POSIX compliant path seperator which is used by Cygwin under the hood. So, this answers how the slashes are being handled in the Makefile.

CY_TOOLS_PATHS ?= $(wildcard \

    $(CY_WIN_HOME)/ModusToolbox/tools_* \

    $(HOME)/ModusToolbox/tools_* \

    /Applications/ModusToolbox/tools_*)

These lines specify where the Makefile searches for the tools directory. The values for $(USERPROFILE) and $(HOME) depend on the environment variables for your particular system.

If you installed ModusToolbox in a custom location say "D:\ModusToolbox". Then you can just specify this path in the "CY_TOOLS_PATHS+=" variable in this way:

CY_TOOLS_PATHS+=$(wildcard D:/ModusToolbox/tools_*)

Q2. I'm missing the launch configs. How can I generate them back?

Ans. The launches can be recreated from the command line in the following manner:

(1) Go to "<modustoolbox install dir>\tools_2.0\modus-shell" and run "Cygwin.bat"

(2) Navigate to the application directory which contains the Makefile using

>> cd "<path to application dir>/<application_name>"

(3) Run the following command to recreate the launch configs

>> make eclipse CY_IDE_PRJNAME="<project name>"

(4) You should observe the lines in the console

rename.png

Now launch ModusToolbox IDE and everything should be visible and in order.

Q3. How do I include libraries external to my application directory?

Ans. Use the LDLIBS variable to specify application-specific precompiled binaries or library files. The LDLIBS value must be a space-separated list of specific files. Use paths relative to the project folder to locate the files. You can create a search pattern with wildcards to find multiple files. These files are included in the link process.

LDLIBS=../MyBinaryFolder/binary.o

LDLIBS+=$(wildcard ../lib/*.a)

LDLIBS+=../<DSP_Library_Dir>/libarm_cortexM4l_math.a

If you need to include the header files for the libraries, use the INCLUDES variable.

We are in the process of creating a guide that explains how to use the Makefile. It should out within the next two weeks, I'll provide a link to that once released here. That should help

Hope I have answered all your questions. Let me know if you have any further queries.

Regards,

Dheeraj

ArPa_4301556
Employee

Hi, Dheeraj, Mark

Thanks for answer, see my inlined answers below

Thx

Arndt

0 Likes
markgsaunders
Employee

I cannot see your answers.

Regards, Mark.

0 Likes
ArPa_4301556
Employee

Hi, Mark

Thx for following up, in one of your emails you mentioned you were asking your support guys to take a look. This happened, Dheeraj send me an email and I was following up on this email, see attached.

So, I did as Dheeraj suggested, but does not really resolve the issue: When trying to debug/program/… the CY8CPROTO-063, both Kit3 and JLink launch configs yield an error. To me, the error message indicates that there is some path problem.

Let me know what I can do to debug this further

Cheers

Arndt

0 Likes
DheerajK_81
Moderator
Moderator

Hello Arndt,

The email notification you received from me would have been when I posted my answer here on the blog. Sorry, I haven't received any email from you if you did send me one.

I think the attachments you might be adding to the blog may not be showing up. Anyways, I will contact you via email and we can continue the discussion there. Or you can create a post on our community and we can assist you there. Whatever works for you.

The community link is here.

Regards,

Dheeraj

DheerajK_81
Moderator
Moderator

The issue was due to Kitprog3 driver not being bound. Once Kitprog3 driver was bound manually and firmware updated, the programming and debugging worked as expected.


Regards,

Dheeraj

0 Likes
Top labels