Firmware Support - Configuration

I am developing embedded software designed to operate from two to three different microcontrollers. At the moment, we have make files that read configuration keys and do compilation.

The process is becoming more and more tedious for both developers and non-developers to be updated using compilation and configuration. I know that the Linux kernel uses ncurses to generate compilation configurations. I am looking for a similar tool, but a cross platform. It should work on Windows and Linux. I know that this still will not solve the problem, but it is more attractive to non-developers as well, I can quickly share my .config file or compare it with an existing one. The configurations will be in a specific order, and the diff tool will help here.

Can anyone share their experience with similar project maintenance or a reference project (built-in and common code base for several micros). I just want to know the best practices.

PS: C language used, 8/16 bit micros, without timer-based OS batch scheduler (baremetal)

+6
source share
3 answers

I have one microcontroller, but several projects that are compiled from the same source code. I think my script is similar to yours, at least to some extent. My solution was also inspired by the Linux kernel.

config.h

All the source code that needs to access some configuration parameter simply includes a header file called config.h .

config.h consists of only one line:

 #include <config/project.h> 

project.h

I have several configuration header files, one per project. A project.h consists of macro definitions with values ​​such as true , false or constants:

 #define CONFIG_FOO true #define CONFIG_BAR false #define CONFIG_TIME 100 

check.c

This file checks the configuration parameters for correctness: - all parameters must be defined, even if they are not used or significant for this project - unwanted combinations of parameters are signaled - parameter values ​​are limited.

 #if !defined(CONFIG_FOO) #error CONFIG_FOO not defined #endif #if !defined(CONFIG_BAR) #error CONFIG_BAR not defined #endif #if !defined(CONFIG_TIME) #error CONFIG_TIME not defined #endif #if !(CONFIG_FOO ^ CONFIG_BAR) #error either CONFIG_FOO or CONFIG_BAR should be se #endif #if CONFIG_TIME > 250 #error CONFIG_TIME too big #endif 

Makefile

By allowing the compiler to output preprocessor macros, it is possible (with a sed expression) to pass the Makefile the same parameter values ​​that were provided for this project.

+1
source

If you didn't find anything, GNU autotools could make things a little easier.

+1
source

When I was doing cross-platform development, I used a solution similar to my answer here. You have a specific platform "platform_XXX.h" for each platform, and restrict conditional compilation to a single master.h file that selects the right subfile.

+1
source

Source: https://habr.com/ru/post/905058/


All Articles