user_config.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #ifndef __USER_CONFIG_H__
  2. #define __USER_CONFIG_H__
  3. // The firmware supports a range of Flash sizes, though 4 Mbyte seems to be
  4. // the most common currently. NodeMCU builds include a discovery function
  5. // which is enabled by FLASH_AUTOSIZE, but you can override this by commenting
  6. // this out and enabling the explicitly size, e.g. FLASH_4M. Valid sizes are
  7. // FLASH_512K, FLASH_1M, FLASH_2M, FLASH_4M, FLASH_8M, FLASH_16M.
  8. #define FLASH_AUTOSIZE
  9. //#define FLASH_4M
  10. // The firmware now selects a baudrate of 115,200 by default, but the driver
  11. // also includes automatic baud rate detection at start-up. If you want to change
  12. // the default rate then vaild rates are 300, 600, 1200, 2400, 4800, 9600, 19200,
  13. // 31250, 38400, 57600, 74880, 115200, 230400, 256000, 460800 [, 921600, 1843200,
  14. // 368640]. Note that the last 3 rates are not recommended as these might be
  15. // unreliable, but 460800 seems to work well for most USB-serial devices.
  16. #define BIT_RATE_DEFAULT BIT_RATE_115200
  17. //#define BIT_RATE_AUTOBAUD
  18. // Three separate build variants are now supported. The main difference is in the
  19. // processing of numeric data types. If LUA_NUMBER_INTEGRAL is defined, then
  20. // all numeric calculations are done in integer, with divide being an integer
  21. // operations, and decimal fraction constants are illegal. Otherwise all
  22. // numeric operations use floating point, though they are exact for integer
  23. // expressions < 2^53.
  24. // The main advantage of INTEGRAL builds is that the basic internal storage unit,
  25. // the TValue, is 8 bytes long. We have now reduced the size of FP TValues to
  26. // 12 bytes rather than the previous 16 as this gives a material RAM saving with
  27. // no performance loss. However, you can define LUA_DWORD_ALIGNED_TVALUES and
  28. // this will force 16 byte TValues on FP builds.
  29. //#define LUA_NUMBER_INTEGRAL
  30. //#define LUA_DWORD_ALIGNED_TVALUES
  31. // The Lua Flash Store (LFS) allows you to store Lua code in Flash memory and
  32. // the Lua VMS will execute this code directly from flash without needing any
  33. // RAM overhead. If you want to enable LFS then set the following define to
  34. // the size of the store that you need. This can be any multiple of 4kB up to
  35. // a maximum 256Kb.
  36. //#define LUA_FLASH_STORE 0x10000
  37. // By default Lua executes the file init.lua at start up. The following
  38. // define allows you to replace this with an alternative startup. Warning:
  39. // you must protect this execution otherwise you will enter a panic loop;
  40. // the simplest way is to wrap the action in a function invoked by a pcall.
  41. // The example provided executes the LFS module "_init" at startup or fails
  42. // through to the interactive prompt.
  43. //#define LUA_INIT_STRING "pcall(function() node.flashindex'_init'() end)"
  44. // NodeMCU supports two file systems: SPIFFS and FATFS, the first is available
  45. // on all ESP8266 modules. The latter requires extra H/W so is less common.
  46. // If you use SPIFFS then there are a number of options which impact the
  47. // RAM overhead and performance of the file system.
  48. // If you use the spiffsimg tool to create your own FS images on your dev PC
  49. // then we recommend that you fix the location and size of the FS, allowing
  50. // some headroom for rebuilding flash images and LFS. As an alternative to
  51. // fixing the size of the FS, you can force the SPIFFS file system to end on
  52. // the next 1Mb boundary. This is useful for certain OTA scenarios. In
  53. // general, limiting the size of the FS only to what your application needs
  54. // gives the fastest start-up and imaging times.
  55. #define BUILD_SPIFFS
  56. //#define SPIFFS_FIXED_LOCATION 0x100000
  57. //#define SPIFFS_MAX_FILESYSTEM_SIZE 0x20000
  58. //#define SPIFFS_SIZE_1M_BOUNDARY
  59. #define SPIFFS_CACHE 1 // Enable if you use you SPIFFS in R/W mode
  60. #define SPIFFS_MAX_OPEN_FILES 4 // maximum number of open files for SPIFFS
  61. #define FS_OBJ_NAME_LEN 31 // maximum length of a filename
  62. //#define BUILD_FATFS
  63. // The HTTPS stack requires client SSL to be enabled. The SSL buffer size is
  64. // used only for espconn-layer secure connections, and is ignored otherwise.
  65. // Some HTTPS applications require a larger buffer size to work. See
  66. // https://github.com/nodemcu/nodemcu-firmware/issues/1457 for details.
  67. // The SHA2 and MD2 libraries are also optionally used by the crypto functions.
  68. // The SHA1 and MD5 function are implemented in the ROM BIOS. The MD2 and SHA2
  69. // are by firmware code, and can be enabled if you need this functionality.
  70. //#define CLIENT_SSL_ENABLE
  71. //#define MD2_ENABLE
  72. #define SHA2_ENABLE
  73. #define SSL_BUFFER_SIZE 4096
  74. #define SSL_MAX_FRAGMENT_LENGTH_CODE MBEDTLS_SSL_MAX_FRAG_LEN_4096
  75. // GPIO_INTERRUPT_ENABLE needs to be defined if your application uses the
  76. // gpio.trig() or related GPIO interrupt service routine code. Likewise the
  77. // GPIO interrupt hook is requited for a few modules such as rotary. If you
  78. // don't require this functionality, then commenting out these options out
  79. // will remove any associated runtime overhead.
  80. #define GPIO_INTERRUPT_ENABLE
  81. #define GPIO_INTERRUPT_HOOK_ENABLE
  82. // If your application uses the light sleep functions and you wish the
  83. // firmware to manage timer rescheduling over sleeps (the CPU clock is
  84. // suspended so timers get out of sync) then enable the following options
  85. //#define TIMER_SUSPEND_ENABLE
  86. //#define PMSLEEP_ENABLE
  87. // The WiFi module optionally offers an enhanced level of WiFi connection
  88. // management, using internal timer callbacks. Whilst many Lua developers
  89. // prefer to implement equivalent features in Lua, others will prefer the
  90. // Wifi module to do this for them. Uncomment the following to enable
  91. // this functionality. See the relevant WiFi module documentation for
  92. // further details, as the scope of these changes is not obvious.
  93. // Enable the wifi.startsmart() and wifi.stopsmart()
  94. //#define WIFI_SMART_ENABLE
  95. // Enable wifi.sta.config() event callbacks
  96. #define WIFI_SDK_EVENT_MONITOR_ENABLE
  97. // Enable creation on the wifi.eventmon.reason table
  98. #define WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE
  99. // Enable use of the WiFi.monitor sub-module
  100. //#define LUA_USE_MODULES_WIFI_MONITOR
  101. // Whilst the DNS client details can be configured through the WiFi API,
  102. // the defaults can be exposed temporarily during start-up. The following
  103. // WIFI_STA options allow you to configure this in the firmware. If the
  104. // WIFI_STA_HOSTNAME is not defined then the hostname will default to
  105. // to the last 3 octets (6 hexadecimal digits) of MAC address with the
  106. // prefix "NODE-". If it is defined then the hostname must only contain
  107. // alphanumeric characters. If you are imaging multiple modules with this
  108. // firmware then you must also define WIFI_STA_HOSTNAME_APPEND_MAC to
  109. // append the last 3 octets of the MAC address. Note that the total
  110. // Hostname MUST be 32 chars or less.
  111. //#define WIFI_STA_HOSTNAME "NodeMCU"
  112. //#define WIFI_STA_HOSTNAME_APPEND_MAC
  113. // If you use the enduser_setup module, then you can also set the default
  114. // SSID when this module is running in AP mode.
  115. #define ENDUSER_SETUP_AP_SSID "SetupGadget"
  116. // The following sections are only relevent for those developers who are
  117. // developing modules or core Lua changes and configure how extra diagnostics
  118. // are enabled in the firmware. These should only be configured if you are
  119. // building your own custom firmware and have full access to the firmware
  120. // source code.
  121. // Enabling DEVELOPMENT_TOOLS adds the asserts in LUA and also some useful
  122. // extras to the node module. These are silent in normal operation and so can
  123. // be enabled without any harm (except for the code size increase and slight
  124. // slowdown). If you want to use the remote GDB to handle breaks and failed
  125. // assertions then enable the DEVELOPMENT_USE GDB option. A supplimentary
  126. // define DEVELOPMENT_BREAK_ON_STARTUP_PIN allows you to define a GPIO pin,
  127. // which if pulled low at start-up will immediately initiate a GDB session.
  128. // The DEVELOP_VERSION option enables lots of debug output, and is normally
  129. // only used by hardcore developers.
  130. // These options can be enabled globally here or you can alternatively use
  131. // the DEFINES variable in the relevant Makefile to set these on a per
  132. // directory basis. If you do this then you can also set the corresponding
  133. // compile options (-O0 -ggdb) on a per directory as well.
  134. //#define DEVELOPMENT_TOOLS
  135. //#define DEVELOPMENT_USE_GDB
  136. //#define DEVELOPMENT_BREAK_ON_STARTUP_PIN 1
  137. //#define DEVELOP_VERSION
  138. // *** Heareafter, there be demons ***
  139. // The remaining options are advanced configuration options and you should only
  140. // change this if you have tracked the implications through the Firmware sources
  141. // and understand the these.
  142. #define LUA_TASK_PRIO USER_TASK_PRIO_0
  143. #define LUA_PROCESS_LINE_SIG 2
  144. #define LUA_OPTIMIZE_DEBUG 2
  145. #define READLINE_INTERVAL 80
  146. #define STRBUF_DEFAULT_INCREMENT 3
  147. #define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()
  148. #ifdef DEVELOPMENT_TOOLS
  149. #if defined(LUA_CROSS_COMPILER) || !defined(DEVELOPMENT_USE_GDB)
  150. extern void luaL_assertfail(const char *file, int line, const char *message);
  151. #define lua_assert(x) ((x) ? (void) 0 : luaL_assertfail(__FILE__, __LINE__, #x))
  152. #else
  153. extern void luaL_dbgbreak(void);
  154. #define lua_assert(x) ((x) ? (void) 0 : luaL_dbgbreak())
  155. #endif
  156. #endif
  157. #if !defined(LUA_NUMBER_INTEGRAL) && defined (LUA_DWORD_ALIGNED_TVALUES)
  158. #define LUA_PACK_TVALUES
  159. #else
  160. #undef LUA_PACK_TVALUES
  161. #endif
  162. #ifdef DEVELOP_VERSION
  163. #define NODE_DEBUG
  164. #define COAP_DEBUG
  165. #endif /* DEVELOP_VERSION */
  166. #ifdef NODE_DEBUG
  167. #define NODE_DBG dbg_printf
  168. #else
  169. #define NODE_DBG
  170. #endif /* NODE_DEBUG */
  171. #define NODE_ERROR
  172. #ifdef NODE_ERROR
  173. #define NODE_ERR dbg_printf
  174. #else
  175. #define NODE_ERR
  176. #endif /* NODE_ERROR */
  177. // #define GPIO_SAFE_NO_INTR_ENABLE
  178. #define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
  179. #define ICACHE_STORE_ATTR __attribute__((aligned(4)))
  180. #define ICACHE_STRING(x) ICACHE_STRING2(x)
  181. #define ICACHE_STRING2(x) #x
  182. #define ICACHE_RAM_ATTR \
  183. __attribute__((section(".iram0.text." __FILE__ "." ICACHE_STRING(__LINE__))))
  184. #define ICACHE_FLASH_RESERVED_ATTR \
  185. __attribute__((section(".irom.reserved." __FILE__ "." ICACHE_STRING(__LINE__)),\
  186. used,unused,aligned(INTERNAL_FLASH_SECTOR_SIZE)))
  187. #ifdef GPIO_SAFE_NO_INTR_ENABLE
  188. #define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
  189. #else
  190. #define NO_INTR_CODE inline
  191. #endif
  192. #endif /* __USER_CONFIG_H__ */