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.

RTOS/AM5728: Long long format does not print

Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi,

We 're not able to print "long long" with sprintf ("%lld"). We get only "ld" instead of number. 

Compiler "gcc-arm-none-eabi-6-2017-q1"

Linker flags:

-mtune=cortex-a15 -marm -Dam5728 -Dcore0 -DSOC_AM572x -DidkAM572x -DTI_RTOS -DUART_DMA_ENABLE -DUART_V1 -DOPP_HIGH -O0 -g -gdwarf-3 -gstrict-dwarf -Wall -mfloat-abi=hard -Wl,-Map,"sitara_a15_eval.map" -nostartfiles -static -Wl,--gc-sections -L"C:/ti/bios_6_52_00_12/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard" -L"\"C:/ti/ndk_2_26_00_08/packages/ti/ndk/os/lib\" ,--defsym,CORE0=1" -L"\"C:/ti/ndk_2_26_00_08/packages/ti/ndk/os/lib\" ,--defsym,STACKSIZE=0x10000" -L"C:/ti/ndk_2_26_00_08/packages/ti/ndk/os/lib" -Wl,--defsym,HEAPSIZE=0x400 -Wl,--defsym,CORE0=1 -Wl,--defsym,STACKSIZE=0x10000 -Wl,--undefined,_scanf_float -Wl,--undefined,_printf_float -Wl,--undefined,_fprintf_float --specs=nano.specs

Any hint?

Thanks

  • The RTOS team have been notified. They will respond here.
  • Hi,

    I am not sure how do code looks like, this is a compiler question. I tried below:

    #if 1

       char buffer [50];

       long long a=5000ll;

       unsigned int n;

       n=sprintf (buffer, "%ld \n", a);

    #endif

    I have no issue:

    Building file: "../main.c"
    Invoking: GNU Compiler
    "C:/ti/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-a15 -mtune=cortex-a15 -marm -mfloat-abi=hard -Dam5728 -Dcore0 -DevmAM572x -DSOC_AM572x -Dgcc -I"C:/ti/pdk_am57xx_1_0_11/packages/ti/drv/usb" -I"C:/ti/gcc-arm-none-eabi-6-2017-q1-update/arm-none-eabi/include" -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF"main.d" -MT"main.o" @"configPkg/compiler.opt" -o"main.o" "../main.c"
    ../main.c: In function 'main':
    ../main.c:82:27: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'long long int' [-Wformat=]
    n=sprintf (buffer, "%ld \n", a);
    ^
    ../main.c:81:18: warning: variable 'n' set but not used [-Wunused-but-set-variable]
    unsigned int n;
    ^
    Finished building: "../main.c"

    If I use:

    n=sprintf (buffer, "%lld \n", a); I saw the issue just "ld" printed. So please use %ld instead.

    Regards, Eric

  • Hi Eric,

    Please try it with a number larger than 32 bit.

    Thanks

    Rasty

  • Part Number: AM5728

    Tool/software: TI-RTOS

    Hi,

    We  got similar problem undefined __sf_fake_stderr,  __sf_fake_stdin, __sf_fake_stdout is we remove nano.specs from linker.

    How issue e2e.ti.com/.../607830  was solved?

    Thanks

  • The post you refer is one year old, and for a completely different processor. Please describe your problem in details. Refer to processors.wiki.ti.com/.../Checklist_for_Processor_SDK_RTOS_questions_on_E2E for the information we need.
  • Please check the resolution for this issue here:
    e2e.ti.com/.../640006
  • Hello Eric,

    It didn't work for me,

    I have tried the following code, but i get an incorrect values for long long:

      char buffer1 [50];
    
      char buffer2 [50];
    
      long long a = 123456789999ll;
    
      long b = 123456789l;
    
      unsigned int n1, n2;
    
      n1=sprintf (buffer1, "%ld \n", a);
    
      n2=sprintf (buffer2, "%d \n", b);

    sprintf - long long:

    sprintf long:

    please advise,

    Sergei Pilipenko

  • Hi,

    I tired what you did, with sprintf with %ld" and got the same results. Let me check with my colleague in compiler team.

    Regards, Eric
  • Unfortunately, documentation on the RTS library newlib-nano is hard to come by.  According to this entry on Ask Ubuntu, long long support for printf and related functions is disabled by default.  The only way to get it is to rebuild the library with an additional build setting.

    Thanks and regards,

    -George

  • Oh wait, here is a better description of newlib-nano.  It says ...

    support only conversion specifiers defined in C89 standard

    C89 is a much older standard for the C programming language and library.  The %lld conversion is not present in C89.

    Thanks and regards,

    -George

  • Suggestion will not work for me, because if I use nano.specs I return to original problem %lld does not print.
  • OK. Let's approach it from different direction.

    if I remove nano.specs I get linker errors described here 

    :

    please do not suggest adding  " --specs=nano.specs" to select 'newlib-nano' as the C runtime library as describer here  :-)  :-)

    Thanks

    Rasty

  • George,

    All of the TI Processor SDK RTOS AM57x examples are built with "--specs=nano.specs", so the newlib-nano will be linked with this. As you mentioned, newlib-nano supports only conversion specifiers defined in C89 standard, which is a much older standard for the C programming language and library. The %lld conversion is not present in C89.

    As Rasty described, if we remove the "--specs=nano.specs", we got error like below:
    C:/ti/bios_6_52_00_12/packages/ti/sysbios/rts/gnu/ReentSupport.c:173: undefined reference to `__sf_fake_stdin'
    C:/ti/bios_6_52_00_12/packages/ti/sysbios/rts/gnu/ReentSupport.c:173: undefined reference to `__sf_fake_stdout'
    C:/ti/bios_6_52_00_12/packages/ti/sysbios/rts/gnu/ReentSupport.c:173: undefined reference to `__sf_fake_stderr'
    C:/ti/bios_6_52_00_12/packages/ti/sysbios/rts/gnu/ReentSupport.c:173: undefined reference to `__sf_fake_stdin'
    C:/ti/bios_6_52_00_12/packages/ti/sysbios/rts/gnu/ReentSupport.c:173: undefined reference to `__sf_fake_stdout'
    C:/ti/bios_6_52_00_12/packages/ti/sysbios/rts/gnu/ReentSupport.c:173: undefined reference to `__sf_fake_stderr'

    Is there a way to rebuild the newlib-nano with lld% support? Or how to resolve the RTS error above to support %lld?

    Regards, Eric
  • Rasty,

    Let's use e2e.ti.com/.../718820 for tracking this issue.

    Regards, Eric
  • Please realize you have, without intending to, wandered into a combination of requirements we do not support.  Other components presume you link with nano.specs.  But that RTS library does not support %lld conversions.  We will continue to help you.  But you remain responsible for whatever solution you implement.

    I think there is a way to rebuild the RTS library so that it supports %lld.  But, if it were me, I wouldn't do that.  I suspect that creates more problems than it solves.  For one thing, if you ever change to another version of the compiler, you have to remember to rebuild the library again.  The rebuilt library is likely to be larger.  Perhaps too large.

    So, I recommend you write your own routine for converting a long long value into an string.  Call that first.  Then pass that string to sprintf (or a related function) using the %s conversion.

    Thanks and regards,

    -George

  • Hi George

    I realized that that would be the answer and did what you suggest.

    Namely, converting string to "long long" and vice versa.

    We use vary basic formatting and it is sufficient for us. 

    Hope to find %lld in some future release.

    Thanks

    Rasty