How do I add a "settings shell" to any Zephyr project

Say I have a Zephyr project and I want to be able to set some of the settings from the UART. What is required in the prj.conf to enable this feature?

Setup

# Settings shell

CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y
CONFIG_GOLIOTH_SAMPLE_SETTINGS_AUTOLOAD=y
CONFIG_GOLIOTH_SAMPLE_SETTINGS_SHELL=y
CONFIG_GOLIOTH_SYSTEM_SETTINGS=y

CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y

These settings enable the shell, in addition to the non-volatile storage section. The NVS memory partitions are likely called out in the boards folder of Zephyr (if working with an upstreamed board definition).

Compile and flash the program to your board.

Trying it out

You should now have access to the settings shell when you connect to the device over UART. From here, you can set Golioth credentials (and wifi, if relevant). You can always add additional shell commands as well.

The following is the format of the commands for setting Golioth credentials:

settings set golioth/psk-id <your-psk-id>
settings set golioth/psk <your-psk>

You can get your PSK information on the Golioth Console

For more information about different ways to commission a new device to Golioth, check out the blog post on the Settings service:

1 Like