0

Currently i am preparing a firmware application that will be used in a product for customers. However, the customer should be able to configure some of the parameters/settings before deploying the product. Unfortunately, the product, hence the firmware, is based off Espressif's ESP-IDF library and they define configurable parameters using macros like

CONFIG_BT_ENABLED=y
CONFIG_BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE=y
CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN=y
CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MANUAL=y
CONFIG_BT_BTU_TASK_STACK_SIZE=4512
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y

And this means that everytime the customer needs to reconfigure, they have to recompile with modifications to the macro and that would mean they can see the source code.

Is there any tools for C/C++ or any methods that can allow the end user to configure and yet be unable to see the source code? Thanks.

Iberico
  • 162
  • 2
  • 15
  • 3
    You could split the code into two parts: The public parts which uses the macros, and a private part which doesn't use the macros and instead gets the values passed as arguments (or possible through global variables). The private part could be built into object files or as a static library, that is distributed with the public source files. – Some programmer dude Dec 23 '22 at 09:27
  • ESP-IDF is open-source, so I wouldn't worry about whether your customer can see that source. If it's *your* source code that you are concerned about, then splitting your code into separate parts as Some programmer dude suggests is the way to go. There isn't a tool, AFAIK, to reorganise your code for you (basically, too many potential options for partitioning your code so the customer can see some parts but not others) - it comes down to how you organise your source code and build scripts. – Peter Dec 23 '22 at 09:37
  • How do these so-called macros make any sense? This doesn't look like something that can reasonably be valid C, but just some script file. With gcc you could do something like `gcc -DCONFIG_BT_ENABLED=y`, is that what you mean? Otherwise, that might be the solution, in case you are indeed using gcc. – Lundin Dec 23 '22 at 09:48
  • @Someprogrammerdude The bare-bone application flow is generally straightforward with a main program file and libraries linked to it. So the parts that are from ESP-IDF will be released to the customer as source code and those will be recompiled and configured as and when the user likes and they will be linked to the main program which is already an object file. This main program will be designed in a way to take parameters from the library. I am not sure if at this point i am following correctly but, wouldn't that mean the library itself needs to be modified? – Iberico Dec 23 '22 at 09:58
  • @Lundin what i am asking for is if there are ways in C to manipulate the linkers, compilers to achieve my objective or if there are build tools for C out there that i have not heard about that can encrypt the code or something. I wouldn't say that is totally not related to C – Iberico Dec 23 '22 at 10:00
  • Passing them as `-D` to gcc through command line or a make file would be possible but cumbersome. If it's just some script then maybe just write a program that generates it and launch that program before compiling/linking? – Lundin Dec 23 '22 at 11:16

0 Answers0