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

GDB and exception handling improvements #1655

Merged
merged 50 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b831b8f
Initial commit
mikee47 Mar 27, 2019
e82c5bf
Fix error in `gdbstub-entry.S` DebugExceptionExit, wrong register value
mikee47 Apr 2, 2019
5d4674b
Bugfix: `uart_rxfifo_count()` values _include_ 0x80 so mask must be 0…
mikee47 Apr 2, 2019
8df1e56
Implement 'X' command and correct checksum calculation when un-escapi…
mikee47 Apr 2, 2019
62aec17
Fix uart receive overflow handling and error/status reporting
mikee47 Apr 2, 2019
5f8ef40
Add uart notification to support `uart_wait_tx()` function, and handl…
mikee47 Apr 2, 2019
d95df21
Add mode parameter to uart_flush() so tx/rx can be flushed independen…
mikee47 Apr 2, 2019
b4ef2d5
Add `uart_set_break()` function
mikee47 Apr 2, 2019
fc1dbbe
Add support for GDB system calls and update LiveDebug sample
mikee47 Apr 2, 2019
84fc6ee
Coding style, docs, optimise stub code via #pragma
mikee47 Apr 2, 2019
affa797
Testing serial operation using Basic_Serial sample, overflow still no…
mikee47 Apr 2, 2019
96b519d
Update LiveDebug sample to deal with errors in receive handler
mikee47 Apr 2, 2019
e6540c8
Fix stack dumper - registers incorrect
mikee47 Apr 2, 2019
a6a2cbc
Flush serial data to hardware before sending a stop packet
mikee47 Apr 2, 2019
bc2bb9c
Change `gdb_present()` to return attachment state
mikee47 Apr 2, 2019
33d305e
Implement simple serial line editor in LiveDebug sample to provide co…
mikee47 Apr 2, 2019
1123ee1
Fix codacy advisories (uart.cpp)
mikee47 Apr 3, 2019
45e2eb0
Fix problem with writing to IRAM
mikee47 Apr 3, 2019
3af913b
Don't produce exception dump if attached to debugger
mikee47 Apr 3, 2019
160499e
syscalls should work with UART2 disabled
mikee47 Apr 3, 2019
6977b4b
Update readme.md
mikee47 Apr 3, 2019
4a0a869
Enable debug output in LiveDebug sample
mikee47 Apr 3, 2019
3597d4d
Add `restart` command to LiveDebug sample
mikee47 Apr 3, 2019
a8396de
LiveDebug sample, use static buffer for reading console (simpler)
mikee47 Apr 3, 2019
9abf808
Add `gdb_on_attach()` function and update LiveDebug sample
mikee47 Apr 3, 2019
84fac9a
errno can be > 255 so treat as unsigned int, not uint8_t.
mikee47 Apr 4, 2019
0db6e16
Stack dumping code needs to use \r\n instead of just \n
mikee47 Apr 6, 2019
623fc8d
For all builds, reset serial ports to user-specified baud rate in `gd…
mikee47 Apr 6, 2019
eb0b4f4
Add `gdbFlushUserData()` function and rename `gdbstub_send_user_data(…
mikee47 Apr 6, 2019
103a5d6
Implement `gdb_detach()`
mikee47 Apr 6, 2019
8f8f84a
LiveDebug sample revisions
mikee47 Apr 6, 2019
531b949
Un-patched GDB uses 'C' rather than 'c', so respond to both
mikee47 Apr 7, 2019
14a620c
Remove 'ack counting'
mikee47 Apr 7, 2019
722bc98
Add a welcome message to `gdbcmds`
mikee47 Apr 7, 2019
373ca18
Document GDB syscall functions, some fixes
mikee47 Apr 7, 2019
2846138
Add GdbFileStream for simpler access to host files via syscall, updat…
mikee47 Apr 7, 2019
7efe770
Disable Ctrl+C trapping when running GDB via Makefile
mikee47 Apr 7, 2019
b70ab28
Define `gdbstub_break_internal()` macro
mikee47 Apr 7, 2019
16569d6
Return previous hook function from `m_setPuts()` so it can be tempora…
mikee47 Apr 7, 2019
ce5b7f0
Add `gdbWriteConsole()` function so internal GDB code can write direc…
mikee47 Apr 7, 2019
8de62f0
Sort out stack dumping and system restart issues
mikee47 Apr 7, 2019
62db957
After flashing, run GDB instead of terminal if ENABLE_GDB is set
mikee47 Apr 7, 2019
321b027
Change Ctrl+C handling to 'safe' break inside task callback routine r…
mikee47 Apr 7, 2019
f6a9fcf
Implement Host I/O support for `remote get`, `remote put` and `remote…
mikee47 Apr 7, 2019
37be3a1
GDBSTUB_CMDENABLE_X should be #if not #ifdef
mikee47 Apr 7, 2019
7e76852
Correct format of n:r pairs in 'T' response - not currently used but …
mikee47 Apr 7, 2019
b7a3a11
Fix documentation (doxygen)
mikee47 Apr 7, 2019
300a147
Update `readme.md`, remove `todo.md`
mikee47 Apr 7, 2019
78d7dfc
Linux doesn't recognise `SIGINT` with `trap` command, so just use `SI…
mikee47 Apr 7, 2019
45e70a5
In `debug_crash_callback()`, interrupt level must be reduced to enabl…
mikee47 Apr 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
path = docs/wiki
url = https://github.com/SmingHub/Sming.wiki.git
ignore = dirty
[submodule "Sming/third-party/esp-gdbstub"]
path = Sming/third-party/esp-gdbstub
url = https://github.com/espressif/esp-gdbstub.git
ignore = dirty
[submodule "Sming/third-party/pwm"]
path = Sming/third-party/pwm
url = https://github.com/StefanBruens/ESP8266_new_pwm.git
Expand Down
65 changes: 11 additions & 54 deletions Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
# MacOS / Linux
# SMING_HOME = /opt/esp-open-sdk

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
COM_SPEED = 115200

# Git command
GIT ?= git

Expand Down Expand Up @@ -117,7 +107,7 @@ export COMPILE := gcc
export PATH := $(ESP_HOME)/xtensa-lx106-elf/bin:$(PATH)
XTENSA_TOOLS_ROOT := $(ESP_HOME)/xtensa-lx106-elf/bin

# select which tools to use as compiler, librarian and linker
# select which tools to use as assembler, compiler, librarian and linker
AS := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
Expand All @@ -126,16 +116,6 @@ LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

## COM port parameters
# Default COM port speed (generic)
COM_SPEED ?= 115200

# Default COM port speed (used for flashing)
COM_SPEED_ESPTOOL ?= $(COM_SPEED)

# Default COM port speed (used in code)
COM_SPEED_SERIAL ?= $(COM_SPEED)

### Debug output parameters
# By default `debugf` does not print file name and line number. If you want this enabled set the directive below to 1
DEBUG_PRINT_FILENAME_AND_LINE ?= 0
Expand Down Expand Up @@ -220,15 +200,6 @@ ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE)))
SDK_INTERNAL = 1
endif

