Error: register 'sp' unsuitable for global register variables on this target - stm32

I am playing around with a project for a STM32 µC. I use the SW4STM32 workbench and CubeMX on a Mac OSX system. My project itself is fine, everything compiles accordingly and behaves on the device as expected.
For a further learning purpose, I would like to implement unit tests using the CppuUTest framework. I have set up everything, got my test directories and a makefile to configure the MakefileWorker variables in place.
However, when executing the Makefile, I keep getting the error:
error:
register 'sp' unsuitable for global register variables on this target
This error originates from the file syscalls.c (which is a file generated by CubeMX). The line causing the error is:
register char * stack_ptr asm("sp");
After doing my research, it seems like there is no easy workaround to solve the issue. The source code is generated by Cube and works fine when compiling with the sw4stm32 toolchain (which is using a mcu gcc compiler).
However, the CppUTest toolchain is using clang, which cannot cope with global register variables (as the error says aswell).
My question here ist:
Has anyone of you had the same error yet or more experience in setting up CppUTest for a sw4stm32 project on an OSx system? Does anyone have an idea how to solve this problem?
If you need more information / code snippets from me, I will gladly share it.
Thank you very much guys! Any help would be highly appreciated :-)
Cheers,
Tobi

Related

Debugging MBED with Eclipse

I am currently using mac OS to set up a debugger to debug Mbed OS application , I followed the instruction from https://os.mbed.com/docs/mbed-os/v5.12/tutorials/eclipse.html .
I successfully set up the local debug toolchain and I am stuck at this error for quite awhile already. I install "make" as written in the documentary using homebrew and also set the path as suggested but still getting this error
00:13:27 **** Incremental Build of configuration Default for project mbed-os-example-blinky ****
make all
Cannot run program “make”: Unknown reason
Error: Program “make” not found in PATH
PATH=[/Users/roseyv/Developer/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-g++]
00:13:27 Build Failed. 1 errors, 0 warnings. (took 4ms)
Any idea how to resolve this issue? or if there is any other better way we can set up debugger to debug MBED os application
Your help will be greatly appreciated, Thank you in advance!
In the mean time Mbed has updated their website. The link you posted is no longer valid. My suggestion now would be to use Mbed Studio.
Unfortunately Mbed is moving away from supporting Eclipse and only supports IDE's for which you have to be logged in with your account, Mbed Studio or the online compiler.
You could build from the command line option. Next use something like a Segger j-link and Segger Ozone to debug. I found Ozone easier to setup with random code compared to embedded debugging on Eclipse. This is what you pay for.

why I got the right message from the usart of stm32 when debugged by Keil MDK , but got a wrong out put from USART when using eclipse+CDT

I install these Plug-in in eclipse to build the stm32 develop environment:
GNU ARM Eclipse Plug-in
CDT GNU Cross Development Tools
Sourcery CodeBench Lite 2014.05-28 for ARM EABI
J-Link ARM V4.15e
I am trying to run a USART1 program in eclipse and check the output of the USART1,but when I debug this code,I got the wrong output message. The message I send is "DECA0130",but what I got is "???????",this is obviously a garbled.
At first, I think the problem is I didn't write a write code .I checked my project again.But didn't find any error.
Then I build a new project in Keil Mdk use the same code.This time I got the right message from USATR1.I receive the string "DECA0130".
It's very strange. Because I'm not familiar with eclipse environment,I used Keil do my coding before.But the recent projects have forced me to write code .I think maybe somewhere I forgot to configure.
Because it's a new user,I don't know how to insert the program。If there is any need, please tell me.I will try my best to let you see
Thanks in advance
Seems to be a clock issue. Check the clock settings. The eclipse ARM plugin generates some configs for that. Check the function SetSysClock in the system/src/cmsis/system_stm32*.c file. I think the Keil MDK does this too, but with differnt config.
Edit: The function SetSysClock i mentioned is wrong. The clock config is done in the configure_system_clock function (file _initialize_hardware.c).

Issue with Embedded Coder Target for Arduino

