How to use log function and add libm.a library in wiced studio

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

cross mob
lock attach
Attachments are accessible only for community members.
AkJa_4647796
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

HELLO, AnjanaM_61BoonT_56KeTa_1341526

                    i am trying to do the process mentioned below.

Go to Project and select Properties. Expand C/C++ Build and choose Settings. Under the Tool settings tab expand GCC Linker and select Libraries. At the right of the window, add a library named m at Libraries (-l).

As you can see in attached file, there is no Tool Setting?

Please help.

Thank you.

0 Likes
16 Replies
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi AkJa_4647796 ,

Log function is not supported on our SDK .

Regarding libm , please check this thread - Re: How to add libm for math funtion?

Regards,

Anjana

0 Likes

AnjanaM_61​,

i have mentioned the similar procedure and attached image.

Go to Project and select Properties. Expand C/C++ Build and choose Settings.

under setting i dont have any TOOL setting.

please see the above attached file.

if log function doesnt exits then what should i do? what other oprtion i can use?

Thank you

0 Likes

hello,

I tried using this thread. Re: How to add libm for math funtion?

I am getting error.

Error: Program "make" not found in PATH

PATH=

this link https://pinguino.cc/forum/showthread.php?tid=4463 is not available now?

Thank You

Hi AkJa_4647796 ,

The one in the other thread was for Modus Tool box. Please note CYBT-343026 is now supported in Modus Tool box.

So you can try MTB as well.

I have not tried any external math libs. However below is the general steps to add external library file to WICED

  1. Copy xxxx.a to /20706-A2_Bluetooth/Wiced-BT/tier2/brcm/libraries/lib/20703. You can directly copy paste the file into the folder using WICED GUI, look for the library folder under WICED (Be careful there is another “library” folder directly under /20706-A2_Bluetooth don’t put the file there)
  2. Copy the xxx.h into your project folder and include it into your source fie by using #include “xxxx.h”.
  3. Update your make file to include xxxx.a library by adding following line to your make file.

          APP_PATCHES_AND_LIBS +=  xxxx.a

Could you please try these steps and see if it works ?

Q) if log function doesnt exits then what should i do? what other oprtion i can use?

A) Either you have to use a external math lib or custom function to implement the functionality.

Regards,

Anjana

lock attach
Attachments are accessible only for community members.

Hello AnjanaM_61​,

Thank you for your response.

I did as you said,

1. Copy lib_fixmath.a to /20706-A2_Bluetooth/Wiced-BT/tier2/brcm/libraries/lib/20703

2. In libfixmath source directory. (file attached below)

Header files: libfixmath.h  fix16.h fract32.h int64.h uint32.h (5 in total) .  I copy all the header file to 20706-A2_Bluetooth\include

      Source files: fix16.c fix16_exp.c fix16_sqrt.c fix16_str.c fix16_trig.c fract32.c uint32.c (totally 7)

      I am not getting in which library folder i have to include it?

           a. C:\Users\abc\Documents\WICED-Studio-6.4\20706-A2_Bluetooth\libraries  ?

           b. C:\Users\abc\Documents\WICED-Studio-6.4\20706-A2_Bluetooth\Debug\libraries

           c. C:\Users\abc\Documents\WICED-Studio-6.4\20706-A2_Bluetooth\Release1\libraries ?

3. what i did is i all all the .c file into my project. and updated the makefile.mk file. As you can see in triumph >> adc_read project.

Untitled_3.png

I am getting error as

make.exe[1]: *** No rule to make target '../../build/adc_read-CYBT_343026_EVAL-rom-ram-Wiced-release/fix16_32.o', needed by '../../build/adc_read-CYBT_343026_EVAL-rom-ram-Wiced-release/lib_installer.c'.  Stop.

make.exe[1]: *** Waiting for unfinished jobs....

make: *** [triumph.adc_read-CYBT_343026_EVAL] Error 2

Makefile:552: recipe for target 'triumph.adc_read-CYBT_343026_EVAL' failed

what is fix16_32.o file?

in libfixmath zip files there is a makefile in which OBJ = fix16.o fix16_exp.o fix16_sqrt.o fix16_str.o fix16_trig.o fract32.o uint32.o this is included. Do i need to copy this file in my project and where?

Thank You.

0 Likes

Hi AkJa_4647796 ,

