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

Fix/debugging with enabled gdb #1544

Merged
merged 7 commits into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install:
fi
- if [ "$SDK_VERSION" == "1.5.0" ]; then bsdtar -xf ${SDK_FILE_NAME} -C $TRAVIS_BUILD_DIR/opt/esp-alt-sdk;
fi
- if [[ "$SDK_VERSION" != "1.5.0" && "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/nodemcu/nodemcu-firmware/raw/master/tools/esp-open-sdk.tar.xz;
- if [[ "$SDK_VERSION" != "1.5.0" && "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/nodemcu/nodemcu-firmware/raw/2d958750b56fc60297f564b4ec303e47928b5927/tools/esp-open-sdk.tar.xz;
tar -Jxvf esp-open-sdk.tar.xz; ln -s `pwd`/esp-open-sdk/xtensa-lx106-elf $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/.
; fi
- if [ "$SDK_VERSION" == "2.0.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then wget
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ This feature is still **experimental** which means that we do not recommend it i
- **Custom heap allocation**: (default: OFF) If your application is experiencing heap fragmentation then you can try the [umm_malloc](https://github.com/rhempel/umm_malloc) heap allocation. To enable it compile Sming with `ENABLE_CUSTOM_HEAP=1`. In order to use it in your sample/application make sure to compile the sample with `ENABLE_CUSTOM_HEAP=1`. **Do not enable custom heap allocation and -mforce-l32 compiler flag at the same time**.
- **Debug information log level and format**: There are four debug levels: debug=3, info=2, warn=1, error=0. Using `DEBUG_VERBOSE_LEVEL` you can set the desired level (0-3). For example `DEBUG_VERBOSE_LEVEL=2` will show only info messages and above. Another make directive is `DEBUG_PRINT_FILENAME_AND_LINE=1` which enables printing the filename and line number of every debug line. This will require extra space on flash. Note: you can compile the Sming library with a set of debug directives and your project with another settings, this way you can control debugging separately for Sming and your application code.
- **Debug information for custom LWIP**: If you use custom LWIP (see above) some debug information will be printed for critical errors and situations. You can enable all debug information printing using `ENABLE_LWIPDEBUG=1`. To increase debugging for certain areas you can modify debug options in `third-party/esp-open-lwip/include/lwipopts.h`.
- **Interactive debugging on the device**: (default: OFF) In order to be able to debug live directly on the ESP8266 microcontroller you should re-compile the Sming library and your application with `ENABLE_GDB=1` directive. See [Basic_Debug](https://github.com/SmingHub/Sming/tree/develop/samples/Basic_Debug) sample for more details.
- **Interactive debugging on the device**: (default: OFF) In order to be able to debug live directly on the ESP8266 microcontroller you should re-compile the Sming library and your application with `ENABLE_GDB=1` directive. See [LiveDebug](https://github.com/SmingHub/Sming/tree/develop/samples/LiveDebug) sample for more details.
- **CommandExecutor feature**: (default: ON) This feature enables execution of certain commands by registering token handlers for text received via serial, websocket or telnet connection. If this feature is not used additional RAM/Flash can be obtained by setting `ENABLE_CMD_EXECUTOR=0`. This will save ~1KB RAM and ~3KB of flash memory.
- **SDK 3.0+**: (default: OFF) In order to use SDK 3.0.0 or newer you should set one environment variable before (re)compiling Sming AND applications based on it. The variable is SDK_BASE and it should point to `$SMING_HOME/third-party/ESP8266_NONOS_SDK`.

Expand Down
2 changes: 1 addition & 1 deletion Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ ifeq ($(SMING_RELEASE),1)
# 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
CFLAGS += -Og -ggdb -DGDBSTUB_FREERTOS=0 -DENABLE_GDB=1 -DGDBSTUB_CTRLC_BREAK=0
else
CFLAGS += -Os -g
endif
Expand Down
6 changes: 3 additions & 3 deletions Sming/Makefile-project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ ifeq ($(SMING_RELEASE),1)
# 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
MODULES += $(THIRD_PARTY_DIR)/gdbstub
EXTRA_INCDIR += $(THIRD_PARTY_DIR)/gdbstub
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
STRIP := @true
else
CFLAGS += -Os -g
Expand Down
6 changes: 3 additions & 3 deletions Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ ifeq ($(SMING_RELEASE),1)
# 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
MODULES += $(THIRD_PARTY_DIR)/gdbstub
EXTRA_INCDIR += $(THIRD_PARTY_DIR)/gdbstub
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
STRIP := @true
else
CFLAGS += -Os -g
Expand Down
38 changes: 28 additions & 10 deletions Sming/third-party/.patches/rboot.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
diff --git a/Makefile b/Makefile
index ca234de..f76fbaa 100644
index ca234de..5f1c72b 100644
--- a/Makefile
+++ b/Makefile
@@ -55,6 +55,16 @@ endif
@@ -22,10 +22,16 @@ else
Q := @
endif

-CFLAGS = -Os -O3 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
+CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
LD_SCRIPT = eagle.app.v6.ld

+ifeq ($(ENABLE_GDB),1)
+ CFLAGS += -Og -ggdb -DGDBSTUB_FREERTOS=0 -DENABLE_GDB=1 -DGDBSTUB_CTRLC_BREAK=0
+else
+ CFLAGS += -Os -O3
+endif
+
E2_OPTS = -quiet -bin -boot0

ifeq ($(RBOOT_BIG_FLASH),1)
@@ -55,6 +61,16 @@ endif
ifeq ($(RBOOT_IROM_CHKSUM),1)
CFLAGS += -DBOOT_IROM_CHKSUM
endif
Expand Down Expand Up @@ -52,7 +70,7 @@ index 6e10a2f..03cc87b 100644
@@ -291,86 +309,94 @@ uint32 NOINLINE find_image(void) {
ets_delay_us(BOOT_DELAY_MICROS);
#endif

- ets_printf("\r\nrBoot v1.4.2 - [email protected]\r\n");
+#ifndef BOOT_SILENT
+#define echof(fmt, ...) ets_printf(fmt, ##__VA_ARGS__)
Expand All @@ -61,10 +79,10 @@ index 6e10a2f..03cc87b 100644
+#endif
+
+ echof("\r\nrBoot v1.4.2 - [email protected]\r\n");

// read rom header
SPIRead(0, header, sizeof(rom_header));

// print and get flash size
- ets_printf("Flash Size: ");
+ echof("Flash Size: ");
Expand Down Expand Up @@ -103,7 +121,7 @@ index 6e10a2f..03cc87b 100644
// assume at least 4mbit
flashsize = 0x80000;
}

// print spi mode
- ets_printf("Flash Mode: ");
+ echof("Flash Mode: ");
Expand All @@ -123,7 +141,7 @@ index 6e10a2f..03cc87b 100644
- ets_printf("unknown\r\n");
+ echof("unknown\r\n");
}

// print spi speed
- ets_printf("Flash Speed: ");
+ echof("Flash Speed: ");
Expand All @@ -138,7 +156,7 @@ index 6e10a2f..03cc87b 100644
+ else if (flag == 2) echof("20 MHz\r\n");
+ else if (flag == 0x0f) echof("80 MHz\r\n");
+ else echof("unknown\r\n");

// print enabled options
#ifdef BOOT_BIG_FLASH
- ets_printf("rBoot Option: Big flash\r\n");
Expand Down Expand Up @@ -168,7 +186,7 @@ index 6e10a2f..03cc87b 100644
+ echof("\r\n");
+
+#undef echof

// read boot config
SPIRead(BOOT_CONFIG_SECTOR * SECTOR_SIZE, buffer, SECTOR_SIZE);
diff --git a/rboot.h b/rboot.h
Expand All @@ -181,6 +199,6 @@ index 93ae317..bd3ad6d 100644
// cannot be used at same time as BOOT_GPIO_ENABLED
-#define BOOT_GPIO_SKIP_ENABLED
+//#define BOOT_GPIO_SKIP_ENABLED

// set the GPIO pin used by GPIO modes above (will default
// to 16 if not manually set), only applicable when
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Basic_Debug</name>
<name>LiveDebug</name>
<comment></comment>
<projects>
<project>SmingFramework</project>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ MODULES = app
# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

DISABLE_SPIFFS = 1

# Com port speed
# COM_SPEED = 115200
ENABLE_GDB=1

export ENABLE_GDB
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
/*
* This example uses the hardware timer for best timing accuracy. There is only one of these on the ESP8266,
* so it may not be available if another module requires it.
* Most timing applicatons can use a SimpleTimer, which is good for intervals of up to about 268 seconds.
* Most timing applications can use a SimpleTimer, which is good for intervals of up to about 268 seconds.
* For longer intervals, use a Timer.
*/
HardwareTimer procTimer;
bool state = true;

/*
* Notice: Software breakpoints work only on code that is in RAM.
* Notice: Software breakpoints work only on code that is in RAM.
* In Sming you have to use the GDB_IRAM_ATTR to do this.
*/
void GDB_IRAM_ATTR blink()
Expand Down