Change user_config_override usage

5.12.0i
 * Change user_config_override usage by providing
user_config_override_sample.h (#2228)
This commit is contained in:
Theo Arends 2018-04-02 11:24:36 +02:00
parent fa556897fe
commit 8ddd121953
6 changed files with 149 additions and 72 deletions

View File

@ -3,23 +3,17 @@ Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and Electr
Current version is **5.12.0i** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
### ATTENTION All versions
### Quick install
Only Flash Mode DOUT is supported. Do not use Flash Mode DIO / QIO / QOUT as it might seem to brick your device.
Download one of the release binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki.
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips) for background information.
### User compilation parameters
### ATTENTION Version 5 and up
If you want to compile Tasmota yourself keep in mind the following:
These versions use a new linker script to free flash memory for future code additions. It moves the settings from Spiffs to Eeprom. If you compile your own firmware download the new linker to your IDE or Platformio base folder. See [Wiki > Prerequisite](https://github.com/arendst/Sonoff-Tasmota/wiki/Prerequisite).
Best practice to implement is:
- Open the webpage to your device
- Perform option ``Backup Configuration``
- Upgrade new firmware using ``Firmware upgrade``
- If configuration conversion fails keep the webpage open and perform ``Restore Configuration``
You should now have a device with 32k more code memory to play with.
- Only Flash Mode **DOUT** is supported. Do not use Flash Mode DIO / QIO / QOUT as it might seem to brick your device. See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips) for background information.
- Tasmota uses a linker script WITHOUT spiffs for optimal code space. If you compile your own firmware on Arduino IDE and ESP/Arduino library 2.3.0 then download the new linker to your IDE or Platformio base folder. Later version of ESP/Arduino library already contain the correct linker script. See [Wiki > Prerequisite](https://github.com/arendst/Sonoff-Tasmota/wiki/Prerequisite).
- To make compile time changes to Tasmota can use the user_config_override.h file. It assures keeping your settings when you compile a new version. To use user_config.override.h copy the provided user_config.override_sample.h file to user_config.override.h and add your setting overrides. To enable the override file you will need to add a compile define as documented in the user_config_override_sample.h file
### Version Information

View File

@ -14,6 +14,7 @@ src_dir = sonoff
;env_default = sonoff
;env_default = sonoff-minimal
;env_default = sonoff-xxl
;env_default = sonoff-CZ
;env_default = sonoff-DE
;env_default = sonoff-ES
;env_default = sonoff-FR
@ -24,6 +25,7 @@ src_dir = sonoff
;env_default = sonoff-PT
;env_default = sonoff-RU
;env_default = sonoff-CN
;env_default = sonoff-TW
[env:sonoff]
;platform = espressif8266@1.5.0 ; v2.3.0
@ -33,7 +35,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -60,7 +62,8 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DBE_MINIMAL
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DBE_MINIMAL -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; Serial Monitor options
@ -74,12 +77,26 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_ALL_SENSORS
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_ALL_SENSORS -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; Serial Monitor options
monitor_baud = 115200
[env:sonoff-CZ]
;platform = espressif8266@1.5.0 ; v2.3.0
;platform = espressif8266@1.6.0 ; v2.4.0
platform = espressif8266
framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=cs-CZ
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=cs-CZ -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-DE]
;platform = espressif8266@1.5.0 ; v2.3.0
;platform = espressif8266@1.6.0 ; v2.4.0
@ -88,7 +105,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=de-DE
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=de-DE -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -102,7 +119,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=es-AR
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=es-AR -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -116,7 +133,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=fr-FR
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=fr-FR -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -130,7 +147,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=hu-HU
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=hu-HU -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -144,7 +161,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=it-IT
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=it-IT -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -158,7 +175,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=nl-NL
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=nl-NL -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -172,7 +189,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pl-PL
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pl-PL -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -186,7 +203,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pt-PT
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pt-PT -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -200,7 +217,7 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=ru-RU
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=ru-RU -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
@ -214,7 +231,21 @@ framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-CN
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-CN -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-TW]
;platform = espressif8266@1.5.0 ; v2.3.0
;platform = espressif8266@1.6.0 ; v2.4.0
platform = espressif8266
framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-TW
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-TW -DUSE_CONFIG_OVERRIDE
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options

View File

@ -32,9 +32,9 @@
#include "sonoff.h" // Enumeration used in user_config.h
#include "user_config.h" // Fixed user configurable options
//#ifdef USE_CONFIG_OVERRIDE
#ifdef USE_CONFIG_OVERRIDE
#include "user_config_override.h" // Configuration overrides for user_config.h
//#endif
#endif
#include "i18n.h" // Language support configured by user_config.h
#include "sonoff_template.h" // Hardware configuration

View File

