[En-Nut-Discussion] Problem with ARM floating point, again

Harald Kipp harald.kipp at egnite.de
Wed Jan 30 09:52:09 CET 2013


Hi,

a user reported, that printf output of a double float fails on SAM7X
with Nut/OS 4.10, using the latest Yagarto toolchain.

int main(void)
{
    unsigned long baud = 115200;
    double val = 15.1;

    NutRegisterDevice(&DEV_UART0, 0, 0);
    freopen(DEV_UART0_NAME, "w", stdout);
    freopen(DEV_UART0_NAME, "r", stdin);
    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

    printf("Float: %lf\n", val);

    for (;;)
    {
        NutSleep(1000);
    }
    return 0;
}

In fact the program correctly prints "15.100000", but as soon as he
inserts another function _before_ main, the output becomes "0.000000".

I tried the same with

GCC 4.7.2
newlib 1.20

on a SAM7SE running Nut/OS trunk. The same problem appeared. In this
case I do not need to add any additional function to the code, the
simple main fails.

However, if I change DEV_UART0 to DEV_CONSOLE, using the polling DBGU
driver on the SAM7SE, then it works fine.

Looks like we have a problem with newlib's floating point to ASCII
conversion again.

Regards,

Harald



More information about the En-Nut-Discussion mailing list