Coder Social home page Coder Social logo

whitecatboard / lua-rtos-esp32 Goto Github PK

View Code? Open in Web Editor NEW
1.2K 71.0 221.0 154.89 MB

Lua RTOS for ESP32

License: Other

C 91.64% C++ 2.35% Makefile 0.58% Lua 2.38% CMake 0.26% Perl 0.25% Shell 0.31% Assembly 0.01% JavaScript 0.08% Python 0.10% M4 0.10% Roff 0.07% TeX 1.78% HTML 0.01% VBScript 0.08% Raku 0.01% Dockerfile 0.01%
lua esp32 espressif rtos freertos iot lorawan iot-platform lora lua-rtos

lua-rtos-esp32's Introduction

What's Lua RTOS?

Lua RTOS is a real-time operating system designed to run on embedded systems, with minimal requirements of FLASH and RAM memory. Currently Lua RTOS is available for ESP32, ESP8266 and PIC32MZ platforms, and can be easilly ported to other 32-bit platforms.

Lua RTOS has a 3-layer design:

  1. In the top layer there is a Lua 5.3.4 interpreter which offers to the programmer all the resources provided by the Lua programming language, plus special modules for access the hardware (PIO, ADC, I2C, RTC, etc …), and middleware services provided by Lua RTOS (Lua Threads, LoRa WAN, MQTT, …).
  2. In the middle layer there is a Real-Time micro-kernel, powered by FreeRTOS. This is the responsible for that things happen in the expected time.
  3. In the bottom layer there is a hardware abstraction layer, which talk directly with the platform hardware.

For porting Lua RTOS to other platforms is only necessary to write the code for the bottom layer, because the top and the middle layer are the same for all platforms.

How is it programmed?

The Lua RTOS compatible boards can be programmed with The Whitecat IDE in two ways: using the Lua programming language directly, or using a block-based programming language that translates blocks to Lua. No matter if you use Lua or blocks, both forms of programming are made from the same programming environment. The programmer can decide, for example, to made a fast prototype using blocks, then change to Lua, and finally back to blocks.

The Whitecat IDE is available at: https://ide.whitecatboard.org.

In our wiki you have more information about this.

How to get the Lua RTOS firmware?

Prerequisites

  1. Please note you need probably to download and install drivers for your board's USB-TO-SERIAL adapter for Windows and Mac OSX versions. The GNU/Linux version usually doesn't need any drivers. This drivers are required for connect to your board through a serial port connection.

    Board
    WHITECAT ESP32 N1
    ESP32 CORE
    ESP32 THING
  2. For Linux, the currently logged user should have read and write access the sUSB-TO-SERIAL device. On most Linux distributions, this is done by adding the user to dialout group with the following command:

    $ sudo usermod -a -G dialout $USER

     

Method 1: get a precompiled firmware

  1. Install The Whitecat Console. The Whitecat Console is a command line tool that allows the programmer to flash a Lua RTOS compatible board with the last available firmware.

    • Download The Whitecat Console binary for your platform.

    • Copy The Whitecat Console binary to a folder accessed by the system path. For example:

      • Ubuntu: sudo cp wcc /usr/bin
      • Mac OS: sudo cp wcc /usr/bin
      • Windows: runas /noprofile /user:Administrator "copy wcc.exe c:\windows\system32"
    • Test that The Whitecat Console binary works well.

      For Ubuntu / Mac OS open a terminal and type:

      $ wcc
      wcc -p port | -ports [-ls path | 
             [-down source destination] | [-up source destination] | 
             [-f | -ffs] | [-erase] | -d]
      
      -ports:        list all available serial ports on your computer
      -p port:       serial port device, for example /dev/tty.SLAB_USBtoUART
      -ls path:      list files present in path
      -down src dst: transfer the source file (board) to destination file (computer)
      -up src dst:   transfer the source file (computer) to destination file (board)
      -f:            flash board with last firmware
      -ffs:          flash board with last filesystem
      -erase:        erase flash board
      -d:            show debug messages

      For Windows open a "command" window and type wcc.exe

  2. Find which serial device is used by your board.

    Open a terminal with your board unplugged.

    $ wcc -ports
    Available serial ports on your computer:
    
    /dev/cu.Bluetooth-Incoming-Port
    /dev/cu.Bluetooth-Modem

    Now plug your board.

    $ wcc -ports
    Available serial ports on your computer:
    
    /dev/cu.Bluetooth-Incoming-Port
    /dev/cu.Bluetooth-Modem
    /dev/cu.SLAB_USBtoUART

    In the above example, board is using /dev/cu.SLAB_USBtoUART serial device. This device will be used in the following steps as parameter value -p.

    For windows use wcc.exe instead of wcc.

  3. Flash your board.

    Open a terminal with your board plugged.

    $ wcc -p /dev/cu.SLAB_USBtoUART -f

    If you want to flash the default file system add the -ffs option.

    $ wcc -p /dev/cu.SLAB_USBtoUART -f -ffs

    If you are flashing the Lua RTOS firmware for first time you will get an error:

    Unknown board model.
    Maybe your firmware is corrupted, or you haven't a valid Lua RTOS firmware installed.
    
    Do you want to install a valid firmware now [y/n])?

    Enter "y" if you want to install a valid firmware:

    Please, enter your board type:
      1: WHITECAT N1
      2: WHITECAT N1 WITH OTA
      3: ESP32 CORE BOARD
      4: ESP32 CORE BOARD WITH OTA
      5: ESP32 THING
      6: ESP32 THING WITH OTA
      7: GENERIC
      8: GENERIC WITH OTA
    
    Type: 

    Finally enter your board type and your board will be flashed.

    For windows use wcc.exe instead of wcc.

    To upgrade a board with a Lua RTOS firmware installed on it:

    $ wcc -p /dev/cu.SLAB_USBtoUART -f

    If you need to change the firmware type on a board with a Lua RTOS firmware installed on it, for example to change an OTA firmware to a non OTA firmware:

    $ wcc -p /dev/cu.SLAB_USBtoUART -erase
    $ wcc -p /dev/cu.SLAB_USBtoUART -f

Method 2: build by yourself

  1. Install ESP32 toolchain for your desktop platform. Please, follow the instructions provided by ESPRESSIF:

  2. Clone or pull esp-idf repository from ESPRESSIF:

    If you are build Lua RTOS for first time, clone the esp-idf repository:

    git clone --recursive https://github.com/espressif/esp-idf.git

    otherwise, pull last esp-idf changes from your esp-idf folder:

    git pull
    git submodule update --init --recursive
  3. Clone or pull Lua RTOS repository:

    If you are building Lua RTOS for first time, clone Lua RTOS repository:

    git clone --recursive https://github.com/whitecatboard/Lua-RTOS-ESP32

    otherwise, pull last Lua RTOS changes from your Lua Lua-RTOS-ESP32 folder:

    git pull origin master
  4. The installer works only with Python 2.

    You can check your python version by running

    python --version
    

    If your default python verision is 3.x.x then the most convenient way to switch is to install pyenv. Then install the latest python2, and activate the python2 version. Activating Python2 in the Lua-RTOS-ESP32 directory may be your best approach.

    You may need to revert your pyparsing version using

    pip install pyparsing==2.4.7
    

    which is the latest version that works with Python2.

  5. Setup the build environment:

    Go to Lua-RTOS-ESP32 folder:

    cd Lua-RTOS-ESP32

    Edit the env file and change PATH, IDF_PATH, LIBRARY_PATH, PKG_CONFIG_PATH, CPATH for fit to your installation locations.

    Now do:

    source ./env
  6. Build:

    $ make flash

    If you are building Lua RTOS for first time, select your board type, and press enter:

    Please, enter your board type:
    
     1: Whitecat N1 ESP32
     2: Whitecat N1 ESP32 with OTA
     3: Whitecat N1 ESP32 DEVKIT
     4: Whitecat N1 ESP32 DEVKIT with OTA
     5: Espressif Systems ESP32-CoreBoard
     6: Espressif Systems ESP32-CoreBoard with OTA
     7: SparkFun ESP32 Thing
     8: SparkFun ESP32 Thing with OTA
    
    Board type:

    When the Lua RTOS build process finish, the board will be flashed. It is possible that for certain operating systems, or boards, the flashing process fails, due to a not compatible device name for your board's USB-TO-SERIAL adapter. In this case change the default configuration to met your board or operating system requirements, as described above.

  7. Change the default configuration:

    You can change the default configuration:

    $ make menuconfig

    Check the device name for your board's USB-TO-SERIAL adapter under the "Serial flasher config / Default serial port" category.

  8. Build for other board:

    If you have already build Lua RTOS previously and want to build for other board type:

    $ make clean

    Go to step 5.

Connect to the console

You can connect to the Lua RTOS console using your favorite terminal emulator program, such as picocom, minicom, hyperterminal, putty, etc ... The connection parameters are:

  • speed: 115200 bauds
  • data bits: 8
  • stop bits: 1
  • parity: none
  • terminal emulation: VT100

For example, if you use picocom:

picocom --baud 115200 /dev/tty.SLAB_USBtoUART
  /\       /\
 /  \_____/  \
/_____________\
W H I T E C A T

Lua RTOS beta 0.1 build 1479953238 Copyright (C) 2015 - 2017 whitecatboard.org
cpu ESP32 at 240 Mhz
spiffs0 start address at 0x180000, size 512 Kb
spiffs0 mounted
spi2 at pins sdi=012/sdo=013/sck=014/cs=015
sd0 is at spi2, pin cs=015
sd0 type II, size 1943552 kbytes, speed 15 Mhz
sd0a partition type 0b, sector 227, size 1943438 kbytes
fat init file system
fat0 mounted
redirecting console messages to file system ...

Lua RTOS beta 0.1 powered by Lua 5.3.4


Executing /system.lua ...
Executing /autorun.lua ...

/ > 

Lua RTOS is free for you, but funds are required for make it possible. Feel free to donate as little or as much as you wish. Every donation is very much appreciated.

paypal

lua-rtos-esp32's People

Contributors

adrianvielsack avatar andreasdotorg avatar ayyaris avatar bhgv avatar bkent-nerdery avatar bytebang avatar chowette avatar chromico avatar gjongenelen avatar jcw avatar jcwren avatar jolivepetrus avatar loboris avatar mynogs avatar oskarirauta avatar the0ne avatar xopxe avatar xorbit avatar yawor avatar zagaria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lua-rtos-esp32's Issues

OK to remove HOST_PLATFORM from env file?

While setting up the development environment on a Windows machine, I was looking for what to set HOST_PLATFORM to (default is macosx). After checking the Lua-RTOS-ESP32, esp-idf, and xtensa-esp32-elf trees, I cannot find any reference to it being used.

If you see no issue with this, I will submit a pull request to remove it from env and README.md.

'dmesg' shell command causes Guru Meditation Error

'dmesg' command causes Lua to reset

\ > dmesg
Guru Meditation Error of type LoadProhibited occurred on core  0. Exception was unhandled.
Register dump:
PC      : 0x4000c619  PS      : 0x00060230  A0      : 0x80082c86  A1      : 0x3ffcb860  
A2      : 0x00000000  A3      : 0x3f404ffc  A4      : 0x0000000a  A5      : 0x3ffae4f4  
A6      : 0xfffffffc  A7      : 0x00000000  A8      : 0x00000000  A9      : 0x3ffcb840  
A10     : 0x3ffae0ac  A11     : 0x3ffcd188  A12     : 0x00000004  A13     : 0x00000000  
A14     : 0x0000001f  A15     : 0x00000000  SAR     : 0x0000001b  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x4000c46c  LEND    : 0x4000c477  LCOUNT  : 0xffffffff  

Backtrace: 0x4000c619:0x3ffcb860 0x40082c86:0x3ffcb880 0x40128c79:0x3ffcb8a0 0x40128d08:0x3ffcb8d0 0x4010bad8:0x3ffcb8f0 0x4010bbb4:0x3ffcb920 0x40104bc3:0x3ffcb940 0x40104e05:0x3ffcb970 0x40104e2c:0x3ffcb990 0x400ff7b0:0x3ffcb9b0 0x40104810:0x3ffcb9d0 0x40104f91:0x3ffcba50 0x40100334:0x3ffcba80 0x400fa1d4:0x3ffcbab0 0x401116ce:0x3ffcbc80 0x40111827:0x3ffcbe00 0x40111a10:0x3ffcbe30 0x40104bc3:0x3ffcbe60 0x40104e05:0x3ffcbe90 0x40104e2c:0x3ffcbeb0 0x400ff7b0:0x3ffcbed0 0x40104810:0x3ffcbef0 0x40104f91:0x3ffcbf70 0x40100334:0x3ffcbfa0 0x40111a4f:0x3ffcbfd0 0x401391a2:0x3ffcbff0 0x400f9541:0x3ffcc010

Rebooting...
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0008,len:8
load:0x3fff0010,len:2380
ho 0 tail 12 room 4
load:0x40078000,len:9088
load:0x40080000,len:252
entry 0x40080034
ÿBooting Lua RTOS...
�[2J�[1;1H  /\       /\
 /  \_____/  \
/_____________\
W H I T E C A T

Lua RTOS beta 0.1 build 1495202299 Copyright (C) 2015 - 2017 whitecatboard.org
board type ESP32THING
cpu ESP32 rev 0 at 240 Mhz
spiffs0 start address at 0x180000, size 512 Kb
spiffs0 mounted

Lua RTOS beta 0.1 powered by Lua 5.3.4

Executing /system.lua ...
Executing /autorun.lua ...

/ > 

I2S support -- philosophical question how to handle data formats

I'm in the process of adding I2S support, and hitting an issue about how to best pass the data back and forth between the C API and Lua.

When writing to the I2S device, the Espressif driver wants a buffer of type const char *. Should the Lua write function be passed a string or userdata memory? A string seems unnatural for manipulating audio data, but the userdata would require providing a series of methods for modifying the memory from Lua.

The same holds true for the read(), push(), and pop() functions. Should the data being returned be strings or userdata? And for the read() and pop() functions, should the user provide a pre-allocated buffer, or should I dynamically allocate these? There can be a lot of data flying back and forth in I2S, so static buffers would appear to be more efficient.

If you'd like to look at what I've done so far (and optionally make fun of it), it's at https://github.com/jcwren/Lua-RTOS-ESP32/tree/i2s_support. While it does compile cleanly, it's still not functional (or even tested on real hardware yet).

Printing pairs(lora) causes infinite loop

for n in pairs(lora) do print(n) end causes an infinite loop of printing 'setAppKey', 'setNwksKey', 'setAppsKey'

There is a duplicate 'setAppKey' entry in the lora_map table in Lua-RTOS-ESP32/components/lua_rtos/Lua/modules/lora.c. Removing this appears to fix the issue.

static const LUA_REG_TYPE lora_map[] = {
#if CONFIG_LUA_RTOS_LORA_DEVICE_TYPE_NODE
    { LSTRKEY( "setup" ),        LFUNCVAL( llora_setup ) }, 
    { LSTRKEY( "setDevAddr" ),   LFUNCVAL( llora_set_setDevAddr ) }, 
    { LSTRKEY( "setDevEui" ),    LFUNCVAL( llora_set_DevEui ) }, 
    { LSTRKEY( "setAppEui" ),    LFUNCVAL( llora_set_AppEui ) }, 
    { LSTRKEY( "setAppKey" ),    LFUNCVAL( llora_set_AppKey ) }, 
    { LSTRKEY( "setNwksKey" ),   LFUNCVAL( llora_set_NwkSKey ) }, 
    { LSTRKEY( "setAppsKey" ),   LFUNCVAL( llora_set_AppSKey ) }, 
    { LSTRKEY( "setAppKey" ),    LFUNCVAL( llora_set_AppKey ) }, 
    { LSTRKEY( "setDr" ),        LFUNCVAL( llora_set_Dr ) }, 
    { LSTRKEY( "setAdr" ),       LFUNCVAL( llora_set_Adr ) }, 
    { LSTRKEY( "setReTx" ),      LFUNCVAL( llora_set_ReTx ) },
    { LSTRKEY( "getDevAddr" ),   LFUNCVAL( llora_get_DevAddr ) }, 
    { LSTRKEY( "getDevEui" ),    LFUNCVAL( llora_get_DevEui ) }, 
    { LSTRKEY( "getAppEui" ),    LFUNCVAL( llora_get_AppEui ) }, 
    { LSTRKEY( "getDr" ),        LFUNCVAL( llora_get_Dr ) }, 
    { LSTRKEY( "getAdr" ),       LFUNCVAL( llora_get_Adr ) }, 
    { LSTRKEY( "getReTx" ),      LFUNCVAL( llora_get_ReTx ) },
    { LSTRKEY( "join" ),         LFUNCVAL( llora_join ) }, 
    { LSTRKEY( "tx" ),           LFUNCVAL( llora_tx ) },
    { LSTRKEY( "whenReceived" ), LFUNCVAL( llora_rx ) },
	
	// Constant definitions
    { LSTRKEY( "BAND868" ),		 LINTVAL( 868 ) },
    { LSTRKEY( "BAND433" ), 	 LINTVAL( 433 ) },
    { LSTRKEY( "BAND915" ), 	 LINTVAL( 915 ) },
#endif

#if CONFIG_LUA_RTOS_LORA_DEVICE_TYPE_GATEWAY
	{ LSTRKEY( "start" ),        LFUNCVAL( llora_gw_start ) },
#endif

	// Error definitions
	{LSTRKEY("error"), 			 LROVAL( lora_error_map )},

	{LNILKEY, LNILVAL}
};

Bit module

I'm trying to receive messages via 868MHz. The only problem I'm facing is the checksum of the package.

To verify the checksum, I need to use bitwise operators (BXOR) which can be found in the bit(32) module. As far as I can see this is not included at this moment.

Am I wrong or is there a possibility to compile with bit(32)-module?

SPIFFS component for ESP32 as a distinct repository/project?

Howdy,
I am a consumer of the SPIFFS code in your Lua project and am enjoying it very much. I wonder if would be possible for you to create a distinct repository for your SPIFFS ESP32 component? Ideally I'd like to be able to GIT clone it as a unit. I haven't heard of any plans for anyone else to produce a SPIFFS implementation for ESP32 and yours definitely works just great.

adc.c compile error

When compiling on Linux I've got the following error:

In file included from /home/LoBo2_Razno/ESP32/Lua-RTOS-ESP32/components/lua_rtos/Lua/modules/adc.c:39:0:
/home/LoBo2_Razno/ESP32/Lua-RTOS-ESP32/components/lua_rtos/Lua/modules/adc.h:34:25: fatal error: drivers/CPU.h: No such file or directory
 #include "drivers/CPU.h"
                         ^
compilation terminated.
/home/LoBo2_Razno/ESP32/esp-idf/make/component_wrapper.mk:176: recipe for target 'Lua/modules/adc.o' failed

After changing (in components/lua_rtos/Lua/modules/adc.h/adc.h)

#include "drivers/adc.h"
#include "drivers/CPU.h"

to

#include <drivers/adc.h>
#include <drivers/cpu.h>

it builds without errors.

By the way, great work, I'm testing the wifi branch, for now everything works...

SD driver does not compile

Recent changes to the SPI interface has broken the SD driver.

spi_transfer function signature has changed; the results is now error / success status, and the byte read is passed by reference.

If you haven't already fixed this then I have a version that is working (along with a few other small enhancements). I can submit a pull request

Improved TLS support for MQTT

I've recently been trying to use the TLS support in MQTT.

First the good news: the stack is able to establish a secure connection to my MQTT broker (mosquitto in this case), and to send messages.

Bad news: I get this error message:

SSLSocket error WANT_READ/WANT_WRITE in SSL_read - getch for socket 16

Also, I'd like to suggest support for server certificate validation, as well as client certificates, as a feature request.

i2c driver/module implementation

I have analized your implementation of i2c driver & lua module and found some problems/bugs.

First, the whole idea of esp-idf i2c master driver implementation (i2c_cmd_link_create -> commands -> i2c_master_cmd_begin) is to place complete master<->slave communication in one transaction which includes start condition, addres/rd|wr, data r/w, [repeated start, address/rd|wr, data r/w], stop condition.

In your current implementation, the master <->slave transaction is executed after each write or read command (i2c_flush in li2c_read & li2c_write functions) and all commands after the first read|write are executed as separate transactions. In most cases it will work (specially when single slave is present on the bus), but can potentially lead to problems (specially when multiple slaves are connected to the i2c bus).
I understand that you have to issue the i2c_flush command if you want to return the single read byte, but I don't understand why it is necessary after each write

// We need to flush because data buffers are on the stack and if we
// flush on the stop condition its values will be indeterminate

I would also suggest changing:

    i2c_master_read(cmd, (uint8_t *)data, len, 1);

in i2c driver function i2c_read to:

    if (len > 1) {
        i2c_master_read(cmd, (uint8_t *)data, len-1, 0);
    }
    i2c_master_read_byte(cmd, (uint8_t *)(data+len-1), 1);

so that reading multiple bytes from slave can handle ACK/NACK correctly.
With current implementation, reading multiple bytes will return wrong result (tested with BME280 sensor).

I understand your desire to have low level i2c commands (start, address, read, write, stop), it is great for educational purposes, but for all practical purposes I think you should consider implementing higher level functions (send, receive, send_receive), which would handle complete master<->slave transactions with data from/to Lua string, table or numbers.

Best regards.

lsntp_stop -> net_check_connectivity

What is the reason for calling net_check_connectivity() inside lsntp_stop?

Example:

  1. network connection is good
  2. start sntp
  3. network connection changes to "bad" (wifi problem, etc.)
  4. sntp cannot be stopped

I believe that the call to net_check_connectivity() in function lsntp_stop(lua_State* L) could be removed.
What do you think?

UART2 not working?

Hello!
I am reading from a GPS device that is streaming NMEA lines. The following works consistently (from the console):

uart.setpins(uart.UART1,4,5)
uart.attach(uart.UART1, 9600, 8, uart.PARNONE, uart.STOP1)
uart.lock(uart.UART1)
uart.read(uart.UART1, "*el", 1000)

But, if I reboot and change UART1 to UART2, I can't read data.

uart.setpins(uart.UART2,4,5)
uart.attach(uart.UART2, 9600, 8, uart.PARNONE, uart.STOP1)
uart.lock(uart.UART2)
uart.read(uart.UART2, "*el", 1000)

No errors and attach shows:

uart2: at pins rx=GPIO4/tx=GPIO5
uart2: speed 9600 bauds
uart2: interrupts enabled

I've even tried single character reads with no success. The reads return nothing.

Oh, and here is my environment:

build 1500492256
commit 8ab1dd1ce2953eb6a048200be8088ff5ce3a97aa
board type ESP32COREBOARD
cpu ESP32 rev 0 at 240 Mhz

LoRaWAN Reboot

Hi, I wrote a simple script which sends a sample data:

-- ----------------------------------------------------------------
-- Send a frame via LoRa WAN using ABP
-- ----------------------------------------------------------------
os.loglevel(os.LOG_ALL)

-- Register received callbacks
lora.whenReceived(function(port, payload)
  print("port "..port)
  print("payload "..payload)
end)

thread.start(function()
-- Setup LoRa WAN
    lora.setup(lora.BAND868)
    lora.setDevAddr("020FD5D2")
    lora.setNwksKey("BFDE6748451AE5FAC129F579EA4B97B1")
    lora.setAppsKey("6987FB08D1C5447F49591D5AE011C135")
    lora.setDr(5)
    lora.setReTx(0)

    while true do
        print("Sending data...")
        -- Send frame
        lora.tx(false,1,pack.pack(25.3))
        
        -- Wait 5 seconds
        tmr.delay(15)
    end
end)

But the boards (ESP32CORE with RFM96 SPI connected) reboots:

dofile('/lora.lua')
/ > lora: setup, band 868^M
spi3 at pins miso=GPIO19/mosi=GPIO23/clk=GPIO18^M
lmic is at spi3, pin cs=GPIO5^M
Sending data...
Sending data...
Guru Meditation Error of type InstrFetchProhibited occurred on core  0. Exception was unhandled.
Register dump:
PC      : 0x00000000  PS      : 0x00060730  A0      : 0x800f9ca1  A1      : 0x3ffd1eb0
A2      : 0x3ffbe1a8  A3      : 0x3ffbc1c0  A4      : 0x3ffbea5c  A5      : 0x400f9a84
A6      : 0x3ffb2078  A7      : 0x00000014  A8      : 0x8016cc6c  A9      : 0x3ffd1e90
A10     : 0x3ffbe1a8  A11     : 0x00000001  A12     : 0x3ffd175c  A13     : 0x00000000
A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x0000001b  EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff

Backtrace: 0x00000000:0x3ffd1eb0 0x400f9ca1:0x3ffd1ed0

Rebooting...

NodeMCU compatibility?

I just wanted to ask if you're aware of long time existing https://github.com/nodemcu/nodemcu-firmware/ project and if there is a good reason for starting another Lua interpreter for ESP.

While I appreciate it and admire that you're using a much newer Lua and you're based on RTOS from the start it's still a pity that the API of libraries is different so the potential Lua programs will not be compatible at all.

If there was a possibility of cooperating between the projects in order to maintain the API for user programs compatible it would be great.

Thanks.

LoRaWAN fcnt reset after sleep

I made a simple script which sends the temperature out on LoRa and sleeps for 60 seconds with os.sleep(60). After sleep the board reset (Ok) but the new packet has always fcnt=1. I could disable fcnt strict check but I would expect fcnt saved on flash and retained after sleep.

drivers/spi.c doesn't allow a mode value of 3

When calling (in Lua) spi.attach(), a mode of 3 is rejected.

In the C function spi_setup() you return an error if mode is >= 3 (CKP=1, CPHA = 1)

Also, the (wiki) documentation for spi.attach() doesn't match the example (and the ordering of parameters are incorrect).

version 9.0.0 FreeRTOS

whether it is possible to transfer the project to the latest version 9.0.0 FreeRTOS ?

Latest version (703abe1) errors when building CAN.c

Pulled a fresh copy of esp-idf, xtensa-esp32-elf, Lua-RTOS-ESP32. Changed board to ESP32 THING, no other modifications to configuration. Fails when building CAN.c. Configuration at
sdkconfig.txt

$ make
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o mconf.o mconf.c
flex -L -P zconf -o zconf.lex.c zconf.l
zconf.l:255: warning, -s option given but default rule can be matched
bison -t -l -p zconf -o zconf.tab.c zconf.y
sed -E "s/\\x0D$//" zconf.gperf | gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$' -p -t
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o zconf.tab.o zconf.tab.c
lxdialog/check-lxdialog.sh -check cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE -lncurses 
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o lxdialog/checklist.o lxdialog/checklist.c
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o lxdialog/util.o lxdialog/util.c
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o lxdialog/inputbox.o lxdialog/inputbox.c
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o lxdialog/textbox.o lxdialog/textbox.c
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o lxdialog/yesno.o lxdialog/yesno.c
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o lxdialog/menubox.o lxdialog/menubox.c
cc -o mconf mconf.o zconf.tab.o lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o -lncurses 
cc  -DCURSES_LOC="<curses.h>" -DKBUILD_NO_NLS -Wno-format-security  -DLOCALE   -c -o conf.o conf.c
cc -o conf conf.o  zconf.tab.o -lncurses 
GENCONFIG
Configure esp-idf ...
Configure esp-idf for Lua RTOS ...
patching file /Users/jcw/Projects/esp-idf/components/lwip/api/api_msg.c
Hunk #1 succeeded at 875 (offset 6 lines).
patching file /Users/jcw/Projects/esp-idf/components/vfs/include/sys/dirent.h
patching file /Users/jcw/Projects/esp-idf/components/spi_flash/flash_ops.c
Hunk #1 succeeded at 486 with fuzz 1 (offset 7 lines).
patching file /Users/jcw/Projects/esp-idf/components/spi_flash/include/esp_spi_flash.h
Hunk #1 succeeded at 347 (offset 42 lines).
patching file components/esp32/event_default_handlers.c
patching file components/esp32/include/esp_event.h
patching file components/esp32/include/esp_interface.h
patching file components/tcpip_adapter/include/tcpip_adapter.h
patching file components/tcpip_adapter/tcpip_adapter_lwip.c
Hunk #3 succeeded at 110 (offset 1 line).
Hunk #4 succeeded at 178 (offset 1 line).
Hunk #5 succeeded at 207 (offset 1 line).
Hunk #6 succeeded at 242 (offset 1 line).
Hunk #7 succeeded at 265 (offset 1 line).
Hunk #8 succeeded at 326 (offset 1 line).
Hunk #9 succeeded at 341 (offset 1 line).
Hunk #10 succeeded at 443 (offset 1 line).
Hunk #11 succeeded at 461 (offset 1 line).
Hunk #12 succeeded at 664 (offset 1 line).
Hunk #13 succeeded at 675 (offset 1 line).
Hunk #14 succeeded at 694 (offset 1 line).
Hunk #15 succeeded at 721 (offset 1 line).
Hunk #16 succeeded at 845 (offset 1 line).
Configure esp-idf for Lua RTOS tests ...
CC src/bootloader_flash.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/bootloader_random.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/efuse.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/esp_image_format.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/flash_encrypt.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/flash_partitions.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/secure_boot.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC src/secure_boot_signatures.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
AR libbootloader_support.a
CC log.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
AR liblog.a
CC spi_flash_rom_patch.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
AR libspi_flash.a
CC micro-ecc/uECC.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
AR libmicro-ecc.a
CC esp32/brownout.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC esp32/cpu_util.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC esp32/rtc_clk.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC esp32/rtc_init.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC esp32/rtc_pm.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC esp32/rtc_sleep.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC esp32/rtc_time.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
AR libsoc.a
CC bootloader_start.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
CC flash_qio_mode.o
<command-line>:0:0: warning: "IDF_VER" redefined
<command-line>:0:0: note: this is the location of the previous definition
AR libmain.a
LD bootloader.elf
esptool.py v2.0-beta3
Building partitions from /Users/jcw/Projects/esp-idf/components/partition_table/partitions_singleapp.csv...
CC esp_ota_ops.o
AR libapp_update.a
CC src/bootloader_flash.o
CC src/bootloader_random.o
CC src/efuse.o
CC src/esp_image_format.o
CC src/flash_encrypt.o
CC src/flash_partitions.o
CC src/secure_boot.o
CC src/secure_boot_signatures.o
AR libbootloader_support.a
CC bt.o
AR libbt.a
CC CAN.o
In file included from /Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:20:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/rom/ets_sys.h:21,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOSConfig.h:108,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOS.h:99,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN_config.h:32,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN.h:33,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:30:
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c: In function 'CAN_init':
/Users/jcw/Projects/esp-idf/components/esp32/include/esp_assert.h:23:13: error: static assertion failed: "(Cannot use SET_PERI_REG_MASK for DPORT registers use DPORT_SET_PERI_REG_MASK)"
             _Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);   \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:138:38: note: in expansion of macro 'TRY_STATIC_ASSERT'
 #define ASSERT_IF_DPORT_REG(_r, OP)  TRY_STATIC_ASSERT(!IS_DPORT_REG(_r), (Cannot use OP for DPORT registers use DPORT_##OP));
                                      ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:229:13: note: in expansion of macro 'ASSERT_IF_DPORT_REG'
             ASSERT_IF_DPORT_REG((reg), SET_PERI_REG_MASK);                                                             \
             ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:147:5: note: in expansion of macro 'SET_PERI_REG_MASK'
     SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
     ^
/Users/jcw/Projects/esp-idf/components/esp32/include/esp_assert.h:23:13: error: static assertion failed: "(Cannot use WRITE_PERI_REG for DPORT registers use DPORT_WRITE_PERI_REG)"
             _Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);   \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:138:38: note: in expansion of macro 'TRY_STATIC_ASSERT'
 #define ASSERT_IF_DPORT_REG(_r, OP)  TRY_STATIC_ASSERT(!IS_DPORT_REG(_r), (Cannot use OP for DPORT registers use DPORT_##OP));
                                      ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:217:13: note: in expansion of macro 'ASSERT_IF_DPORT_REG'
             ASSERT_IF_DPORT_REG((addr), WRITE_PERI_REG);                                                               \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:230:13: note: in expansion of macro 'WRITE_PERI_REG'
             WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask)));                                                        \
             ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:147:5: note: in expansion of macro 'SET_PERI_REG_MASK'
     SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
     ^
In file included from /Users/jcw/Projects/esp-idf/components/esp32/include/rom/ets_sys.h:21:0,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOSConfig.h:108,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOS.h:99,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN_config.h:32,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN.h:33,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:30:
/Users/jcw/Projects/esp-idf/components/esp32/include/esp_assert.h:23:13: error: static assertion failed: "(Cannot use READ_PERI_REG for DPORT registers use DPORT_READ_PERI_REG)"
             _Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);   \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:218:76: note: in definition of macro 'WRITE_PERI_REG'
             (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val);                                       \
                                                                            ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:138:38: note: in expansion of macro 'TRY_STATIC_ASSERT'
 #define ASSERT_IF_DPORT_REG(_r, OP)  TRY_STATIC_ASSERT(!IS_DPORT_REG(_r), (Cannot use OP for DPORT registers use DPORT_##OP));
                                      ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:211:13: note: in expansion of macro 'ASSERT_IF_DPORT_REG'
             ASSERT_IF_DPORT_REG((addr), READ_PERI_REG);                                                                \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:230:36: note: in expansion of macro 'READ_PERI_REG'
             WRITE_PERI_REG((reg), (READ_PERI_REG(reg)|(mask)));                                                        \
                                    ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:147:5: note: in expansion of macro 'SET_PERI_REG_MASK'
     SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_CAN_CLK_EN);
     ^
In file included from /Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:20:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/rom/ets_sys.h:21,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOSConfig.h:108,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOS.h:99,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN_config.h:32,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN.h:33,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:30:
/Users/jcw/Projects/esp-idf/components/esp32/include/esp_assert.h:23:13: error: static assertion failed: "(Cannot use CLEAR_PERI_REG_MASK for DPORT registers use DPORT_CLEAR_PERI_REG_MASK)"
             _Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);   \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:138:38: note: in expansion of macro 'TRY_STATIC_ASSERT'
 #define ASSERT_IF_DPORT_REG(_r, OP)  TRY_STATIC_ASSERT(!IS_DPORT_REG(_r), (Cannot use OP for DPORT registers use DPORT_##OP));
                                      ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:223:13: note: in expansion of macro 'ASSERT_IF_DPORT_REG'
             ASSERT_IF_DPORT_REG((reg), CLEAR_PERI_REG_MASK);                                                           \
             ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:148:5: note: in expansion of macro 'CLEAR_PERI_REG_MASK'
     CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
     ^
/Users/jcw/Projects/esp-idf/components/esp32/include/esp_assert.h:23:13: error: static assertion failed: "(Cannot use WRITE_PERI_REG for DPORT registers use DPORT_WRITE_PERI_REG)"
             _Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);   \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:138:38: note: in expansion of macro 'TRY_STATIC_ASSERT'
 #define ASSERT_IF_DPORT_REG(_r, OP)  TRY_STATIC_ASSERT(!IS_DPORT_REG(_r), (Cannot use OP for DPORT registers use DPORT_##OP));
                                      ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:217:13: note: in expansion of macro 'ASSERT_IF_DPORT_REG'
             ASSERT_IF_DPORT_REG((addr), WRITE_PERI_REG);                                                               \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:224:13: note: in expansion of macro 'WRITE_PERI_REG'
             WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask))));                                                     \
             ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:148:5: note: in expansion of macro 'CLEAR_PERI_REG_MASK'
     CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
     ^
In file included from /Users/jcw/Projects/esp-idf/components/esp32/include/rom/ets_sys.h:21:0,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOSConfig.h:108,
                 from /Users/jcw/Projects/esp-idf/components/freertos/include/freertos/FreeRTOS.h:99,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN_config.h:32,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/include/CAN.h:33,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:30:
/Users/jcw/Projects/esp-idf/components/esp32/include/esp_assert.h:23:13: error: static assertion failed: "(Cannot use READ_PERI_REG for DPORT registers use DPORT_READ_PERI_REG)"
             _Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG);   \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:218:76: note: in definition of macro 'WRITE_PERI_REG'
             (*((volatile uint32_t *)ETS_UNCACHED_ADDR(addr))) = (uint32_t)(val);                                       \
                                                                            ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:138:38: note: in expansion of macro 'TRY_STATIC_ASSERT'
 #define ASSERT_IF_DPORT_REG(_r, OP)  TRY_STATIC_ASSERT(!IS_DPORT_REG(_r), (Cannot use OP for DPORT registers use DPORT_##OP));
                                      ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:211:13: note: in expansion of macro 'ASSERT_IF_DPORT_REG'
             ASSERT_IF_DPORT_REG((addr), READ_PERI_REG);                                                                \
             ^
/Users/jcw/Projects/esp-idf/components/soc/esp32/include/soc/soc.h:224:36: note: in expansion of macro 'READ_PERI_REG'
             WRITE_PERI_REG((reg), (READ_PERI_REG(reg)&(~(mask))));                                                     \
                                    ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/can/./CAN.c:148:5: note: in expansion of macro 'CLEAR_PERI_REG_MASK'
     CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_CAN_RST);
     ^
make[1]: *** [CAN.o] Error 1
make: *** [can-build] Error 2
$

Compiler version:

$ xtensa-esp32-elf-gcc -v
Using built-in specs.
COLLECT_GCC=xtensa-esp32-elf-gcc
COLLECT_LTO_WRAPPER=/Users/jcw/Projects/xtensa-esp32-elf/bin/../libexec/gcc/xtensa-esp32-elf/5.2.0/lto-wrapper
Target: xtensa-esp32-elf
Configured with: /Users/ivan/e/ESPTools/crosstool-NG/.build/src/gcc-5.2.0/configure --build=x86_64-build_apple-darwin16.0.0 --host=x86_64-build_apple-darwin16.0.0 --target=xtensa-esp32-elf --prefix=/Users/ivan/e/ESPTools/crosstool-NG/builds/xtensa-esp32-elf --with-local-prefix=/Users/ivan/e/ESPTools/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/sysroot --with-sysroot=/Users/ivan/e/ESPTools/crosstool-NG/builds/xtensa-esp32-elf/xtensa-esp32-elf/sysroot --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG crosstool-ng-1.22.0-61-gab8375a' --disable-__cxa_atexit --enable-cxx-flags='-fno-exceptions -fno-rtti' --with-gmp=/Users/ivan/e/ESPTools/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-mpfr=/Users/ivan/e/ESPTools/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-mpc=/Users/ivan/e/ESPTools/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-isl=/Users/ivan/e/ESPTools/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-cloog=/Users/ivan/e/ESPTools/crosstool-NG/.build/xtensa-esp32-elf/buildtools --with-libelf=/Users/ivan/e/ESPTools/crosstool-NG/.build/xtensa-esp32-elf/buildtools --enable-lto --enable-target-optspace --without-long-double-128 --disable-libgomp --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-nls --disable-multilib --enable-languages=c,c++ --disable-libstdcxx-verbose
Thread model: single
gcc version 5.2.0 (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 
$

case sensivity issue including "FreeRTOS.h"

Several files has wrong case on the FreeRTOS.h file so that the code doesnt compile on Linux without modifying the source files.

This includes:
components/lua_rtos/drivers/lmic_hal.c
components/lua_rtos/luartos.h
components/lua_rtos/pthread/attr.c
components/lua_rtos/unix/getcwd.c

mtx_lock() occurs in two times

mtx_lock() function occurs in two times in pthread_create(). So it should be?

mtx_lock(&thread->init_mtx);

    // Create related task
    res = xTaskCreate(
            pthreadTask, "lthread", stacksize, taskArgs,
            tskDEF_PRIORITY, &xCreatedTask
    );

    if(res != pdPASS) {
        // Remove from thread list
        list_remove(&thread_list,*id);
        free(taskArgs);
        free(thread);

        if (res == errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY) {
            errno = ENOMEM;
            return ENOMEM;
        } else {
            errno = EAGAIN;
            return EAGAIN;
        }
    }

    mtx_lock(&thread->init_mtx);

ADC channel sanity check not working?

First of: Excuse me if I'm wrong I haven't tried the code I just happened to see something strang while looking through the code in the repo.
In Lua-RTOS-ESP32/components/lua_rtos/drivers/adc.c it's written (in a couple of places):
if (!((1 << channel) && CPU_ADC_ALL))

I'm quite sure that that should be written as so:
if (!((1 << channel) & CPU_ADC_ALL))

That is: & instead of &&

minor issues

case sensivity issue (FreeRTOS.h) in components/lua_rtos/sys/semaphore.h

Makefile -> restore-idf -> @rm $(IDF_PATH)/components/lua_rtos
error on first build, when symbolic link $(IDF_PATH)/components/lua_rtos does not exist

GPIO for activity led is configured in components/lua_rtos/Makefile.projbuild. Probably should be better if it is configurable with menuconfig (e.g., I'm using SparkFun ESP32 Thing board which has the led on GPIO5)

Selecting LUA_RTOS_LORA_NODE_BAND_US915=y fails to compile.

This is with commit 799b155. Selecting LUA_RTOS_LORA_NODE_BAND_EU868=y succeeds.

CC node/lmic/aes.o
CC node/lmic/lmic.o
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.c: In function 'decodeFrame':
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.c:1126:17: warning: unused variable 'window' [-Wunused-variable]
     const char *window = (LMIC.txrxFlags & TXRX_DNW1) ? "RX1" : ((LMIC.txrxFlags & TXRX_DNW2) ? "RX2" : "Other");
                 ^
CC node/lmic/lmic_hal.o
CC node/lmic/lora_lmic.o
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:117:2: error: 'DR_SF12' undeclared here (not in a function)
  DR_SF12, DR_SF11, DR_SF10, DR_SF9, DR_SF8, DR_SF7, DR_SF7B, DR_FSK
  ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:117:11: error: 'DR_SF11' undeclared here (not in a function)
  DR_SF12, DR_SF11, DR_SF10, DR_SF9, DR_SF8, DR_SF7, DR_SF7B, DR_FSK
           ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:117:53: error: 'DR_SF7B' undeclared here (not in a function)
  DR_SF12, DR_SF11, DR_SF10, DR_SF9, DR_SF8, DR_SF7, DR_SF7B, DR_FSK
                                                     ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:117:62: error: 'DR_FSK' undeclared here (not in a function)
  DR_SF12, DR_SF11, DR_SF10, DR_SF9, DR_SF8, DR_SF7, DR_SF7B, DR_FSK
                                                              ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c: In function 'lora_init':
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:218:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:218:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:218:70: error: 'BAND_CENTI' undeclared (first use in this function)
      LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:218:70: note: each undeclared identifier is reported only once for each function it appears in
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:218:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:218:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:219:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:77: error: invalid operands to binary - (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                                             ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:219:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:72: error: invalid operands to binary >> (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                                        ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:219:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:219:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:219:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:219:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:220:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:220:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:220:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:220:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:221:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:221:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:221:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:221:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:222:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:222:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:222:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:222:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:223:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:223:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:223:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:223:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:224:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:224:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:224:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:224:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:225:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'int')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:225:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:225:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:225:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:47: error: invalid operands to binary << (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                               ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:77: error: invalid operands to binary - (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                                             ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:72: error: invalid operands to binary >> (have 'int' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                                        ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:57: error: invalid operands to binary & (have 'const u1_t * {aka const unsigned char *}' and 'const u1_t * {aka const unsigned char *}')
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                                         ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:70: error: 'BAND_MILLI' undeclared (first use in this function)
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:270:33: warning: passing argument 3 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
 #define DR_RANGE_MAP(drlo,drhi) (((u2_t)0xFFFF<<(drlo)) & ((u2_t)0xFFFF>>(15-(drhi))))
                                 ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:38: note: in expansion of macro 'DR_RANGE_MAP'
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                      ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 'u2_t {aka short unsigned int}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:226:70: warning: passing argument 4 of 'LMIC_setupChannel' makes integer from pointer without a cast [-Wint-conversion]
      LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK,  DR_FSK),  BAND_MILLI); 
                                                                      ^
In file included from /Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:56:0:
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lmic.h:275:7: note: expected 's1_t {aka signed char}' but argument is of type 'const u1_t * {aka const unsigned char *}'
 bit_t LMIC_setupChannel (u1_t channel, u4_t freq, u2_t drmap, s1_t band);
       ^
/Users/jcw/esp/Lua-RTOS-ESP32/components/lora/./node/lmic/lora_lmic.c:240:16: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     current_dr = DR_SF12;
                ^
make[1]: *** [node/lmic/lora_lmic.o] Error 1
make: *** [lora-build] Error 2
mbpro:Lua-RTOS-ESP32 $

MQTT does not support encrypted transmission

The current MQTT implementation relys on OpenSSL being available at compile time.
The Problem is that OpenSSL is not used for the creation of the lua_rtos binary but mbedTLS is being used.
For this reason the MQTT implementation needs to be ported to mbedTLS as unencrypted MQTT is not an option except when using a local MQTT broker because of MITM-Attacks, Replay Attacks, etc.

Using uart1 or uart2 does not work

Hello,
I am trying to read serial data from a PMS1003 dust sensor. The dust sensor works correct and i receive valid data when using a 3.3v serial to USB convertor. The sensor sends every 2 seconds a 32 byte string.
When connecting the sensor to port 9 and 10 (uart1) no valid data is returned to the LUA program.
When connecting a 3.3v serial to USB converter instead of the sensor only the first byte is returned until the queue is empty.

Also when using:

print (uart.read(uart.UART1, "*l", 1000))
you get:
stdin:1: bad argument #3 to 'read' (boolean expected, got number)
stack traceback:
[C]: in field 'read'
stdin:1: in main chunk
[C]: in ?
It does not matter if anything is received first. Also when using:
print (uart.read(uart.UART1, "*c", 1000))

Nothing valid returns..

Regards, Jan

Error when calling pthread_cond_signal() function

Inside pthread_cond_signal() is called each time mtx_init().
mtx_init() is created the semaphore in any case:

mutex->sem = xSemaphoreCreateBinary ();

This condition should be avoided:

if ( !mutex-> sem ) mutex->sem = xSemaphoreCreateBinary ();

In addition, all of the objects by malloc () must be reset. Used calloc () or memcpy(0) after malloc().

error running with latest esp-idf

After latest esp-idf commits (09 Jan) Lua-RTOS-ESP32 builds OK, but cannot run:

Guru Meditation Error of type LoadProhibited occurred on core 1. Exception was unhandled.

Add method to disable SPI2 or SPI3 when SPI enabled?

Currently, if CONFIG_LUA_RTOS_LUA_USE_SPI == y, both SPI2 and SPI3 are enabled and the respective GPIO pins are configured. Given that the I/O on the ESP32 is somewhat limited, it would be advantageous to be able to selectively enable SPI2 or SPI3.

This could be done by either having a sub-menu in the SPI configuration and allowing SPI2 and SPI3 to be selectively enabled, or by allowing the pins in the SPI pin map menu to be set to -1.

Additionally, it would be helpful if the SPI MOSI or MISO pin on each SPI channel could be selectively disabled. There are some devices that don't need to read data back, and being able to disable the MISO pin and leave it available as a GPIO might be helpful.

Thoughts?

sensors module

I've created the sensors module which (for now) has support for BME280 temperature/humidity/pressure sensor and 1-wire devices (for now DS1820 temperature sensors family).
I've tried to write the drivers and modules according to your rules and I would appreciate If you could find some time to review the code and possible give some comments.

All patches are in the attached zip and in GitHub repository
sensors.patch.zip

SENSOR for PIR

Hi:-

The wiki invites suggestions for other types of sensors to implement. I would be interested in an implementation for infrared motion detectors (PIR). There are only one or two in common use, and by far the most common is a module with a BISS0001 sensor.

Thanks

Whitecat console tool, for transfer files without an IDE

Hi.

I'm playing with an ESP32 Thing from Sparkfun. I like the idea of using a lightweight scripting language to simplify programming on this board, so I installed Lua RTOS on it.

However, to my surprise, I found nowhere how to transfer a Lua file from a Linux terminal to the board.

I searched every terms I could think of. I read a good part of the wiki (all the pages that seemed relevant). I tried ESPlorer (but that seems targeted only at NodeMCU, not Lua RTOS).

Maybe it's not possible and there is no simple tool for Linux to achieve that. But either ways, I think it might be a good idea to talk about that in the documentation (whether it's feasible or not.)

I don't think the only way is to rebuild the FS image and then flashes it each time. Right?

With NodeMCU, there is a tool (nodemcu-uploader) to download/upload file. I was expecting something similar for Lua RTOS.

How do you transfer a single file (without an IDE)? I can't be the only one wondering about that.

info about transferring files

Is any info on the way for this empty wiki page? https://github.com/whitecatboard/Lua-RTOS-ESP32/wiki/How-to-transfer-files

I know that the combination of the web IDE and the agent can do it, but I'm looking for an easy way to do it from local files. I had a quick look at the agent code to see if there was an easy way to write a local program that talks to the agent or directly to the board the same way the IDE does it. It looked like enough work that I wanted someone else to do it. :-)

So, is there already some easy pipeline for doing it? (Feel free to tell me that there is a way to have the boards filesystem appear as something mountable on my PC. I wouldn't object to that at all :-))

HTTP Server static only

The HTTP Server does not seem to interpret Lua code which seems like a show-stopper.
Is there a way to workaround this limitation?

SPI module - device not selected

Hello,

When trying to read from a SPI device with LUA the following output is generated:

/ > halencoder = spi.setup(spi.SPI3, spi.MASTER, pio.GPIO5, 1000, 8, 1, 3)
spi3 at pins miso=GPIO19/mosi=GPIO23/clk=GPIO18
/ > halencoder:select()
/ > setting1 = halencoder:write(0x00, 0x19)
device is not selected
device is not selected
/ > print("setting ="..setting1)
stdin:1: attempt to concatenate a nil value (global 'setting1')
stack traceback:
stdin:1: in main chunk
[C]: in ?
/ > halencoder:deselect()
/ >
/ >

The output pins show no activity. It does not matter if using the flag argument.

From in the module description it is not clear if you should use the instance:readwrite or the instance:write function to read registers from the device. the examples are not very clear..

regards, Jan

Australian Lorawan Frequencies

Hi, great board and nice code, would it be possible to support the Australian and New Zealand lorawan frequencies? I see that you are using the arduino-lmic code which has defined configs such as CFG_us915/CFG_eu868 which sets up the lorawan related functions ... could other configs could be added? would be great if you could support more than just US and EU out of the box.

Cheers

problem compiling using msys32 with error unrecognized command -mno-ms-bitfields

While trying to compile Lua-RTOS_ESP32 I am getting the error:
xtensa-esp32-elf-gcc.exe: error: unrecognized command line option '-mno-ms-bitfields'
It seem like the $(OS) used is Windows_NT instead of LINUX perhaps or MSYS32. Is this correct? The LUA-RTOS-32, esp-idf and MSYS are the newest versions in github. Below is a screen capture:

john@hpi7 MSYS ~/Lua-RTOS-ESP32
$ make flashfs
GENCONFIG
Building mkspiffs ...
xtensa-esp32-elf-gcc.exe: error: unrecognized command line option '-mno-ms-bitfields'
make[1]: *** [Makefile:58: mkspiffs.exe] Error 1
make: *** [/home/john/Lua-RTOS-ESP32/components/mkspiffs/Makefile.projbuild:10: mkspiffs] Error 2

stat function, fat timestamp and few others...

While working on some code I've needed stat function to return the file timestamp (fat fs) and I've found it is not working (not only for timestamp, but always returns error).

I've managed to make it work, maybe you are interested to include the changes:

  • added stat.c to components/lua_rtos/syscalls
  • made some changes, as in changes.patch

I've also changed few things to address the following issues:

  • os.ls() : does not show the file time for files on fat fs
  • os.cd() : after changing the working directory it is not possible to change it back to root

All changes are in attached zip.
changes.zip

Delete files?

We cant delete lua or xml or any files from Whitecat IDE.
Only way is to end wccagent.exe and start putty. From "normal" editor than all command work normaly.
Why hidening some stuf and why just not opened everything.?
Where to find saved lua or xml files on computer, same problem.... Just download it on Download section..
If i use Whitecad editor some command are filtered(seems os.shell(false) ) why that?
Thing is totaly useless in school if you block on that way.....
Do you plan to support blue tooth on lua and whitecard IDE?
What about DHT22 sensor?
Don't protect against unwanted or stupid command, if we or students make mistake, we just flash it again.....

Selectively disable MISO or MOSI in SPI driver

It would be helpful if the SPI MOSI or MISO pin on each SPI channel could be selectively disabled. There are some devices that don't need to read data back, and being able to disable the MISO pin and leave it available as a GPIO might be helpful.

Guru Mediaton Error if readonly cache enabled and table element doesn't exists

If "Use cache for readonly tables access (experimental)" is enabled in Kconfig, if a table's key doesn't exists a Guru Mediaton Error is raided. Examles:

/ > lora.inexistent
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x4011a2af PS : 0x00060c30 A0 : 0x8010e258 A1 : 0x3ffc7120
A2 : 0x3ffc770c A3 : 0x3ffc9f9c A4 : 0x3ffc8d40 A5 : 0x3ffca174
A6 : 0x3ffc9f94 A7 : 0x3ffca174 A8 : 0x8011a10c A9 : 0x3ffc70f0
A10 : 0x00000000 A11 : 0x3ffc9f9c A12 : 0x00000101 A13 : 0x00000000
A14 : 0x0000002a A15 : 0x3ffc7290 SAR : 0x0000001a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

spi_eth.c throws compiler warnings

(I'd submit a patch, but I have next to zero git skills, unless messing up a repository is a skill...)

Adding a ip_addr_t *dns_p = &dns; and passing dns_p instead of &dns to ip_addr_set_ip4_u32() fixes two of the warnings.

CC drivers/spi_eth.o
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c: In function 'spi_eth_setup':
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:88:23: warning: the address of 'dns' will always evaluate as 'true' [-Waddress]
   ip_addr_set_ip4_u32(&dns, dns1);
                       ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:95:49: note: in definition of macro 'ip_addr_set_ip4_u32'
 #define ip_addr_set_ip4_u32(ipaddr, val)  do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
                                                 ^
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:73:58: warning: the comparison will always evaluate as 'true' for the address of 'dns' will never be NULL [-Waddress]
 #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
                                                          ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:96:3: note: in expansion of macro 'IP_SET_TYPE'
   IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
   ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:88:3: note: in expansion of macro 'ip_addr_set_ip4_u32'
   ip_addr_set_ip4_u32(&dns, dns1);
   ^
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:94:23: warning: the address of 'dns' will always evaluate as 'true' [-Waddress]
   ip_addr_set_ip4_u32(&dns, dns2);
                       ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:95:49: note: in definition of macro 'ip_addr_set_ip4_u32'
 #define ip_addr_set_ip4_u32(ipaddr, val)  do{if(ipaddr){ip4_addr_set_u32(ip_2_ip4(ipaddr), val); \
                                                 ^
In file included from /Users/jcw/Projects/esp-idf/components/tcpip_adapter/include/tcpip_adapter.h:47:0,
                 from /Users/jcw/Projects/esp-idf/components/esp32/include/esp_event.h:23,
                 from /Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:37:
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:73:58: warning: the comparison will always evaluate as 'true' for the address of 'dns' will never be NULL [-Waddress]
 #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
                                                          ^
/Users/jcw/Projects/esp-idf/components/lwip/include/lwip/lwip/ip_addr.h:96:3: note: in expansion of macro 'IP_SET_TYPE'
   IP_SET_TYPE(ipaddr, IPADDR_TYPE_V4); }}while(0)
   ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:94:3: note: in expansion of macro 'ip_addr_set_ip4_u32'
   ip_addr_set_ip4_u32(&dns, dns2);
   ^
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c: In function 'spi_eth_stop':
/Users/jcw/Projects/Lua-RTOS-ESP32/components/lua_rtos/drivers/spi_eth.c:130:18: warning: unused variable 'error' [-Wunused-variable]
  driver_error_t *error;
                  ^

hw i2c & sensor module

As isp-idf now supports hw i2c, I've changed the i2c module.
Software i2c is removed and only the hw i2c is now used.
Only i2c master mode is supported for now.
The module is tested and works as expected.
I've also added the sensor module, for now support for BME280 sensor (in i2c mode) is added.
All related patches are in
i2c_sensor.patch.zip
You can also check my Lua-RTOS-ESP32 fork

Best regards.

minor issue in mqtt.subscribe

Mqtt subscribe causes the panic:

/ > mq:subscribe("test",0,mqmsg)
Guru Meditation Error of type LoadProhibited occurred on core  0. Exception was unhandled.
Register dump:
....

The source of the error is to small alocated memory for topic string in add_subs_callback function.
It is necessary to change:
callback->topic = (char *)malloc(strlen(topic));
to
callback->topic = (char *)malloc(strlen(topic)+1);

With that change subscribe function works as expected.

ymodem file transfer

This is not an issue, but suggestion for adding ymodem file transfer functions in io module.
The functions are fully tested and works as expected.

queue_byte() function in components/lua_rtos/drivers/uart.c is patched to allow receiving of binnary files and ymodem protocol codes

I would also suggest changing the default console buffer length to 1040 bytes to enable receiving maximum ymodem packet length (1024 + 5) as well as adding more baud rate options.

All patches are in attached
patches.zip

Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.