I am not sure libfixmath files are compatible with WICED studio. I will try at my side and will confirm.

Meanwhile did you tried adding libm.a ?

Regards,
Anjana

Hello AnjanaM_61

Yes i tried all steps using libm.a also.

1. Copy libm.a to /20706-A2_Bluetooth/Wiced-BT/tier2/brcm/libraries/lib/20703

2. APP_PATCHES_AND_LIBS +=  libm.a and adding #include "math.h" in hal_adc.c

Untitled_4.png

3. Go to Project and select Properties. Expand C/C++ Build and choose Settings. Under the Tool settings tab expand GCC Linker and select Libraries. At the right of the window, add a library named m at Libraries (-l).

Untitled_5.png

Still i am getting error?

13:43:32 **** Build of configuration Release1 for project 20706-A2_Bluetooth ****

triumph.adc_read-CYBT_343026_EVAL download

Cannot run program "": Launching failed

Error: Program "" not found in PATH

PATH=

13:43:32 Build Finished (took 26ms)

Am i missing any steps?

Thank You

0 Likes

Hi AkJa_4647796 ,

Let me try at my side , give me one day.

However I doubt your error is not related to adding libs.

Can you just try download any other existing demo to 343026 ? say hello_sensor?

Hope you have included the platform files for CYBT-343026 : Platform Files for CYBT-343026-EVAL – KBA221025

Regards,

Anjana

Hello AnjanaM_61​ ,

Yes, i have followed all the step mentioned in Platform Files for CYBT-343026-EVAL – KBA221025

Currently using the same platform files. Even if i use hello_sensor code still get the same error.

Initially i didn't have any TOOL setting. as you can see in image belowUntitled_6.png

What i did was, Go to Project and select Properties. Expand C/C++ Build and choose Settings. In setting window UNDER CONFIGURATION -->> Manage ConfigurationUntitled_7.png

IN pop \up window, Selecting NEW. A new windo appears.

Untitled_8.png

In Import Predefined menu, selecting Executable > Cross ARM GCC > Debug.

Then i got Tool Setting option, so then, i can add m library in linker.(this is how i added m library, was it right?)

Untitled_9.png

But i have some doubt, in Toolchains -->> Toolchain path is empty.

Untitled_10.png

i tried adding GNU arm paths aslo

C:\Users\abc\Documents\WICED-Studio-6.4\20706-A2_Bluetooth\Debug\wiced_tools\ARM_GNU\

C:\Users\abc\Documents\WICED-Studio-6.4\20706-A2_Bluetooth\Release1\wiced_tools\ARM_GNU\

But still end up getting errors.

Thank You.

Hi Hi AkJa_4647796 ,,

Please don't do any change in the tool settings .

Please keep the default settings , add platform files as per the KBA and only follow the steps mentioned in previous response. Copying it below :

below is the general steps to add external library file to WICED

  1. Copy xxxx.a to /20706-A2_Bluetooth/Wiced-BT/tier2/brcm/libraries/lib/20703. You can directly copy paste the file into the folder using WICED GUI, look for the library folder under WICED (Be careful there is another “library” folder directly under /20706-A2_Bluetooth don’t put the file there)
  2. Copy the xxx.h into your project folder and include it into your source fie by using #include “xxxx.h”.
  3. Update your make file to include xxxx.a library by adding following line to your make file.

          APP_PATCHES_AND_LIBS +=  xxxx.a

Could you please try these steps and see if it works ?

Regards,

Anjana

Hello AnjanaM_61​,

I tried without changing in the settings but still i am encountering make file error?

11:02:34 **** Build of configuration Release for project 20706-A2_Bluetooth ****

make triumph.adc_read-CYBT_343026_EVAL download

Compiling platform.c

Compiling spar_setup.c

Compiling hal_adc.c

make.exe[1]: *** No rule to make target '../../apps/triumph/adc_read/fix16_exp.c', needed by '../../build/adc_read-CYBT_343026_EVAL-rom-ram-Wiced-release/fix16_exp.o'.  Stop.

make.exe[1]: *** Waiting for unfinished jobs....

make: *** [triumph.adc_read-CYBT_343026_EVAL] Error 2

Makefile:552: recipe for target 'triumph.adc_read-CYBT_343026_EVAL' failed

11:02:35 Build Finished (took 1s.93ms)

