Skip to content

Commit

Permalink
Add Kconfig support (#2374)
Browse files Browse the repository at this point in the history
Type `make manuconfig` in your Sming based application to see the available options. 
You might need to run `make python-requirements` before that if you are missing the required python libraries.
Sample `Basic_IFS` provides an example how to add application specific configuration settings.
  • Loading branch information
mikee47 committed Sep 29, 2021
1 parent 9f61deb commit 97aa2cd
Show file tree
Hide file tree
Showing 27 changed files with 624 additions and 27 deletions.
12 changes: 12 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/sdk/config/debug
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
#

# The bootloader logs all type of messages
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=
CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=
CONFIG_BOOTLOADER_LOG_LEVEL=3

# ESP-IDF logs all type of messages
CONFIG_LOG_DEFAULT_LEVEL_NONE=
CONFIG_LOG_DEFAULT_LEVEL_ERROR=
CONFIG_LOG_DEFAULT_LEVEL_WARN=
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=
CONFIG_LOG_DEFAULT_LEVEL=3

# Sets watchpoint index 1 (the second of two) at the end of any task stack. This is the most accurate way to debug task stack overflows.
Expand Down
12 changes: 12 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/sdk/config/release
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@
#

# The bootloader logs only errors
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=
CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=
CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=
CONFIG_BOOTLOADER_LOG_LEVEL=1

# ESP-IDF logs only errors
CONFIG_LOG_DEFAULT_LEVEL_NONE=
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
CONFIG_LOG_DEFAULT_LEVEL_WARN=
CONFIG_LOG_DEFAULT_LEVEL_INFO=
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=
CONFIG_LOG_DEFAULT_LEVEL=1

22 changes: 22 additions & 0 deletions Sming/Arch/Esp8266/Components/driver/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
menu "Drivers"
config USE_US_TIMER
bool "Enable microsecond precision for software timers (Timer2)"
help
The following functions depend on Timer2:
- NOW() return value, the Timer2 tick count
- Software timers
- System time

Software timers are driven by Timer2, which by default uses a /256 prescale
providing a resolution of 3.2us and a range of 1' 54".

Enabling this setting increases the resolution to 200ns but reduces the maximum
software timer to 7" 9.5s.

config ENABLE_CUSTOM_PWM
bool "Use the *New PWM* driver"
default y
help
New PWM is a drop-in replacement for the version provided in the Espressif SDK.

endmenu
20 changes: 20 additions & 0 deletions Sming/Arch/Esp8266/Components/heap/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
menu "Heap"
config ENABLE_CUSTOM_HEAP
bool "Enable custom heap using UMM Malloc"

if ENABLE_CUSTOM_HEAP

config UMM_POISON_CHECK
bool "UMM Poison Check"
help
Add heap integrity checks

config UMM_FUNC_IRAM
bool "Store custom heap functions in IRAM"
default y
help
Custom heap functions are stored in IRAM by default for performance reasons.
If you need the IRAM (about 1.5K bytes) then disable this option.

endif
endmenu
37 changes: 37 additions & 0 deletions Sming/Components/Hosted/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
menu "Hosted"
choice
depends on SMING_ARCH="Host"
default ENABLE_HOSTED_NONE
prompt "Hosted transport mechanism"
config ENABLE_HOSTED_NONE
bool "None"
config ENABLE_HOSTED_TCP
bool "TCP"
config ENABLE_HOSTED_SERIAL
bool "Serial"
endchoice

config ENABLE_HOSTED
string
default "" if ENABLE_HOSTED_NONE
default "tcp" if ENABLE_HOSTED_TCP
default "serial" if ENABLE_HOSTED_SERIAL

if ENABLE_HOSTED="tcp"
config HOSTED_SERVER_IP
depends on ENABLE_HOSTED="tcp"
string "Remote RPC server IP address"
default "192.168.13.1"
endif

if ENABLE_HOSTED="serial"
config HOSTED_COM_PORT
string "COM port connected to remote RPC server"
default "$(COM_PORT)"

config HOSTED_COM_SPEED
int "Baud rate for hosted COM port"
default 115200
endif

endmenu
2 changes: 1 addition & 1 deletion Sming/Components/Hosted/samples/serial/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hosted RCP Server over Serial
Hosted RPC Server over Serial
=============================

Overview
Expand Down
53 changes: 53 additions & 0 deletions Sming/Components/Network/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
menu "Network"
depends on !DISABLE_NETWORK

config DISABLE_WIFI
bool "Build without WiFi support"
default n
help
Keeps the core Network library but excludes WiFi code.
Applications using ethernet can use this to reduce code size.

if !DISABLE_WIFI
config WIFI_SSID
string "Default WiFi SSID"
depends on !DISABLE_WIFI

config WIFI_PWD
string "Default WiFi Passphrase"
depends on !DISABLE_WIFI

if SMING_ARCH=Esp8266
config ENABLE_WPS
bool "Enable WiFi Protected Setup (WPS)"
help
WPS is not enabled by default to preserve resources, and because
there may be security implications which you should consider carefully.

config ENABLE_SMART_CONFIG
bool "Enable WiFi Smart Configuration API"
help
See :sample:`Basic_SmartConfig` sample application.
endif
endif

config HTTP_SERVER_EXPOSE_NAME
bool "Add \"HttpServer/Sming\" to the SERVER field in response headers"
default y
help
If disabled, the SERVER field is omitted from all responses.

config HTTP_SERVER_EXPOSE_VERSION
bool "Include Sming version in HTTP server headers"
depends on HTTP_SERVER_EXPOSE_NAME
help
Adds the current Sming build version to the SERVER field in response headers.
For example, "Sming/4.0.0-rc2".

config ENABLE_CUSTOM_LWIP
int "LWIP version (0 for SDK, 1 or 2)"
range 0 2
default 1
depends on SMING_ARCH=Esp8266

endmenu
7 changes: 7 additions & 0 deletions Sming/Components/Network/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ COMPONENT_DEPENDS := \
mqtt-codec \
libyuarel

# WiFi settings may be provide via Environment variables
CONFIG_VARS += WIFI_SSID WIFI_PWD
ifdef WIFI_SSID
APP_CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\"
APP_CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\"
endif

# => WPS
COMPONENT_VARS += ENABLE_WPS
ifeq ($(ENABLE_WPS), 1)
Expand Down
9 changes: 9 additions & 0 deletions Sming/Components/esptool/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
menu "esptool"
config COM_PORT_ESPTOOL
string "Port to use for flashing device"
default COM_PORT

config COM_SPEED_ESPTOOL
string "Baud rate to use for flashing device"
default COM_SPEED
endmenu
22 changes: 22 additions & 0 deletions Sming/Components/rboot/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
menu "rBoot"
depends on SMING_ARCH = "Esp8266"

config RBOOT_RTC_ENABLED
bool "Enable extended boot information via RTC memory"

choice
prompt "GPIO boot behaviour"
default RBOOT_GPIO_DISABLED
config RBOOT_GPIO_DISABLED
bool "Disable GPIO features"
config RBOOT_GPIO_ENABLED
bool "Enable GPIO boot slot 2"
help
rBoot supports booting into a third slot upon explicit user request,
e.g. by pressing a button during reset/power up.
This is especially useful for implementing some sort of recovery mechanism.
config RBOOT_GPIO_SKIP_ENABLED
bool "Use GPIO to skip between boot roms"
endchoice

endmenu
28 changes: 28 additions & 0 deletions Sming/Components/ssl/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
menu "SSL"
depends on !DISABLE_NETWORK

choice
default SELECT_SSL_NONE
prompt "SSL adapter"
config SELECT_SSL_NONE
bool "None"
config SELECT_SSL_DEFAULT
bool "Default (Axtls)"
config SELECT_SSL_AXTLS
bool "AXTLS"
config SELECT_SSL_BEARSSL
bool "Bear SSL"
endchoice

config ENABLE_SSL
string
default "0" if SELECT_SSL_NONE
default "1" if SELECT_SSL_DEFAULT
default "Axtls" if SELECT_SSL_AXTLS
default "Bearssl" if SELECT_SSL_BEARSSL

config SSL_DEBUG
depends on ENABLE_SSL != "0"
bool "Enable SSL debug"

endmenu
33 changes: 33 additions & 0 deletions Sming/Components/terminal/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
menu "Terminal"

config COM_PORT
string "Default port for device communications"
help
Default value depends on the development platform being used.
default "/dev/cuaU0" if ("$UNAME" = "FreeBSD")
default "/dev/tty.usbserial" if "$UNAME" = "MacOS"
default "/dev/ttyUSB0" if "$UNAME" = "Linux"
default "COM3" if "$UNAME" = "Windows"

config COM_SPEED_SERIAL
int "Default baud rate to use for serial communication within application"
default COM_SPEED

config COM_OPTS
string "Additional options to pass to the terminal"
default "--raw --encoding ascii --rts 0 --dtr 0"

config TERMINAL
string "Command line to use when running `make terminal`"
help
Redefine if you want to use a different terminal application
default "powershell.exe -Command \"python -m serial.tools.miniterm $(COM_OPTS) $(COM_PORT) $(COM_SPEED_SERIAL)\"" if $WSL_ROOT
default "$(PYTHON) -m serial.tools.miniterm $(COM_OPTS) $(COM_PORT) $(COM_SPEED_SERIAL)" if !$WSL_ROOT

config KILL_TERM
string "Command line to use to kill the running terminal process"
help
If the terminal never runs in the background and the warnings annoy you, just clear it
default "pkill -9 -f \"$(COM_PORT) $(COM_SPEED_SERIAL)\" || exit 0"

endmenu
Loading

0 comments on commit 97aa2cd

Please sign in to comment.