I am following this MathWorks File Exchange Link. I am having problem while running the myarduino_blink.slx demo.
My MATLAB version is R2015a, and I am using an Arduino Uno. I ran the file setup_custom_target_arduino.m after changing the relevant directory listing and the arduino version in the m file, and I got the output of Arduino on COM 3, which was correct.
After this, I checked the Simulink Library Browser and I had the Custom C/C++ Target Arduino Library will all its modules. Now when I simulate the model, I get the following error:
Error in S-function 'myarduino_blink/Digital Output':
S-Function 'sfunar_digitalOutput' does not exist
Kindly help me out, what could I have done wrong?
Update 1
Ok, I solved the "does not exist" problem. Apparently, no MEX compiler was installed. So I installed the Windows SDK, then re-ran the m file and now I am able to generate the .mex64 files. Now I run into another problem, when I build the simulink model, it gives this error:
Build procedure for model: 'myarduino_blink' aborted due to an error
How to solve this?
setup_custom_target_arduino.m calls build_all_sfunctions.m which should compile all of the S-Functions in the blocks directory. It looks as if that hasn't occurred for some reason. Check in the blocks directory that each of the S-Functions has a .c, .tlc (both of which come with the package) and a .mex64 (which is the compiled version of the .c generated by build_all_sfunctions.m) file.
If they are not there then the setup hasn't executed correctly, and you'll need to compile all of the S-Functions.
If they are there then you most likely have some sort of path issue (although since you say you can see the library in the library browser this seems unlikely).

Eclipse #ifdef error using JNI, Android NDK and Vuforia

With Vuforia's ImageTargets sample application, I tried using OpenGL ES 1.1 by setting USE_OPENGL_ES_1_1 to true in jni/Android.mk and uncommenting and changing the corresponding line in AndroidManifest.xml (). After converting the project so that it has a C++ perspective and associating ndk-build and the proper include directories, I could successfully run the application on my Android device.
However, the problem is that once I open up jni/ImageTargets.cpp, I get several errors from Eclipse, all from places where OpenGL ES 2.0 code would execute, the first one being:
Description Resource Path Location Type Symbol 'vertexHandle' could
not be resolved ImageTargets.cpp /ImageTargets/jni line 402 Semantic
Error
Sure enough, vertexHandle is defined at the top of the ImageTargets.cpp, inside the "#ifdef USE_OPENGL_ES_2_0" block. Because USE_OPENGL_ES_2_0 is not defined (per Android.mk), the code should be able to compile successfully, and sure enough, ndk-build does not report any problems. So it seems that only Eclipse reports the problems and when I run the project, Eclipse says, "Your project contains error(s), please fix them before running your application." And thus, I cannot run my application anymore. In a sense, it's kind of strange that this never occurred until I opened ImageTargets.cpp and Eclipse "discovered" the errors.
The best work-around I've found so far is to just delete or comment out those lines (that should not be causing problems because USE_OPENGL_ES_2_0 is not supposed to be defined)... Is there a better way to deal with this problem? Did I miss a setting in Eclipse that should solve this?
I've found a solution: go to the project properties -> C/C++ Build -> Discovery Options -> Check "Automate discovery of paths and symbols"

How to resolve MAC OS _XOPEN_SOURCE error in Xcode while compiling?

I am developing application for .Epub extension file reader.I have source code available.
But while compiling the code i am getting below error :
#error The deprecated ucontext routines require _XOPEN_SOURCE to be defined
I have gone through the internet for different kind of help, but not able to find exact solution.
Can anybody having any idea which kind of error it is?
How to resolve the above error in Xcode ?
please help out with any resolution for it.
Thanks.
You need to add a pre-processor define to your build command line (-D_XOPEN_SOURCE=600 for instance). Do this through your IDE's project properties, or by editing your makefile/changing your compiler flag environment variables.
Alternatively, add:
#define _XOPEN_SOURCE 600
before anything includes standard headers in your code.
Afterwards MAC os 10.6, you need to include "sys/ucontext.h" instead of just "ucontext.h" then you'll not need pre-processor include for _XOPEN_SOURCE.