Question

I am developing a embedded software that is meant to run on two to three different family of micro controllers. For now we have makefiles that reads the configuration switches and does compilation.

The process is getting more and more tedious for both developers and non developers to stay updated with compile switches and build configurations. I know Linux kernel uses ncurses for generating compile configurations. I am looking for a similar tool, but cross platform. It should run on Windows and Linux. I know this will still not solve the problem but its more appealing to non developers also I can quickly share my .config file or compare it with existing. The configurations will be in specific order and a diff tool here will help.

Can anyone share their experience with similar project maintenance or a reference project (embedded and common code base for multiple micros). Just want to know best practices.

PS : Language used C, 8/16 bit micros, no OS just timer based batch scheduler (baremetal)

Was it helpful?

Solution

I have one microcontroller but several projects which get compiled from the same source code. I think my scenario is similar to yours, at least to some extent. My solution was inspired by Linux kernel, as well.

config.h

All source code which needs to get access to some configuration parameter simply includes an header file called config.h.

config.h consists of just 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 configuration parameters for correctness: - all parameters must be defined, even if not used or meaningful for that project - unwanted parameter combinations are signalled - parameter values are constrained.

#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 instructing the compiler to output the preprocessor macros, it is possible (with a bit of sed expression) to feed the Makefile with the same parameter values gprovided for a given project.

OTHER TIPS

If you don't find anything else, GNU autotools could make things a bit easier.

When I was doing multi-platform development, I used a solution like the one in my answer here. Have a specific "platform_XXX.h" for each platform, and restrict the conditional compilation to a single master "platform.h" file which selects the right subfile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top