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

LFS evaluation version -- second release #2301

Merged
merged 11 commits into from
Jun 29, 2018
158 changes: 158 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#
# This is very much a work in progress to show how we can use macros to make the
# GDB interface a lot more useable. For example the next / step commands only
# work if the stepper doesn't leave the current scope. Beyond that you have a
# single hardware breakpoint which can be used as an hb or a wa. You have to
# remember to delete the previous one, so the br macro does this for you.
#
file app/.output/eagle/debug/image/eagle.app.v6.out
#set remotedebug 1
set remotelogfile gdb_rsp_logfile.txt
set serial baud 115200
set remote hardware-breakpoint-limit 1
set remote hardware-watchpoint-limit 1
#set debug xtensa 4
target remote /dev/ttyUSB0

set confirm off
set print null-stop
define br
d
hb $arg0
end
set pagination off

define prTS
set $o = &(((TString *)($arg0))->tsv)
printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
printf "String: hash = 0x%08x, len = %u : %s\n", $o->hash, $o->len, (char *)(&$o[1])
end
define prTnodes
set $o = (Table *)($arg0)
set $n = 1<<($o->lsizenode)
set $i = 0
while $i < $n
set $nd = ($o->node) + $i
if $nd->i_key.nk.tt && $nd->i_val.tt
if $nd->i_key.nk.tt == 6
printf "%4u: %s %2i\n", $i, $nd->i_key.nk.tt , $nd->i_val.tt else
printf "%4u: %2i %2i\n", $i, $nd->i_key.nk.tt , $nd->i_val.tt
end
end
set $i = $i +1
end
end
define prTV
if $arg0
set $type = ($arg0).tt
set $val = ($arg0).value

if $type == 0
# NIL
printf "Nil\n"
end
if $type == 1
# Boolean
printf "Boolean: %u\n", $val.n
end
if $type == 2
# ROTable
printf "ROTable: %p\n", $val.p
end
if $type == 3
# Light Function
printf "Light Func: %p\n", $val.p
end
if $type == 4
# Light User Data
printf "Light Udata: %p\n", $val.p
end
if $type == 5
# Number
printf "Number: %u\n", $val.n
end
if $type == 6
prTS $arg0
end
if $type == 7
# Table
set $o = &($val->gc.h)
printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
printf "Nodes: %4i %p\n", 2<<($o->lsizenode), $o->nodes
printf "Arry: %4i %p\n", $o->sizearray, $o->array
end
if $type == 8
# Function
set $o = &($val->gc.cl.c)
printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
if $o->isC == 0
set $o = &($val->gc.cl.l)
printf "LClosure: nupvalues = %u, gclist = %p, env = %p, p = %p\n", $o->nupvalues, $o->gclist, $o->env, $o->p
else
printf "CClosure: nupvalues = %u, gclist = %p, env = %p, f = %p\np", $o->nupvalues, $o->gclist, $o->env, $o->f
end
end
if $type == 9
# UserData
end
if $type == 10
# Thread
end
end
end

define prL
if L > 0
printf " stack: %u\n", L->top-L->base
printf " hooking: %u, %u, %u, %u, %p\n", L->hookmask, L->allowhook, L->basehookcount, L->hookcount, L->hook
end
end

define dumpstrt
set $st = $arg0
set $i = 0
while $i< $st->size
set $o = &(((TString *)($st->hash[$i]))->tsv)
while $o
if $o->next
printf "Slot: %5i %p %p %08x %02x %4u", $i, $o, $o->next, $o->hash, $o->marked, $o->len
else
printf "Slot: %5i %p %08x %02x %4u", $i, $o, $o->hash, $o->marked, $o->len
end
if $o->marked & 0x80
printf "* %s\n", *(char **)($o+1)
else
printf " %s\n", (char *)($o+1)
end
set $o = &(((TString *)($o->next))->tsv)
end
set $i = $i + 1
end
end

define dumpRAMstrt
dumpstrt &(L->l_G->strt)
end

define dumpROstrt
dumpstrt &(L->l_G->ROstrt)
end

define graylist
set $n = $arg0
while $n
printf "%p %2u %02X\n",$n, $n->gch.tt, $n->gch.marked
set $n=$n->gch.next
end
end

define prPC
printf "Excuting instruction %i: %08x\n", (pc - cl->p->code)+1-1, i
end

