Configuration and Setup
Setup, in its simplest form, is Wi-Fi Setup , also called Wi-Fi provisioning: providing Gecko OS with your network ssid and passkey. Once these details are provided, Gecko OS automatically brings the network up when it is required by any Gecko OS activity.
Setup may also involve Variable Configuration and GPIO Configuration .
To configure your own version of the Gecko OS Web App, see Customizing the Gecko OS Web App .
Some of the procedures described below use a Gecko OS terminal. Connecting a terminal is described in Getting Started .
Wi-Fi Setup
A number of flexible and easy-to-use options are available to set up a device running Gecko OS.
Gecko OS is so easy to setup, we bet that within just a couple of minutes after plugging your evaluation board in, you'll be connected to a Wi-Fi network. Why not try it right now? With just four Gecko OS commands, you can connect to the Internet and download information! Enter the following commands into a Gecko OS terminal, substituting the name and password for your access point:
Gecko OS Commands | Description |
---|---|
|
|
The setup steps are the first two lines of the example above - connecting to your local Wi-Fi Access Point. For further quick start information see Getting Started .
Setup with a Web browser
Gecko OS provides the option to use a web browser running on a network client (such as a smartphone, tablet or computer) to set the wlan.ssid and wlan.passkey .
In web setup mode, the Gecko OS device starts a soft AP and an HTTP server. The network client joins the device network via the soft AP and loads a set up page running on the Gecko OS HTTP server.
Note : Web setup mode does NOT currently support WEP. You can setup WEP using a terminal and Gecko OS commands. See wlan.passkey .
Starting Web Setup Mode on a Silicon Labs Evaluation Board
On a Silicon Labs evaluation board in the factory default state, you can start web setup mode without connecting via a terminal: hold down Button 2, press Reset, and continue to hold down Button 2 for another three seconds. The evaluation board red LED flashes to indicate the Gecko OS soft AP is running. See Initiating Setup by GPIO .
Starting Web Setup Mode from a Gecko OS Terminal
Alternatively, to start web setup mode, connect via a terminal and enter the command setup_web .
Gecko OS starts the local network and web server as indicated by the final message:
In progress
.
> setup_web
[Disassociated]
IPv4 address: 10.10.10.1
Web setup started with the SSID: "Gecko OS-###"
In progress
Opening the Web Setup Page
Open the Wi-Fi settings on your smartphone, tablet or computer and join the network called Gecko OS-###. The ### represents a unique ID derived from the last 3 characters of the device
MAC address
, e.g.
Gecko OS-2D6
for a device with MAC address
4C:55:CC:10:32:D6
. The password for the network is simply:
password
.
The local network name and password, and the web address may be customised to suit your needs. See setup.web.ssid , setup.web.passkey and setup.web.url .
After joining the local network, open a web browser on the network client and direct the browser to setup.com. The Gecko OS web page appears, and a scan begins for Wi-Fi access points in range. Select the remote network you wish to join, enter the network password then select
Save & Exit
and follow the prompts.
Once the settings are successfully saved, Gecko OS prints
Web Setup Mode exited
to the terminal. You can check that the settings were successfully saved using
get wlan.ssid
and
get wlan.passkey
.
Web Setup Mode exited
> get wlan.ssid
YOUR_NETWORK_NAME
> get wlan.passkey
YOUR_NETWORK_PASSWORD
Web Setup Timeout
Web Setup times out after a period of user inactivity. If after web setup starts, the user does not open the web page, Gecko OS exits setup mode after five minutes. If after opening the page the user does not click any button on the web page for five minutes, the setup web page displays a warning message. If there is no activity for 60 seconds after the message is displayed, the web page exits and web setup stops.
Setup by Gecko OS Terminal
Perhaps the most common option used for general setup (and also the most convenient when prototyping) is to use a Gecko OS terminal and set variables using Gecko OS commands. See Getting Started .
It is straightforward to set the
wlan.ssid
and
wlan.passkey
variables manually. Be sure to save afterwards, or the values will be lost when the device reboots.
> set wlan.ssid YOUR_NETWORK_NAME
Set OK
> set wlan.passkey YOUR_NETWORK_PASSWORD
Set OK
> save
Saved
Success
Any subsequent command requiring network access, such as an ICMP (Internet Control Message Protocol) ping, automatically results in the device attempting to join the network.
> ping -g
[Associating to YOUR_NETWORK_NAME]
Security type from probe: WPA2-Mixed
Obtaining IPv4 address via DHCP
IPv4 address: 192.168.0.31
[Associated]
Ping reply in 25ms
Network Setup Option
The
network_up
command provides a
-s
option that prompts for the network and passkey. This simplifies the process by scanning for networks and allowing the desired network to be selected by index number, e.g.:
> nup -s
Scanning for networks...
! 5 networks found
! # Ch RSSI MAC (BSSID) Network (SSID)
# 0 1 -78 00:0E:E8:B2:FE:FC someone-else
# 1 1 -79 18:33:9D:5F:9E:F3 another-network
# 2 6 -28 30:85:A9:E7:9C:B0 Silicon Labs Guest
# 3 11 -84 58:BF:EA:D8:C9:D2 not_us
Type the number # that matches your Network: 3
Type the password for your Network : <passkey>
After running
nup -s
you may want to set
wlan.auto_join.enabled
. Save the variables if you want them to persist through a reboot:
> set wlan.auto_join.enabled 1
Set OK
> save
Saved
Success
Setup by Remote Terminal
An (optionally) password-secured remote terminal provides command line setup convenience (look ma, no wires!) via one of the Gecko OS wireless network interfaces. See Application Examples - Remote Terminal . After connecting to the Gecko OS device via a remote terminal, follow the procedure described above in Setup by Gecko OS Terminal .
Initiating Setup by GPIO
Setup can be triggered by changing the level of a specified GPIO. See Executing a Script on GPIO Assertion or Reboot .
If
setup.gpio.mode
is set to
gpio
, and the GPIO specified by
setup.gpio.control_gpio
is held to the level specified by
setup.gpio.level
for 3 seconds during and immediately after reset, then the command specified by
setup.gpio.cmd
is run.
On Gecko OS evaluation boards, the default factory configuration is:
Variable | Value |
---|---|
setup.gpio.control_gpio | GPIO corresponding to Button 2 |
setup.gpio.cmd |
setup_web
|
setup.gpio.level |
1
|
setup.gpio.mode |
gpio
|
Accordingly, on a default configuration eval board, hold down Button 2, press reset, and continue to hold Button 2 for three seconds to start web setup.
Web Setup Note : On some Gecko OS evaluation boards, the web setup GPIO configuration to Button 2 to is lost after a hardware factory_reset using Button 1. In this case use the setup_web command to enter web setup mode, or use another configuration method.
Initiating Setup on Boot
Set the value of setup.auto.cmd to the required setup cmd.
See Executing a Script on Reboot .
Setup Configuration Script
A custom configuration script can be set up to execute on boot-up. The file is in Configuration Script Format .
If you issue the
setup cmd
without a specified
<script_file>
argument, Gecko OS automatically uses the file
default_setup.script
if it exists in the Gecko OS file system. You can customise a setup script as required. You can create multiple setup scripts and supply the filename as an argument:
setup cmd <script_file>
.
Sample
default_setup.script
file contents are as follows:
network_up,-s,Configuration network credentials
set wlan.auto_join.enabled,true,Enable network auto-join
save,-,Saving settings
On running the
default_setup.script
, the output is similar to the following:
> setup cmd
Running setup script: default_setup.script
In progress
> Configuration network credentials
network_up -s
Scanning for networks...
! 9 networks found
! # Ch RSSI MAC (BSSID) Network (SSID)
# 0 1 -77 18:33:9D:5F:9E:F2 Some AP
# 1 1 -79 18:33:9D:5F:9E:F4 Another AP
# 2 6 -31 30:85:A9:E7:9C:B0 Silicon Labs Guest
# 3 6 -66 E8:08:8B:CA:4A:CC Yet Another AP
Type the number # that matches your Network: 2
Type the password for your Network : secret_passkey
[Associating to Silicon Labs Guest]
> In progress
Enable network auto-join
set wlan.auto_join.enabled true
Set OK
Saving settings
save
Saved
Success
Script executed successfully
Configuration Scripts
A configuration script is a csv file containing commands to be executed sequentially. The format is described in Configuration Script Format .
Executing a Script on Command
To execute a script, use the
setup cmd
command. Use the
-v
option to see commands, comments and command responses.
For example, to verbosely execute the script
my_script.csv
:
setup cmd -v my_script.csv
You can also load a variable configuration script with the load command. For example:
load my_config.csv
Executing a Script on Reboot
To automatically execute a script on booting an unconfigured device (a device with
wlan.ssid
not yet set), set the value of
setup.auto.cmd
to the required
setup cmd
. For example:
set setup.auto.cmd "setup cmd my.script"
Note
: The
"setup cmd"
value must be enclosed in double quotes because it is a single argument containing spaces.
See Serial Interface, Setup Auto Command .
Executing a Script on GPIO Assertion or Reboot
To execute a script on in response to a reboot, or a GPIO being asserted, set the value of the setup.gpio.control_gpio variable to the required command.
See Serial Interface, Setup GPIO .
For example, the following settings cause the configuration script
my_script.csv
to be executed when GPIO 2 is asserted for 3 seconds during a reboot:
set setup.gpio.cmd "setup cmd my_script.csv"
set setup.gpio.control_gpio 2
set setup.gpio.level 1
set set.gpio.mode gpio
Displaying Comments and Command Output on Script Execution
To display comments and command output, add the
-v
option after the
setup cmd
, e.g.
set setup.gpio.cmd "setup cmd -v my.script"
See setup cmd .
Configuration Script Format
A configuration script specifies a list of commands, to be executed in sequence. A variable configuration file is an example of a configuration script. See Variable Configuration File .
The configuration script is in .csv format. Each line represents a command, in the form:
<command>,<arguments>,<comment>
The maximum line length of any line in a configuration script is 128 characters (including the
\r\n
characters at the end of the line).
You can create complex scripts, that run other commands to perform actions such as GPIO configuration. This is an example script that frees up four GPIOs.
,,--------------------------------------------- Free up GPIOs
set, gpio.init 0 none, \r\n# Free up GPIO 0
set, gpio.init 22 none, \r\n# Free up GPIO 22
set, gpio.init 16 none, \r\n# Free up GPIO 16
set, gpio.init 13 none, \r\n# Free up GPIO 13
The comment is printed before the corresponding command is executed.
The comment fields in the above example contain
\r\n#
characters for formatting purposes only. The effect is to skip a line then print the
#
character before the text of the comment.
Note : To comment out a line completely, insert two commas at the beginning of the line. See examples above. A variable configuration file cannot have full line comments.
Note
: Each line of the script is terminated by
\r\n
(<CR><LF>).
Example - Creating and Running a Configuration Script
This example demonstrates writing the sample GPIO script above to a file and executing it.
Write the script to the Gecko OS file system. See File System, Writing Files .
The script has 251 characters, including the <CR><LF> characters at the end of each line. To create the file, issue the
file_create
command and after pressing
Enter
, paste the file contents into the Gecko OS terminal:
> fcr test.script 251
,,--------------------------------------------- Free up GPIOs
set, gpio.init 0 none, \r\n# Free up GPIO 0
set, gpio.init 22 none, \r\n# Free up GPIO 22
set, gpio.init 16 none, \r\n# Free up GPIO 16
set, gpio.init 13 none, \r\n# Free up GPIO 13
File created
Now you can run the script as follows:
> setup cmd -v test.script
Running setup script: test.script
In progress
# Free up GPIO 0
set gpio.init 0 none
Set OK
# Free up GPIO 22
set gpio.init 22 none
Set OK
# Free up GPIO 16
set gpio.init 16 none
Set OK
# Free up GPIO 13
set gpio.init 13 none
Set OK
Script executed successfully
To create a variable configuration file that can be run with the load command, omit full line comments such as the
Free up GPIOs
line in the example above. For example:
> fcr test2.script 186
set, gpio.init 0 none, \r\n# Free up GPIO 0
set, gpio.init 22 none, \r\n# Free up GPIO 22
set, gpio.init 16 none, \r\n# Free up GPIO 16
set, gpio.init 13 none, \r\n# Free up GPIO 13
File created
Then to run the script:
> load -v test2.script
# Free up GPIO 0
set gpio.init 0 none
Set OK
# Free up GPIO 22
set gpio.init 22 none
Set OK
# Free up GPIO 16
set gpio.init 16 none
Set OK
# Free up GPIO 13
set gpio.init 13 none
Set OK
Rebooting to complete loading sequence
Loaded & saved settings
JTAG debug enabled
[Ready]
Variable Configuration
Gecko OS maintains current variable values in Configuration RAM . To ensure that variable values persist after reboot, you save Configuration RAM to NVM flash with the save command. NVM stands for Non-Volatile-Memory. When you reboot, the device loads the configuration from NVM flash into Configuration RAM.
Certain critical variable values in NVM flash are backed up in NVM backup . If NVM flash becomes corrupted, the values are automatically restored from NVM backup. See NVM Backup Variables below for the list of critical variables.
You can save Configuration RAM to a file by specifying a configuration filename with the
save
command, e.g.:
save config1.cfg
To store multiple configurations, save multiple files.
You can load a specified variable configuration file with the
load
command after reboot is complete, e.g.:
load config1.cfg
Platform-specific variable values are typically stored in OTP (One-Time Programmable) memory. For example, settings related to antenna configuration, buttons or indicator LEDs are stored in OTP memory at manufacture.
To summarise, variable values are stored in several places:
Variable Location | Description |
---|---|
Factory Default Values | Stored in firmware |
Configuration RAM | Stores current variable values. Must be saved to persist. |
NVM Flash | Saved variable values |
NVM Backup | Backup of critical variable values |
OTP memory | Platform-specific variable values |
Variable files | Snapshot of Configuration RAM |
Variable values are restored from these storage locations as described below in Resetting Variable Values .
Variable Configuration File
A variable configuration file allows settings of variables to be saved and loaded as required.
A variable configuration file is a configuration script , with the format described in Configuration Script Format , with the exception that comment-only lines are not permitted. Each line should have a variable setting command.
The variable configuration file is saved with the file type
FD
(decimal
253
):
SETUP_SCRIPT
. If you create your own variable configuration file, it may have the file type
FE
(decimal
254
):
MISC_FIX_LEN
. See
File Types
.
Either type can be executed with the load command or the setup cmd command.
For a default variable configuration file, see Default Variable Configuration below.
For a factory configuration file, see Factory Configuration below.
Native API Variable Configuration
The Native API supports variable configuration files with the Gecko OS Settings function group .
Use gos_settings_save() to save the current variable configuration.
Use gos_load_app_settings() to load a config file from the file system via zap.
Default Variable Configuration
You can create a default
variable configuration file
by issuing the
save
command with the file name
default_config.csv
:
save default_config.csv
The default configuration in
default_config.csv
is loaded in response to a
User Factory Reset
, unless there is a
factory_config.csv
file. See
Factory Configuration
.
The default configuration in
default_config.csv
is automatically loaded upon startup if there is no valid NVM flash, for example after reprogramming, or after a successful update.
You can also create a variable configuration file by other means. See the configuration file example above. It is not necessary to supply a setting for every variable.
Factory Configuration
The
factory_config.csv
factory configuration file provides a way of saving a known configuration that is loaded in response to a factory reset.
You can create a factory
variable configuration file
by issuing the
save
command with the file name
factory_config.csv
:
save factory_config.csv
The
factory_config.csv
file is loaded after either a
'hard'
or a
'soft' factory reset
, however the user can invoke only a
'hard' factory reset
.
Invoke a 'hard' factory reset either by using GPIO 0 or with the factory_reset command. See Update and Recovery, Factory Reset .
If there is no
factory_config.csv
but there is a
default_config.csv
, a factory reset loads the
default_config.csv
file. See
Default Variable Configuration
.
Resetting Variable Values
There are several kinds of reset that affect the value of variables.
Powerup or Reboot
To restore variable values on restart, Gecko OS:
- Loads variable values from NVM flash into Configuration RAM
Hard Factory Reset
A hard factory reset returns all values to their original default values. This is under user control. To perform a hard factory reset:
either
- use the factory_reset command, or
- assert GPIO0 for at least 10 seconds during and after reboot
The factory_reset command requires a MAC address in order to avoid accidental reset. The MAC address can be obtained from the wlan.mac variable.
To restore variable values, Gecko OS:
- Resets NVM flash
- Resets NVM backup
- Loads factory default values from firmware into Configuration RAM
- Loads platform specific settings from OTP memory into Configuration RAM
- Saves Configuration RAM to NVM flash
Soft Factory Reset
A soft factory reset restores the NVM from NVM backup. This happens automatically if the NVM is corrupted.
To restore variable values, Gecko OS:
- Resets NVM flash
- Loads factory default values from firmware into Configuration RAM
- Loads variable values stored in NVM Backup into Configuration RAM
- Loads platform specific settings from OTP memory into Configuration RAM
-
Loads variable values from the
default_config.csv
file into Configuration RAM - Saves Configuration RAM to NVM flash
User Factory Reset
A user factory reset restores from NVM backup. This is under user control.
Note : The effect of a soft factory reset and a user factory reset is the same. They differ only in how they are invoked.
To perform a user factory reset:
- assert GPIO0 for 5 seconds
To restore variable values, Gecko OS:
- Resets NVM flash
- Loads factory default values from firmware into Configuration RAM
- Loads variable values stored in NVM Backup into Configuration RAM
- Loads platform specific settings from OTP memory into Configuration RAM
-
Loads variable values from the
default_config.csv
file into Configuration RAM - Saves Configuration RAM to NVM flash
Load User Settings
This reset takes place when the load command is issued.
The following steps take place, in the following order. Gecko OS:
- Loads factory default values from firmware into Configuration RAM
- Restores variable values stored in NVM Backup into Configuration RAM
- Loads platform specific settings from OTP memory into Configuration RAM
- Loads user settings, from the file specified as the parameter to the load command, into Configuration RAM
- Saves Configuration RAM to NVM flash
NVM Backup Variables
The values of the following critical user variables are saved in NVM backup, in case there is some damage to NVM flash:
- bus.data_bus
- bus.log_bus
- bus.mode
- system.cmd.buffered
- system.cmd.echo
- system.cmd.header_enabled
- system.cmd.prompt_enabled
- system.cmd.timestamp
- system.print_level
- tcp.client.connect_timeout
- tcp.client.local_port
- tcp.client.retries
- tcp.client.retry_period
- tcp.keepalive.enabled
- tcp.keepalive.initial_timeout
- tcp.keepalive.retry_count
- tcp.keepalive.retry_timeout
- uart.baud
- uart.data
- uart.flow
- uart.parity
- uart.stop
- wlan.antenna.select
- wlan.dhcp.enabled
- wlan.dhcp.timeout
- wlan.hide_passkey
- wlan.join.retries
- wlan.join.timeout
- wlan.passkey
- wlan.rate.protocol
- wlan.rate.transmit
- wlan.roam.threshold
- wlan.scan.active_dwell
- wlan.scan.channel_mask
- wlan.scan.home_dwell
- wlan.scan.num_probes
- wlan.scan.passive_dwell
- wlan.scan.retries
- wlan.scan.type
- wlan.security
- wlan.ssid
- wlan.static.dns
- wlan.static.gateway
- wlan.static.ip
- wlan.static.netmask
- wlan.tx_power
GPIO Configuration
GPIOs are configured in the factory default variable configuration. You can use GPIO commands and variables to configure GPIOs. See Peripherals, GPIO Commands and Variables . It is also possible to use a csv file to configure and initialize GPIOs on bootup.
Standard GPIO Functions
These correspond to the direction names used in arguments for the gpio_dir command.
I/O Type Description | Direction Name |
---|---|
Input, pull-up | ipu |
Input, pull-down | ipd |
Input, high-impedance | in |
Output, push-pull | out |
Output, open-drain no-pull | ood |
Output, open-drain pull-up | oodpu |
Deregister the GPIO | none |
Sleep State
To set the sleep state in the gpio config file add the | in the gpio function column.
For example:
Set GPIO 0 with gpio.alias = "reset", gpio.init = "ipd", gpio.sleep = "in":
0,reset,ipd|in
See the gpio.sleep variable description for state options.
Alternative GPIO Functions
- bus.stream.cmd_gpio
- ioconn.control_gpio
- ioconn.status_gpio
- setup.gpio.control_gpio
- system.activity.gpio (see System Activity Function below)
- system.indicator.gpio wlan
- system.indicator.gpio network
- system.indicator.gpio softap
- tcp.server.connected_gpio
- tcp.server.data_gpio
- udp.server.data_gpio
- wlan.network.status_gpio
System Indicator State Options
State Name | Blink Period | Blink Frequency |
---|---|---|
static_on | - | - |
static_off | - | - |
slow_blink | T=2s | f=0.5Hz |
medium_blink | T=1s | f=1Hz |
fast_blink | T=0.250s | f=4Hz |
Example GPIO config file
10,grn,system.indicator.wlan,static_off|fast_blink|medium_blink
11,yel,system.indicator.network,fast_blink|medium_blink|slow_blink
0,red,system.indicator.softap,static_off|fast_blink|medium_blink
4,button1,ipu,
3,button2,ipu,
1,network_status,wlan.network.status_gpio,
2,io_status,ioconn.status_gpio,
5,alias_only,,
8,output_high,out,1
7,,out,0
System Activity Function
Other than the GPIO parameter, each parameter for the
set
command is concatenated with a
|
character. For example, the following commands:
set system.activity.gpio 10 wlan_rx,wlan_tx
set system.activity.gpio 11 uart1_rx,uart1_tx
correspond to the following entries in the
gpio_config.csv
file:
10,,system.activity.gpio,wlan_rx|wlan_tx
11,,system.activity.gpio,uart1_rx|uart1_tx