Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


itoa() and utoa() have bad results; definitions of data types

Hello,
I have bad experience with using itoa() or utoa() functions in the SW4STM32. I am not sure if the problem is in the GCC or AC6 or other part of the System Workbench. I am programming STM32F4.
For example if I use

static char buf[12] = {0};
uint32_t n1 = 900;
itoa(n1, (char*) buf, 11);

in some user defined function. Then itoa() or utoa() gives me result {‘7’, ‘4’, ‘9’, 0, 0, 0, 0, 0 ,0, 0, 0, 0} in the buf, it means “749”. It doesn’t matter if n1 is int or static int.

Eclipse CDT (which contain GCC cross compiler support, C/C++ development tools, GDB, etc.) - all in version 9.2.1.2017...
AC6 C/C++ Debugging Tools for MCU - version 2.3.1.2018...
AC6 C/C++ Embedded Development Tools for MCU - version 2.7.2.2018...
AC6 Linker Script Editor - version 1.11.1.2017...
etc.

I see the only workaround - it is to use sprintf();
However I’d like to know the cause and solution of the problem of the itoa() or utoa().

Additional question:
Where I can find proper documentation for my compiler? Is my GCC version 9.2.1 or is it only Eclipse version? I was searching through IDE files (stdlib.h, etc.) but I have found only

char * itoa (int, char *, int);
char * utoa (unsigned, char *, int);

prototypes without any description. I would like to know also the size and signedness of default datatypes (char, int, ...). I cannot find it in the h-files.

#ifdef __INT8_TYPE__

typedef __INT8_TYPE__ __int8_t;

and similar for uint8_t,... int64_t. There is not explicitly specified the connection with unsigned/signed short/long int anywhere in the h-files.

Hello,
OK, finally in some common C language documentation I found, that the 3rd argument of the itoa() or utoa() represents numerical base, not the number of the characters to be converted (size). rolleyes
However the Additional question stays unanswered.
Best regards
vt


Hello,
9.2.1 is the eclipse version, the gcc version is :
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) ARM/embedded-7-branch revision 261907

you can find the compiler in this directory :
Ac6\SystemWorkbench\plugins\fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825\tools\compiler\bin
then usind cmd : arm-none-eabi-gcc.exe --version

char is unsigned by default on gcc- arm architecture, unless -fsigned-char is used.
you can test it :
char c = -1;
if(c < 0)
printf(“char is signed”);
else
printf(“char is unsigned”);
for other types (short, int, long ... ) they are signed by default

Best reagrds,
Roy,
AC6


Hello,
thank you very much Roy. So I went through the GCC Manual for gcc version 7.3.0 (https://gcc.gnu.org/onlinedocs/7.3.0/). I was looking for datatypes implementation but I have not found information which I need. There are some possible options like in the chapter >> 3.18.34 PDP-11 Options:

-mint16

Use 16-bit int. This is the default.

However this is not valid for ARM (Cortex-M4 = ARMv7-M architecture) which I use, I think.
I am very curious where are the data types implemented. Where it is defined that int is 16-bit (half-word) or that short int is the same size as signed char etc. Does anybody know?

Best regards
vt



Hello,
thank you Roy, this is important part of the documentation for STM32 programming which I didn’t know sooner.
So the data types are somehow defined in the GCC source files but not in the c-files or h-files. I assume that similarly (invisible for the user) are defined also the keywords or macros used in the machine/_default_types.h file.
These are:

__INT8_TYPE__ 
__UINT8_TYPE__
__INT16_TYPE__
__UINT16_TYPE__
__INT32_TYPE__
__UINT32_TYPE__
__INT64_TYPE__
__UINT64_TYPE__


However they are not explicitly defined in c-files or h-files.

Note: I changed the title of the topic to be more precise.
Best regards
vt


Hello,

You are welcome biggrin
these types are not defined in header files, but in the built-in settings,
to visualize it:
Project -> Properties -> (C/C++ General) -> Preprocessor Include Paths, Macro etc. -> select GNU C -> Ac6 SW4 STM32 MCU Build-in Compiler Settings

Best Regards,
Roy,
AC6


Thank you, again.
These prepocessor macros are pretty hidden. Now I can see precisely which data type macro is connected with fundamental data type.
This little bit explains this warning when I use uint8_t* instead of the char* or vice versa (e.g. when passing this pointer as an argument to the function).

pointer targets in passing argument 2 of 'USART_SendAll' differ in signedness [-Wpointer-sign]

Although char and unsigned char (=uint8_t) have the same signedness, still there is the warning. Is it only stupid annoying warning in this case or is there any good reason?
Best regards
vt23