Floating point support for EWL C/C   libraries.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Floating point support for EWL C/C   libraries.

1,767 Views
rseal
Contributor I

I'm working with TWR-K70F120M tower along with EWL C/C++ and MQX libraries inside CodeWarrior v10.5. I'm trying to use the sscanf() function and find that I get undefined references:

 

ARM_GCC_Support/ewl/EWL_C/src/stdio/__strtold.c:762: undefined reference to `__dec2num'

ARM_GCC_Support/ewl/EWL_C/src/stdio/__strtold.c:943: undefined reference to `__double_huge'

mingw32-make: *** [cpac_message_test.elf] Error 1

 

As far as I can tell, it looks like my EWL libraries don't have floating point support compiled in? I've tried rebuilding all EWL libraries with the _EWL_FLOATING_POINT definition defined in the makefiles, but that doesn't appear to help. Can someone point me to a possible solution?

Labels (1)
0 Kudos
Reply
8 Replies

1,068 Views
trytohelp
NXP Employee
NXP Employee

Hello Ryan,

according to the info provided, you're using CW for MCU V10.5 and MQX libraries.

On my side I've created an example based on MCU V10.5 for the K70F.

With the generic project, using GCC dev tool, I can use float without problem.

However if you're using MQX libraries, there is an option to valid floating type too.

this could be the problem ...

++++++++++++++++++

you must enable floating point support in the user_config.h file by adding this line #define MQX_INCLUDE_FLOATING_POINT_IO 1. Then you will need to recompile the MQX libraries (bsp and psp).

++++++++++++++++++

hope this will help you.

Pascal

0 Kudos
Reply

1,068 Views
rseal
Contributor I

Hi Pascal,

I've double-checked the BSP and PSP settings. I have the following set in my user_config.h:

#define MQXCFG_ENABLE_FP                          1

#define MQX_INCLUDE_FLOATING_POINT_IO    1

I've still not resolved the issue. I've posted my test below:

test_program.PNG.png

EDIT: that should be _io_sscanf(in,"%s %d %f", label, &a, &b)

Here's the result when compiling:

test_compile.png

I should also note that I'm coding in C++ while linking in the C-based MQX libraries. I've enabled the MQX_SUPPRESS_STDIO_MACROS setting and explicitly use the mqx-specific prefix "_io_" to all of the stdio-related calls as I was running into problems when attempting to include the c++ string header with the provided io assignments (problems with the getline() function signature).

Any additional ideas would be greatly appreciated.

Ryan

0 Kudos
Reply

1,068 Views
trytohelp
NXP Employee
NXP Employee

Hi Ryan,

I've performed some tests on my side and was not able to reproduce the issue.

Below is my config:

      PC -> Win 7 32bit

      CodeWarrior for MCU V10.5

      MQX V4.0.2

I've created a sample project using the project wizard:

    - file + New + MQX 4.0 Project

    - Project name: Test

    - Select Board: TWRK70F120M Board

    - Select application type: New application

    - Build Tools Options: GCC

    - MQX options: Add MFS support and Add Shell support

    - MQX Project type: Empty application

    - Add Additional files: NA

    - Connections: your connection

    - Finish

then a new project is created.

Edit the main.c file and add the code:

+++++++++++++++++++++++

void Main_task(uint_32 initial_data)

