Include user files in firmware

Good morning, I have been exploring the function of the Photon for a while and have added two files (FILE1.c and FILE1.h) into the firmware (firmware/hal/src/photon/). I am now attempting to call a function from the file from the user directory (firmware/user/applications/FILE1) with no success - I get “Undefined reference to FILE1.function1()” when trying to make the firmware with “sudo make PLATFORM=photon APP=FILE1 MODULAR_FIRMWARE=n” ran from the firmware/main directory. I believe this is because the standard makefile is not including my new .c and .h files in with the binary, and I assume there is some makefile wizardry that I need to modify to enable make to include the files. I have been looking around the various makefiles in the project with little luck. Could anyone point me in the right direction?

Much appreciated

Why don’t you simply have the two files in the same directory as your application folder?

Also, Is there a reason to use MODULAR_FIRMWARE=n?

1 Like

At first I had both files in my application folder along with the application file, but the compiler encountered multiple errors involving not being able to find some imports I used - specifically:

#include "wifi_config_dct.h"
#include "wiced.h"
#include "wiced_security.h"
#include "wwd_wifi.h"
#include "wiced_management.h"

If I changed the above imports to their absolute path relative to the src/photon directory (what I am assuming is on the build path somewhere) then it would find them but not be able to find any of the imports that they used. I found that if I placed my files directly in src/photon then make would be happy for a little longer. As for the MODULAR_FIRMWARE flag, I have been advised to use it by a team lead but do not really understand what it does aside from it may fix some of my issues.

When I compile from firmware/main as opposed to /modules, I receive this error instead:

In file included from ../hal/src/photon/include/wiced.h:43:0, from ../hal/src/photon/spawnAP.c:2, from applications/hostAP/application.cpp:3: ../hal/src/photon/include/wiced_framework.h:44:26: fatal error: platform_dct.h: No such file or directory #include "platform_dct.h" ^

A quick search for platform_dct.h on the firmware github and in my local repo comes up with only files using it, but no actual platform_dct.h which leaves me to wonder where it is…