define prT
print *(Table*)($arg0)
end
set history save on
set history size 1000

8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ addons:
packages:
- python-serial
- srecord
- lua5.1
cache:
- pip
- directories:
- cache
before_install:
- pip install --user hererocks esptool
- hererocks env --lua 5.1 -rlatest
- source env/bin/activate
- luarocks install luafilesystem
install:
- tar -Jxvf tools/esp-open-sdk.tar.xz
- export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin
script:
- lua tools/cross-lua.lua || exit 1
- export BUILD_DATE=$(date +%Y%m%d)
- make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all
- cd bin/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ifdef DEBUG
CCFLAGS += -ggdb -O0
LDFLAGS += -ggdb
else
CCFLAGS += -Os
CCFLAGS += -O2
endif

#############################################################
Expand Down
46 changes: 8 additions & 38 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,93 +20,64 @@ FLAVOR = debug
ifndef PDIR # {
GEN_IMAGES= eagle.app.v6.out
GEN_BINS= eagle.app.v6.bin
SPECIAL_MKTARGETS=$(APP_MKTARGETS)
OPT_MKTARGETS := coap crypto dht http mqtt pcm sjson sqlite3 tsl2561 u8glib ucglib websocket
Copy link
Member

@pjsg pjsg Mar 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that the u8g stuff doesn't work right -- see the current travis build failure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm, linker fails with lots of undefined references to u8g functions when LUA_USE_MODULES_U8G is defined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devsaurus Arnim, re the warning: this has been there since eLua days, so this is a case of no change. The NodeMCU make only works under the Xtensa toolchain on Linux, so this is a global issue with our build. Maybe we should do an OS detect and abort on anything else, But this isn't an issue introduced by this patch.

@pjsg, Agreed and this needs fixing, so I'll have a look at the Travis build and work out what is going wrong, but the assumption in the normal make is that you enable a given module by setting the corresponding define in user_modulea.h. This Travis make seems to be overriding this by a backdoor and forcing all modules into a link, despite the settings of these defines. This is a QA artiffact as such a biuld will never be capable of being downloaded onto a real ESP module. It isn't a real-life issue but one of the way the Travis build is configured. I just need to mirror this short circuit in the make and detect a Travis build and similarly force the build of all of the associated subdirs..

Copy link
Collaborator Author

@TerryE TerryE Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm, linker fails with lots of undefined references to u8g functions when LUA_USE_MODULES_U8G is defined.

I'll take a look at this and fix. :)

Copy link
Collaborator Author

@TerryE TerryE Mar 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My tweak to the magic works fine but

spiffsimg/spiffsimg -f ../bin/0x%x-4mb.img  -S 4mb -U 0x7c2d0 -r ./spiffsimg/spiffs.lst -d

is dying with "Not enough space: fatal error" Why? swapping the -S 4mb for -c 0x8000 works fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I've bottomed this. The underlying issue is that most of these adjunct directories have the same root name as the module, e.g. coap uses coap, etc. The two u?g modules don't follow this pattern as u8g uses u8glib and ditto ucg. I just had to add a couple of extra magic lines to handle this second case.

SEL_MKTARGETS := $(shell $(CC) -E -dM include/user_modules.h | sed -n '/^\#define LUA_USE_MODULES_/{s/.\{24\}\(.*\)/\L\1/; p}')
OPT_SEL_MKTARGETS := $(foreach tgt,$(OPT_MKTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS)))
OPT_SEL_COMPONENTS := $(foreach tgt,$(OPT_SEL_MKTARGETS),$(tgt)/lib$(tgt).a)
SPECIAL_MKTARGETS :=$(APP_MKTARGETS)

SUBDIRS= \
user \
driver \
pcm \
mbedtls \
platform \
libc \
lua \
lwip \
coap \
mqtt \
task \
u8glib \
ucglib \
smart \
modules \
spiffs \
crypto \
dhtlib \
tsl2561 \
net \
http \
fatfs \
esp-gdbstub \
websocket \
swTimer \
misc \
pm \
sjson \
sqlite3 \

$(OPT_SEL_MKTARGETS)

endif # } PDIR

APPDIR = .
LDDIR = ../ld

CCFLAGS += -Os

TARGET_LDFLAGS = \
-nostdlib \
-Wl,-EL \
--longcalls \
--text-section-literals

ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -Os
endif

