Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev-esp32' into http-ws
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsg committed Feb 1, 2024
2 parents 2280953 + 3cc1d48 commit 7cf7f4c
Show file tree
Hide file tree
Showing 93 changed files with 1,667 additions and 1,479 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Prepare cache key
run: git rev-parse HEAD:sdk/esp32-esp-idf > idf.rev
shell: bash
- name: Cache Espressif tools
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.espressif
key: ${{ runner.os }}-espressif-tools-${{ hashFiles('idf.rev') }}
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
echo lua_build_opts="$(expr "$(./build/luac_cross/luac.cross -v)" : '.*\[\(.*\)\]')" >> $GITHUB_ENV
shell: bash
- name: Upload luac.cross
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: ${{ success() }}
with:
name: luac.cross-${{ env.lua_build_opts }}-${{ matrix.target }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ build/
app/
components/*/.output/
tools/toolchains
extmods.ini
.ccache
bin
version.txt
managed_components/
dependencies.lock

#ignore Eclipse project files
.cproject
Expand Down
14 changes: 9 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# .readthedocs.yaml
# Read the Docs configuration file
# Read the Docs configuration file for MkDocs projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

mkdocs:
configuration: mkdocs.yml

# Optionally set the version of Python and requirements required to build your docs
# Optionally declare the Python requirements required to build your docs
python:
version: "3.7"
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
cmake_minimum_required(VERSION 3.5)

if(DEFINED ENV{EXTRA_COMPONENT_DIRS})
# Turn space-separated, quote-aware environment var into CMake list
separate_arguments(
EXTRA_COMPONENT_DIRS UNIX_COMMAND "$ENV{EXTRA_COMPONENT_DIRS}")
endif()

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(nodemcu)

Expand Down
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,3 @@ all:
$(IDF_PATH)/tools/idf.py $(IDFPY_ARGS) "$@"

endif

# FIXME - needs updating to work in IDF4
#
#extmod-update:
# @tools/extmod/extmod.sh update
#
#extmod-clean:
## @tools/extmod/extmod.sh clean
2 changes: 1 addition & 1 deletion components/base_nodemcu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ idf_component_register(
SRCS "ip_fmt.c" "user_main.c"
INCLUDE_DIRS "include"
REQUIRES "lua"
PRIV_REQUIRES "nvs_flash" "spiffs"
PRIV_REQUIRES "nvs_flash" "spiffs" "esp_netif" "driver"
LDFRAGMENTS "nodemcu.lf"
)
22 changes: 0 additions & 22 deletions components/base_nodemcu/include/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,3 @@
ROTable_entry MODULE_EXPAND_PASTE_(cfgname,MODULE_EXPAND_PASTE_(_module_selected,MODULE_PASTE_(CONFIG_NODEMCU_CMODULE_,cfgname))) \
= {luaname, LRO_ROVAL(map)}
#endif


// helper stringing macros
#define xstr(s) str(s)
#define str(s) #s

// EXTMODNAME is injected by the generated component.mk
#ifdef EXTMODNAME
#define MODNAME xstr(EXTMODNAME)
#else
#define MODNAME "module"
#endif

// use NODEMCU_MODULE_METATABLE() to generate a unique metatable name for your objects:
#define NODEMCU_MODULE_METATABLE() MODULE_EXPAND_(MODNAME xstr(__COUNTER__))

// NODEMCU_MODULE_STD() defines the entry points for an external module:
#define NODEMCU_MODULE_STD() \
static const LOCK_IN_SECTION(libs) \
ROTable_entry lua_lib_module = {MODNAME, LRO_FUNCVAL(module_init)}; \
const const LOCK_IN_SECTION(rotable) \
ROTable_entry MODULE_EXPAND_PASTE_(EXTMODNAME, _entry) = {MODNAME, LRO_ROVAL(module_map)};
4 changes: 2 additions & 2 deletions components/base_nodemcu/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "esp_system.h"
#include "esp_event.h"
#include "esp_spiffs.h"
#include "esp_netif.h"
#include "nvs_flash.h"
#include "flash_api.h"

#include "task/task.h"
#include "sections.h"
Expand Down Expand Up @@ -64,7 +64,7 @@ static void relay_default_loop_events(
if (task_post_medium(relayed_event_task, (intptr_t)&event))
xSemaphoreTake(relayed_event_handled, portMAX_DELAY);
else
printf("ERROR: failed to forward esp event %s/%d", base, id);
printf("ERROR: failed to forward esp event %s/%ld", base, id);
}


Expand Down
3 changes: 3 additions & 0 deletions components/driver_can/CAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"

#include "soc/gpio_sig_map.h"
#include "rom/gpio.h"

#include "esp_intr_alloc.h"
#include "soc/dport_reg.h"
#include <math.h>
Expand Down
1 change: 1 addition & 0 deletions components/driver_can/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if(IDF_TARGET STREQUAL "esp32")
idf_component_register(
SRCS "CAN.c"
INCLUDE_DIRS "include"
PRIV_REQUIRES "driver" "esp_rom"
)

endif()
3 changes: 2 additions & 1 deletion components/driver_i2c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
idf_component_register(
SRCS "i2c_sw_master.c"
INCLUDE_DIRS "include"
REQUIRES "esp32"
REQUIRES "esp_rom"
PRIV_REQUIRES "driver"
)
2 changes: 1 addition & 1 deletion components/driver_i2c/i2c_sw_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void i2c_sw_master_gpio_init(uint8_t sda, uint8_t scl)

gpio_config_t cfg;

cfg.pin_bit_mask = 1 << sda | 1 << scl;
cfg.pin_bit_mask = 1ULL << sda | 1ULL << scl;
cfg.mode = GPIO_MODE_INPUT_OUTPUT_OD;
cfg.pull_up_en = GPIO_PULLUP_ENABLE;
cfg.pull_down_en = GPIO_PULLDOWN_DISABLE;
Expand Down
4 changes: 2 additions & 2 deletions components/driver_i2c/include/driver/i2c_sw_master.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef __I2C_SW_MASTER_H__
#define __I2C_SW_MASTER_H__

#include "rom/ets_sys.h"
#include "esp_rom_sys.h"

#define I2C_NUM_MAX 1

void i2c_sw_master_gpio_init(uint8_t sda, uint8_t scl);
void i2c_sw_master_init(void);

#define i2c_sw_master_wait ets_delay_us
#define i2c_sw_master_wait esp_rom_delay_us
void i2c_sw_master_stop(void);
void i2c_sw_master_start(void);
void i2c_sw_master_setAck(uint8_t level);
Expand Down
33 changes: 32 additions & 1 deletion components/lua/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ menu "Lua configuration"

choice LUA_VERSION
prompt "Lua version"
default LUA_VERSION_51
default LUA_VERSION_53
help
The version of Lua interpreter to use.

Expand Down Expand Up @@ -132,4 +132,35 @@ menu "Lua configuration"
select NODEMCU_CMODULE_UART
select LUA_BUILTIN_DEBUG

choice LUA_INIT_STRING
prompt "Boot command"
default LUA_INIT_STRING_INIT_LUA
help
Command to run on boot. This can be a .lua file, an LFS module, or
any valid Lua expression. By default init.lua is loaded and run
from the SPIFFS filesystem.
config LUA_INIT_STRING_INIT_LUA
bool "init.lua from SPIFFS"
config LUA_INIT_STRING_INIT_LFS
bool "init module from LFS"
config LUA_INIT_STRING_CUSTOM
bool "Custom"
endchoice

config LUA_INIT_STRING_CUSTOM_STRING
string "Custom boot command" if LUA_INIT_STRING_CUSTOM
default ""
help
Run a custom command on boot.

Specify @filename.lua to load "filename.lua" from SPIFFS.
Specify node.LFS.get('foo')() to load the module "foo" from LFS.
Or specify any other valid Lua expression to execute that on boot.

config LUA_INIT_STRING
string
default "@init.lua" if LUA_INIT_STRING_INIT_LUA
default "node.LFS.get('init')()" if LUA_INIT_STRING_INIT_LFS
default LUA_INIT_STRING_CUSTOM_STRING if LUA_INIT_STRING_CUSTOM

endmenu
2 changes: 1 addition & 1 deletion components/lua/common/lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ bool lfs_get_location(lfs_location_info_t *out)
return false; // Nothing to do if no LFS partition available

out->size = part->size; // in bytes
out->addr_mem = spi_flash_phys2cache(out->addr_phys, SPI_FLASH_MMAP_DATA);
out->addr_phys = part->address;
out->addr_mem = spi_flash_phys2cache(out->addr_phys, SPI_FLASH_MMAP_DATA);
if (!out->addr_mem) { // not already mmap'd, have to do it ourselves
spi_flash_mmap_handle_t ignored;
esp_err_t err = spi_flash_mmap(
Expand Down
1 change: 1 addition & 0 deletions components/lua/lua-5.1/lauxlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ LUALIB_API int (luaL_posttask) ( lua_State* L, int prio );
#define LUA_TASK_LOW 0
#define LUA_TASK_MEDIUM 1
#define LUA_TASK_HIGH 2
LUALIB_API int (luaL_totoggle) (lua_State *L, int idx);

/* }====================================================== */

Expand Down
17 changes: 17 additions & 0 deletions components/lua/lua-5.1/lnodemcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,20 @@ LUA_API int lua_pushlfsindex (lua_State *L) {
return p ? LUA_TFUNCTION : LUA_TNIL;
}
#endif


/* luaL_totoggle provides lenient boolean interpretation for feature toggles
* true, 1 => true
* false, 0, nil => false
*/
LUALIB_API int luaL_totoggle(lua_State *L, int idx)
{
if (lua_isboolean(L, idx))
return lua_toboolean(L, idx);
else if (lua_isnoneornil(L, idx))
return 0;
else if (lua_isnumber(L, idx))
return lua_tonumber(L, idx) != 0;
else
return luaL_error(L, "unexpected type");
}
4 changes: 1 addition & 3 deletions components/lua/lua-5.1/lobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include "lstate.h"
#include "lstring.h"
#include "lvm.h"
#ifndef LUA_CROSS_COMPILER
#include "flash_api.h"
#else
#ifdef LUA_CROSS_COMPILER
#include <limits.h>
#endif
const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
Expand Down
17 changes: 17 additions & 0 deletions components/lua/lua-5.3/lauxlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,3 +1177,20 @@ LUALIB_API int luaL_pcallx (lua_State *L, int narg, int nres) {
return status;
}
#endif


/* luaL_totoggle provides lenient boolean interpretation for feature toggles
* true, 1 => true
* false, 0, nil => false
*/
LUALIB_API bool luaL_totoggle(lua_State *L, int idx)
{
if (lua_isboolean(L, idx))
return lua_toboolean(L, idx);
else if (lua_isnoneornil(L, idx))
return false;
else if (lua_isnumber(L, idx))
return lua_tonumber(L, idx) != 0;
else
return luaL_error(L, "unexpected type");
}
1 change: 1 addition & 0 deletions components/lua/lua-5.3/lauxlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ LUALIB_API void (luaL_lfsreload) (lua_State *L);
LUALIB_API int (luaL_posttask) (lua_State* L, int prio);
LUALIB_API int (luaL_pcallx) (lua_State *L, int narg, int nres);
#define luaL_pushlfsmodule(l) lua_pushlfsfunc(L)
LUALIB_API bool (luaL_totoggle) (lua_State *L, int idx);

/* }============================================================ */

Expand Down
8 changes: 4 additions & 4 deletions components/lua/lua-5.3/lnodemcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static void platform_flash_erase_sector(lu_int32 i) {
lockFlashWrite();
}

static void platform_s_flash_write(const void *from, lu_int32 to, lu_int32 len) {
static void platform_flash_write(const void *from, lu_int32 to, lu_int32 len) {
lua_assert(to >= LFSbase && to + len < LFSbase + LFS_SIZE); /* DEBUG */
unlockFlashWrite();
memcpy(byteptr(LFSregion) + (to-LFSbase), from, len);
Expand Down Expand Up @@ -449,7 +449,7 @@ static const char *readF (lua_State *L, void *ud, size_t *size) {
static void eraseLFS(LFSflashState *F) {
lu_int32 i;
#ifdef LUA_USE_ESP
printf("\nErasing LFS from flash addr 0x%06x", F->addrPhys);
printf("\nErasing LFS from flash addr 0x%06lx", F->addrPhys);
#endif
unlockFlashWrite();
for (i = 0; i < F->size; i += FLASH_PAGE_SIZE) {
Expand All @@ -464,7 +464,7 @@ static void eraseLFS(LFSflashState *F) {
platform_flash_erase_sector(s);
}
#ifdef LUA_USE_ESP
printf(" to 0x%06x\n", F->addrPhys + F->size-1);
printf(" to 0x%06lx\n", F->addrPhys + F->size-1);
#endif
flush_icache(F);
lockFlashWrite();
Expand All @@ -483,7 +483,7 @@ LUAI_FUNC void luaN_flushFlash(void *vF) {
lu_int32 size = F->oNdx * WORDSIZE;
lua_assert(start + size < F->addrPhys + F->size); /* is write in bounds? */
//printf("Flush Buf: %6x (%u)\n", F->oNdx, size); //DEBUG
platform_s_flash_write(F->oBuff, start, size);
platform_flash_write(F->oBuff, start, size);
F->oChunkNdx += F->oNdx;
F->oNdx = 0;
}
Expand Down
6 changes: 1 addition & 5 deletions components/lua/lua-5.3/lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
#endif

#ifndef LUA_INIT_STRING
# if defined(CONFIG_NODEMCU_EMBED_LFS)
# define LUA_INIT_STRING "node.LFS.get('init')()"
# else
# define LUA_INIT_STRING "@init.lua"
# endif
# define LUA_INIT_STRING CONFIG_LUA_INIT_STRING
#endif

#if !defined(STARTUP_COUNT)
Expand Down
Loading

0 comments on commit 7cf7f4c

Please sign in to comment.