From 3a66ae51c3f34108428e582ef693866d71496d16 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 28 Aug 2020 15:25:37 +0200 Subject: Expose configuration via Kconfig --- .gitignore | 3 + Makefile | 209 +++++++++++++++++++------- script/mkconfig | 92 ++++++++++++ src/app/aemr/Kconfig | 2 + src/app/aemr/Makefile.inc | 4 +- src/app/blinkencat3/Kconfig | 2 + src/app/blinkencat3/Makefile.inc | 6 +- src/app/button-and-motion-logger/Kconfig | 2 + src/app/button-and-motion-logger/Makefile.inc | 6 +- src/app/ccs811test/Kconfig | 2 + src/app/ccs811test/Makefile.inc | 8 +- src/app/countertest/Kconfig | 2 + src/app/countertest/Makefile.inc | 6 +- src/app/donothing/Makefile.inc | 7 +- src/app/i2cbench/Makefile.inc | 4 +- src/app/i2cdetect/Kconfig | 2 + src/app/i2cdetect/Makefile.inc | 7 +- src/app/ledblink/Kconfig | 2 + src/app/ledblink/Makefile.inc | 4 +- src/app/loratest/Makefile.inc | 4 +- src/app/luxlog/Kconfig | 2 + src/app/luxlog/Makefile.inc | 8 +- src/app/mpu9250_motionlog/Kconfig | 2 + src/app/mpu9250_motionlog/Makefile.inc | 6 +- src/app/nrf24l01test/Makefile.inc | 8 +- src/app/sharp96test/Kconfig | 2 + src/app/sharp96test/Makefile.inc | 6 +- src/app/shell/Kconfig | 2 + src/app/shell/Makefile.inc | 7 +- src/app/shell/main.cc | 1 - src/app/sysinfo/Makefile.inc | 4 +- src/app/timertest/Makefile.inc | 8 +- src/app/transactiontest/Makefile.inc | 11 +- src/app/waittest/Makefile.inc | 8 +- src/app/wetterstation/Kconfig | 2 + src/app/wetterstation/Makefile.inc | 4 +- src/app/ws2812b_dmap/Makefile.inc | 6 +- src/app/ws2812b_uart/Kconfig | 2 + src/app/ws2812b_uart/Makefile.inc | 6 +- src/arch/arduino-nano-168/Kconfig | 37 +++++ src/arch/arduino-nano-168/Makefile.inc | 62 ++++++-- src/arch/arduino-nano-168/prompt | 1 + src/arch/arduino-nano/Kconfig | 37 +++++ src/arch/arduino-nano/Makefile.inc | 54 ++++++- src/arch/arduino-nano/arch.cc | 5 - src/arch/arduino-nano/prompt | 1 + src/arch/blinkenrocket/Kconfig | 10 ++ src/arch/blinkenrocket/Makefile.inc | 21 ++- src/arch/blinkenrocket/arch.cc | 4 - src/arch/blinkenrocket/prompt | 1 + src/arch/esp8266/Kconfig | 11 ++ src/arch/esp8266/Makefile.inc | 27 +++- src/arch/esp8266/prompt | 1 + src/arch/msp430fr5969lp/Kconfig | 31 ++++ src/arch/msp430fr5969lp/Makefile.inc | 61 ++++++-- src/arch/msp430fr5969lp/arch.cc | 6 - src/arch/msp430fr5969lp/driver/counter.cc | 4 - src/arch/msp430fr5969lp/prompt | 1 + src/arch/msp430fr5994lp-256k/Kconfig | 31 ++++ src/arch/msp430fr5994lp-256k/prompt | 1 + src/arch/msp430fr5994lp/Kconfig | 31 ++++ src/arch/msp430fr5994lp/Makefile.inc | 60 ++++++-- src/arch/msp430fr5994lp/arch.cc | 6 - src/arch/msp430fr5994lp/driver/counter.cc | 4 - src/arch/msp430fr5994lp/prompt | 1 + src/arch/posix/Kconfig | 10 ++ src/arch/posix/Makefile.inc | 18 ++- src/arch/posix/prompt | 1 + src/arch/stm32f446re-nucleo/Kconfig | 11 ++ src/arch/stm32f446re-nucleo/Makefile.inc | 31 ++-- src/arch/stm32f446re-nucleo/prompt | 1 + src/driver/Kconfig | 88 +++++++++++ src/driver/soft_i2c.cc | 3 - 73 files changed, 950 insertions(+), 191 deletions(-) create mode 100755 script/mkconfig create mode 100644 src/app/aemr/Kconfig create mode 100644 src/app/blinkencat3/Kconfig create mode 100644 src/app/button-and-motion-logger/Kconfig create mode 100644 src/app/ccs811test/Kconfig create mode 100644 src/app/countertest/Kconfig create mode 100644 src/app/i2cdetect/Kconfig create mode 100644 src/app/ledblink/Kconfig create mode 100644 src/app/luxlog/Kconfig create mode 100644 src/app/mpu9250_motionlog/Kconfig create mode 100644 src/app/sharp96test/Kconfig create mode 100644 src/app/shell/Kconfig create mode 100644 src/app/wetterstation/Kconfig create mode 100644 src/app/ws2812b_uart/Kconfig create mode 100644 src/arch/arduino-nano-168/Kconfig create mode 100644 src/arch/arduino-nano-168/prompt create mode 100644 src/arch/arduino-nano/Kconfig create mode 100644 src/arch/arduino-nano/prompt create mode 100644 src/arch/blinkenrocket/Kconfig create mode 100644 src/arch/blinkenrocket/prompt create mode 100644 src/arch/esp8266/Kconfig create mode 100644 src/arch/esp8266/prompt create mode 100644 src/arch/msp430fr5969lp/Kconfig create mode 100644 src/arch/msp430fr5969lp/prompt create mode 100644 src/arch/msp430fr5994lp-256k/Kconfig create mode 100644 src/arch/msp430fr5994lp-256k/prompt create mode 100644 src/arch/msp430fr5994lp/Kconfig create mode 100644 src/arch/msp430fr5994lp/prompt create mode 100644 src/arch/posix/Kconfig create mode 100644 src/arch/posix/prompt create mode 100644 src/arch/stm32f446re-nucleo/Kconfig create mode 100644 src/arch/stm32f446re-nucleo/prompt create mode 100644 src/driver/Kconfig diff --git a/.gitignore b/.gitignore index c9c518a..9bc48ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ *.o *.su +/.config +/.config.old /build +/Kconfig /src/app/aemr/main.cc /src/app/prototest/nanopb.pb.h /src/app/prototest/nanopb.pb.cc diff --git a/Makefile b/Makefile index bcbff7b..49a1e16 100644 --- a/Makefile +++ b/Makefile @@ -1,116 +1,206 @@ -default: build/system.elf +# Only load .config when app/arch are not specified on commandline +ifneq (${app}, ) + CONFIG_app = ${app} +else + -include .config +endif + +ifneq (${arch}, ) + CONFIG_arch = ${arch} +endif + +# Make cannot include "foo"/Makefile.inc, so remove quotes from config entries +quote=" +app_dir = $(subst ${quote},,${CONFIG_app}) +arch_dir = $(subst ${quote},,${CONFIG_arch}) -INCLUDES = -Iinclude -Iinclude/arch/${arch} +INCLUDES = -Iinclude -Iinclude/arch/${arch_dir} COMMON_FLAGS = -g -Os -Wall -Wextra CFLAGS = -std=c99 CXXFLAGS = -std=c++14 -fno-rtti -fno-threadsafe-statics -fno-exceptions +QUIET = @ + ASM_TARGETS = C_TARGETS = -CXX_TARGETS = src/app/${app}/main.cc src/os/object/cpp_helpers.cc src/os/object/outputstream.cc - -QUIET = @ +CXX_TARGETS = src/app/${app_dir}/main.cc src/os/object/cpp_helpers.cc src/os/object/outputstream.cc -ifneq (${verbose}, ) +ifdef verbose QUIET = endif +ifneq (${app_dir}, ) + include src/app/${app_dir}/Makefile.inc +endif + ifneq (${stack_usage}, ) COMMON_FLAGS += -fstack-usage endif -ifneq (${app}, ) - include src/app/${app}/Makefile.inc -endif +# Allow .config driver entries to be overriddenvia commandline / environment ifneq ($(findstring dummy,${drivers}), ) + CONFIG_driver_dummy = y +endif + +ifneq ($(findstring lm75,${drivers}), ) + CONFIG_driver_lm75 = y +endif + +ifneq ($(findstring s5851a,${drivers}), ) + CONFIG_driver_s5851a = y +endif + +ifneq ($(findstring am2320,${drivers}), ) + CONFIG_driver_am2320 = y +endif + +ifneq ($(findstring bme280,${drivers}), ) + CONFIG_driver_bme280 = y +endif + +ifneq ($(findstring bme680,${drivers}), ) + CONFIG_driver_bme680 = y +endif + +ifneq ($(findstring ccs811,${drivers}), ) + CONFIG_driver_ccs811 = y +endif + +ifneq ($(findstring eeprom24lc64,${drivers}), ) + CONFIG_driver_eeprom24lc64 = y +endif + +ifneq ($(findstring max44006,${drivers}), ) + CONFIG_driver_max44006 = y +endif + +ifneq ($(findstring max44009,${drivers}), ) + CONFIG_driver_max44009 = y +endif + +ifneq ($(findstring hdc1080,${drivers}), ) + CONFIG_driver_hdc1080 = y +endif + +ifneq ($(findstring mpu9250,${drivers}), ) + CONFIG_driver_mpu9250 = y +endif + +ifneq ($(findstring mmsimple,${drivers}), ) + CONFIG_driver_mmsimple = y +endif + +ifneq ($(findstring mmsubstate,${drivers}), ) + CONFIG_driver_mmsubstate = y +endif + +ifneq ($(findstring nrf24l01,${drivers}), ) + CONFIG_driver_nrf24l01 = y +endif + +ifneq ($(findstring sharp96,${drivers}), ) + CONFIG_driver_sharp96 = y +endif + +ifneq ($(findstring resistive_load,${drivers}), ) + CONFIG_driver_resistive_load = y +endif + +ifneq ($(findstring softi2c,${drivers}), ) + CONFIG_driver_softi2c = y +endif + +# Load drivers + +ifdef CONFIG_driver_dummy CXX_TARGETS += src/driver/dummy.cc COMMON_FLAGS += -DDRIVER_DUMMY endif -ifneq ($(findstring lm75,${drivers}), ) +ifdef CONFIG_driver_lm75 CXX_TARGETS += src/driver/lm75.cc COMMON_FLAGS += -DDRIVER_LM75 endif -ifneq ($(findstring s5851a,${drivers}), ) +ifdef CONFIG_driver_s5851a CXX_TARGETS += src/driver/s5851a.cc COMMON_FLAGS += -DDRIVER_S5851A endif -ifneq ($(findstring am2320,${drivers}), ) +ifdef CONFIG_driver_am2320 CXX_TARGETS += src/driver/am2320.cc COMMON_FLAGS += -DDRIVER_AM2320 endif -ifneq ($(findstring bme280,${drivers}), ) +ifdef CONFIG_driver_bme280 CXX_TARGETS += src/driver/bme280.cc src/driver/bme680_util.cc COMMON_FLAGS += -DDRIVER_BME280 endif -ifneq ($(findstring bme680,${drivers}), ) +ifdef CONFIG_driver_bme680 CXX_TARGETS += src/driver/bme680.cc src/driver/bme680_util.cc COMMON_FLAGS += -DDRIVER_BME680 endif -ifneq ($(findstring ccs811,${drivers}), ) +ifdef CONFIG_driver_ccs811 CXX_TARGETS += src/driver/ccs811.cc COMMON_FLAGS += -DDRIVER_CCS811 endif -ifneq ($(findstring eeprom24lc64,${drivers}), ) +ifdef CONFIG_driver_eeprom24lc64 CXX_TARGETS += src/driver/eeprom24lc64.cc COMMON_FLAGS += -DDRIVER_EEPROM24LC64 endif -ifneq ($(findstring max44006,${drivers}), ) +ifdef CONFIG_driver_max44006 CXX_TARGETS += src/driver/max44006.cc COMMON_FLAGS += -DDRIVER_MAX44006 endif -ifneq ($(findstring max44009,${drivers}), ) +ifdef CONFIG_driver_max44009 CXX_TARGETS += src/driver/max44009.cc COMMON_FLAGS += -DDRIVER_MAX44009 endif -ifneq ($(findstring hdc1080,${drivers}), ) +ifdef CONFIG_driver_hdc1080 CXX_TARGETS += src/driver/hdc1080.cc COMMON_FLAGS += -DDRIVER_HDC1080 endif -ifneq ($(findstring mpu9250,${drivers}), ) +ifdef CONFIG_driver_mpu9250 CXX_TARGETS += src/driver/mpu9250.cc COMMON_FLAGS += -DDRIVER_MPU9250 endif -ifneq ($(findstring mmsimple,${drivers}), ) +ifdef CONFIG_driver_mmsimple CXX_TARGETS += src/driver/mmsimple.cc COMMON_FLAGS += -DDRIVER_MMSIMPLE endif -ifneq ($(findstring mmsubstate,${drivers}), ) +ifdef CONFIG_driver_mmsubstate CXX_TARGETS += src/driver/mmsubstate.cc COMMON_FLAGS += -DDRIVER_MMSUBSTATE endif -ifneq ($(findstring nrf24l01,${drivers}), ) +ifdef CONFIG_driver_nrf24l01 CXX_TARGETS += src/driver/nrf24l01.cc - ifeq (${arch}, msp430fr5994lp) + ifeq (${arch_dir}, msp430fr5994lp) nrf24l01_cs_pin ?= p1_3 nrf24l01_en_pin ?= p6_2 nrf24l01_irq_pin ?= p8_3 endif - ifeq (${arch}, msp430fr5969lp) + ifeq (${arch_dir}, msp430fr5969lp) nrf24l01_en_pin ?= p4_3 nrf24l01_cs_pin ?= p2_4 nrf24l01_irq_pin ?= p1_5 endif - ifeq (${arch}, arduino-nano) + ifeq (${arch_dir}, arduino-nano) nrf24l01_en_pin ?= pc1 nrf24l01_cs_pin ?= pc0 nrf24l01_irq_pin ?= pc2 endif - ifeq (${arch}, arduino-nano-168) + ifeq (${arch_dir}, arduino-nano-168) nrf24l01_en_pin ?= pc1 nrf24l01_cs_pin ?= pc0 nrf24l01_irq_pin ?= pc2 @@ -121,19 +211,19 @@ ifneq ($(findstring nrf24l01,${drivers}), ) COMMON_FLAGS += -DNRF24L01_IRQ_PIN=GPIO::${nrf24l01_irq_pin} endif -ifneq ($(findstring sharp96,${drivers}), ) +ifdef CONFIG_driver_sharp96 CXX_TARGETS += src/driver/sharp96.cc - ifeq (${arch}, msp430fr5969lp) + ifeq (${arch_dir}, msp430fr5969lp) sharp96_power_pin ?= p4_2 sharp96_en_pin ?= p4_3 sharp96_cs_pin ?= p2_4 endif - ifeq (${arch}, msp430fr5994lp) + ifeq (${arch_dir}, msp430fr5994lp) sharp96_power_pin ?= p1_2 sharp96_en_pin ?= p6_2 sharp96_cs_pin ?= p1_3 endif - ifeq (${arch}, msp430fr5994lp-256k) + ifeq (${arch_dir}, msp430fr5994lp-256k) sharp96_power_pin ?= p1_2 sharp96_en_pin ?= p6_2 sharp96_cs_pin ?= p1_3 @@ -144,7 +234,7 @@ ifneq ($(findstring sharp96,${drivers}), ) COMMON_FLAGS += -DSHARP96_CS_PIN=GPIO::${sharp96_cs_pin} endif -ifneq ($(findstring resistive_load,${drivers}), ) +ifdef CONFIG_driver_resistive_load CXX_TARGETS += src/driver/resistive_load.cc resistor1_pin ?= p3_0 resistor2_pin ?= p3_1 @@ -157,17 +247,25 @@ ifneq ($(findstring resistive_load,${drivers}), ) COMMON_FLAGS += -DRESISTIVE_LOAD_PIN4=GPIO::${resistor4_pin} endif -ifneq ($(findstring softi2c,${drivers}), ) +ifdef CONFIG_driver_softi2c CXX_TARGETS += src/driver/soft_i2c.cc COMMON_FLAGS += -DDRIVER_SOFTI2C endif +# Configure drivers (TODO: Kconfig) + ifneq (${i2c_freq}, ) - COMMON_FLAGS += -DF_I2C=${i2c_freq} + CONFIG_i2c_freq = ${i2c_freq} +endif +ifdef CONFIG_i2c_freq + COMMON_FLAGS += -DF_I2C=${CONFIG_i2c_freq} endif ifneq (${timer_freq}, ) - COMMON_FLAGS += -DF_TIMER=${timer_freq} + CONFIG_timer_freq = ${timer_freq} +endif +ifdef CONFIG_timer_freq + COMMON_FLAGS += -DF_TIMER=${CONFIG_timer_freq} endif ifeq (${softi2c_pullup}, internal) @@ -191,43 +289,42 @@ ifeq (${softi2c_timer}, 1) COMMON_FLAGS += -DSOFTI2C_TIMER endif -ifeq (${kout_nop}, 1) - COMMON_FLAGS += -DKOUT_NOP -endif - -ifeq (${timer_cycles}, 1) - COMMON_FLAGS += -DTIMER_CYCLES -endif - ifeq (${timer_us}, 1) COMMON_FLAGS += -DTIMER_US endif -ifeq (${timer_s}, 1) - COMMON_FLAGS += -DTIMER_S -endif - ifeq (${loop}, 1) COMMON_FLAGS += -DWITH_LOOP endif +ifdef CONFIG_loop + COMMON_FLAGS += -DWITH_LOOP +endif ifeq (${wakeup}, 1) COMMON_FLAGS += -DWITH_WAKEUP endif +ifdef CONFIG_wakeup + COMMON_FLAGS += -DWITH_WAKEUP +endif ifeq (${ostream}, 1) COMMON_FLAGS += -DWITH_OSTREAM endif +ifdef CONFIG_ostream + COMMON_FLAGS += -DWITH_OSTREAM +endif ifeq (${trace_malloc}, 1) CXX_TARGETS += src/lib/mpmalloc.cc COMMON_FLAGS += -DMULTIPASS_TRACE_MALLOC endif -ifneq (${arch}, ) - include src/arch/${arch}/Makefile.inc +ifneq (${arch_dir}, ) + include src/arch/${arch_dir}/Makefile.inc endif +default: build/system.elf + stack: default ${QUIET}test -n "${OBJDUMP}" ${QUIET}test -n "${ARCH_SHORTNAME}" @@ -238,13 +335,19 @@ stackm: default ${QUIET}test -n "${ARCH_SHORTNAME}" ${QUIET}script/static-stack-analyze.pl --machine-readable ${OBJDUMP} ${ARCH_SHORTNAME} ${OBJECTS} +Kconfig: script/mkconfig + ${QUIET}script/mkconfig > Kconfig + +config: Kconfig + ${QUIET}kconfig-qconf Kconfig + clean: arch_clean rm -f build/system.elf help: arch_help @echo @echo "common flags:" - @echo " timer_cycles timer_us timer_s -- enable specific timers. May be mutually exclusive" + @echo " timer_us timer_s -- enable specific timers. May be mutually exclusive" @echo " loop -- enable loop() function" @echo " i2c_freq -- I2C Frequency in Hz" @echo " timer_freq -- Timer frequency in Hz" @@ -260,8 +363,8 @@ help: arch_help @echo " trace_malloc -- trace mpmalloc/mpcalloc/mprealloc calls on stdout" @echo " stack_usage -- Generate .su files for stack usage estimation (-> make stack)" @echo - @echo "${arch} drivers:" - @ls -1 src/arch/${arch}/driver | fgrep .c | cut -d . -f 1 | sed 's/^/ /' + @echo "${arch_dir} drivers:" + @ls -1 src/arch/${arch_dir}/driver | fgrep .c | cut -d . -f 1 | sed 's/^/ /' @echo @echo "common drivers:" @ls -1 src/driver | fgrep .c | cut -d . -f 1 | sed 's/^/ /' @@ -275,4 +378,4 @@ info: arch_info @echo "CXXFLAGS: ${CXXFLAGS}" @echo "Selected (common/arch) drivers: ${drivers} / ${arch_drivers}" -.PHONY: clean default stack stackm help info +.PHONY: clean config default stack stackm help info diff --git a/script/mkconfig b/script/mkconfig new file mode 100755 index 0000000..b6d50a3 --- /dev/null +++ b/script/mkconfig @@ -0,0 +1,92 @@ +#!/bin/sh + +cat <