# => esp-gdbstub
ifeq ($(ENABLE_GDB), 1)
THIRD_PARTY_DATA += third-party/esp-gdbstub/Makefile
MODULES += third-party/esp-gdbstub
EXTRA_INCDIR += third-party/esp-gdbstub
else ifneq ($(SMING_RELEASE),1)
MODULES += gdb
endif

# => umm_malloc (custom heap allocation)
ifeq ($(ENABLE_CUSTOM_HEAP), 1)
THIRD_PARTY_DATA += third-party/umm_malloc/Makefile
Expand Down Expand Up @@ -284,16 +255,21 @@ MFORCE32 := $(shell $(CC) --help=target | grep mforce-l32)
CFLAGS_COMMON = -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections
# compiler flags using during compilation of source files. Add '-pg' for debugging
CFLAGS += -Wall -Wundef -Wpointer-arith -Wno-comment $(CFLAGS_COMMON) \
-D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DESP8266=1 -DSMING_INCLUDED=1
-D__ets__ -DICACHE_FLASH -DUSE_OPTIMIZE_PRINTF -DARDUINO=106 -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DESP8266=1 -DSMING_INCLUDED=1
ifneq ($(STRICT),1)
CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized
endif

ifeq ($(ENABLE_GDB), 1)
CFLAGS += -ggdb -DENABLE_GDB=1
endif

ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
CFLAGS += -Os -DSMING_RELEASE=1 -DLWIP_NOASSERT
else ifeq ($(ENABLE_GDB), 1)
CFLAGS += -Og -ggdb -DGDBSTUB_FREERTOS=0 -DENABLE_GDB=1 -DGDBSTUB_CTRLC_BREAK=0
CFLAGS += -Og
else
CFLAGS += -Os -g
endif
Expand All @@ -319,16 +295,8 @@ ifneq ($(STRICT),1)
CXXFLAGS += -Wno-reorder
endif

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections -Wl,-wrap,system_restart_local

