FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2009 Threads] Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Stephen Osborn on October 28, 2009 I decided to make the upgrade to FreeRTOS 6.0.0 from FreeRTOS 5.2.0. I have been using sprintf to display floating point values to the serial port. Changing to 6.0.0 I cannot get sprintf to display anything other than zero. The format string works properly, but I only see zeros on the display.
With 5.2.0 I had to play around with stack sizes to get sprintf to work properly, and to make the stack smaller, only one task, the serial port gatekeeper task, is allowed to use sprintf. With 6.0.0, adjusting the stack size makes no difference in the output. I get no error messages from sprintf.
The only difference between the working and the non-working versions are the versions of FreeRTOS. Everything else is the same.
Anybody have any suggestions? (besides "Don't use sprintf.")
CPU is STM32F103 (Cortex-M3) Board is custom.
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Samuel Tardieu on October 28, 2009 Which libc are you using?
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Richard on October 28, 2009 One of the differences between V5.x.x and V6.x.x is the stack byte alignment used on ARM ports. Previously it was set to 4 as this was good enough for everything except some operations on 8 byte data types (like using %f with sprintf). Now it is set to 8 and all 8 byte data type problems should be fixed (?) so it is odd that you report it working before but not now.
Can you look at the stack pointer in the debugger and check that it is indeed 8 byte aligned.
Also, do you have stack overflow detection turned on? Maybe you are simply overflowing a stack.
You could try setting portBYTE_ALIGNMENT to 4 (its old value) in portmacro.h to see if that makes it work again. As 8 is a multiple of 4 I would not have thought it would make any difference, unless I have made a mistake somewhere else.
Regards.
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Stephen Osborn on October 28, 2009 Samuel, I am using newlib.
Richard, I had forgotten to mention that I had changed the stack alignment in 5.2.0 to 8
Stack overflow detection is enabled and no stacks are overflowing.
The stack pointer value I looked at is 0x200027B4, which looks like a 4 byte aligned address. I will dig into this.
Thanks.
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Stephen Osborn on October 29, 2009 I set a break point on the sprintf line that writes a floating point value. GDB reports that the SP = 0x20002794.
At the start of the program I printed these values:
portBYTE_ALIGNMENT = 8
portBYTE_ALIGNMENT_MASK = 7
Suggestions?
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Richard on October 30, 2009 Could you try setting a break point on the very first line of the task that calls sprintf(). Depending on the debugger being used that will often be on the opening bracket of the function. For example:
void vATaskFunction( void *pv ) { /* Place break point here, before variable definitions. */ int x, y, etc;
Alternatively view the code in assembly, and add a break point on the first assembly line. The important thing is that the break point is hit before the function prologue that sets up the stack and frame pointers is executed.
What is the stack pointer value when that break point is hit?
Which compiler are you using?
Regards.
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Richard on October 30, 2009 Hi again. It looks like I might have messed up because of the 'decrement before' behaviour. I would be grateful if you could try the following:
<ol> <li> Open up port.c from the Source/portable/[compiler]/CM3 directory. <li> Add the line "pxTopOfStack--;" to the top of the function pxPortInitialiseStack(). </ol>
Let me know if that fixes the problem.
Thanks and regards.
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Richard on October 30, 2009 Using markdown syntax in the reply is fine when viewed in the preview window, but does not work when viewed in the forum or in the emails of posts I received. This forum seems totally screwy at the moment.
Regards.
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Stephen Osborn on October 30, 2009 Richard,
The stack pointer at the beginning of the function, before any other operations occur is 0x200027AC.
I put the "pxTopOfStack--;" as the first line of code in pxPortInitialiseStack() and now it is working.
Thank You!!!!
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by francis wang on November 7, 2009 Where exactly should the "pxTopOfStack--;" be put? I checked the code in pxPortInitialiseStack, but in different versions they are the same?
RE: Upgrading from 5.2.0 to 6.0.0 breaks sprintfPosted by Richard on November 7, 2009 As already said - the first line in the function. Code in that function has not changed, but code elsewhere has.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|