Thank You.

0 Likes

HELLO AnjanaM_61​,

Now i am using Modus Toolbox.

1. Copy libm.a to C:\Users\abc\ModusToolbox\tools_2.1\gcc-7.2.1\arm-none-eabi\lib

2. APP_PATCHES_AND_LIBS +=  libm.a and adding #include "math.h" in hal_adc.c

I am getting error?

==============================================================================

Generated 1 source file(s)

C:/Users/abc/mtw/RFCOMM-CYBT-343026/rfcomm/spp/build/CYBT-343026-EVAL/generated/lib_installer.c already present, use clean if it needs updating

Building 10 file(s)

    Linking output file BT_SPP.elf

C:/Users/abc/mtw/RFCOMM-CYBT-343026/rfcomm/spp/build/CYBT-343026-EVAL/Debug/spp.o: In function `app_timeout':

C:\Users\abc\mtw\RFCOMM-CYBT-343026\rfcomm\spp/spp.c:601: undefined reference to `__aeabi_ui2f'

C:\Users\abc\mtw\RFCOMM-CYBT-343026\rfcomm\spp/spp.c:602: undefined reference to `__aeabi_fmul'

C:\Users\abc\mtw\RFCOMM-CYBT-343026\rfcomm\spp/spp.c:603: undefined reference to `__aeabi_f2iz'

collect2.exe: error: ld returned 1 exit status

make[1]: *** [../../../wiced_btsdk/dev-kit/baselib/20706A2/make/core/build.mk:470: C:/Users/abc/mtw/RFCOMM-CYBT-343026/rfcomm/spp/build/CYBT-343026-EVAL/Debug/BT_SPP.elf] Error 1

make: *** [../../../wiced_btsdk/dev-kit/baselib/20706A2/make/core/main.mk:350: secondstage] Error 2

"C:/Users/abc/ModusToolbox/tools_2.1/modus-shell/bin/make CY_MAKE_IDE=eclipse CY_IDE_TOOLS_DIR=C:/Users/abc/ModusToolbox/tools_2.1 -j4 all" terminated with exit code 2. Build might be incomplete.

14:02:34 Build Failed. 5 errors, 0 warnings. (took 8s.871ms)

Please Help.

Thank You.

0 Likes

Hello AnjanaM_61​,

I am trying to use this  function.

    WICED_BT_TRACE("log  : %s\r\n\n", temp_val);

    sprintf("%9.3f",temp_val);

i am getting error as

hal_adc.c: In function 'seconds_app_timer_cb':

./../../../wiced_btsdk/dev-kit/baselib/20706A2/WICED/common/spar_utils.h:55:17: warning: implicit declaration of function '__2sprintf'; did you mean 'sprintf'? [-Wimplicit-function-declaration]

#define sprintf __2sprintf

                 ^

hal_adc.c:262:5: note: in expansion of macro 'sprintf'

     sprintf("%9.3f",temp_val);

     ^~~~~~~

As you stated

sprintf(float_txt"%9.3f",(float)log(wiced_timer_count));

what is float_txt?

As per the snip/hal/gpio app;

the output in putty terminal is shown below.

Untitled.png

I think the module is getting reset?

Thank You.


                                 log = GPIO application startsample_gpio_app_management_cback 21sample_gpio_app_management_cback 0gpio_test_ledPin config of P0 is 521seconds periodic timer count: 1 s                                 log = GPIO application startsample_gpio_app_management_cback 21sample_gpio_app_management_cback 0gpio_test_ledPin config of P0 is 521seconds periodic timer count: 1 s                                 log = GPIO application startsample_gpio_app_management_cback 21sample_gpio_app_management_cback 0gpio_test_ledPin config of P0 is 521seconds periodic timer count: 1 s                                 log =

0 Likes

Hi AkJa_4647796 ,

I am sorry, float is not supported in our SDK for our BT chips .

Instead of sprintf , please use snprintf

Regards,

Anjana

Hello AnjanaM_61

printf(float_txt"%9.3f",(float)log(wiced_timer_count));

what is float_txt in above sentence?

Thank You.

0 Likes

Hi AkJa_4647796 ,

We have never noticed float_txt . If possible please share the complete code , I shall check it.

However As I mentioned before float is anyway not supported on 20706 SDK.

Regards,

Anjana