{

    _io_printf("MQX SSCANF Test V1.0\n");

    const uint_8 MAX_STR_LENGTH = 20;

    char in[]= "ten 10 10.0";

    char label[MAX_STR_LENGTH];

    int a=0;

    float b=0.0f;

  

    _io_sscanf(in,"%s %d %f", label, a, b);

  

    _io_printf("label = %s\n", label);

    _io_printf("a = %d\n", a);

    _io_printf("b = %f\n", b);

...

+++++++++++++++++++++++

Now I need to build the MQX libraries for TWRK70F120M board.

Under the MQX installation folder \Freescale_MQX_4_0_2\config\twrk70f120m\cw10gcc, select twrk70f120m.wsd file and drag and drop to Eclipse.

The BSP, MFS, PSP, RTCS, SHELL, USBD and USBH projects are opened.

I've checked the user_config.h and by default the

#define MQXCFG_ENABLE_FP           1

#define MQX_INCLUDE_FLOATING_POINT_IO  1

I don't changed the config and just rebuild them.

Now I back to the test project and build it.

The project is working fine.

+++++++++++++++++++

**** Build of configuration twrk70f120m_Int_Flash_DDRData_Debug for project test ****

"C:\\Freescale\\CW MCU v10.5\\gnu\\bin\\mingw32-make" -j8 all

'Building file: ../Sources/main.c'

'Executing target #1 ../Sources/main.c'

'Invoking: ARM Ltd Windows GCC C Compiler'

"C:/Freescale/CW MCU v10.5/Cross_Tools/arm-none-eabi-gcc-4_7_3/bin/arm-none-eabi-gcc" "../Sources/main.c" @"Sources/main.args" -Wa,-adhlns="Sources/main.o.lst" -MMD -MP -MF"Sources/main.d" -o"Sources/main.o"

'Finished building: ../Sources/main.c'

' '

'Building target: test.elf'

'Executing target #2 test.elf'

'Invoking: ARM Ltd Windows GCC C Linker'

"C:/Freescale/CW MCU v10.5/Cross_Tools/arm-none-eabi-gcc-4_7_3/bin/arm-none-eabi-gcc"    @"test.args" -o"test.elf"

'Finished building target: test.elf'

' '

+++++++++++++++++++

Attached you will find my project.

If you want to use it, you need to change the paths.

Launch the Project Properties.

      Under Resource + Linked Resources.

Hope this will help you.

Regards

Pascal

0 Kudos
Reply

1,068 Views
rseal
Contributor I

Hi Pascal,

I am able to build this using a standard C project, as you've shown, but my problems relate to a C++ project that links in the BSP and PSP C libraries.

I was able to partially get this working by replacing the "_io_sscanf" call with "std::sscanf", which forces the program to use the standard implementation instead of the mqx version. However, that version does not seem to have float support out of the box, which leads me back to questions about enabling floating point support for the EWL C++ library?

Has anyone there worked projects that use EWL C++ combined with the MQX libraries? That's where things have gotten weird for me. We've had some success with this, but it's been mostly trial-and-error.

Sincerely,

Ryan

0 Kudos
Reply

1,068 Views
trytohelp
NXP Employee
NXP Employee

Hi Ryan,

I got info from MQX team:

+++++++++++++

No, there are no instruction to do this.

Due all the needed steps to do this and complexity it is not recommended.

Also, remember that the main() function does no longer belongs to the application. That also needs to be changed.

It isn’t simple to just include MQX to a project due all the changes involved in a MQX project.

+++++++++++++

To resume, you must use the MQX project wizard.

Pascal

0 Kudos
Reply

1,068 Views
rseal
Contributor I

Pascal,

Thanks for the help. We are well versed with the complexity of mixing C, C++, and the MQX libraries. Our project currently contains more than 100 files, mostly C++, but we do have others writing pure C code. We've invested quite a bit of time understanding the subtleties in the MQX vs. C++ projects. I agree, the setup is quite tricky, but we have to understand every aspect of the setup to reduce risk given the size and scope of our project.

I ran through your setup as suggested and everything appeared to work correctly as you stated. I was working a different, but similar (i.e. undefined references related to libstdc++) problem last week and stumbled onto the solution. We have quite a few custom libraries linked into our project and had neglected the order in which they were seen by the linker.

Here's a stripped-down version of our original link order that caused the undefined references:

lib_order_wrong.png

After reordering the inclusion of "libm" and "libc", the problem has been resolved:

lib_order_correct.png

Thanks again for taking the time to look into the matter.

Sincerely,

Ryan

0 Kudos
Reply

1,068 Views
trytohelp
NXP Employee
NXP Employee

Hi Ryan,

thanks for feedback.

this could help me and other customer.

Regards

Pascal

0 Kudos
Reply

1,068 Views
trytohelp
NXP Employee
NXP Employee

Hi Ryan,

Based on same MQX libraries, I've created another example based on MQX project wizard.

Under Example application + cplus.

The example is a C++ project.

      then I added your function in the cpp file and enable the EWL libraries.

I'm able to build the project without problem.

How did you create the project ?

- with MQX project wizard,

- with bareboard project wizard and added the MQX libraries ?

It seems you want to add MQX libs in an existing project.

I've checked all documentations and we don't recommend this solution.

the right way is to create a project based on MQX project wizard.

I've contacted MQX colleagues too.

Regards

Pascal

0 Kudos
Reply