@ -48,6 +48,9 @@
// As an IDE restriction it needs to be the same as the main .ino file
#define CFG_HOLDER 0x20161209 // [Reset 1] Change this value to load following default configuration parameters
//#define USE_CONFIG_OVERRIDE // Uncomment to use your own user_config_override.h file. See README.md
#define SAVE_DATA 1 // [SaveData] Save changed parameters to Flash (0 = disable, 1 - 3600 seconds)
#define SAVE_STATE 1 // [SetOption0] Save changed power state to Flash (0 = disable, 1 = enable)

View File

@ -1,44 +0,0 @@
/*
user_config_override.h - user configuration overrides user_config.h for Sonoff-Tasmota
Copyright (C) 2018 Theo Arends
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _USER_CONFIG_OVERRIDE_H_
#define _USER_CONFIG_OVERRIDE_H_
/*****************************************************************************************************\
* ATTENTION: - Changes to most PARAMETER defines will only override flash settings if you change
* define CFG_HOLDER.
* - Expect compiler warnings when no ifdef/undef/endif sequence is used.
* - You still need to update user_config.h for major defines MODULE and USE_MQTT_TLS.
* - Changing MODULE defines are not being tested for validity as they are in user_config.h.
* - Most parameters can be changed online using commands via MQTT, WebConsole or serial.
* - So I see no use in this but anyway, your on your own.
\*****************************************************************************************************/
// Examples
//#ifdef CFG_HOLDER
//#undef CFG_HOLDER
//#endif
//#define CFG_HOLDER 0x20161210
//#ifdef STA_SSID1
//#undef STA_SSID1
//#endif
//#define STA_SSID1 "yourssid1"
#endif // _USER_CONFIG_OVERRIDE_H_

View File

@ -0,0 +1,93 @@
/*
user_config_override.h - user configuration overrides user_config.h for Sonoff-Tasmota
Copyright (C) 2018 Theo Arends
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _USER_CONFIG_OVERRIDE_H_
#define _USER_CONFIG_OVERRIDE_H_
// force the compiler to show a warning to confirm that this file is inlcuded
#warning **** Using Settings from user_config_override.h File ***
/*****************************************************************************************************\
* USAGE:
* To modify the stock configuration without changing the user_config.h file:
* (1) copy this file to "user_config_override.h" (It will be ignored by Git)
* (2) define your own settings below
* (3) for platformio:
* define USE_CONFIG_OVERRIDE as a build flags.
* ie1 : export PLATFORMIO_BUILD_FLAGS='-DUSE_CONFIG_OVERRIDE'
* ie2 : enable in file platformio.ini ;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_CONFIG_OVERRIDE
* for Arduino IDE:
* enable define USE_CONFIG_OVERRIDE in user_config.h
******************************************************************************************************
* ATTENTION:
* - Changes to most PARAMETER defines will only override flash settings if you change define CFG_HOLDER.
* - Expect compiler warnings when no ifdef/undef/endif sequence is used.
* - You still need to update user_config.h for major defines MODULE and USE_MQTT_TLS.
* - Changing MODULE defines are not being tested for validity as they are in user_config.h.
* - Most parameters can be changed online using commands via MQTT, WebConsole or serial.
\*****************************************************************************************************/
/*
Examples :
// Setup your own Wifi settings -------------------------------------------------------
#undef STA_SSID1
#define STA_SSID1 "YourSSID" // [Ssid1] Wifi SSID
#undef STA_PASS1
#define STA_PASS1 "YourWifiPassword" // [Password1] Wifi password
// Setup your own MQTT settings -------------------------------------------------------
#undef MQTT_HOST
#define MQTT_HOST "your-mqtt-server.com" // [MqttHost]
#undef MQTT_PORT
#define MQTT_PORT 1883 // [MqttPort] MQTT port (10123 on CloudMQTT)
#undef MQTT_USER
#define MQTT_USER "YourMqttUser" // [MqttUser] Optional user
#undef MQTT_PASS
#define MQTT_PASS "YourMqttPass" // [MqttPassword] Optional password
// You might even pass some parameters from the command line ----------------------------
// Ie: export PLATFORMIO_BUILD_FLAGS='-DUSE_CONFIG_OVER -DMY_IP="192.168.1.99" -DMY_GW="192.168.1.1" -DMY_DNS="192.168.1.1"'
#ifdef MY_IP
#undef WIFI_IP_ADDRESS
#define WIFI_IP_ADDRESS MY_IP // Set to 0.0.0.0 for using DHCP or IP address
#endif
#ifdef MY_GW
#undef WIFI_GATEWAY
#define WIFI_GATEWAY MY_GW // if not using DHCP set Gateway IP address
#endif
#ifdef MY_DNS
#undef WIFI_DNS
#define WIFI_DNS MY_DNS // If not using DHCP set DNS IP address (might be equal to WIFI_GATEWAY)
#endif
*/
#endif // _USER_CONFIG_OVERRIDE_H_