This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Okay, i find it hard to believe I'm even having to ask this, but is there a known issue in CCSv5 with sprintf?
We have a project that we're bringing from CCSv4 to CCSv5. The project has been developed and is fully working in CCSv4, with no problems. However, when we brought it to CCSv5, sprintf seems to be breaking.
We couldn't believe it at first either. But we've created an entirely new project, and it breaks exactly the same way.
To replicate:
New Project->CCS Project
Project Name: <Whatever>
Output Type: Executable
Family: MSP430
Variant: MSP430x5xx Family / MSP4305438
Connection: TI MSP430 USB1 [Default]
Once the project is created, goto Properties, then Build->MSP430 Compiler->Advanced Options->Library Function Assumption and change Level of Printf Support from Minimal to Full.
Then your source should be as follows:
Main.c:
/*
* main.c
*/
#include <stdio.h>
void main(void)
{
int Length;
unsigned int temp = 20;
char Msg[255];
Length = sprintf(Msg, "Hello, World, %u", temp);
}
Place a debug point at the closing brace. Then debug the program and run until the breakpoint. Once there, check the status of Msg, and it should be the following:
"Hello, World, 24"
It seems as if it prints the first digit of the value (20) but then the second digit is printed as the hexidecimal value of the number (0x14).
Has anyone else seen this? Is this a known bug? If not, any thoughts on how we screwed up our sprintf function? This is a fresh install of CCSv5.
Thanks,
Ian
Hi Ian,
please have a look at this thread and bug found by my colleague Aarti. Do you think this is the issue you are seeing?
http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/140177.aspx#514935
Best Regards,
Lisa
That looks very similiar, yes. I'm amazed that this hasn't been addressed in an update - it seems like a fairly severe issue with an obscure work around - not even a fix, really.
But I will attempt to institute some of those fixes into our projects, and see if they help or fix things.
Hi Ian,
Actually an easier solution is if I send you the 4.0.1 compiler version offline which fixes this.
I will contact you via a conversation or friend request.
Best Regards,
Lisa
Hi Ian,
I just sent a friend request so I can send you a download offline afterwards once we can start a conversation.
Best Regards,
Lisa
Hi Ian,
just wanted to see if you got the request and if you like v4.0.1 of the tools with the integrated fix for this issue.
Best Regards,
LIsa
Hey Lisa-
The fix appears to have fixed that issue, but both 4.0.0 and 4.0.1 seem to break our system in ways that 3.3.3 do not still. Unfortunately at this point we're still trying to figure out specifics to try and get a handle on what might have broken, but as far as the sprintf problem goes, 4.0.1 did appear to fix that, I think. So at this point in time we're returning to 3.3.3, and will probably stay with it for the duration of the project.
Thanks,
Ian
Has the problem with CC 5 and sprinf been fixed? Using the compiler from CC4 (3.3...) will not compile without 'ERROR's
I have CC5 code is running on a MSP430G2231
Code Size - Text: 1842 bytes Data: 38 bytes
Hi David,
yes I believe so. We now package in compiler v4.1.1 into the latest CCS release.
Best Regards,
LIsa
Interesting I'm running CC5 and have compiler v4.0 and when I check for updates the response is 'No updates available'
What do I need to do to get this update. As I mentioned before I run the 'Check for Updates' and it comes back saying none are available?
Code Composer Studio
Version: 5.1.0.09000
(c) Copyright Texas Instruments, 2011. All rights reserved.
Visit http://www.ti.com
How can I get that update since when I use 'Check for Update" it returns with no update available?
I don't see any other compiler selection then 4.01 under Build Options
CC 5.1
Licensed version
UPDATE
Lisa,
I installed CC 5.2 over the weekend and now have compiler 4.1., Imported the project compiled and tested without success.. :-(
Things I notices and attempted to correct but with issues
Project Linker commands file could not be set to msp430g2231.cmd. If set and exited properties window and the re-entered it was blank,,,
Code snippet:
char msg[32];
int temp;
temp = sprintf( msg, "%d C", temp);
---- cut --------
NOTE:
- When ever the above code is executed the MCU resets. The watch DOG is STOPPED ( WDTCTL = WDTPW + WDTHOLD; // Stop WDT )
Any suggestions? Thanks
Hi David,
one thing might be to try switching between COFF and ELF format.
Please keep us informed.
Best Regards,
LIsa
Well I switched and the results follow:
During compiling:
I now receive these warnings:
Description Resource Path Location Type
#10247-D creating output section ".int05" without a SECTIONS Single_PWM C/C++ Problem
#10247-D creating output section ".stack" without a SECTIONS Single_PWM C/C++ Problem
During attempting to load the part:
MSP430: Trouble Writing Memory Block at 0x200 on Page 0 of Length 0x838: Could not write device memory
MSP430: GEL: File: C:\Documents and Settings\Administrator\workspace_v5_2\Single_PWM\Debug\Single_PWM.out: Load failed.
With some experiments during using COFF I did notice that the sprintf() call would write to memory where there were static variables kept
Hi David,
what exact errors do you get and settings are you using? Can you confirm you have 4.1.0 and not 4.1.1 compiler version? (I should be able to send you this offline)
If you are originally using ELF mode and things look like they are getting stuck in the init function, I would recommend looking at this thread.
http://e2e.ti.com/support/development_tools/compiler/f/343/t/162429.aspx?pi25500=1
Best Regards,
Lisa
Lisa
These are the exact errors I'm getting from CC5.2
Warnings during comiling
Description Resource Path Location Type
#10247-D creating output section ".int05" without a SECTIONS Single_PWM C/C++ Problem
#10247-D creating output section ".stack" without a SECTIONS Single_PWM C/C++ Problem
During attempting to load the part: using Debug
MSP430: Trouble Writing Memory Block at 0x200 on Page 0 of Length 0x838: Could not write device memory
MSP430: GEL: File: C:\Documents and Settings\Administrator\workspace_v5_2\Single_PWM\Debug\Single_PWM.out: Load failed.
I was initailly using COFF but as your request to try ELF I received the errors mentioned above. Below is the Project Properties form displaying compiler v4.1.1 I also checked for update this AM and none were available.
Looking forward to resolving this soon
Thanks
Dave
UPDATE
Lisa,
I attempt to go back to the COFF output as I initially was using. Now I get warning that I was not getting before..
Description Resource Path Location Type
#10247-D creating output section ".int05" without a SECTIONS Single_PWM C/C++ Problem
#10247-D creating output section ".stack" without a SECTIONS Single_PWM C/C++ Problem
Thses warning are preventing me from loading and debuging could.. The ONLY thing changed was output type from ELF back to the oringinal COFF..
Hi David,
let me send you a newer compiler version offline and we can go from there. These are just warnings so I am not sure why they might be preventing your build/debug? Did you do a clean first? I suspect this is to do with the linker command file.
Best Regards,
Lisa
Lisa,
Sorry for the slow response had other items to tend too
Yes I did do a 'Clean' prior to a build.
I created a new project and copied the source file in to the new project and compiled without those warnings. The only change outside the source files was COFF and/or ELF format. And as we know once I changed to ELF I could not get a clean compiled in ELF or COFF any more
Lisa,
Finally got some time to get back to this problem. Thanks for the file (off line). I downloaded and installed. I created a new project and copied the source file into and proceeded to compile and test. My findings are as follows:
The initial compile would not fit in the part in use (ouch), but nothing to dry about.
I reduced the code to fit (removed some code that was not under test) and was able to successfully compile/link
Though testing was not successfully. During the sprintf() call it would reset. I do have INT handlers for all INT. Watch Dog is disabled..
I find this interesting since as with the earlier compiler I would see RAM allocated for a variable (static) be modified during the sprinf() call
Any comments?
Hi David,
my suggestion and the way you can get an expert opinion is likely to post your findings on either the msp430 or the compiler forum.
Glad you got the new compiler running ok and seem to be working in the right direction.
Best Regards,
Lisa
Lisa
Really? nothing has changed. I had the v4.1.1 running a week ago and that didn't correct the sprintf() error as claimed..
Hi David,
I would still recommend posting there. I am pretty sure the bug that I am aware of has been fixed. My strong suspicion is that the value line msps simply can not handle printf/sprintf support. Do you have different msps to try?
Best Regards,
Lisa
Hi David,
I have been continuing to try and dig into this for you. Would you be able to send your test code to me offline? I would like to see if we can reproduce this here.
Thanks
Lisa
My guess would be that not enough stack is being reserved in the linker command file. If the part has very little RAM then it might be hard to allocate a large enough stack to avoid overruns.
The #10247-D linker warnings mean that the linker doesn't know which area of memory to place a .section in. This can result in the program failing at runtime - see Should linker warning #10247-D really be an error.Lisa TI said:These are just warnings so I am not sure why they might be preventing your build/debug?
The warnings can be caused if the list of sections in the linker .cmd command file, in the default files supplied by CCS, are out of step with the list of sections output by the MSP430 compiler (which has changed between different versions of the compiler).
It you haven't changed the linker command file, you should be able to remove the warnings by copying default the linker command file for your device from the CCS version which installs the MSP430 compiler version in use.