ifeq ($(FLAVOR),release)
TARGET_LDFLAGS += -Os
endif

LD_FILE = $(LDDIR)/nodemcu.ld

COMPONENTS_eagle.app.v6 = \
user/libuser.a \
driver/libdriver.a \
pcm/pcm.a \
platform/libplatform.a \
task/libtask.a \
libc/liblibc.a \
lua/liblua.a \
lwip/liblwip.a \
coap/coap.a \
mqtt/mqtt.a \
u8glib/u8glib.a \
ucglib/ucglib.a \
smart/smart.a \
spiffs/spiffs.a \
fatfs/libfatfs.a \
crypto/libcrypto.a \
dhtlib/libdhtlib.a \
tsl2561/tsl2561lib.a \
http/libhttp.a \
pm/libpm.a \
websocket/libwebsocket.a \
esp-gdbstub/libgdbstub.a \
net/libnodemcu_net.a \
mbedtls/libmbedtls.a \
modules/libmodules.a \
swTimer/libswtimer.a \
misc/libmisc.a \
sjson/libsjson.a \
sqlite3/libsqlite3.a \

$(OPT_SEL_COMPONENTS)

# Inspect the modules library and work out which modules need to be linked.
# For each enabled module, a symbol name of the form XYZ_module_selected is
Expand Down Expand Up @@ -194,6 +165,5 @@ INCLUDES += -I ./
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile


.PHONY: FORCE
FORCE:
2 changes: 1 addition & 1 deletion app/coap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# a generated lib/image xxx.a ()
#
ifndef PDIR
GEN_LIBS = coap.a
GEN_LIBS = libcoap.a
endif

#############################################################
Expand Down
2 changes: 1 addition & 1 deletion app/dhtlib/Makefile → app/dht/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# a generated lib/image xxx.a ()
#
ifndef PDIR
GEN_LIBS = libdhtlib.a
GEN_LIBS = libdht.a
endif


Expand Down
File renamed without changes.
File renamed without changes.
Empty file modified app/driver/uart.c
100755 → 100644
Empty file.
Empty file modified app/include/arch/cc.h
100755 → 100644
Empty file.
Empty file modified app/include/driver/uart.h
100755 → 100644
Empty file.
Empty file modified app/include/driver/uart_register.h
100755 → 100644
Empty file.
Empty file modified app/include/lwipopts.h
100755 → 100644
Empty file.
15 changes: 9 additions & 6 deletions app/include/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
#define MODULE_PASTE_(x,y) x##y
#define MODULE_EXPAND_PASTE_(x,y) MODULE_PASTE_(x,y)

#define LOCK_IN_SECTION(s) __attribute__((used,unused,section(s)))

#ifdef LUA_CROSS_COMPILER
#define LOCK_IN_SECTION(s) __attribute__((used,unused,section(".rodata1." #s)))
#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 @@ -51,20 +54,20 @@
* to be linked in.
*/
#define NODEMCU_MODULE(cfgname, luaname, map, initfunc) \
const LOCK_IN_SECTION(".lua_libs") \
const LOCK_IN_SECTION(libs) \
luaL_Reg MODULE_PASTE_(lua_lib_,cfgname) = { luaname, initfunc }; \
const LOCK_IN_SECTION(".lua_rotable") \
const LOCK_IN_SECTION(rotable) \
luaR_table MODULE_EXPAND_PASTE_(cfgname,MODULE_EXPAND_PASTE_(_module_selected,MODULE_PASTE_(LUA_USE_MODULES_,cfgname))) \
= { luaname, map }


/* System module registration support, not using LUA_USE_MODULES_XYZ. */
#define BUILTIN_LIB_INIT(name, luaname, initfunc) \
const LOCK_IN_SECTION(".lua_libs") \
const LOCK_IN_SECTION(libs) \
luaL_Reg MODULE_PASTE_(lua_lib_,name) = { luaname, initfunc }

#define BUILTIN_LIB(name, luaname, map) \
const LOCK_IN_SECTION(".lua_rotable") \
const LOCK_IN_SECTION(rotable) \
luaR_table MODULE_PASTE_(lua_rotable_,name) = { luaname, map }

#if !defined(LUA_CROSS_COMPILER) && !(MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2)
Expand Down
Loading