Proper way of Makefile organizing for porting POSIX service to WICED platform

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

cross mob
SeSh_3921701
Level 1
Level 1

Hi, everybody!

I would ask you how to properly create a Makefile for the project with POSIX origins that we want to port on WICED platform.

First of all, I can see that the actual work to build the source is performed "under the hood" via general .mk makefiles within WICED platform SDK, so the only thing that you need to do is properly point your source to different places where all other needed parts are located.

But that's my problem.

Initially, the service that we're porting knows something about the WICED platform, cause there're some defines, like 'TARGET_PLATFORM_WICED', that control conditional compilation process. So I have created the directory inside '43xxx_Wi-Fi/libraries', created an .mk file with the same name, set the name for the service with 'NAME' variable and added a path to single C file which contains the main function and started to check what else will be needed.

Along the way, I have added other header files from our service that are included.

Everything was good until I needed to include 'wiced_security.h' header. It is located under '20706-A2_Bluetooth/include' directory (we use Wi-Fi/Bluetooth WICED platform combo). I have added a relative path to it, but after that, there are many "double definitions" of various macros and alike:

In file included from .../wiced_result.h:45:0,

...

./include/wiced_bluetooth_result.h:58:0: error: "BT_RESULT_LIST" redefined [-Werror]

#define BT_RESULT_LIST( prefix ) \

^

In file included from .../20706-A2_Bluetooth/include/wiced_result.h:26:0,

.../20706-A2_Bluetooth/include/wiced_bt_constants.h:43:0: note: this is the location of the previous definition

#define BT_RESULT_LIST( prefix ) \

^

So, my main question is how you deal with such problems? Are there some conventions to be used that I'm missing?

Thanks in advance for responses.

0 Likes
1 Solution

I think you need to  add a global include like below in your makefile:

GLOBAL_INCLUDES    += libraries/drivers/bluetooth/wiced_hci_bt

View solution in original post

0 Likes
8 Replies
Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

hello:

     Are you porting your own code into 43xx project , but need to include 20706 header files ?

The 20706-A2_Bluetooth/include/wiced_result.h  and  43xx ./include/wiced_bluetooth_result.h

are defining same macro #define BT_RESULT_LIST( prefix ),  but  the defined members have some differences at the value .   If you are using a small account of 20706 code,  suggest you to modify the prefix in 20706 code, like to define from :

typedef enum

{

#ifdef MPAF_CUSTOM_STACK

  WICED_RESULT_LIST(WICED_)

#endif

  BT_RESULT_LIST ( WICED_BT_ )  /**< 8000 - 8999 */

} wiced_result_t;

to:

typedef enum

{

#ifdef MPAF_CUSTOM_STACK

  WICED_RESULT_LIST(WICED_)

#endif

  BT_RESULT_LIST ( WICED_BT_SMART_)  /**< 8000 - 8999 */

} wiced_result_t;

Thanks for the reply!

Excuse me, didn't clarify about 43xxx and 20706 parts: it would be not good to use cross-references between them, cause it can make the future porting process to the new version of SDK harder. So I need to rework my implementation. I need to use some crypto library that is present in 43xxx part of the code. It seems that it will be the WICED/security/BESL module.

So my question now, how can I properly reference some external component in the '.mk' makefile? If I use this:

'$(NAME)_COMPONENTS' := WICED/security/BESL

is it the correct way to do that? I mean will I get all needed defines, prototypes etc. that are provided by that module after including it that way?

Thanks.

0 Likes

yes, exactly , '$(NAME)_COMPONENTS' := WICED/security/BESL  can compile the module as a lib before linked together.  You can check them from the file config.mk in the build directory , if your need is included in the compile setting.   and I just did some tests , seems BESL will be default compiled , so you can use the api from the BESL module directly , need your help to have a try .

0 Likes

Thanks for the reply, zhez!

And don't you know if declaring the component this way gives you access to the headers that it has? I need, for example, to include 'compat-1.3.h' header that has defines I need, but during the compilation, I receive the error that there's no such file or directory.

0 Likes

I think you need to  add a global include like below in your makefile:

GLOBAL_INCLUDES    += libraries/drivers/bluetooth/wiced_hci_bt

0 Likes

Thanks again, zhez!

Sorry for the silence, was checking this and that.

And some more points to clarify, if you don't mind:

1) what's the difference between $(NAME)_INCLUDES and $(NAME)_COMPONENTS in the app Makefile?

2) do we need both of them in the app Makefile for header files to be accessible and functions called properly?

3) is it the proper way to refer to a particular component to start with some directory name in 43xxx_Wi-Fi folder and name directories divided by the slash to the level which contains .mk file?

Thanks in advance for the response!

0 Likes

Hello:

- I  means include.

-D  means define.

you can have a reference in below setting.

CFLAGS += $(addprefix -I,$(GLOBAL_INCLUDES)) $(addprefix -D,$(GLOBAL_DEFINES)) $(addprefix -I,$($(NAME)_INCLUDES)) $(addprefix -D,$($(NAME)_DEFINES)) $($(NAME)_CFLAGS)

and $(NAME)_COMPONENTS is for lib.

I think you can take a reference from our app .mk setting for your own source file with a .mk  .

Hi!

Thanks for the idea, and which app can I take as an example?

0 Likes