nodemcu-firmware/app/include/user_config.h

289 lines
12 KiB
C
Raw Normal View History

#ifndef __USER_CONFIG_H__
#define __USER_CONFIG_H__
// The firmware supports a range of Flash sizes, though 4 Mbyte seems to be
// the most common currently. NodeMCU builds include a discovery function
2018-04-19 17:27:47 +02:00
// which is enabled by FLASH_AUTOSIZE, but you can override this by commenting
// this out and enabling the explicitly size, e.g. FLASH_4M. Valid sizes are
// FLASH_512K, FLASH_1M, FLASH_2M, FLASH_4M, FLASH_8M, FLASH_16M.
//#define FLASH_AUTOSIZE
#define FLASH_4M
2018-04-19 17:27:47 +02:00
// The firmware now selects a baudrate of 115,200 by default, but the driver
// also includes automatic baud rate detection at start-up. If you want to change
// the default rate then vaild rates are 300, 600, 1200, 2400, 4800, 9600, 19200,
// 31250, 38400, 57600, 74880, 115200, 230400, 256000, 460800 [, 921600, 1843200,
// 368640]. Note that the last 3 rates are not recommended as these might be
// unreliable, but 460800 seems to work well for most USB-serial devices.
2018-04-19 17:27:47 +02:00
#define BIT_RATE_DEFAULT BIT_RATE_115200
//#define BIT_RATE_AUTOBAUD
2018-04-19 17:27:47 +02:00
// Three separate build variants are now supported. The main difference is in the
// processing of numeric data types. If LUA_NUMBER_INTEGRAL is defined, then
// all numeric calculations are done in integer, with divide being an integer
2018-04-19 17:27:47 +02:00
// operations, and decimal fraction constants are illegal. Otherwise all
// numeric operations use floating point, though they are exact for integer
// expressions < 2^53.
// The main advantage of INTEGRAL builds is that the basic internal storage unit,
// the TValue, is 8 bytes long. We have now reduced the size of FP TValues to
// 12 bytes rather than the previous 16 as this gives a material RAM saving with
// no performance loss. However, you can define LUA_DWORD_ALIGNED_TVALUES and
// this will force 16 byte TValues on FP builds.
2018-04-19 17:27:47 +02:00
//#define LUA_NUMBER_INTEGRAL
//#define LUA_DWORD_ALIGNED_TVALUES
2018-04-19 17:27:47 +02:00
// The Lua Flash Store (LFS) allows you to store Lua code in Flash memory and
// the Lua VMS will execute this code directly from flash without needing any
// RAM overhead. You can now configure LFS directly in the System Partition
// Table insted of at compile time. However for backwards compatibility setting
// LUA_FLASH_STORE defines the default partition size if the NodeMCU partition
// tool is not used.
2018-04-19 17:27:47 +02:00
//#define LUA_FLASH_STORE 0x10000
2018-04-19 17:27:47 +02:00
// By default Lua executes the file init.lua at start up. The following
// define allows you to replace this with an alternative startup. Warning:
// you must protect this execution otherwise you will enter a panic loop;
// the simplest way is to wrap the action in a function invoked by a pcall.
2018-04-19 17:27:47 +02:00
// The example provided executes the LFS module "_init" at startup or fails
// through to the interactive prompt.
//#define LUA_INIT_STRING "pcall(function() node.flashindex'_init'() end)"
2018-04-19 17:27:47 +02:00
// NodeMCU supports two file systems: SPIFFS and FATFS, the first is available
// on all ESP8266 modules. The latter requires extra H/W so is less common.
// If you use SPIFFS then there are a number of options which impact the
// RAM overhead and performance of the file system.
2018-04-19 17:27:47 +02:00
// If you use the spiffsimg tool to create your own FS images on your dev PC
// then we recommend that you fix the location and size of the FS, allowing
// some headroom for rebuilding flash images and LFS. As an alternative to
// fixing the size of the FS, you can force the SPIFFS file system to end on
2018-04-19 17:27:47 +02:00
// the next 1Mb boundary. This is useful for certain OTA scenarios. In
// general, limiting the size of the FS only to what your application needs
2018-04-19 17:27:47 +02:00
// gives the fastest start-up and imaging times.
// You can now configure SPIFFS size and position directly in the System
// Partition Table. However backwards compatibility SPIFFS_MAX_FILESYSTEM_SIZE
// can be set and this defines the default SPIFFS partition size if the NodeMCU
// partition tool is not used. The value (~0x0) means the maximum size remaining.
2018-04-19 17:27:47 +02:00
#define BUILD_SPIFFS
#define SPIFFS_CACHE 1 // Enable if you use you SPIFFS in R/W mode
//#define SPIFFS_MAX_FILESYSTEM_SIZE 0x20000
2018-04-19 17:27:47 +02:00
#define SPIFFS_MAX_OPEN_FILES 4 // maximum number of open files for SPIFFS
#define FS_OBJ_NAME_LEN 31 // maximum length of a filename
//#define BUILD_FATFS
2018-04-19 17:27:47 +02:00
// The HTTPS stack requires client SSL to be enabled. The SSL buffer size is
// used only for espconn-layer secure connections, and is ignored otherwise.
2018-04-19 17:27:47 +02:00
// Some HTTPS applications require a larger buffer size to work. See
// https://github.com/nodemcu/nodemcu-firmware/issues/1457 for details.
// The SHA2 and MD2 libraries are also optionally used by the crypto functions.
// The SHA1 and MD5 function are implemented in the ROM BIOS. The MD2 and SHA2
// are by firmware code, and can be enabled if you need this functionality.
2018-04-19 17:27:47 +02:00
//#define CLIENT_SSL_ENABLE
//#define MD2_ENABLE
#define SHA2_ENABLE
#define SSL_BUFFER_SIZE 4096
#define SSL_MAX_FRAGMENT_LENGTH_CODE MBEDTLS_SSL_MAX_FRAG_LEN_4096
2018-04-19 17:27:47 +02:00
// GPIO_INTERRUPT_ENABLE needs to be defined if your application uses the
// gpio.trig() or related GPIO interrupt service routine code. Likewise the
// GPIO interrupt hook is requited for a few modules such as rotary. If you
// don't require this functionality, then commenting out these options out
// will remove any associated runtime overhead.
2018-04-19 17:27:47 +02:00
#define GPIO_INTERRUPT_ENABLE
#define GPIO_INTERRUPT_HOOK_ENABLE
// If your application uses the light sleep functions and you wish the
// firmware to manage timer rescheduling over sleeps (the CPU clock is
2018-04-19 17:27:47 +02:00
// suspended so timers get out of sync) then enable the following options
//#define TIMER_SUSPEND_ENABLE
2018-04-19 17:27:47 +02:00
//#define PMSLEEP_ENABLE
// The WiFi module optionally offers an enhanced level of WiFi connection
// management, using internal timer callbacks. Whilst many Lua developers
// prefer to implement equivalent features in Lua, others will prefer the
// Wifi module to do this for them. Uncomment the following to enable
2019-02-17 19:26:29 +01:00
// this functionality. See the relevant WiFi module documentation for
// further details, as the scope of these changes is not obvious.
2018-04-19 17:27:47 +02:00
2019-02-17 19:26:29 +01:00
// Enable the wifi.startsmart() and wifi.stopsmart()
2018-04-19 17:27:47 +02:00
//#define WIFI_SMART_ENABLE
// Enable wifi.sta.config() event callbacks
2018-04-19 17:27:47 +02:00
#define WIFI_SDK_EVENT_MONITOR_ENABLE
// Enable creation on the wifi.eventmon.reason table
2018-04-19 17:27:47 +02:00
#define WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE
// Enable use of the WiFi.monitor sub-module
//#define LUA_USE_MODULES_WIFI_MONITOR
2018-04-19 17:27:47 +02:00
// Whilst the DNS client details can be configured through the WiFi API,
// the defaults can be exposed temporarily during start-up. The following
// WIFI_STA options allow you to configure this in the firmware. If the
// WIFI_STA_HOSTNAME is not defined then the hostname will default to
// to the last 3 octets (6 hexadecimal digits) of MAC address with the
2018-04-19 17:27:47 +02:00
// prefix "NODE-". If it is defined then the hostname must only contain
// alphanumeric characters. If you are imaging multiple modules with this
// firmware then you must also define WIFI_STA_HOSTNAME_APPEND_MAC to
// append the last 3 octets of the MAC address. Note that the total
2018-04-19 17:27:47 +02:00
// Hostname MUST be 32 chars or less.
//#define WIFI_STA_HOSTNAME "NodeMCU"
//#define WIFI_STA_HOSTNAME_APPEND_MAC
// If you use the enduser_setup module, then you can also set the default
// SSID when this module is running in AP mode.
#define ENDUSER_SETUP_AP_SSID "SetupGadget"
// I2C software driver partially supports use of GPIO16 (D0) pin for SCL line.
// GPIO16 does not support open-drain mode and works in push-pull mode,
// so clock stretching will not be possible, because circuit in slave device that
// supposed to drive SCL low during stretching will not be capable to hold SCL low.
// Also I2C speed will be limited to no more than 400000 Hz (FAST mode).
// This define is does not have an effect on an old driver (see I2C_MASTER_OLD_VERSION).
//#define I2C_MASTER_GPIO16_ENABLE
// For compatibility reasons you can switch to old version of I2C software driver.
// It does not support changing speed, have only one bus id = 0, does not support GPIO16
// and works only in Standard(slow) mode with clock speed around 50kHz.
#define I2C_MASTER_OLD_VERSION
// The following sections are only relevent for those developers who are
2018-04-19 17:27:47 +02:00
// developing modules or core Lua changes and configure how extra diagnostics
// are enabled in the firmware. These should only be configured if you are
// building your own custom firmware and have full access to the firmware
// source code.
// Enabling DEVELOPMENT_TOOLS adds the asserts in LUA and also some useful
// extras to the node module. These are silent in normal operation and so can
// be enabled without any harm (except for the code size increase and slight
// slowdown). If you want to use the remote GDB to handle breaks and failed
2018-04-19 17:27:47 +02:00
// assertions then enable the DEVELOPMENT_USE GDB option. A supplimentary
// define DEVELOPMENT_BREAK_ON_STARTUP_PIN allows you to define a GPIO pin,
2018-04-19 17:27:47 +02:00
// which if pulled low at start-up will immediately initiate a GDB session.
// The DEVELOP_VERSION option enables lots of debug output, and is normally
2018-04-19 17:27:47 +02:00
// only used by hardcore developers.
// These options can be enabled globally here or you can alternatively use
2018-04-19 17:27:47 +02:00
// the DEFINES variable in the relevant Makefile to set these on a per
// directory basis. If you do this then you can also set the corresponding
2018-04-19 17:27:47 +02:00
// compile options (-O0 -ggdb) on a per directory as well.
2016-03-20 17:54:16 +01:00
//#define DEVELOPMENT_TOOLS
//#define DEVELOPMENT_USE_GDB
2018-04-19 17:27:47 +02:00
//#define DEVELOPMENT_BREAK_ON_STARTUP_PIN 1
//#define DEVELOP_VERSION
// *** Heareafter, there be demons ***
// The remaining options are advanced configuration options and you should only
// change this if you have tracked the implications through the Firmware sources
// and understand the these.
#define NODEMCU_EAGLEROM_PARTITION 1
#define NODEMCU_IROM0TEXT_PARTITION 2
#define NODEMCU_LFS0_PARTITION 3
#define NODEMCU_LFS1_PARTITION 4
#define NODEMCU_TLSCERT_PARTITION 5
#define NODEMCU_SPIFFS0_PARTITION 6
#define NODEMCU_SPIFFS1_PARTITION 7
#ifndef LUA_FLASH_STORE
# define LUA_FLASH_STORE 0x0
#endif
#define SPIFFS_FIXED_LOCATION 0x0
#ifndef SPIFFS_MAX_FILESYSTEM_SIZE
# define SPIFFS_MAX_FILESYSTEM_SIZE 0xFFFFFFFF
#endif
//#define SPIFFS_SIZE_1M_BOUNDARY
2018-04-19 17:27:47 +02:00
#define LUA_TASK_PRIO USER_TASK_PRIO_0
#define LUA_PROCESS_LINE_SIG 2
#define LUA_OPTIMIZE_DEBUG 2
#define READLINE_INTERVAL 80
#define STRBUF_DEFAULT_INCREMENT 3
#define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()
2016-03-20 17:54:16 +01:00
#ifdef DEVELOPMENT_TOOLS
#if defined(LUA_CROSS_COMPILER) || !defined(DEVELOPMENT_USE_GDB)
2016-03-20 17:54:16 +01:00
extern void luaL_assertfail(const char *file, int line, const char *message);
#define lua_assert(x) ((x) ? (void) 0 : luaL_assertfail(__FILE__, __LINE__, #x))
#else
extern void luaL_dbgbreak(void);
#define lua_assert(x) ((x) ? (void) 0 : luaL_dbgbreak())
#endif
2016-03-20 17:54:16 +01:00
#endif
#if !defined(LUA_NUMBER_INTEGRAL) && defined (LUA_DWORD_ALIGNED_TVALUES)
#define LUA_PACK_TVALUES
#else
#undef LUA_PACK_TVALUES
#endif
2015-02-04 18:42:14 +01:00
#ifdef DEVELOP_VERSION
#define NODE_DEBUG
#define COAP_DEBUG
#endif /* DEVELOP_VERSION */
#ifdef NODE_DEBUG
#define NODE_DBG dbg_printf
#else
#define NODE_DBG
#endif /* NODE_DEBUG */
#define NODE_ERROR
#ifdef NODE_ERROR
#define NODE_ERR dbg_printf
#else
#define NODE_ERR
#endif /* NODE_ERROR */
// #define GPIO_SAFE_NO_INTR_ENABLE
#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_STRING(x) ICACHE_STRING2(x)
#define ICACHE_STRING2(x) #x
#define ICACHE_RAM_ATTR \
__attribute__((section(".iram0.text." __FILE__ "." ICACHE_STRING(__LINE__))))
#define ICACHE_FLASH_RESERVED_ATTR \
__attribute__((section(".irom.reserved." __FILE__ "." ICACHE_STRING(__LINE__)),\
used,unused,aligned(INTERNAL_FLASH_SECTOR_SIZE)))
#ifdef GPIO_SAFE_NO_INTR_ENABLE
#define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
#else
#define NO_INTR_CODE inline
#endif
#endif /* __USER_CONFIG_H__ */