Newlib, syscall.c and printf

Federico Terraneo fede.tft@hotmail.it
Wed Feb 9 11:48:00 GMT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/08/2011 04:38 PM, Hard Maker wrote:
> Thank's for your answer Federico,
> 
> I try with 8192 bytes of stack and this code and printf not work.
> 
> extern unsigned int _HEAP_START;
> extern unsigned int _HEAP_END;
> int main(void)
> {
>     char txt[20];
>     float fVal = 3.141596;
>     setvbuf(stdin, NULL, _IONBF, 0);
>     setvbuf(stdout, NULL, _IONBF, 0);
>     setvbuf(stderr, NULL, _IONBF, 0);
> 
>     InitHW();
> 
>     lcd_gotoxy(0,0);
>     snprintf(txt, 20, "Start: %X", (unsigned int)&_HEAP_START);
>     _write(0, txt, strlen(txt));    // work
> 
>     lcd_gotoxy(0,1);
>     snprintf(txt, 20, "End:   %X", (unsigned int)&_HEAP_END);
>     lcd_print(txt); // work
> 
>     lcd_gotoxy(0,2);
>     printf("Hi %.2f\n", fVal);    // not work
>     fflush(stdout);
>     while (1)
>         ;
>     return 0;
> }
> 
> Thank's for your answer.
> 
> Sergio
> 
> El 08/02/2011 11:03 a.m., Federico Terraneo escribió:
> On 02/08/2011 02:23 PM, Hard Maker wrote:
>>>> I'm using 1 KB of system stack and have 60KB free of heap. Anyone has
>>>> this problem?
>>>>
> Hi, I'm not a newlib developer, just an user.
> I've been using newlib with stm32 for quite some time, and printf works,
> but takes up nearly 2KB of stack. Maybe the problem is this.
> 
> 

Are you copying .data from flash to ram, and clearing .bss before
calling main?
To check, try to declare two global variables and print them, like this:

#include <stdio.h>

int a=12345; //Ends up in .data
int b=0;     //Ends up in .bss

int main()
{
    //Print a and b
}

If they don't have the right value, that's the problem.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNUal7AAoJECkLFtN5Xr9fkxYIAIHJRq6QlD06R3Rs5Ri6yEtf
qlBdnRevFBbNNC880fMCmpZ6iYLFfILs5O35nOkD3LvvqE+LXN9o9xZyfX2N0mIQ
R1mjtgiB9Bhqs0cDreTmlcyLv96eCrjWOXpsyAJMBseUkK4GT7gao0TvZFFXi2Xn
q/5Cvdm2B3VOCoFKbGB4JM2m/v0N0JvK4OwLnW2tZd5S8J4OiyquPfgYsyNujOVH
j5PCueSi6IBjV5hOi089PeYRWCYriwGtA+sve7+qqFv0MUNdkFtyostjW60b0UnB
fVbpFjHqDso0hYmCDh0HJ3RH7L4HMGvr/0dwApClBrSUCBEZFaD3T+1rTQ+2Wdw=
=82hy
-----END PGP SIGNATURE-----



More information about the Newlib mailing list