Commit 16ef39e2 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

idf4: overhaul to new build system, part 1 of 3

Yet to come:
  - part 2: dealing with deprecated and removed APIs
  - part 3: making it actually work again
parent 8e0e0cb3
menu "NodeMCU modules"
menu "Core Lua modules"
config LUA_BUILTIN_STRING
bool "String module"
default "y"
help
Includes the string module (recommended).
config LUA_BUILTIN_TABLE
bool "Table module"
default "y"
help
Includes the table module (recommended).
config LUA_BUILTIN_COROUTINE
bool "Coroutine module"
default "y"
help
Includes the coroutine module (recommended).
config LUA_BUILTIN_MATH
bool "Math module"
default "y"
help
Includes the math module (recommended).
config LUA_BUILTIN_DEBUG
bool "Debug module"
default "n"
help
Includes the debug module.
config LUA_BUILTIN_DEBUG_EXTENDED
depends on LUA_BUILTIN_DEBUG
bool "Extended debug support"
default "n"
help
Includes the full debug module, rather than just getregistry and traceback.
config LUA_BUILTIN_DEBUG_MINIMAL
depends on LUA_BUILTIN_DEBUG
bool
default !LUA_BUILTIN_DEBUG_EXTENDED
endmenu
config NODEMCU_CMODULE_ADC
config NODEMCU_CMODULE_ADC
bool "ADC module"
default "n"
help
Includes the adc module. This module provides access to the
adc1 hardware.
config NODEMCU_CMODULE_BIT
config NODEMCU_CMODULE_BIT
bool "Bit module"
default "n"
help
Includes the bit module. This module provide bit manipulation functions
on Lua numbers.
Includes the bit module. This module provide bit manipulation
functions on Lua numbers.
config NODEMCU_CMODULE_BTHCI
config NODEMCU_CMODULE_BTHCI
bool "BlueTooth HCI interface module"
default "n"
select BT_ENABLED
help
Includes the simple BlueTooth HCI module.
config NODEMCU_CMODULE_CAN
config NODEMCU_CMODULE_CAN
bool "CAN module"
default "n"
help
Includes the can module.
config NODEMCU_CMODULE_CRYPTO
config NODEMCU_CMODULE_CRYPTO
bool "Crypto module"
default "n"
help
Includes the crypto module.
config NODEMCU_CMODULE_DAC
config NODEMCU_CMODULE_DAC
bool "DAC module"
default "n"
help
Includes the dac module.
config NODEMCU_CMODULE_DHT
config NODEMCU_CMODULE_DHT
bool "DHT11/21/22/AM2301/AM2302 module"
default "n"
help
Includes the dht module.
config NODEMCU_CMODULE_ENCODER
config NODEMCU_CMODULE_ENCODER
bool "Encoder module"
default "n"
help
Includes the encoder module. This provides hex and base64 encoding and
decoding functionality.
Includes the encoder module. This provides hex and base64 encoding
and decoding functionality.
config NODEMCU_CMODULE_ETH
config NODEMCU_CMODULE_ETH
bool "Ethernet module"
default "n"
help
Includes the ethernet module.
config NODEMCU_CMODULE_FILE
config NODEMCU_CMODULE_FILE
bool "File module"
default "y"
help
Includes the file module (recommended).
config NODEMCU_CMODULE_GPIO
config NODEMCU_CMODULE_GPIO
bool "GPIO module"
default "y"
help
Includes the GPIO module (recommended).
config NODEMCU_CMODULE_HTTP
config NODEMCU_CMODULE_HTTP
bool "HTTP module"
default "y"
help
Includes the HTTP module (recommended).
config NODEMCU_CMODULE_I2C
config NODEMCU_CMODULE_I2C
bool "I2C module"
default "y"
help
Includes the I2C module (recommended).
config NODEMCU_CMODULE_I2S
config NODEMCU_CMODULE_I2S
bool "I2S module"
default "n"
help
Includes the I2S module.
config NODEMCU_CMODULE_LEDC
config NODEMCU_CMODULE_LEDC
bool "LEDC module"
default "n"
help
Includes the LEDC module.
config NODEMCU_CMODULE_MQTT
config NODEMCU_CMODULE_MQTT
bool "MQTT module"
default "n"
help
Includes the MQTT module.
config NODEMCU_CMODULE_NET
config NODEMCU_CMODULE_NET
bool "Net module"
default "y"
help
Includes the net module (recommended).
config NODEMCU_CMODULE_NODE
config NODEMCU_CMODULE_NODE
bool "Node module"
default "y"
help
Includes the node module (recommended).
config NODEMCU_CMODULE_OW
config NODEMCU_CMODULE_OW
bool "1-Wire module"
default "y"
help
Includes the 1-Wire (ow) module (recommended).
config NODEMCU_CMODULE_OTAUPGRADE
config NODEMCU_CMODULE_OTAUPGRADE
bool "Over-The-Air upgrade module"
default "n"
help
Includes the over-the-air firmware upgrade module. Use of this requires
a partition table with at least two OTA partitions, plus the OTA data
partition. See the IDF documentation for details.
Includes the over-the-air firmware upgrade module. Use of this
requires a partition table with at least two OTA partitions, plus
the OTA data partition. See the IDF documentation for details.
config NODEMCU_CMODULE_PULSECNT
config NODEMCU_CMODULE_PULSECNT
bool "Pulse counter module"
default "n"
help
Includes the pulse counter module to use ESP32's built-in pulse counting hardware.
Includes the pulse counter module to use ESP32's built-in pulse
counting hardware.
config NODEMCU_CMODULE_QRCODEGEN
config NODEMCU_CMODULE_QRCODEGEN
bool "QR Code Generator module"
default "n"
help
Includes the QR Code Generator from
https://www.nayuki.io/page/qr-code-generator-library
config NODEMCU_CMODULE_SDMMC
config NODEMCU_CMODULE_SDMMC
bool "SD-MMC module"
default "n"
help
Includes the sdmmc module.
config NODEMCU_CMODULE_SIGMA_DELTA
config NODEMCU_CMODULE_SIGMA_DELTA
bool "Sigma-Delta module"
default "n"
help
Includes the sigma_delta module. This module provides access to the
sigma-delta hardware.
Includes the sigma_delta module. This module provides access to
the sigma-delta hardware.
config NODEMCU_CMODULE_SJSON
config NODEMCU_CMODULE_SJSON
bool "SJSON module"
default "n"
help
Includes the sjson module.
config NODEMCU_CMODULE_SODIUM
config NODEMCU_CMODULE_SODIUM
bool "Sodium module"
default "n"
help
Includes the libsodium crypto module.
config NODEMCU_CMODULE_SPI
config NODEMCU_CMODULE_SPI
bool "SPI module"
default "n"
help
Includes the spi module.
config NODEMCU_CMODULE_STRUCT
config NODEMCU_CMODULE_STRUCT
bool "Struct module"
default "n"
help
Includes the struct module. This module provides [un]packing of raw
byte strings into Lua values and vice versa.
Includes the struct module. This module provides [un]packing of
raw byte strings into Lua values and vice versa.
config NODEMCU_CMODULE_TMR
config NODEMCU_CMODULE_TMR
bool "Timer module"
default "y"
help
Includes the timer module (recommended).
config NODEMCU_CMODULE_TOUCH
config NODEMCU_CMODULE_TOUCH
bool "Touch module"
default "n"
help
Includes the touch module to use ESP32's built-in touch sensor hardware.
Includes the touch module to use ESP32's built-in touch sensor
hardware.
config NODEMCU_CMODULE_U8G2
config NODEMCU_CMODULE_U8G2
bool "U8G2 module"
default "n"
help
Includes the u8g2 module.
source "$PROJECT_PATH/components/u8g2/u8g2.kconfig"
rsource "../u8g2/Kconfig.u8g2"
config NODEMCU_CMODULE_UCG
config NODEMCU_CMODULE_UCG
bool "UCG module"
default "n"
select NODEMCU_CMODULE_SPI
help
Includes the ucg module.
source "$PROJECT_PATH/components/ucg/ucg.kconfig"
rsource "../ucg/Kconfig.ucg"
config NODEMCU_CMODULE_WIFI
config NODEMCU_CMODULE_WIFI
bool "WiFi module"
default "y"
help
Includes the WiFi module (recommended).
config NODEMCU_CMODULE_WS2812
config NODEMCU_CMODULE_WS2812
bool "WS2812 module"
default "n"
help
Includes the ws2812 module.
config NODEMCU_CMODULE_TIME
config NODEMCU_CMODULE_TIME
bool "Time module"
default "n"
help
......
# Match up all the module source files with their corresponding Kconfig
# option in the form NODEMCU_CMODULE_<modname> and if enabled, add a
# "-u <modname>_module_selected1" option to force the linker to include
# the module. See components/core/include/module.h for further details on
# how this works.
-include $(PROJECT_PATH)/build/include/config/auto.conf
include $(PROJECT_PATH)/components/modules/uppercase.mk
ifneq (4.0, $(firstword $(sort $(MAKE_VERSION) 4.0)))
# make versions below 4.0 will fail on the uppercase function used in
# the exapnsion of MODULE_NAMES.
$(error GNU make version 4.0 or above required)
endif
MODULE_NAMES:=$(call uppercase,$(patsubst $(COMPONENT_PATH)/%.c,%,$(wildcard $(COMPONENT_PATH)/*.c)))
FORCE_LINK:=$(foreach mod,$(MODULE_NAMES),$(if $(CONFIG_NODEMCU_CMODULE_$(mod)), -u $(mod)_module_selected1))
COMPONENT_ADD_LDFLAGS=$(FORCE_LINK) -lmodules $(if $(CONFIG_NODEMCU_CMODULE_BTHCI),-lbtdm_app)
# These are disabled by default in the IDF, so switch them back on
CFLAGS += \
-Werror=unused-function \
-Werror=unused-but-set-variable \
-Werror=unused-variable \
COMPONENT_EXTRA_CLEAN := u8g2_fonts.h u8g2_displays.h ucg_config.h
u8g2.o: u8g2_fonts.h u8g2_displays.h
u8g2_fonts.h: $(BUILD_DIR_BASE)/include/sdkconfig.h
perl -w $(PROJECT_PATH)/tools/u8g2_config_fonts.pl < $^ > $@
u8g2_displays.h: $(BUILD_DIR_BASE)/include/sdkconfig.h
perl -w $(PROJECT_PATH)/tools/u8g2_config_displays.pl < $^ > $@
ucg.o: ucg_config.h
ucg_config.h: $(BUILD_DIR_BASE)/include/sdkconfig.h
perl -w $(PROJECT_PATH)/tools/ucg_config.pl < $^ > $@
......@@ -147,7 +147,7 @@ static int file_obj_free( lua_State *L )
return 0;
}
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
// Lua: format()
static int file_format( lua_State* L )
{
......@@ -187,7 +187,7 @@ static int file_open( lua_State* L )
const char *fname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( fname );
luaL_argcheck(L, strlen(basename) <= CONFIG_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
luaL_argcheck(L, strlen(basename) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
const char *mode = luaL_optstring(L, 2, "r");
......@@ -265,7 +265,7 @@ static int file_exists( lua_State* L )
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( fname );
luaL_argcheck(L, strlen(basename) <= CONFIG_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
luaL_argcheck(L, strlen(basename) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
struct vfs_stat stat;
lua_pushboolean(L, vfs_stat((char *)fname, &stat) == VFS_RES_OK ? 1 : 0);
......@@ -279,7 +279,7 @@ static int file_remove( lua_State* L )
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( fname );
luaL_argcheck(L, strlen(basename) <= CONFIG_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
luaL_argcheck(L, strlen(basename) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
vfs_remove((char *)fname);
return 0;
}
......@@ -305,11 +305,11 @@ static int file_rename( lua_State* L )
const char *oldname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( oldname );
luaL_argcheck(L, strlen(basename) <= CONFIG_FS_OBJ_NAME_LEN && strlen(oldname) == len, 1, "filename invalid");
luaL_argcheck(L, strlen(basename) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(oldname) == len, 1, "filename invalid");
const char *newname = luaL_checklstring( L, 2, &len );
basename = vfs_basename( newname );
luaL_argcheck(L, strlen(basename) <= CONFIG_FS_OBJ_NAME_LEN && strlen(newname) == len, 2, "filename invalid");
luaL_argcheck(L, strlen(basename) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(newname) == len, 2, "filename invalid");
if(0 <= vfs_rename( oldname, newname )){
lua_pushboolean(L, 1);
......@@ -324,7 +324,7 @@ static int file_stat( lua_State* L )
{
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
luaL_argcheck( L, strlen(fname) <= CONFIG_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid" );
luaL_argcheck( L, strlen(fname) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid" );
struct vfs_stat stat;
if (vfs_stat( (char *)fname, &stat ) != VFS_RES_OK) {
......@@ -539,7 +539,7 @@ typedef struct {
vfs_vol *vol;
} volume_type;
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
// Lua: success = file.chdir("/SD0/")
static int file_chdir( lua_State *L )
{
......@@ -571,7 +571,7 @@ LROT_BEGIN(file)
LROT_FUNCENTRY( writeline, file_writeline )
LROT_FUNCENTRY( read, file_read )
LROT_FUNCENTRY( readline, file_readline )
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
LROT_FUNCENTRY( format, file_format )
LROT_FUNCENTRY( fscfg, file_fscfg )
#endif
......@@ -583,7 +583,7 @@ LROT_BEGIN(file)
LROT_FUNCENTRY( fsinfo, file_fsinfo )
LROT_FUNCENTRY( on, file_on )
LROT_FUNCENTRY( stat, file_stat )
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
LROT_FUNCENTRY( chdir, file_chdir )
#endif
LROT_END(file, NULL, 0)
......
......@@ -198,8 +198,8 @@ static int node_i2s_start( lua_State *L )
if (i2s_config.mode & I2S_MODE_TX) {
// prepare TX task
char pcName[8];
snprintf( pcName, 8, "I2S_tx_%d", i2s_id );
char pcName[20];
snprintf( pcName, sizeof(pcName), "I2S_tx_%d", i2s_id );
pcName[7] = '\0';
if ((is->tx.queue = xQueueCreate( 2, sizeof( i2s_tx_data_t ) )) == NULL)
return luaL_error( L, "cannot create queue" );
......@@ -208,8 +208,8 @@ static int node_i2s_start( lua_State *L )
if (i2s_config.mode & I2S_MODE_RX) {
// prepare RX task
char pcName[8];
snprintf( pcName, 8, "I2S_rx_%d", i2s_id );
char pcName[20];
snprintf( pcName, sizeof(pcName), "I2S_rx_%d", i2s_id );
pcName[7] = '\0';
xTaskCreate(task_I2S_rx, pcName, 1024, (void *)i2s_id, ESP_TASK_MAIN_PRIO + 1, &is->rx.taskHandle);
}
......
......@@ -150,8 +150,6 @@ typedef struct lnet_userdata {
int cb_sent_ref;
// Only for TCP:
bool connecting;
int hold;
size_t num_held;
size_t num_send;
int cb_connect_ref;
int cb_disconnect_ref;
......@@ -250,8 +248,6 @@ lnet_userdata *net_create( lua_State *L, enum net_type type ) {
ud->client.cb_connect_ref = LUA_NOREF;
ud->client.cb_reconnect_ref = LUA_NOREF;
ud->client.cb_disconnect_ref = LUA_NOREF;
ud->client.hold = 0;
ud->client.num_held = 0;
ud->client.connecting = false;
case TYPE_UDP_SOCKET:
ud->client.wait_dns = 0;
......@@ -497,7 +493,6 @@ static int net_listen( lua_State *L ) {
if (!ud->netconn)
return luaL_error(L, "cannot allocate netconn");
netconn_set_nonblocking(ud->netconn, 1);
netconn_set_noautorecved(ud->netconn, 1);
err = netconn_bind(ud->netconn, &addr, port);
if (err == ERR_OK) {
......@@ -509,7 +504,6 @@ static int net_listen( lua_State *L ) {
if (!ud->netconn)
return luaL_error(L, "cannot allocate netconn");
netconn_set_nonblocking(ud->netconn, 1);
netconn_set_noautorecved(ud->netconn, 1);
err = netconn_bind(ud->netconn, &addr, port);
break;
......@@ -557,7 +551,6 @@ static int net_connect( lua_State *L ) {
if (!ud->netconn)
return luaL_error(L, "cannot allocate netconn");
netconn_set_nonblocking(ud->netconn, 1);
netconn_set_noautorecved(ud->netconn, 1);
ud->port = port;
return lnet_socket_resolve_dns(L, ud, domain, true);
......@@ -680,39 +673,6 @@ static int net_send( lua_State *L ) {
return lwip_lua_checkerr(L, err);
}
// Lua: client:hold()
static int net_hold( lua_State *L ) {
lnet_userdata *ud = net_get_udata(L);
if (!ud || ud->type != TYPE_TCP_CLIENT)
return luaL_error(L, "invalid user data");
if (!ud->client.hold && ud->netconn)
{
if (ud->client.hold == 0)
{
ud->client.hold = 1;
ud->client.num_held = 0;
}
}
return 0;
}
// Lua: client:unhold()
static int net_unhold( lua_State *L ) {
lnet_userdata *ud = net_get_udata(L);
if (!ud || ud->type != TYPE_TCP_CLIENT)
return luaL_error(L, "invalid user data");
if (ud->client.hold && ud->netconn)
{
if (ud->client.hold != 0)
{
ud->client.hold = 0;
netconn_recved(ud->netconn, ud->client.num_held);
ud->client.num_held = 0;
}
}
return 0;
}
// Lua: client/socket:dns(domain, callback(socket, addr))
static int net_dns( lua_State *L ) {
lnet_userdata *ud = net_get_udata(L);
......@@ -1082,17 +1042,8 @@ static void lrecv_cb (lua_State *L, lnet_userdata *ud) {
}
} while (netbuf_next(p) != -1);
if (p) {
if (p)
netbuf_delete(p);
if (ud->type == TYPE_TCP_CLIENT) {
if (ud->client.hold) {
ud->client.num_held += len;
} else {
netconn_recved(ud->netconn, len);
}
}
}
}
......@@ -1110,7 +1061,6 @@ static void laccept_cb (lua_State *L, lnet_userdata *ud) {
if (err == ERR_OK) {
nud->netconn = newconn;
netconn_set_nonblocking(nud->netconn, 1);
netconn_set_noautorecved(nud->netconn, 1);
nud->netconn->pcb.tcp->so_options |= SOF_KEEPALIVE;
nud->netconn->pcb.tcp->keep_idle = ud->server.timeout * 1000;
nud->netconn->pcb.tcp->keep_cnt = 1;
......@@ -1168,8 +1118,6 @@ LROT_BEGIN(net_tcpsocket)
LROT_FUNCENTRY( close, net_close )
LROT_FUNCENTRY( on, net_on )
LROT_FUNCENTRY( send, net_send )
LROT_FUNCENTRY( hold, net_hold )
LROT_FUNCENTRY( unhold, net_unhold )
LROT_FUNCENTRY( dns, net_dns )
LROT_FUNCENTRY( getpeer, net_getpeer )
LROT_FUNCENTRY( getaddr, net_getaddr )
......
......@@ -560,7 +560,7 @@ static int node_compile( lua_State* L )
size_t len;
const char *fname = luaL_checklstring( L, 1, &len );
const char *basename = vfs_basename( fname );
luaL_argcheck(L, strlen(basename) <= CONFIG_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
luaL_argcheck(L, strlen(basename) <= CONFIG_NODEMCU_FS_OBJ_NAME_LEN && strlen(fname) == len, 1, "filename invalid");
char *output = luaM_malloc( L, len+1 );
strcpy(output, fname);
......
......@@ -13,7 +13,7 @@
lua_pushinteger (L, val); \
lua_setfield (L, -2, key);
void inline time_tmToTable(lua_State *L, struct tm *date)
static void inline time_tmToTable(lua_State *L, struct tm *date)
{
lua_createtable (L, 0, 9);
......
......@@ -27,7 +27,7 @@ CONDITIONS OF ANY KIND, either express or implied.
#include "esp_log.h"
#include "lextra.h"
#include "soc/rtc_periph.h"
#include "soc/touch_channel.h"
#include "soc/touch_sensor_periph.h"
#include <string.h>
......
idf_component_register(
SRCS "dht.c" "flash_api.c" "flash_fs.c" "onewire.c" "platform.c"
"platform_flash.c" "platform_partition.c" "platform_rmt.c"
"u8x8_nodemcu_hal.c" "ucg_nodemcu_hal.c" "vfs.c" "wdt.c" "ws2812.c"
INCLUDE_DIRS "include"
REQUIRES "spiffs" "u8g2" "ucg" "driver_i2c"
PRIV_REQUIRES "bootloader_support" "driver_console" "lua" "esp32"
)
menu "Platform config"
menu "NodeMCU platform config"
choice CONSOLE_BIT_RATE
choice NODEMCU_CONSOLE_BIT_RATE
prompt "UART console default bit rate"
default CONSOLE_BIT_RATE_115200
default NODEMCU_CONSOLE_BIT_RATE_115200
help
Configure the default bit rate for the UART console.
The resulting UART setting will be xxx-8N1, where xxx represents the
chosen bit rate.
config CONSOLE_BIT_RATE_300
The resulting UART setting will be xxx-8N1, where xxx represents
the chosen bit rate.
config NODEMCU_CONSOLE_BIT_RATE_300
bool "300"
config CONSOLE_BIT_RATE_600
config NODEMCU_CONSOLE_BIT_RATE_600
bool "600"
config CONSOLE_BIT_RATE_1200
config NODEMCU_CONSOLE_BIT_RATE_1200
bool "1200"
config CONSOLE_BIT_RATE_2400
config NODEMCU_CONSOLE_BIT_RATE_2400
bool "2400"
config CONSOLE_BIT_RATE_4800
config NODEMCU_CONSOLE_BIT_RATE_4800
bool "4800"
config CONSOLE_BIT_RATE_9600
config NODEMCU_CONSOLE_BIT_RATE_9600
bool "9600"
config CONSOLE_BIT_RATE_19200
config NODEMCU_CONSOLE_BIT_RATE_19200
bool "19200"
config CONSOLE_BIT_RATE_38400
config NODEMCU_CONSOLE_BIT_RATE_38400
bool "38400"
config CONSOLE_BIT_RATE_57600
config NODEMCU_CONSOLE_BIT_RATE_57600
bool "57600"
config CONSOLE_BIT_RATE_74880
config NODEMCU_CONSOLE_BIT_RATE_74880
bool "74880"
config CONSOLE_BIT_RATE_115200
config NODEMCU_CONSOLE_BIT_RATE_115200
bool "115200"
config CONSOLE_BIT_RATE_230400
config NODEMCU_CONSOLE_BIT_RATE_230400
bool "230400"
config CONSOLE_BIT_RATE_460800
config NODEMCU_CONSOLE_BIT_RATE_460800
bool "460800"
config CONSOLE_BIT_RATE_921600
config NODEMCU_CONSOLE_BIT_RATE_921600
bool "921600"
config CONSOLE_BIT_RATE_1843200
config NODEMCU_CONSOLE_BIT_RATE_1843200
bool "1843200"
config CONSOLE_BIT_RATE_3683400
config NODEMCU_CONSOLE_BIT_RATE_3683400
bool "3683400"
endchoice
endchoice
config CONSOLE_BIT_RATE
config NODEMCU_CONSOLE_BIT_RATE
int
default 300 if CONSOLE_BIT_RATE_300
default 600 if CONSOLE_BIT_RATE_600
default 1200 if CONSOLE_BIT_RATE_1200
default 2400 if CONSOLE_BIT_RATE_2400
default 4800 if CONSOLE_BIT_RATE_4800
default 9600 if CONSOLE_BIT_RATE_9600
default 19200 if CONSOLE_BIT_RATE_19200
default 38400 if CONSOLE_BIT_RATE_38400
default 57600 if CONSOLE_BIT_RATE_57600
default 74880 if CONSOLE_BIT_RATE_74880
default 115200 if CONSOLE_BIT_RATE_115200
default 230400 if CONSOLE_BIT_RATE_230400
default 460800 if CONSOLE_BIT_RATE_460800
default 921600 if CONSOLE_BIT_RATE_921600
default 1843200 if CONSOLE_BIT_RATE_1843200
default 3683400 if CONSOLE_BIT_RATE_3683400
config CONSOLE_BIT_RATE_AUTO
default 300 if NODEMCU_CONSOLE_BIT_RATE_300
default 600 if NODEMCU_CONSOLE_BIT_RATE_600
default 1200 if NODEMCU_CONSOLE_BIT_RATE_1200
default 2400 if NODEMCU_CONSOLE_BIT_RATE_2400
default 4800 if NODEMCU_CONSOLE_BIT_RATE_4800
default 9600 if NODEMCU_CONSOLE_BIT_RATE_9600
default 19200 if NODEMCU_CONSOLE_BIT_RATE_19200
default 38400 if NODEMCU_CONSOLE_BIT_RATE_38400
default 57600 if NODEMCU_CONSOLE_BIT_RATE_57600
default 74880 if NODEMCU_CONSOLE_BIT_RATE_74880
default 115200 if NODEMCU_CONSOLE_BIT_RATE_115200
default 230400 if NODEMCU_CONSOLE_BIT_RATE_230400
default 460800 if NODEMCU_CONSOLE_BIT_RATE_460800
default 921600 if NODEMCU_CONSOLE_BIT_RATE_921600
default 1843200 if NODEMCU_CONSOLE_BIT_RATE_1843200
default 3683400 if NODEMCU_CONSOLE_BIT_RATE_3683400
config NODEMCU_CONSOLE_BIT_RATE_AUTO
bool "UART console auto-baud detection"
default "y"
help
......@@ -74,51 +74,59 @@ config CONSOLE_BIT_RATE_AUTO
If you are doing advanced things with the console, you may want
to disable this feature.
config NODE_DEBUG
config NODEMCU_NODE_DEBUG
bool "Enable NODE_DBG() output"
default "n"
help
Enable debugging output via NODE_DBG(). This is VERY chatty.
For development/debugging use only.
config NODE_ERR
config NODEMCU_NODE_ERR
bool "Enable NODE_ERR() output"
default "y"
help
Enable error reporting via NODE_ERR().
It is recommended to leave this enabled - if it ever produces output,
something has gone seriously wrong and you probably want to know about
it.
It is recommended to leave this enabled - if it ever produces
output, something has gone seriously wrong and you probably want
to know about it.
config FS_OBJ_NAME_LEN
config NODEMCU_FS_OBJ_NAME_LEN
int "Make filesystem object name length"
default 31
help
Maximum name of filesystem objects (files, directories).
config SPIFFS_MAX_OPEN_FILES
config NODEMCU_SPIFFS_MAX_OPEN_FILES
int "Maximum number of open files for SPIFFS"
default 4
help
Maximum number of open files for SPIFFS
# I don't think we can deal without SPIFFS at this point, so always on for now
config BUILD_SPIFFS
config NODEMCU_BUILD_SPIFFS
bool
default "y"
# I don't think we can deal without SPIFFS at this point, so always on for now
config LUA_EMBED_LFS
config NODEMCU_BUILD_FATFS
bool "Support for FAT filesystems"
default "n"
select NODEMCU_CMODULE_SDMMC
help
Include support for accessing FAT filesystems on SD cards.
config NODEMCU_EMBED_LFS
bool "Embed LFS as part of the NodeMCU firmware"
default "n"
help
The LFS (Lua Flash Store) normally has its own partition entry, and can
can be replaced at will. Optionally, the LFS can instead be permanently
embedded into the NodeMCU firmware image itself. This can be useful for
scenarios where over-the-air firmware upgrades are needed to also
bundle Lua code. The major downside is that once embedded, the LFS can
no longer be changed, as doing so would break the firmware checksums
and signatures and leave the system unable to boot.
The LFS (Lua Flash Store) normally has its own partition entry,
and can can be replaced at will. Optionally, the LFS can instead
be permanently embedded into the NodeMCU firmware image itself.
This can be useful for scenarios where over-the-air firmware
upgrades are needed to also bundle Lua code. The major downside
is that once embedded, the LFS can no longer be changed, as
doing so would break the firmware checksums and signatures and
leave the system unable to boot.
The default option is to not embed the LFS, in which case LFS is
looked for in a partition of type 0xC2 and subtype 0x01.
......@@ -126,19 +134,12 @@ config LUA_EMBED_LFS
To embed LFS data into firmware, use:
./tools/embed_lfs.sh /path/to/file1.lua /path/to/file2.lua ...
config LUA_EMBEDDED_FLASH_STORE
config NODEMCU_EMBEDDED_LFS_SIZE
hex "Embedded LUA Flash Store size"
default 0x0
depends on LUA_EMBED_LFS
depends on NODEMCU_EMBED_LFS
help
Embedded LUA Flash Store size. Set to zero to use an LFS partition instead
of embedding the LFS within the NodeMCU firmware itself.
config BUILD_FATFS
bool "Support for FAT filesystems"
default "n"
select NODEMCU_CMODULE_SDMMC
help
Include support for accessing FAT filesystems on SD cards.
Embedded LUA Flash Store size. Set to zero to use an LFS partition
instead of embedding the LFS within the NodeMCU firmware itself.
endmenu
COMPONENT_ADD_INCLUDEDIRS:=include
# for u8x8
CPPFLAGS+=-DU8X8_USE_PINS -DU8X8_WITH_USER_PTR
# for ucg
CPPFLAGS+=-DUSE_PIN_LIST
......@@ -7,7 +7,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "rom/spi_flash.h"
#include "esp32/rom/spi_flash.h"
#include "platform_wdt.h"
......
......@@ -23,13 +23,13 @@ enum
};
#if CONFIG_NODE_DEBUG
#if CONFIG_NODEMCU_NODE_DEBUG
# define NODE_DBG printf
#else
# define NODE_DBG(...) do{}while(0)
#endif
#if CONFIG_NODE_ERR
#if CONFIG_NODEMCU_NODE_ERR
# define NODE_ERR printf
#else
# define NODE_ERR(...) do{}while(0)
......
......@@ -18,7 +18,7 @@
// vfs_close - close file descriptor and free memory
// fd: file descriptor
// Returns: VFS_RES_OK or negative value in case of error
inline int32_t vfs_close( int fd ) {
static inline int32_t vfs_close( int fd ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->close( f ) : VFS_RES_ERR;
}
......@@ -28,7 +28,7 @@ inline int32_t vfs_close( int fd ) {
// ptr: destination data buffer
// len: requested length
// Returns: Number of bytes read, or VFS_RES_ERR in case of error
inline int32_t vfs_read( int fd, void *ptr, size_t len ) {
static inline int32_t vfs_read( int fd, void *ptr, size_t len ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->read( f, ptr, len ) : VFS_RES_ERR;
}
......@@ -38,7 +38,7 @@ inline int32_t vfs_read( int fd, void *ptr, size_t len ) {
// ptr: source data buffer
// len: requested length
// Returns: Number of bytes written, or VFS_RES_ERR in case of error
inline int32_t vfs_write( int fd, const void *ptr, size_t len ) {
static inline int32_t vfs_write( int fd, const void *ptr, size_t len ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->write( f, ptr, len ) : VFS_RES_ERR;
}
......@@ -54,7 +54,7 @@ int vfs_ungetc( int c, int fd );
// VFS_SEEK_CUR - set pointer to current position + off
// VFS_SEEK_END - set pointer to end of file + off
// Returns: New position, or VFS_RES_ERR in case of error
inline int32_t vfs_lseek( int fd, int32_t off, int whence ) {
static inline int32_t vfs_lseek( int fd, int32_t off, int whence ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->lseek( f, off, whence ) : VFS_RES_ERR;
}
......@@ -62,7 +62,7 @@ inline int32_t vfs_lseek( int fd, int32_t off, int whence ) {
// vfs_eof - test for end-of-file
// fd: file descriptor
// Returns: 0 if not at end, != 0 if end of file
inline int32_t vfs_eof( int fd ) {
static inline int32_t vfs_eof( int fd ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->eof( f ) : VFS_RES_ERR;
}
......@@ -70,7 +70,7 @@ inline int32_t vfs_eof( int fd ) {
// vfs_tell - get read/write position
// fd: file descriptor
// Returns: Current position
inline int32_t vfs_tell( int fd ) {
static inline int32_t vfs_tell( int fd ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->tell( f ) : VFS_RES_ERR;
}
......@@ -78,7 +78,7 @@ inline int32_t vfs_tell( int fd ) {
// vfs_flush - flush write cache to file
// fd: file descriptor
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
inline int32_t vfs_flush( int fd ) {
static inline int32_t vfs_flush( int fd ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->flush( f ) : VFS_RES_ERR;
}
......@@ -86,7 +86,7 @@ inline int32_t vfs_flush( int fd ) {
// vfs_size - get current file size
// fd: file descriptor
// Returns: File size
inline uint32_t vfs_size( int fd ) {
static inline uint32_t vfs_size( int fd ) {
vfs_file *f = (vfs_file *)fd;
return f ? f->fns->size( f ) : 0;
}
......@@ -103,13 +103,13 @@ int32_t vfs_ferrno( int fd );
// vfs_closedir - close directory descriptor and free memory
// dd: dir descriptor
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
inline int32_t vfs_closedir( vfs_dir *dd ) { return dd->fns->close( dd ); }
static inline int32_t vfs_closedir( vfs_dir *dd ) { return dd->fns->close( dd ); }
// vfs_readdir - read next directory item
// dd: dir descriptor
// buf: pre-allocated stat structure to be filled in
// Returns: VFS_RES_OK if next item found, otherwise VFS_RES_ERR
inline int32_t vfs_readdir( vfs_dir *dd, struct vfs_stat *buf ) { return dd->fns->readdir( dd, buf ); }
static inline int32_t vfs_readdir( vfs_dir *dd, struct vfs_stat *buf ) { return dd->fns->readdir( dd, buf ); }
// ---------------------------------------------------------------------------
// volume functions
......@@ -118,7 +118,7 @@ inline int32_t vfs_readdir( vfs_dir *dd, struct vfs_stat *buf ) { return dd->fns
// vfs_umount - unmount logical drive and free memory
// vol: volume object
// Returns: VFS_RES_OK, or VFS_RES_ERR in case of error
inline int32_t vfs_umount( vfs_vol *vol ) { return vol->fns->umount( vol ); }
static inline int32_t vfs_umount( vfs_vol *vol ) { return vol->fns->umount( vol ); }
// ---------------------------------------------------------------------------
// file system functions
......
......@@ -50,7 +50,7 @@ typedef const struct vfs_file vfs_file;
// stat data
struct vfs_stat {
uint32_t size;
char name[CONFIG_FS_OBJ_NAME_LEN+1];
char name[CONFIG_NODEMCU_FS_OBJ_NAME_LEN+1];
struct vfs_time tm;
uint8_t tm_valid;
uint8_t is_dir;
......
......@@ -248,10 +248,10 @@ uint32_t platform_uart_setup( unsigned id, uint32_t baud, int databits, int pari
}
uart_param_config(id, &cfg);
uart_set_pin(id, pins->tx_pin, pins->rx_pin, pins->rts_pin, pins->cts_pin);
uart_set_line_inverse(id, (pins->tx_inverse? UART_INVERSE_TXD : UART_INVERSE_DISABLE)
| (pins->rx_inverse? UART_INVERSE_RXD : UART_INVERSE_DISABLE)
| (pins->rts_inverse? UART_INVERSE_RTS : UART_INVERSE_DISABLE)
| (pins->cts_inverse? UART_INVERSE_CTS : UART_INVERSE_DISABLE)
uart_set_line_inverse(id, (pins->tx_inverse? UART_TXD_INV_M : 0)
| (pins->rx_inverse? UART_RXD_INV_M : 0)
| (pins->rts_inverse? UART_RTS_INV_M : 0)
| (pins->cts_inverse? UART_CTS_INV_M : 0)
);
if(uart_event_task_id == 0) uart_event_task_id = task_get_id( uart_event_task );
......
......@@ -35,7 +35,6 @@
#include <string.h>
#include <stdlib.h>
#include "esp_flash_data_types.h"
#include "esp_flash_partitions.h"
#include "esp_spi_flash.h"
......
if(DEFINED ENV{BUILD_DATE})
idf_build_set_property(COMPILE_OPTIONS -DBUILD_DATE="$ENV{BUILD_DATE}" APPEND)
endif()
#include <string.h>
#include "rom/ets_sys.h"
#include "esp32/rom/ets_sys.h"
#include "driver/gpio.h"
#include "driver/i2c.h"
......
......@@ -76,13 +76,13 @@ vfs_vol *vfs_mount( const char *name, int num )
const char *normname = normalize_path( name );
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return fs_fns->mount( outname, num );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
vfs_vol *r = fs_fns->mount( outname, num );
free( outname );
......@@ -99,13 +99,13 @@ int vfs_open( const char *name, const char *mode )
const char *normname = normalize_path( name );
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return (int)fs_fns->open( outname, mode );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
int r = (int)fs_fns->open( outname, mode );
free( outname );
......@@ -122,13 +122,13 @@ vfs_dir *vfs_opendir( const char *name )
const char *normname = normalize_path( name );
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return fs_fns->opendir( outname );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
vfs_dir *r = fs_fns->opendir( outname );
free( outname );
......@@ -145,13 +145,13 @@ int32_t vfs_stat( const char *name, struct vfs_stat *buf )
const char *normname = normalize_path( name );
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return fs_fns->stat( outname, buf );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
int32_t r = fs_fns->stat( outname, buf );
free( outname );
......@@ -168,13 +168,13 @@ int32_t vfs_remove( const char *name )
const char *normname = normalize_path( name );
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return fs_fns->remove( outname );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
int32_t r = fs_fns->remove( outname );
free( outname );
......@@ -192,7 +192,7 @@ int32_t vfs_rename( const char *oldname, const char *newname )
const char *normnewname = normalize_path( newname );
char *oldoutname, *newoutname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if (myspiffs_realm( normoldname, &oldoutname, false )) {
if ((fs_fns = myspiffs_realm( normnewname, &newoutname, false ))) {
return fs_fns->rename( oldoutname, newoutname );
......@@ -200,7 +200,7 @@ int32_t vfs_rename( const char *oldname, const char *newname )
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if (myfatfs_realm( normoldname, &oldoutname, false )) {
if ((fs_fns = myfatfs_realm( normnewname, &newoutname, false ))) {
int32_t r = fs_fns->rename( oldoutname, newoutname );
......@@ -219,12 +219,12 @@ int32_t vfs_mkdir( const char *name )
{
vfs_fs_fns *fs_fns;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
// not supported
(void)fs_fns;
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
const char *normname = normalize_path( name );
char *outname;
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
......@@ -246,13 +246,13 @@ int32_t vfs_fsinfo( const char *name, uint32_t *total, uint32_t *used )
const char *normname = normalize_path( name );
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return fs_fns->fsinfo( total, used );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
free( outname );
return fs_fns->fsinfo( total, used );
......@@ -267,13 +267,13 @@ int32_t vfs_fscfg( const char *name, uint32_t *phys_addr, uint32_t *phys_size)
vfs_fs_fns *fs_fns;
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( "/FLASH", &outname, false ))) {
return fs_fns->fscfg( phys_addr, phys_size );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
// not supported
#endif
......@@ -286,13 +286,13 @@ int32_t vfs_format( void )
vfs_fs_fns *fs_fns;
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( "/FLASH", &outname, false ))) {
return fs_fns->format();
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
// not supported
#endif
......@@ -326,7 +326,7 @@ int32_t vfs_chdir( const char *path )
}
#endif
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normpath, &outname, true ))) {
// our SPIFFS integration doesn't support directories
if (strlen( outname ) == 0) {
......@@ -335,7 +335,7 @@ int32_t vfs_chdir( const char *path )
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normpath, &outname, true ))) {
if (strchr( outname, ':' )) {
// need to set FatFS' default drive
......@@ -361,13 +361,13 @@ int32_t vfs_errno( const char *name )
if (!name) name = ""; // current drive
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
return fs_fns->ferrno( );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
int32_t r = fs_fns->ferrno( );
free( outname );
......@@ -389,13 +389,13 @@ int32_t vfs_ferrno( int fd )
const char *name = ""; // current drive
char *outname;
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( name, &outname, false ))) {
return fs_fns->ferrno( );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( name, &outname, false ))) {
int32_t r = fs_fns->ferrno( );
free( outname );
......@@ -416,13 +416,13 @@ void vfs_clearerr( const char *name )
const char *normname = normalize_path( name );
#ifdef CONFIG_BUILD_SPIFFS
#ifdef CONFIG_NODEMCU_BUILD_SPIFFS
if ((fs_fns = myspiffs_realm( normname, &outname, false ))) {
fs_fns->clearerr( );
}
#endif
#ifdef CONFIG_BUILD_FATFS
#ifdef CONFIG_NODEMCU_BUILD_FATFS
if ((fs_fns = myfatfs_realm( normname, &outname, false ))) {
fs_fns->clearerr( );
free( outname );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment