[En-Nut-Discussion] newlib itoa() and RAM funny problem

Ulrich Prinz ulrich.prinz at googlemail.com
Fri Nov 16 08:37:42 CET 2012


Hi!

I use my command.c in almost every project I have. It is a simple
command line system that enables to add commands, debug, setup
functionality via any character device.
In this I use itoa() to get addresses, numbers, indexes e.t.c.

Now I checked map file of a STM32F103 project and found that there is
over 1K of RAM used by a lib_a-impure together with over 1K of flash.

.data          0x0000000020000a9c        0x4
..../../../../arm-eCross-eabi/lib/thumb/v7m/libc.a(lib_a-ctype_.o)
                0x0000000020000a9c                __ctype_ptr__
 .data          0x0000000020000aa0      0x430
..../../../../arm-eCross-eabi/lib/thumb/v7m/libc.a(lib_a-impure.o)
                0x0000000020000aa0                _impure_ptr
                0x0000000020000ed0                . = ALIGN (0x4)
 *(.ramfunc)
                0x0000000020000ed0                . = ALIGN (0x4)
                0x0000000020000ed0                _edata = .

the memory results of the compiler are:
text 90629 data 3304 bss 17172

I googled but only found some small hints to newlib and atoi(). So I
just replaced all calls of atoi() with a fixed value what is not a
problem to my commander.c if you do not call any of the commands.
Without using atoi() I got the following map file regarding RAM:

 .data          0x0000000020000a98        0x4
..../../../../arm-eCross-eabi/lib/thumb/v7m/libc.a(lib_a-ctype_.o)
                0x0000000020000a98                __ctype_ptr__
                0x0000000020000a9c                . = ALIGN (0x4)
 *(.ramfunc)
                0x0000000020000a9c                . = ALIGN (0x4)
                0x0000000020000a9c                _edata = .

the memory results of the compiler are:
text 89528 data 2232 bss 18248

Now the joke of the story: The software crashes into Hardfault of the
CortexM3. I didn't figure out where and why it crashes. It starts
normally and even initializes the board. I guess it crashes with the
first printf().

I used several ARM toolchains on Linux all about gcc 4.5.x but without
any results.

Anyone an idea?
Ulrich


More information about the En-Nut-Discussion mailing list