Skip to content

Commit

Permalink
Merge pull request #2301 from TerryE/dev-LFS
Browse files Browse the repository at this point in the history
LFS evaluation version -- second release
  • Loading branch information
TerryE authored Jun 29, 2018
2 parents 2cc195d + a3c2f48 commit 27a83fe
Show file tree
Hide file tree
Showing 92 changed files with 2,749 additions and 2,465 deletions.
34 changes: 34 additions & 0 deletions .gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# 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

define upto
d
hb $arg0
c
end

set pagination off
set history filename ~/.gdb_history
set history save on
set history size 1000

182 changes: 182 additions & 0 deletions .gdbinitlua
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@

set pagination off
set print null-stop

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->node
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 prT
print *(Table*)($arg0)
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 where
set $f=cl->p
printf "<%s:%u,%u>, opcode %u\n",\
(char *)$f->source+17, $f->linedefined, $f->lastlinedefined, pc - $f->code
end

define callinfo
printf "%p: ", L->ci
print *L->ci
end

define luastack
set $i = 0
set $ci = L->base_ci
set $s = L->stack
set $last = L->stack_last - L->stack
printf "stack = %p, last: %i, size: %i, " , $s, $last, L->stacksize
if $last+6==L->stacksize
printf "(OK)\n"
else
printf "(MISMATCH)\n"
end
printf " Ndx top base func\n"
while $ci <= L->ci
printf "%3u %6i %6i %6i\n", $i++, $ci->top-$s, $ci->base-$s, ($ci++)->func-$s
end
end

define stacklen
printf "%i top: %p, base: %p\n", \
L->ci->top - L->base, L->ci->top, L->base
end

define stackcheck
set $ci = L->ci
printf "Used: %i, Headroom: %i, Total: %i\n", \
L->top-$ci->base-1, $ci->top-L->top+1, $ci->top-$ci->base
end

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
sdk/
cache/
.ccache/
local/
luac.cross
user_config.h
server-ca.crt

Expand Down
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 @@ -28,7 +28,7 @@ ifdef DEBUG
CCFLAGS += -ggdb -O0
LDFLAGS += -ggdb
else
CCFLAGS += -Os
CCFLAGS += -O2
endif

#############################################################
Expand Down
52 changes: 13 additions & 39 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,89 +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 websocket
OPT_MKLIBTARGETS := u8g ucg
SEL_MKTARGETS := $(shell $(CC) -E -dM include/user_modules.h | sed -n '/^\#define LUA_USE_MODULES_/{s/.\{24\}\(.*\)/\L\1/; p}')
OPT_SEL_MKLIBTARGETS := $(foreach tgt,$(OPT_MKLIBTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS)))
OPT_SEL_MKTARGETS := $(foreach tgt,$(OPT_MKTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS))) \
$(foreach tgt,$(OPT_SEL_MKLIBTARGETS),$(tgt)lib)
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 \
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 \
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 @@ -162,7 +137,7 @@ CONFIGURATION_DEFINES = -D__ets__ \
-DLWIP_OPEN_SRC \
-DPBUF_RSV_FOR_WLAN \
-DEBUF_LWIP \
-DUSE_OPTIMIZE_PRINTF \
-DUSE_OPTIMIZE_PRINTF \
-DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \

DEFINES += \
Expand Down Expand Up @@ -191,6 +166,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
Loading

0 comments on commit 27a83fe

Please sign in to comment.