|ARM Technical Support Knowledge Articles|
The intended audience of the knowledge article are software developers having issues when using printf() on ARM cores.
The symptoms of the issue are as follows:
The above issue can occur under the following circumstances:
printf("Example string : %d",example_int)
The ARM compiler produces an assembly code which tries to load the width and precision values from a specific memory address located in the stack area, regardless of those values being given to the printf() format specifier or not. If the stack memory area has not been initialised this can potentially result in loading X values into the registers of the processor, which ultimately can cause the simulation to stall.
It is important to state that the stall issue is caused by the X values, therefore the same assembly code cannot cause any issues in real life systems, it only affects RTL simulation.
The easiest workaround for the issue is explicitly specifying the width or precision in the format specifier, for example
printf("Example string : %1d",example_int)
Another way to work around the issue is adding the following code to the beginning of the C code.
#if defined ( __CC_ARM ) #if (__ARMCC_VERSION < 400000) #else // Insist on keeping widthprec, to avoid X propagation by benign code in C-lib #pragma import _printf_widthprec #endif #endif
Did you find this article helpful? Yes No
How can we improve this article?