snprintf() support of 64-bit variables in ModusToolbox

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

To all,

I have working PSoC Creator that I ported to MTB.

It is generally working however trying to use snprintf() on a 64-bit variable (long long) is not working.

Here is the code fragment:

...

uint64 uid;

uint16_t tstr_sz[50]

#if (CYDEV_CHIP_FAMILY_USED == CYDEV_CHIP_FAMILY_PSOC6)

    uid = Cy_SysLib_GetUniqueId();

#else

    CyGetUniqueId((uint32 *)uid);

#endif

    snprintf(tstr, sizeof(tstr), "Unique Silicon ID: %.8llX\r\n",  uid);

    UART_PutString(tstr);

...

When compiled from PSoC Creator I get:

Unique Silicon ID: ED2F482D69619DA

When compiled from MTB I get:

Unique Silicon ID: llX

Using PSoC Creator I needed to set to get 64-bit vars to work:

pastedImage_10.png

Is there a similar setting in MTB?

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
1 Solution
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

Hi Len,

You have to do the same thing in MTB as well. You need to switch to newlib instead of newlib-nano to print long long which is default disabled in nano specs.

The way to achieve this is: Migrate to <your_app>/libs/psoc6make/make/toolchains/GCC_ARM.mk and modify the CY_TOOLCHAIN_LDFLAGS in the following manner.

pastedImage_0.png

Let me know if this does not work help.

View solution in original post

2 Replies
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

Hi Len,

You have to do the same thing in MTB as well. You need to switch to newlib instead of newlib-nano to print long long which is default disabled in nano specs.

The way to achieve this is: Migrate to <your_app>/libs/psoc6make/make/toolchains/GCC_ARM.mk and modify the CY_TOOLCHAIN_LDFLAGS in the following manner.

pastedImage_0.png

Let me know if this does not work help.

RaktimR,

Thank you.  That worked.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes