Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua 5.1 to 5.3 Realignment Phase 2 and baseline 5.3 #2912

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ifneq (,$(findstring indows,$(OS)))
else
# It is gcc, may be cygwin
# Can we use -fdata-sections?
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections -fpack-struct=4
AR = xtensa-lx106-elf-ar
CC = xtensa-lx106-elf-gcc
CXX = xtensa-lx106-elf-g++
Expand Down
17 changes: 12 additions & 5 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ TARGET = eagle
#FLAVOR = release
FLAVOR = debug

# Handle Lua Directory selector
ifeq ("$(LUA)","53")
LUA_DIR := lua53
else
LUA_DIR := lua
endif

ifndef PDIR # {
GEN_IMAGES= eagle.app.v6.out
GEN_BINS= eagle.app.v6.bin
Expand All @@ -34,15 +41,15 @@ SUBDIRS= \
mbedtls \
platform \
libc \
lua \
$(LUA_DIR) \
lwip \
smart \
modules \
spiffs \
net \
net \
fatfs \
esp-gdbstub \
pm \
pm \
uzlib \
$(OPT_SEL_MKTARGETS)

Expand All @@ -65,7 +72,7 @@ COMPONENTS_eagle.app.v6 = \
driver/libdriver.a \
platform/libplatform.a \
libc/liblibc.a \
lua/liblua.a \
$(LUA_DIR)/liblua.a \
lwip/liblwip.a \
smart/smart.a \
spiffs/spiffs.a \
Expand Down Expand Up @@ -150,7 +157,7 @@ DDEFINES += \
#
# Required for each makefile to inherit from the parent
#
INCLUDES := -I $(PDIR)libc -I $(PDIR)lua -I $(PDIR)platform \
INCLUDES := -I $(PDIR)libc -I $(PDIR)$(LUA_DIR) -I $(PDIR)platform \
$(INCLUDES) -I $(PDIR) -I $(PDIR)include
PDIR := ../$(PDIR)

Expand Down
20 changes: 9 additions & 11 deletions app/driver/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <stdint.h>
#include "mem.h"

/**DEBUG**/extern void dbg_printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));

static void input_handler(platform_task_param_t flag, uint8 priority);

static struct input_state {
Expand Down Expand Up @@ -63,7 +61,7 @@ static bool uart_getc(char *c){
** The ins.data check detects up the first task call which used to initialise
** everything.
*/
int lua_main (void);
extern int lua_main (void);
static bool input_readline(void);

static void input_handler(platform_task_param_t flag, uint8 priority) {
Expand All @@ -79,7 +77,7 @@ static void input_handler(platform_task_param_t flag, uint8 priority) {
/*
** The input state (ins) is private, so input_setup() exposes the necessary
** access to public properties and is called in user_init() before the Lua
** enviroment is initialised. The second routine input_setup_receive() is
** enviroment is initialised. The second routine input_setup_receive() is
** called in lua.c after the Lua environment is available to bind the Lua
** input handler. Any UART input before this receive setup is ignored.
*/
Expand Down Expand Up @@ -112,15 +110,15 @@ void input_setprompt (const char *prompt) {
}

/*
** input_readline() is called from the input_handler() event routine which is
** input_readline() is called from the input_handler() event routine which is
** posted by the UART Rx ISR posts. This works in one of two modes depending on
** the bool ins.run_input.
** - TRUE: it clears the UART FIFO up to EOL, doing any callback and sending
** the line to Lua.
** - FALSE: it clears the UART FIFO doing callbacks according to the data_len /
** end_char break.
** - FALSE: it clears the UART FIFO doing callbacks according to the data_len
** or end_char break.
*/
void lua_input_string (const char *line, int len);
extern void lua_input_string (const char *line, int len);

static bool input_readline(void) {
char ch = NUL;
Expand Down Expand Up @@ -182,9 +180,9 @@ static bool input_readline(void) {
} else {
while (uart_getc(&ch)) {
ins.data[ins.line_pos++] = ch;
if( ins.line_pos >= ins.len ||
(ins.data_len > 0 && ins.line_pos >= ins.data_len) ||
ch == ins.end_char ) {
if( ins.line_pos >= ins.len ||
(ins.data_len >= 0 && ins.line_pos >= ins.data_len) ||
(ins.data_len < 0 && ch == ins.end_char )) {
ins.uart_cb(ins.data, ins.line_pos);
ins.line_pos = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions app/driver/pwm2.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Software PWM using soft-interrupt timer1.
* Software PWM using soft-interrupt timer1.
* Supports higher frequencies compared to Espressif provided one.
*
* Nikolay Fiykov
Expand Down Expand Up @@ -204,7 +204,7 @@ void pwm2_setup_pin(
const uint32_t freqDivisor,
const uint32_t resolution,
const uint32_t initDuty
)
)
{
moduleData->setupData.pin[pin].pulseResolutions = resolution;
moduleData->setupData.pin[pin].divisableFrequency = divisableFreq;
Expand Down
20 changes: 14 additions & 6 deletions app/driver/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,24 @@ uart0_tx_buffer(uint8 *buf, uint16 len)
* FunctionName : uart0_sendStr
* Description : use uart0 to transfer buffer
* Parameters : uint8 *buf - point to send buffer
* uint16 len - buffer len
* Returns :
*******************************************************************************/
void ICACHE_FLASH_ATTR uart0_sendStr(const char *str)
{
void ICACHE_FLASH_ATTR uart0_sendStr(const char *str) {
while(*str)
{
// uart_tx_one_char(UART0, *str++);
uart0_putc(*str++);
}
}

/******************************************************************************
* FunctionName : uart0_sendStr
* Description : use uart0 to transfer buffer
* Parameters : uint8 *buf - point to send buffer
* size_t len - buffer len
* Returns :
*******************************************************************************/
void ICACHE_FLASH_ATTR uart0_sendStrn(const char *str, size_t len) {
size_t i;
for(i = 0; i < len; i++)
uart0_putc(*str++);
}

/******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion app/include/driver/pwm2.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Software PWM using soft-interrupt timer1.
* Software PWM using soft-interrupt timer1.
* Supports higher frequencies compared to Espressif provided one.
*
* Nikolay Fiykov
Expand Down
1 change: 1 addition & 0 deletions app/include/driver/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void uart_init_task(os_signal_t sig_input, uint8 *flag_input);
UartConfig uart_get_config(uint8 uart_no);
void uart0_alt(uint8 on);
void uart0_sendStr(const char *str);
void uart0_sendStrn(const char *str, size_t len);
void uart0_putc(const char c);
void uart0_tx_buffer(uint8 *buf, uint16 len);
void uart_setup(uint8 uart_no);
Expand Down
25 changes: 4 additions & 21 deletions app/include/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __MODULE_H__

#include "user_modules.h"
#include "lrotable.h"
#include "lnodemcu.h"

/* Registering a module within NodeMCU is really easy these days!
*
Expand Down Expand Up @@ -38,23 +38,6 @@
#define MODULE_PASTE_(x,y) x##y
#define MODULE_EXPAND_PASTE_(x,y) MODULE_PASTE_(x,y)

#ifdef LUA_CROSS_COMPILER
#ifdef _MSC_VER
//on msvc it is necessary to go through more pre-processor hoops to get the
//section name built; string merging does not happen in the _declspecs.
//NOTE: linker magic is invoked via the magical '$' character. Caveat editor.
#define __TOKIFY(s) .rodata1$##s
#define __TOTOK(s) __TOKIFY(s)
#define __STRINGIFY(x) #x
#define __TOSTRING(x) __STRINGIFY(x)
#define __ROSECNAME(s) __TOSTRING(__TOTOK(s))
#define LOCK_IN_SECTION(s) __declspec ( allocate( __ROSECNAME(s) ) )
#else
#define LOCK_IN_SECTION(s) __attribute__((used,unused,section(".rodata1." #s)))
#endif
#else
#define LOCK_IN_SECTION(s) __attribute__((used,unused,section(".lua_" #s)))
#endif
/* For the ROM table, we name the variable according to ( | denotes concat):
* cfgname | _module_selected | LUA_USE_MODULES_##cfgname
* where the LUA_USE_MODULES_XYZ macro is first expanded to yield either
Expand All @@ -67,8 +50,8 @@
*/
#define NODEMCU_MODULE(cfgname, luaname, map, initfunc) \
const LOCK_IN_SECTION(libs) \
luaR_entry MODULE_PASTE_(lua_lib_,cfgname) = { luaname, LRO_FUNCVAL(initfunc) }; \
ROTable_entry MODULE_PASTE_(lua_lib_,cfgname) = { luaname, LRO_FUNCVAL(initfunc) }; \
const LOCK_IN_SECTION(rotable) \
luaR_entry MODULE_EXPAND_PASTE_(cfgname,MODULE_EXPAND_PASTE_(_module_selected,MODULE_PASTE_(LUA_USE_MODULES_,cfgname))) \
= {luaname, LRO_ROVAL(map ## _map)}
ROTable_entry MODULE_EXPAND_PASTE_(cfgname,MODULE_EXPAND_PASTE_(_module_selected,MODULE_PASTE_(LUA_USE_MODULES_,cfgname))) \
= {luaname, LRO_ROVAL(map)}
#endif
10 changes: 5 additions & 5 deletions app/include/task/task.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef _TASK_H_
#define _TASK_H_
/*
** The task interface is now part of the core platform interface.
** The task interface is now part of the core platform interface.
** This header is preserved for backwards compatability only.
*/
*/
#include "platform.h"

#define TASK_PRIORITY_LOW PLATFORM_TASK_PRIORITY_LOW
#define TASK_PRIORITY_MEDIUM PLATFORM_TASK_PRIORITY_MEDIUM
#define TASK_PRIORITY_HIGH PLATFORM_TASK_PRIORITY_HIGH
#define TASK_PRIORITY_LOW PLATFORM_TASK_PRIORITY_LOW
#define TASK_PRIORITY_MEDIUM PLATFORM_TASK_PRIORITY_MEDIUM
#define TASK_PRIORITY_HIGH PLATFORM_TASK_PRIORITY_HIGH

#define task_post(priority,handle,param) platform_post(priority,handle,param)
#define task_post_low(handle,param) platform_post_low(handle,param)
Expand Down
10 changes: 7 additions & 3 deletions app/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,16 @@
#define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()

#ifdef DEVELOPMENT_TOOLS
#if defined(LUA_CROSS_COMPILER) || !defined(DEVELOPMENT_USE_GDB)
#ifdef DEVELOPMENT_USE_GDB
extern void LUA_DEBUG_HOOK (void);
#define lua_assert(x) ((x) ? (void) 0 : LUA_DEBUG_HOOK ())
#else
#ifdef LUA_CROSS_COMPILER
extern void luaL_assertfail(const char *file, int line, const char *message);
#define lua_assert(x) ((x) ? (void) 0 : luaL_assertfail(__FILE__, __LINE__, #x))
#else
extern void luaL_dbgbreak(void);
#define lua_assert(x) ((x) ? (void) 0 : luaL_dbgbreak())
#endif
#define lua_assert(x) ((void) (x))
#endif
#endif

Expand Down
Loading