This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Manual example compilation using makefile

Hello,

I was able to flash demo .hex to my nRF52840DKs from this (https://github.com/NordicPlayground/nrf52-ble-multi-link-multi-role) project, but now I would like to make some changes in the source to increase the power of the signal on both aggregator and peripheral, and also I would like to send RSSI frequently not only on the button event. Anyway, before making changes to the source, I wanted to create makefile in order to be able to compile the example source successfully, unfortunately, I`m struggling with it.

Let`s begin with ble_peripheral_long_range. I downloaded the whole ZIP archive from github, extracted "ble_peripheral_long_range" folder into nRF5_SDK_15.3.0_59ac345/examples/ble_peripheral/. As this example doesn`t contain make file, I copied the armgcc folder from .../ble_app_template/pca10056/s140/ to ../ble_peripheral/pca10056/s140/. At first, when running make command, compiler didn`t like line 647 on main.c - "ble_gap_phys_t phys;", as phys is defined but never used. Ok, I put "//" to comment out this line, and this is when the real problems appear.  "app_display.h" was included in main.c, but compiler was unaware of the location of this file so there were problems with linking, so I just added "$(PROJ_DIR)/app_display.c \" to my makefile SRC_FILES. Then app_display.c was included "ugui.h", so I copied /comon/ugui/ folder to project directory and added "$(PROJ_DIR)/ugui" to makefile INC_FOLDERS and "$(PROJ_DIR)/ugui.c" to SRC_FILES.  After that I had to add "$(PROJ_DIR)/gfx_extended" and " $(SDK_ROOT)/external/thedotfactory_fonts" to INC_FOLDERS because of "ugui/ugui.h:1058:10: fatal error: nrf_gfx_ext.h: No such file or directory" and "/gfx_extended/nrf_gfx_ext.h:48:10: fatal error: nrf_font.h: No such file or directory". The next message after adding these two, was "/../../app_display.c:4:10: fatal error: images.h: No such file or directory", so I just copied images.h into my PROJ_DIR. So, at this point I have added "$(PROJ_DIR)/app_display.c \$(PROJ_DIR)/ugui.c \" to the template SRC_FILES and "  $(SDK_ROOT)/external/thedotfactory_fonts \$(PROJ_DIR)/ugui \ $(PROJ_DIR)/gfx_extended \ " to INC_FOLDERS, also I have copied gfx_extended and ugui folders and images.h file to my PROJ_DIR. Now I`m getting this:

In file included from ../../../app_display.c:2:
../../../ugui/ugui.h:1059:18: error: '_HW_draw_line' declared 'static' but never defined [-Werror=unused-function]
 static UG_RESULT _HW_draw_line(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c);
                  ^~~~~~~~~~~~~
../../../ugui/ugui.h:1060:18: error: '_HW_fill_frame' declared 'static' but never defined [-Werror=unused-function]
 static UG_RESULT _HW_fill_frame( UG_S16 x1, UG_S16 y1, UG_S16 x2 , UG_S16 y2 , UG_COLOR c);
                  ^~~~~~~~~~~~~~
../../../ugui/ugui.h:1061:18: error: '_HW_draw_buffer' declared 'static' but never defined [-Werror=unused-function]
 static UG_RESULT _HW_draw_buffer(UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, void *p_data, UG_U32 length);
                  ^~~~~~~~~~~~~~~
../../../ugui/ugui.h:1063:13: error: 'UserSetPixel' declared 'static' but never defined [-Werror=unused-function]
 static void UserSetPixel (UG_S16 x, UG_S16 y, UG_COLOR c);
             ^~~~~~~~~~~~
cc1: all warnings being treated as errors
../../../../../../components/toolchain/gcc/Makefile.common:272: recipe for target '_build/nrf52840_xxaa/app_display.c.o' failed
make: *** [_build/nrf52840_xxaa/app_display.c.o] Error 1

And I`m stuck there. I assume I have to change something in my makefile but I`m not sure of what. I`m not a programmer and this is my first time editing makefile. I`ll appreciate your help. Thanks in advance!

  • Look at what those messages are telling you:

    error: '_HW_draw_line' declared 'static' but never defined [-Werror=unused-function]

    So you have 'static' declarations - but no corresponding definitions.

    So, either:

    • Remove the declarations - if you really don't need them, or
    • Provide the definitions.

    I find this a lot easier to follow in an IDE - where you can see both the messages and the corresponding source code together at the same time, and it allows you to click the error and go straight to the corresponding line in the source file.

  • Thanks for your answer, but as I`m trying to compile an example, I assume that every line in all the codes there is for an reason. If I comment out these lines in ugui.h, I have to comment out more code in ugui.c, where these declarations are used.

  • So you have to do the other option, then - provide the definitions!

    Have you done a text search to find if they are actually there anywhere?

    Quite possibly, they are disabled by a #if - and you're missing the required definition .

    This is standard 'C' stuff - not really specific to Nordic.

    It has been noted before that the examples on GitHub are not necessarily always complete - can you find a similar example in the SDK?

  • When I remove all the lines containing undefined functions/variables and add couple other sources to makefile, I finally I`m able to successfully compile the example, but when I flash the example in nRF, it just doesn`t work. Demo hex works, but the one I compiled doesn`t. Is there anybody who has got running hex when compiling this example?

Related