# linker script used for the above linkier step
LD_PATH = compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# SSL support using axTLS
Expand Down Expand Up @@ -359,25 +327,18 @@ SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s))
ifeq ($(ENABLE_GDB), 1)
AS_SRC += $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S))
endif
AS_SRC += $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S))
C_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
AS_OBJ := $(patsubst %.s,$(BUILD_BASE)/%.o,$(AS_SRC))
ifeq ($(ENABLE_GDB), 1)
AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC))
endif
AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC))
C_OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(C_SRC))
CXX_OBJ := $(patsubst %.cpp,$(BUILD_BASE)/%.o,$(CXX_SRC))
OBJ := $(AS_OBJ) $(C_OBJ) $(CXX_OBJ)
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
Expand All @@ -399,19 +360,15 @@ endif
vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)
vpath %.s $(SRC_DIR)
ifeq ($(ENABLE_GDB), 1)
vpath %.S $(SRC_DIR)
endif
vpath %.S $(SRC_DIR)

define compile-objects
$1/%.o: %.s
$(vecho) "AS $$<"
$(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
ifeq ($(ENABLE_GDB), 1)
$1/%.o: %.S
$(vecho) "AS $$<"
$(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
endif
$1/%.o: %.c $1/%.c.d
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
Expand Down
34 changes: 28 additions & 6 deletions Sming/Makefile-project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ endif
# define your custom directories in the project's own Makefile before including this one
MODULES ?= app # default to app if not set by user
EXTRA_INCDIR ?= include # default to include if not set by user
MODULES += $(SMING_HOME)/appspecific/gdb

ENABLE_CUSTOM_LWIP ?= 1
LWIP_INCDIR = $(SMING_HOME)/system/esp-lwip/lwip/include
Expand Down Expand Up @@ -261,23 +262,32 @@ ifeq ($(ENABLE_WPS),1)
endif

# compiler flags using during compilation of source files
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections \
CFLAGS = -Wall -Wundef -Wpointer-arith -Wno-comment -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections \
-D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR) -DSMING_INCLUDED=1
ifneq ($(STRICT),1)
CFLAGS += -Werror -Wno-sign-compare -Wno-parentheses -Wno-unused-variable -Wno-unused-but-set-variable -Wno-strict-aliasing -Wno-return-type -Wno-maybe-uninitialized
endif

# => SDK
ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE)))
CFLAGS += -DSDK_INTERNAL
endif

ifeq ($(ENABLE_GDB), 1)
CFLAGS += -ggdb -DENABLE_GDB=1
MODULES += $(SMING_HOME)/gdb
endif

ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
CFLAGS += -Os -DSMING_RELEASE=1
else ifeq ($(ENABLE_GDB), 1)
CFLAGS += -Og -ggdb -DGDBSTUB_FREERTOS=0 -DENABLE_GDB=1 -DGDBSTUB_CTRLC_BREAK=0
MODULES += $(THIRD_PARTY_DIR)/esp-gdbstub
EXTRA_INCDIR += $(THIRD_PARTY_DIR)/esp-gdbstub
CFLAGS += -Og
else
CFLAGS += -Os -g
endif

