We are developing software on vybrid processor(A5 core). We are facing issues with the 64 bit data type. When we tried to print the value using printf or sprintf, the values are printed wrongly.
Then we had identified that it is beacause of endian problem. The Lower 32 bit value is placed in upper 32 bit place and so the it is printing big numbers even for small value
for example when we tried to print the value 0x19 of long long int data type, it is printed as 0x1900000000.
Please let us know , how to overcome this issue.
Note : We are using gcc compiler
Solved! Go to Solution.
Karthi,
I verified this. Is working fine on my side.
I am using: MQX 4.0.2 Beta 1
Compiler: Sourcery CodeBench Lite Edition for ARM EABI from mentor graphics
Example: Hello
So please do the following:
- download Sourcery CodeBench Lite Edition for ARM EABI from mentor graphics GCC compiler
- obtain from your FAE: MQX 4.0.2 Beta 1
- compile hello example using gcc_cs tool chain mentioned above.
- modify and try using long long type.
Let us know your results. Again, the most important step is the toolchain. If the toolchain you are using does not supports the proper printf it will fail.
On my side, IAR, and gcc from CodeSourcery work correctly.
Best Regards,
Ioseph
code:
unsigned long long my64var;
void hello_task
(
uint_32 initial_data
)
{
my64var = 0x12345UL;
printf("Hello World\n");
printf("Hello World\n");
printf("%llx", my64var);
_task_block();
}
output:
Hello World
Hello World
12345
Hello,
I think the problem is printf and not the compiler. I tried this on IAR compiler and the way words are ordered is the same as in your case.
For example:
tst = 0x10;
tst = tst + 0xffffffff;
tst = 0x000000010000000F
The printf I am using does not supports printing 64 bits. Please check if in your case the printf supports that size.
See the attached picture of my debug session and how the 64bit integer is handled correctly.
how to fix this issue in sprintf which is library function?...
How to get rid of this issue?
Hi,
Can you please give more details on what tool chain you are using?
Are you using Linux Timesys? OS Less or MQX
From which vendor/where you got your gcc-compiler?
Have you check for any compiler options, flags or documentation notes? Your library seems to support at some degree or may be some port from another system.
This sounds similar: Andrés Moré - Re: printf of unsigned long long in ARM processors, please take a look. If the issue comes from gcc codesourcery they will be the best to answer.
Hi,
Please find the details.
We are using MQX and using gcc compiler version 4.5.2
Could you please provide your inputs on this ASAP?
Thanks
karthi
Karthi,
I verified this. Is working fine on my side.
I am using: MQX 4.0.2 Beta 1
Compiler: Sourcery CodeBench Lite Edition for ARM EABI from mentor graphics
Example: Hello
So please do the following:
- download Sourcery CodeBench Lite Edition for ARM EABI from mentor graphics GCC compiler
- obtain from your FAE: MQX 4.0.2 Beta 1
- compile hello example using gcc_cs tool chain mentioned above.
- modify and try using long long type.
Let us know your results. Again, the most important step is the toolchain. If the toolchain you are using does not supports the proper printf it will fail.
On my side, IAR, and gcc from CodeSourcery work correctly.
Best Regards,
Ioseph
code:
unsigned long long my64var;
void hello_task
(
uint_32 initial_data
)
{
my64var = 0x12345UL;
printf("Hello World\n");
printf("Hello World\n");
printf("%llx", my64var);
_task_block();
}
output:
Hello World
Hello World
12345
Hi ioseph_martinez can you continue with the follow up of this case?
This is not solved yet.
You data type wouldn't happen to be IEEE754 double?
ioseph_martinez / juangutierrez can you help on this case?
How are you printng?
Have you tried to use %llu?
printf("%llu", my64var);