Commit f123d462 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Add ESP32C3 support/coexistence.

The uzlib and parts of Lua had to be switched over to use the
C standard int types, as their custom typedefs conflicted with
RISC-V toolchain provided typedefs.

UART console driver updated to do less direct register meddling
and use the IDF uart driver interface for setup. Still using our
own ISR rather than the default driver ISR. Down the line we
might want to investigate whether the IDF ISR would be a better
fit.

Lua C modules have been split into common and ESP32/ESP32-S
specific ones. In the future there might also be ESP32-C3
specific modules, which would go into components/modules-esp32c3
at that point.

Our old automatic fixup of flash size has been discarded as it
interferes with the checksumming done by the ROM loader and
results in unbootable systems. The IDF has already taken on
this work via the ESPTOOL_FLASHSIZE_DETECT option, which handles
this situation properly.
parent 9647cc21
...@@ -8,10 +8,8 @@ jobs: ...@@ -8,10 +8,8 @@ jobs:
strategy: strategy:
matrix: matrix:
lua_ver: ['5.1'] lua_ver: ['5.1']
numbers: ['float'] numbers: ['float','integral']
include: target: ['esp32','esp32c3']
- lua_ver: '5.1'
numbers: 'integral'
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -34,18 +32,18 @@ jobs: ...@@ -34,18 +32,18 @@ jobs:
if: ${{ matrix.lua_ver == '5.1' && matrix.numbers == 'float' }} if: ${{ matrix.lua_ver == '5.1' && matrix.numbers == 'float' }}
run: | run: |
cp sdkconfig.defaults sdkconfig cp sdkconfig.defaults sdkconfig
make SHELL=/bin/bash make IDF_TARGET=${{ matrix.target }}
shell: bash shell: bash
- name: Build firmware (Lua 5.1, integer-only) - name: Build firmware (Lua 5.1, integer-only)
if: ${{ matrix.lua_ver == '5.1' && matrix.numbers == 'integral' }} if: ${{ matrix.lua_ver == '5.1' && matrix.numbers == 'integral' }}
run: | run: |
cp sdkconfig.defaults sdkconfig cp sdkconfig.defaults sdkconfig
echo CONFIG_LUA_NUMBER_INTEGRAL=y >> sdkconfig echo CONFIG_LUA_NUMBER_INTEGRAL=y >> sdkconfig
make SHELL=/bin/bash make IDF_TARGET=${{ matrix.target }}
shell: bash shell: bash
- name: Upload luac.cross - name: Upload luac.cross
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
if: ${{ success() }} if: ${{ success() }}
with: with:
name: luac.cross-${{ matrix.lua_ver }}-${{ matrix.numbers }} name: luac.cross-${{ matrix.lua_ver }}-${{ matrix.numbers }}-${{ matrix.target }}
path: build/luac_cross/luac.cross path: build/luac_cross/luac.cross
SHELL:=/bin/bash
ifeq ($(IDF_PATH),) ifeq ($(IDF_PATH),)
THIS_MK_FILE:=$(notdir $(lastword $(MAKEFILE_LIST))) THIS_MK_FILE:=$(notdir $(lastword $(MAKEFILE_LIST)))
......
...@@ -264,7 +264,7 @@ static int uart_wakeup (lua_State *L) ...@@ -264,7 +264,7 @@ static int uart_wakeup (lua_State *L)
uint32_t id = luaL_checkinteger(L, 1); uint32_t id = luaL_checkinteger(L, 1);
MOD_CHECK_ID(uart, id); MOD_CHECK_ID(uart, id);
int threshold = luaL_checkinteger(L, 2); int threshold = luaL_checkinteger(L, 2);
esp_err_t err = uart_set_wakeup_threshold(id, threshold); int err = platform_uart_set_wakeup_threshold(id, threshold);
if (err) { if (err) {
return luaL_error(L, "Error %d from uart_set_wakeup_threshold()", err); return luaL_error(L, "Error %d from uart_set_wakeup_threshold()", err);
} }
...@@ -275,7 +275,7 @@ static int luart_tx_flush (lua_State *L) ...@@ -275,7 +275,7 @@ static int luart_tx_flush (lua_State *L)
{ {
uint32_t id = luaL_checkinteger(L, 1); uint32_t id = luaL_checkinteger(L, 1);
MOD_CHECK_ID(uart, id); MOD_CHECK_ID(uart, id);
uart_tx_flush(id); platform_uart_flush(id);
return 0; return 0;
} }
......
...@@ -124,18 +124,6 @@ void nodemcu_init(void) ...@@ -124,18 +124,6 @@ void nodemcu_init(void)
return; return;
} }
if (flash_safe_get_size_byte() != flash_rom_get_size_byte()) {
NODE_ERR("Incorrect flash size reported, adjusting...\n");
// Fit hardware real flash size.
flash_rom_set_size_byte(flash_safe_get_size_byte());
// Reboot to get SDK to use (or write) init data at new location
esp_restart ();
// Don't post the start_lua task, we're about to reboot...
return;
}
#if defined ( CONFIG_NODEMCU_BUILD_SPIFFS ) #if defined ( CONFIG_NODEMCU_BUILD_SPIFFS )
// This can take a while, so be nice and provide some feedback while waiting // This can take a while, so be nice and provide some feedback while waiting
printf ("Mounting flash filesystem...\n"); printf ("Mounting flash filesystem...\n");
......
if(NOT "${IDF_TARGET}" STREQUAL "esp32c3")
idf_component_register( idf_component_register(
SRCS "CAN.c" SRCS "CAN.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
) )
endif()
...@@ -32,16 +32,17 @@ ...@@ -32,16 +32,17 @@
*/ */
#include "driver/console.h" #include "driver/console.h"
#include "driver/uart.h"
#include "esp_intr_alloc.h" #include "esp_intr_alloc.h"
#include "soc/soc.h" #include "soc/soc.h"
#include "soc/uart_reg.h" #include "soc/uart_reg.h"
#include "soc/dport_reg.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/queue.h" #include "freertos/queue.h"
#include <unistd.h>
#include "esp32/rom/libc_stubs.h"
#include "sys/reent.h" #include "sys/reent.h"
#include <unistd.h>
#include "rom/libc_stubs.h"
#include "rom/uart.h"
#define UART_INPUT_QUEUE_SZ 0x100 #define UART_INPUT_QUEUE_SZ 0x100
...@@ -49,23 +50,17 @@ ...@@ -49,23 +50,17 @@
#define UART_GET_RXFIFO_RD_BYTE(i) GET_PERI_REG_BITS2(UART_FIFO_REG(i) , UART_RXFIFO_RD_BYTE_V, UART_RXFIFO_RD_BYTE_S) #define UART_GET_RXFIFO_RD_BYTE(i) GET_PERI_REG_BITS2(UART_FIFO_REG(i) , UART_RXFIFO_RD_BYTE_V, UART_RXFIFO_RD_BYTE_S)
#define UART_GET_RXFIFO_CNT(i) GET_PERI_REG_BITS2(UART_STATUS_REG(i) , UART_RXFIFO_CNT_V, UART_RXFIFO_CNT_S) #define UART_GET_RXFIFO_CNT(i) GET_PERI_REG_BITS2(UART_STATUS_REG(i) , UART_RXFIFO_CNT_V, UART_RXFIFO_CNT_S)
#define UART_SET_AUTOBAUD_EN(i,val) SET_PERI_REG_BITS(UART_AUTOBAUD_REG(i) ,UART_AUTOBAUD_EN_V,(val),UART_AUTOBAUD_EN_S) #define UART_SET_AUTOBAUD_EN(i,val) SET_PERI_REG_BITS(UART_AUTOBAUD_REG(i) ,UART_AUTOBAUD_EN_V,(val),UART_AUTOBAUD_EN_S)
# define UART_SET_PARITY_EN(i,val) SET_PERI_REG_BITS(UART_CONF0_REG(i) ,UART_PARITY_EN_V,(val),UART_PARITY_EN_S)
#define UART_SET_RX_TOUT_EN(i,val) SET_PERI_REG_BITS(UART_CONF1_REG(i) ,UART_RX_TOUT_EN_V,(val),UART_RX_TOUT_EN_S)
#define UART_SET_RX_TOUT_THRHD(i,val) SET_PERI_REG_BITS(UART_CONF1_REG(i) ,UART_RX_TOUT_THRHD_V,(val),UART_RX_TOUT_THRHD_S)
#define UART_SET_RXFIFO_FULL_THRHD(i,val) SET_PERI_REG_BITS(UART_CONF1_REG(i) ,UART_RXFIFO_FULL_THRHD_V,(val),UART_RXFIFO_FULL_THRHD_S)
#define UART_SET_STOP_BIT_NUM(i,val) SET_PERI_REG_BITS(UART_CONF0_REG(i) ,UART_STOP_BIT_NUM_V,(val),UART_STOP_BIT_NUM_S)
#define UART_SET_BIT_NUM(i,val) SET_PERI_REG_BITS(UART_CONF0_REG(i) ,UART_BIT_NUM_V,(val),UART_BIT_NUM_S)
#define UART_SET_PARITY_EN(i,val) SET_PERI_REG_BITS(UART_CONF0_REG(i) ,UART_PARITY_EN_V,(val),UART_PARITY_EN_S)
#define UART_SET_PARITY(i,val) SET_PERI_REG_BITS(UART_CONF0_REG(i) ,UART_PARITY_V,(val),UART_PARITY_S)
typedef int (*_read_r_fn) (struct _reent *r, int fd, void *buf, int size); typedef int (*_read_r_fn) (struct _reent *r, int fd, void *buf, int size);
static _read_r_fn _read_r_pro, _read_r_app; static _read_r_fn _read_r_app;
#if !defined(CONFIG_IDF_TARGET_ESP32C3)
static _read_r_fn _read_r_pro;
#endif
static xQueueHandle uart0Q; static xQueueHandle uart0Q;
static task_handle_t input_task = 0; static task_handle_t input_task = 0;
static intr_handle_t intr_handle;
// --- Syscall support for reading from STDIN_FILENO --------------- // --- Syscall support for reading from STDIN_FILENO ---------------
...@@ -91,10 +86,12 @@ static int console_read_r (struct _reent *r, int fd, void *buf, int size, _read_ ...@@ -91,10 +86,12 @@ static int console_read_r (struct _reent *r, int fd, void *buf, int size, _read_
return -1; return -1;
} }
#if !defined(CONFIG_IDF_TARGET_ESP32C3)
static int console_read_r_pro (struct _reent *r, int fd, void *buf, int size) static int console_read_r_pro (struct _reent *r, int fd, void *buf, int size)
{ {
return console_read_r (r, fd, buf, size, _read_r_pro); return console_read_r (r, fd, buf, size, _read_r_pro);
} }
#endif
static int console_read_r_app (struct _reent *r, int fd, void *buf, int size) static int console_read_r_app (struct _reent *r, int fd, void *buf, int size)
{ {
return console_read_r (r, fd, buf, size, _read_r_app); return console_read_r (r, fd, buf, size, _read_r_app);
...@@ -137,16 +134,31 @@ static void uart0_rx_intr_handler (void *arg) ...@@ -137,16 +134,31 @@ static void uart0_rx_intr_handler (void *arg)
void console_setup (const ConsoleSetup_t *cfg) void console_setup (const ConsoleSetup_t *cfg)
{ {
uart_tx_wait_idle (CONSOLE_UART); esp_rom_uart_tx_wait_idle (CONSOLE_UART);
uart_div_modify (CONSOLE_UART, (UART_CLK_FREQ << 4) / cfg->bit_rate); uart_config_t uart_conf = {
UART_SET_BIT_NUM(CONSOLE_UART, cfg->data_bits); .baud_rate = cfg->bit_rate,
UART_SET_PARITY_EN(CONSOLE_UART, cfg->parity != CONSOLE_PARITY_NONE); .data_bits =
UART_SET_PARITY(CONSOLE_UART, cfg->parity & 0x1); cfg->data_bits == CONSOLE_NUM_BITS_5 ? UART_DATA_5_BITS :
UART_SET_STOP_BIT_NUM(CONSOLE_UART, cfg->stop_bits); cfg->data_bits == CONSOLE_NUM_BITS_6 ? UART_DATA_6_BITS :
cfg->data_bits == CONSOLE_NUM_BITS_7 ? UART_DATA_7_BITS :
UART_DATA_8_BITS,
.stop_bits =
cfg->stop_bits == CONSOLE_STOP_BITS_1 ? UART_STOP_BITS_1 :
cfg->stop_bits == CONSOLE_STOP_BITS_2 ? UART_STOP_BITS_2 :
UART_STOP_BITS_1_5,
.parity =
cfg->parity == CONSOLE_PARITY_NONE ? UART_PARITY_DISABLE :
cfg->parity == CONSOLE_PARITY_EVEN ? UART_PARITY_EVEN :
UART_PARITY_ODD,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
};
uart_param_config(CONSOLE_UART, &uart_conf);
#if !defined(CONFIG_IDF_TARGET_ESP32C3)
// TODO: Make this actually work // TODO: Make this actually work
UART_SET_AUTOBAUD_EN(CONSOLE_UART, cfg->auto_baud); UART_SET_AUTOBAUD_EN(CONSOLE_UART, cfg->auto_baud);
#endif
} }
...@@ -158,26 +170,24 @@ void console_init (const ConsoleSetup_t *cfg, task_handle_t tsk) ...@@ -158,26 +170,24 @@ void console_init (const ConsoleSetup_t *cfg, task_handle_t tsk)
console_setup (cfg); console_setup (cfg);
esp_intr_alloc (ETS_UART0_INTR_SOURCE + CONSOLE_UART, uart_isr_register(CONSOLE_UART, uart0_rx_intr_handler, NULL, 0, NULL);
ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_INTRDISABLED, uart_set_rx_timeout(CONSOLE_UART, 2);
uart0_rx_intr_handler, NULL, &intr_handle); uart_set_rx_full_threshold(CONSOLE_UART, 10);
uart_enable_intr_mask(CONSOLE_UART,
UART_SET_RX_TOUT_EN(CONSOLE_UART, true); UART_RXFIFO_TOUT_INT_ENA_M |
UART_SET_RX_TOUT_THRHD(CONSOLE_UART, 2); UART_RXFIFO_FULL_INT_ENA_M |
UART_SET_RXFIFO_FULL_THRHD(CONSOLE_UART, 10); UART_FRM_ERR_INT_ENA_M);
WRITE_PERI_REG(UART_INT_ENA_REG(CONSOLE_UART),
UART_RXFIFO_TOUT_INT_ENA |
UART_RXFIFO_FULL_INT_ENA |
UART_FRM_ERR_INT_ENA);
esp_intr_enable (intr_handle);
// Register our console_read_r_xxx functions to support stdin input // Register our console_read_r_xxx functions to support stdin input
_read_r_pro = syscall_table_ptr_pro->_read_r; #if defined(CONFIG_IDF_TARGET_ESP32C3)
_read_r_app = syscall_table_ptr->_read_r;
syscall_table_ptr->_read_r = console_read_r_app;
#else
_read_r_app = syscall_table_ptr_app->_read_r; _read_r_app = syscall_table_ptr_app->_read_r;
syscall_table_ptr_pro->_read_r = console_read_r_pro; _read_r_pro = syscall_table_ptr_pro->_read_r;
syscall_table_ptr_app->_read_r = console_read_r_app; syscall_table_ptr_app->_read_r = console_read_r_app;
syscall_table_ptr_pro->_read_r = console_read_r_pro;
#endif
} }
...@@ -185,4 +195,3 @@ bool console_getc (char *c) ...@@ -185,4 +195,3 @@ bool console_getc (char *c)
{ {
return (uart0Q && (xQueueReceive (uart0Q, c, 0) == pdTRUE)); return (uart0Q && (xQueueReceive (uart0Q, c, 0) == pdTRUE));
} }
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* @author Johny Mattsson <jmattsson@dius.com.au> * @author Johny Mattsson <jmattsson@dius.com.au>
*/ */
#include "esp32/rom/uart.h" #include "esp_rom_uart.h"
#include "task/task.h" #include "task/task.h"
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
......
#ifndef __I2C_SW_MASTER_H__ #ifndef __I2C_SW_MASTER_H__
#define __I2C_SW_MASTER_H__ #define __I2C_SW_MASTER_H__
#include "esp32/rom/ets_sys.h" #include "rom/ets_sys.h"
#define I2C_NUM_MAX 1 #define I2C_NUM_MAX 1
......
...@@ -12,6 +12,13 @@ extern char _irom0_text_end; ...@@ -12,6 +12,13 @@ extern char _irom0_text_end;
#define RODATA_START_ADDRESS (&_irom0_text_start) #define RODATA_START_ADDRESS (&_irom0_text_start)
#define RODATA_END_ADDRESS (&_irom0_text_end) #define RODATA_END_ADDRESS (&_irom0_text_end)
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
extern char _rodata_start;
extern char _rodata_end;
#define RODATA_START_ADDRESS (&_rodata_start)
#define RODATA_END_ADDRESS (&_rodata_end)
#elif defined(__ESP32__) || defined(CONFIG_IDF_TARGET_ESP32) #elif defined(__ESP32__) || defined(CONFIG_IDF_TARGET_ESP32)
#define RODATA_START_ADDRESS ((char*)0x3F400000) #define RODATA_START_ADDRESS ((char*)0x3F400000)
......
...@@ -444,5 +444,6 @@ LROT_PUBLIC_BEGIN(dblib) ...@@ -444,5 +444,6 @@ LROT_PUBLIC_BEGIN(dblib)
LROT_END(dblib, NULL, 0) LROT_END(dblib, NULL, 0)
LUALIB_API int luaopen_debug (lua_State *L) { LUALIB_API int luaopen_debug (lua_State *L) {
(void)L;
return 0; return 0;
} }
...@@ -422,13 +422,13 @@ static void put_byte (uint8_t value) { ...@@ -422,13 +422,13 @@ static void put_byte (uint8_t value) {
} }
static uint8_t recall_byte (uint offset) { static uint8_t recall_byte (uint32_t offset) {
if(offset > DICTIONARY_WINDOW || offset >= out->ndx) if(offset > DICTIONARY_WINDOW || offset >= out->ndx)
flash_error("invalid dictionary offset on inflate"); flash_error("invalid dictionary offset on inflate");
/* ndx starts at 1. Need relative to 0 */ /* ndx starts at 1. Need relative to 0 */
uint n = out->ndx - offset; uint32_t n = out->ndx - offset;
uint pos = n % WRITE_BLOCKSIZE; uint32_t pos = n % WRITE_BLOCKSIZE;
uint blockNo = out->ndx / WRITE_BLOCKSIZE - n / WRITE_BLOCKSIZE; uint32_t blockNo = out->ndx / WRITE_BLOCKSIZE - n / WRITE_BLOCKSIZE;
return out->block[blockNo]->byte[pos]; return out->block[blockNo]->byte[pos];
} }
...@@ -462,7 +462,7 @@ int procFirstPass (void) { ...@@ -462,7 +462,7 @@ int procFirstPass (void) {
fh->flash_size > flashSize || fh->flash_size > flashSize ||
out->flagsLen != 1 + (out->flashLen/WORDSIZE - 1) / BITS_PER_WORD) out->flagsLen != 1 + (out->flashLen/WORDSIZE - 1) / BITS_PER_WORD)
flash_error("LFS length mismatch"); flash_error("LFS length mismatch");
out->flags = luaM_newvector(out->L, out->flagsLen, uint); out->flags = luaM_newvector(out->L, out->flagsLen, uint32_t);
} }
/* update running CRC */ /* update running CRC */
......
...@@ -54,26 +54,7 @@ int luaO_fb2int (int x) { ...@@ -54,26 +54,7 @@ int luaO_fb2int (int x) {
int luaO_log2 (unsigned int x) { int luaO_log2 (unsigned int x) {
#ifdef LUA_CROSS_COMPILER return 31 - __builtin_clz(x);
static const lu_byte log_2[256] = {
0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
};
int l = -1;
while (x >= 256) { l += 8; x >>= 8; }
return l + log_2[x];
#else
/* Use Normalization Shift Amount Unsigned: 0x1=>31 up to 0xffffffff =>0
* See Xtensa Instruction Set Architecture (ISA) Refman P 462 */
asm volatile ("nsau %0, %1;" :"=r"(x) : "r"(x));
return 31 - x;
#endif
} }
......
...@@ -333,6 +333,7 @@ static Node *find_prev_node(Node *mp, Node *next) { ...@@ -333,6 +333,7 @@ static Node *find_prev_node(Node *mp, Node *next) {
** (colliding node is in its main position), moving node goes to an empty position. ** (colliding node is in its main position), moving node goes to an empty position.
*/ */
static int move_node (lua_State *L, Table *t, Node *node) { static int move_node (lua_State *L, Table *t, Node *node) {
(void)L;
Node *mp = mainposition(t, key2tval(node)); Node *mp = mainposition(t, key2tval(node));
/* if node is in it's main position, don't need to move node. */ /* if node is in it's main position, don't need to move node. */
if (mp == node) return 1; if (mp == node) return 1;
...@@ -371,6 +372,7 @@ static int move_node (lua_State *L, Table *t, Node *node) { ...@@ -371,6 +372,7 @@ static int move_node (lua_State *L, Table *t, Node *node) {
static int move_number (lua_State *L, Table *t, Node *node) { static int move_number (lua_State *L, Table *t, Node *node) {
(void)L; (void)t;
int key; int key;
lua_Number n = nvalue(key2tval(node)); lua_Number n = nvalue(key2tval(node));
lua_number2int(key, n); lua_number2int(key, n);
...@@ -580,6 +582,7 @@ const TValue *luaH_getnum (Table *t, int key) { ...@@ -580,6 +582,7 @@ const TValue *luaH_getnum (Table *t, int key) {
/* same thing for rotables */ /* same thing for rotables */
const TValue *luaH_getnum_ro (void *t, int key) { const TValue *luaH_getnum_ro (void *t, int key) {
(void)t; (void)key;
const TValue *res = NULL; // integer values not supported: luaR_findentryN(t, key, NULL); const TValue *res = NULL; // integer values not supported: luaR_findentryN(t, key, NULL);
return res ? res : luaO_nilobject; return res ? res : luaO_nilobject;
} }
...@@ -741,6 +744,7 @@ int luaH_getn (Table *t) { ...@@ -741,6 +744,7 @@ int luaH_getn (Table *t) {
/* same thing for rotables */ /* same thing for rotables */
int luaH_getn_ro (void *t) { int luaH_getn_ro (void *t) {
(void)t;
return 0; // Integer Keys are not currently supported for ROTables return 0; // Integer Keys are not currently supported for ROTables
} }
......
...@@ -279,5 +279,6 @@ LROT_PUBLIC_BEGIN(tab_funcs) ...@@ -279,5 +279,6 @@ LROT_PUBLIC_BEGIN(tab_funcs)
LROT_END(tab_funcs, NULL, 0) LROT_END(tab_funcs, NULL, 0)
LUALIB_API int luaopen_table (lua_State *L) { LUALIB_API int luaopen_table (lua_State *L) {
(void)L;
return 1; return 1;
} }
...@@ -266,6 +266,7 @@ static int runargs (lua_State *L, char **argv, int n) { ...@@ -266,6 +266,7 @@ static int runargs (lua_State *L, char **argv, int n) {
#endif #endif
static int handle_luainit (lua_State *L) { static int handle_luainit (lua_State *L) {
(void)dolfsfile; // silence warning about potentially unused function
const char *init = LUA_INIT_STRING; const char *init = LUA_INIT_STRING;
if (init[0] == '@') { if (init[0] == '@') {
#if CONFIG_NODEMCU_EMBEDDED_LFS_SIZE > 0 #if CONFIG_NODEMCU_EMBEDDED_LFS_SIZE > 0
......
if(NOT "${IDF_TARGET}" STREQUAL "esp32c3")
# Globbing isn't recommended, but I dislike it less than having to edit
# this file whenever a new module source file springs into existence.
# Just remember to "idf.py reconfigure" (or do a clean build) to get
# cmake to pick up on the new (or removed) files.
file(
GLOB module_srcs
LIST_DIRECTORIES false
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.c
)
idf_component_register(
SRCS ${module_srcs}
PRIV_INCLUDE_DIRS "." "${CMAKE_CURRENT_BINARY_DIR}"
PRIV_REQUIRES
"base_nodemcu"
"driver"
"driver_can"
"sdmmc"
"esp_eth"
"lua"
"modules"
"platform"
"soc"
)
# 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.
set(modules_enabled)
foreach(module_src ${module_srcs})
string(REPLACE ".c" "" module_name ${module_src})
string(TOUPPER ${module_name} module_ucase)
set(mod_opt "CONFIG_NODEMCU_CMODULE_${module_ucase}")
if (${${mod_opt}})
list(APPEND modules_enabled ${module_ucase})
endif()
endforeach()
message("Including the following modules: ${modules_enabled}")
foreach(mod ${modules_enabled})
target_link_libraries(${COMPONENT_LIB} "-u ${mod}_module_selected1")
endforeach()
endif()
menu "NodeMCU modules (ESP32/ESP32-S specific)"
depends on IDF_TARGET != "ESP32C3"
config NODEMCU_CMODULE_CAN
bool "CAN module"
default "n"
help
Includes the can module.
config NODEMCU_CMODULE_DAC
bool "DAC module"
default "n"
help
Includes the dac module.
config NODEMCU_CMODULE_ETH
select ETH_USE_ESP32_EMAC
bool "Ethernet module"
default "n"
help
Includes the ethernet module.
config NODEMCU_CMODULE_I2S
bool "I2S module"
default "n"
help
Includes the I2S module.
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.
config NODEMCU_CMODULE_SDMMC
bool "SD-MMC module"
default "n"
help
Includes the sdmmc module.
config NODEMCU_CMODULE_TOUCH
bool "Touch module"
default "n"
help
Includes the touch module to use ESP32's built-in touch sensor
hardware.
endmenu
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