ifeq ($(ENABLE_WPS),1)
CFLAGS += -DENABLE_WPS=1
endif
Expand Down Expand Up @@ -320,7 +330,8 @@ ifeq ($(DISABLE_SPIFFS), 1)
endif

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -u custom_crash_callback -Wl,-static -Wl,--gc-sections -Wl,-Map=$(FW_BASE)/firmware.map -Wl,-wrap,system_restart_local
LDFLAGS = -nostdlib -u call_user_start -u custom_crash_callback \
-Wl,-static -Wl,--gc-sections -Wl,-Map=$(FW_BASE)/firmware.map -Wl,-wrap,system_restart_local

# linker script used for the above linkier step
LD_PATH = $(SMING_HOME)/compiler/ld
Expand Down Expand Up @@ -377,7 +388,8 @@ SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include

# select which tools to use as compiler, librarian and linker
# select which tools to use as assembler, compiler, librarian and linker
AS := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
Expand All @@ -396,7 +408,11 @@ CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))

C_OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(C_SRC))
CXX_OBJ := $(patsubst %.cpp,$(BUILD_BASE)/%.o,$(CXX_SRC))

AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s))
AS_OBJ := $(patsubst %.s,$(BUILD_BASE)/%.o,$(AS_SRC))
AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S))
AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC))

OBJ := $(AS_OBJ) $(C_OBJ) $(CXX_OBJ)

Expand All @@ -422,6 +438,12 @@ endif


define compile-objects
${BUILD_BASE}/$1/%.o: $1/%.s
$(vecho) "AS $$<"
$(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
${BUILD_BASE}/$1/%.o: $1/%.S
$(vecho) "AS $$<"
$(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
${BUILD_BASE}/$1/%.o: $1/%.c ${BUILD_BASE}/$1/%.c.d
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
Expand Down
54 changes: 38 additions & 16 deletions Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ BLANK_BIN_ADDR = 0x4b000
# filenames and options for generating rBoot rom images with esptool2
RBOOT_E2_SECTS ?= .text .data .rodata
RBOOT_E2_USER_ARGS ?= -quiet -bin -boot2
# GDB path
GDB ?= $(ESP_HOME)/xtensa-lx106-elf/bin/xtensa-lx106-elf-gdb

## COM port parameters
# Default COM port speed (generic)
Expand Down Expand Up @@ -217,6 +219,7 @@ endif
MODULES ?= app # default to app if not set by user
MODULES += $(THIRD_PARTY_DIR)/rboot/appcode
MODULES += $(SMING_HOME)/appspecific/rboot
MODULES += $(SMING_HOME)/appspecific/gdb
EXTRA_INCDIR ?= include # default to include if not set by user

ENABLE_CUSTOM_LWIP ?= 1
Expand Down Expand Up @@ -246,17 +249,22 @@ endif
ifneq (,$(findstring third-party/ESP8266_NONOS_SDK, $(SDK_BASE)))
CFLAGS += -DSDK_INTERNAL
endif

ifeq ($(ENABLE_GDB), 1)
CFLAGS += -ggdb -DENABLE_GDB=1
MODULES += $(SMING_HOME)/gdb
endif

ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
CFLAGS += -Os -DSMING_RELEASE=1
else ifeq ($(ENABLE_GDB), 1)
CFLAGS += -Og -ggdb -DGDBSTUB_FREERTOS=0 -DENABLE_GDB=1 -DGDBSTUB_CTRLC_BREAK=0
MODULES += $(THIRD_PARTY_DIR)/esp-gdbstub
EXTRA_INCDIR += $(THIRD_PARTY_DIR)/esp-gdbstub
CFLAGS += -Og
else
CFLAGS += -Os -g
endif

ifeq ($(ENABLE_WPS),1)
CFLAGS += -DENABLE_WPS=1
endif
Expand Down Expand Up @@ -360,7 +368,8 @@ ifeq ($(DISABLE_SPIFFS), 1)
endif

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback -Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local
LDFLAGS = -nostdlib -u call_user_start -u Cache_Read_Enable_New -u spiffs_get_storage_config -u custom_crash_callback \
-Wl,-static -Wl,--gc-sections -Wl,-Map=$(basename $@).map -Wl,-wrap,system_restart_local

ifeq ($(SPI_SPEED), 26)
flashimageoptions = -ff 26m
Expand Down Expand Up @@ -413,7 +422,8 @@ SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include

# select which tools to use as compiler, librarian and linker
# select which tools to use as assembler, compiler, librarian and linker
AS := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
Expand All @@ -428,11 +438,16 @@ SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

C_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))

C_OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(C_SRC))

CXX_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
CXX_OBJ := $(patsubst %.cpp,$(BUILD_BASE)/%.o,$(CXX_SRC))

AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s))
AS_OBJ := $(patsubst %.s,$(BUILD_BASE)/%.o,$(AS_SRC))
AS_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.S))
AS_OBJ += $(patsubst %.S,$(BUILD_BASE)/%.o,$(AS_SRC))


OBJ := $(AS_OBJ) $(C_OBJ) $(CXX_OBJ)

Expand Down Expand Up @@ -503,6 +518,12 @@ endif


define compile-objects
${BUILD_BASE}/$1/%.o: $1/%.s
$(vecho) "AS $$<"
$(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
${BUILD_BASE}/$1/%.o: $1/%.S
$(vecho) "AS $$<"
$(Q) $(AS) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
${BUILD_BASE}/$1/%.o: $1/%.c ${BUILD_BASE}/$1/%.c.d
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
Expand All @@ -517,7 +538,7 @@ ${BUILD_BASE}/$1/%.cpp.d: $1/%.cpp
.PRECIOUS: ${BUILD_BASE}/$1/%.c.d ${BUILD_BASE}/$1/%.cpp.d
endef

.PHONY: all checkdirs spiff_update spiff_clean clean
.PHONY: all checkdirs spiff_update spiff_clean clean kill_term terminal gdb

all: $(USER_LIBDIR)/lib$(LIBSMING).a checkdirs $(LIBMAIN_DST) $(RBOOT_BIN) $(RBOOT_ROM_0) $(RBOOT_ROM_1) $(SPIFF_BIN_OUT) $(FW_FILE_1) $(FW_FILE_2)

Expand Down Expand Up @@ -611,10 +632,8 @@ endif

flashboot: $(USER_LIBDIR)/lib$(LIBSMING).a $(RBOOT_BIN)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(RBOOT_BIN)

flashconfig:
$(vecho) "Killing Terminal to free $(COM_PORT)"
-$(Q) $(KILL_TERM)

flashconfig: kill_term
$(vecho) "Deleting rBoot config sector"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x01000 $(SDK_BASE)/bin/blank.bin

Expand All @@ -628,9 +647,7 @@ else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) $(RBOOT_SPIFFS_0) $(SPIFF_BIN_OUT)
endif

flash: all
$(vecho) "Killing Terminal to free $(COM_PORT)"
-$(Q) $(KILL_TERM)
flash: all kill_term
ifeq ($(DISABLE_SPIFFS), 1)
# flashes rboot and first rom
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(RBOOT_BIN) 0x02000 $(RBOOT_ROM_0)
Expand All @@ -644,11 +661,16 @@ otaserver: all
$(vecho) "Starting OTA server for TESTING"
$(Q) cd $(FW_BASE) && python -m SimpleHTTPServer $(SERVER_OTA_PORT)

terminal:
kill_term:
$(vecho) "Killing Terminal to free $(COM_PORT)"
-$(Q) $(KILL_TERM)

terminal: kill_term
$(TERMINAL)

gdb: kill_term
$(GDB) -x $(SMING_HOME)/gdb/gdbcmds -b $(COM_SPEED_SERIAL) -ex "target remote $(COM_PORT)"

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) erase_flash
Expand Down
Loading