mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
Code cleanup. Bugfix after rebase with master. Formating.
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
idf_build_get_property(target IDF_TARGET)
|
idf_build_get_property(target IDF_TARGET)
|
||||||
|
|
||||||
set(esp_gdbstub_srcs "src/gdbstub.c"
|
idf_component_register(SRCS "src/gdbstub.c" "src/packet.c"
|
||||||
"src/packet.c"
|
|
||||||
"esp_common/gdbstub_common.c"
|
|
||||||
"${target}/gdbstub_${target}.c"
|
|
||||||
"xtensa/gdbstub-entry.S"
|
|
||||||
"xtensa/gdbstub_xtensa.c")
|
|
||||||
|
|
||||||
idf_component_register(SRCS "${esp_gdbstub_srcs}"
|
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
PRIV_INCLUDE_DIRS "private_include" "${target}" "xtensa"
|
PRIV_INCLUDE_DIRS "private_include"
|
||||||
LDFRAGMENTS "linker.lf"
|
LDFRAGMENTS "linker.lf"
|
||||||
REQUIRES "freertos"
|
REQUIRES "freertos"
|
||||||
PRIV_REQUIRES "soc" "xtensa" "esp_rom")
|
PRIV_REQUIRES "soc" "esp_rom")
|
||||||
|
|
||||||
|
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
|
||||||
|
target_include_directories(${COMPONENT_LIB} PUBLIC "xtensa" "${target}")
|
||||||
|
target_sources(${COMPONENT_LIB} PRIVATE "xtensa/gdbstub_xtensa.c"
|
||||||
|
"xtensa/gdbstub-entry.S"
|
||||||
|
"esp_common/gdbstub_common.c")
|
||||||
|
|
||||||
|
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
|
||||||
|
target_include_directories(${COMPONENT_LIB} PUBLIC "riscv" "${target}")
|
||||||
|
target_sources(${COMPONENT_LIB} PRIVATE "riscv/gdbstub_riscv.c"
|
||||||
|
"${target}/gdbstub_${target}.c")
|
||||||
|
endif()
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
COMPONENT_ADD_INCLUDEDIRS := include
|
COMPONENT_ADD_INCLUDEDIRS := include
|
||||||
COMPONENT_PRIV_INCLUDEDIRS := private_include esp32 xtensa
|
COMPONENT_PRIV_INCLUDEDIRS := private_include esp32 xtensa
|
||||||
COMPONENT_SRCDIRS := src esp32 xtensa
|
COMPONENT_SRCDIRS := src esp32 xtensa esp_common
|
||||||
COMPONENT_ADD_LDFRAGMENTS += linker.lf
|
COMPONENT_ADD_LDFRAGMENTS += linker.lf
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "soc/uart_periph.h"
|
|
||||||
#include "soc/gpio_periph.h"
|
|
||||||
#include "esp_gdbstub_common.h"
|
|
||||||
#include "sdkconfig.h"
|
|
@@ -1,18 +0,0 @@
|
|||||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "soc/uart_periph.h"
|
|
||||||
#include "soc/gpio_periph.h"
|
|
||||||
#include "esp_gdbstub_common.h"
|
|
||||||
#include "sdkconfig.h"
|
|
@@ -1,19 +0,0 @@
|
|||||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "soc/uart_periph.h"
|
|
||||||
#include "soc/gpio_periph.h"
|
|
||||||
#include "esp_gdbstub_common.h"
|
|
||||||
|
|
@@ -29,12 +29,16 @@ void esp_gdbstub_target_init(void)
|
|||||||
case 0:
|
case 0:
|
||||||
gdb_uart = &UART0;
|
gdb_uart = &UART0;
|
||||||
break;
|
break;
|
||||||
|
#if SOC_UART_NUM > 1
|
||||||
case 1:
|
case 1:
|
||||||
gdb_uart = &UART1;
|
gdb_uart = &UART1;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#if SOC_UART_NUM > 2
|
||||||
case 2:
|
case 2:
|
||||||
gdb_uart = &UART2;
|
gdb_uart = &UART2;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
gdb_uart = &UART0;
|
gdb_uart = &UART0;
|
||||||
break;
|
break;
|
||||||
|
@@ -58,3 +58,8 @@ int esp_gdbstub_get_signal(const esp_gdbstub_frame_t *frame)
|
|||||||
{
|
{
|
||||||
return 5; // SIGTRAP, see IDF-2490
|
return 5; // SIGTRAP, see IDF-2490
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _xt_gdbstub_int(void * frame)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include "hal/wdt_hal.h"
|
#include "hal/wdt_hal.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
//#include "esp_task_wdt.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
|
#ifdef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
|
||||||
@@ -43,11 +42,11 @@ static esp_gdbstub_scratch_t s_scratch;
|
|||||||
static esp_gdbstub_gdb_regfile_t *gdb_local_regfile = &s_scratch.regfile;
|
static esp_gdbstub_gdb_regfile_t *gdb_local_regfile = &s_scratch.regfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @breef panic handler
|
* @brief panic handler
|
||||||
*/
|
*/
|
||||||
void esp_gdbstub_panic_handler(void *in_frame)
|
void esp_gdbstub_panic_handler(void *in_frame)
|
||||||
{
|
{
|
||||||
esp_gdbstub_frame_t* frame = (esp_gdbstub_frame_t*)in_frame;
|
esp_gdbstub_frame_t *frame = (esp_gdbstub_frame_t *)in_frame;
|
||||||
#ifndef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
|
#ifndef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
|
||||||
esp_gdbstub_frame_to_regfile(frame, &s_scratch.regfile);
|
esp_gdbstub_frame_to_regfile(frame, &s_scratch.regfile);
|
||||||
#else
|
#else
|
||||||
@@ -186,7 +185,7 @@ static inline void enable_all_wdts(void)
|
|||||||
* @param curr_regs - actual registers frame
|
* @param curr_regs - actual registers frame
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void gdbstub_handle_uart_int(XtExcFrame *regs_frame)
|
void gdbstub_handle_uart_int(esp_gdbstub_frame_t *regs_frame)
|
||||||
{
|
{
|
||||||
// Disable all enabled WDT on enter
|
// Disable all enabled WDT on enter
|
||||||
disable_all_wdts();
|
disable_all_wdts();
|
||||||
@@ -234,7 +233,7 @@ intr_handle_t intr_handle_;
|
|||||||
extern void _xt_gdbstub_int(void * );
|
extern void _xt_gdbstub_int(void * );
|
||||||
|
|
||||||
#ifdef CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
#ifdef CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
||||||
/** @breef Init gdbstub
|
/** @brief Init gdbstub
|
||||||
* Init uart interrupt for gdbstub
|
* Init uart interrupt for gdbstub
|
||||||
* */
|
* */
|
||||||
void esp_gdbstub_init(void)
|
void esp_gdbstub_init(void)
|
||||||
@@ -395,18 +394,6 @@ static bool get_task_handle(size_t index, TaskHandle_t *handle)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static eTaskState get_task_state(size_t index)
|
|
||||||
{
|
|
||||||
return eSuspended;
|
|
||||||
// return s_scratch.tasks[index].eCurrentState;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_task_cpu_id(size_t index)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
// return s_scratch.tasks[index].xCoreID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the index of the task running on the current CPU, and save the result */
|
/** Get the index of the task running on the current CPU, and save the result */
|
||||||
static void find_paniced_task_index(void)
|
static void find_paniced_task_index(void)
|
||||||
{
|
{
|
||||||
@@ -531,29 +518,8 @@ static void handle_qThreadExtraInfo_command(const unsigned char *cmd, int len)
|
|||||||
esp_gdbstub_send_str_as_hex((const char *)pcTaskGetTaskName(handle));
|
esp_gdbstub_send_str_as_hex((const char *)pcTaskGetTaskName(handle));
|
||||||
esp_gdbstub_send_hex(' ', 8);
|
esp_gdbstub_send_hex(' ', 8);
|
||||||
|
|
||||||
eTaskState state = get_task_state(task_index);
|
// Current version report only Suspended state
|
||||||
switch (state) {
|
|
||||||
case eRunning:
|
|
||||||
esp_gdbstub_send_str_as_hex("State: Running ");
|
|
||||||
esp_gdbstub_send_str_as_hex("@CPU");
|
|
||||||
esp_gdbstub_send_hex(get_task_cpu_id(task_index) + '0', 8);
|
|
||||||
break;
|
|
||||||
case eReady:
|
|
||||||
esp_gdbstub_send_str_as_hex("State: Ready");
|
|
||||||
break;
|
|
||||||
case eBlocked:
|
|
||||||
esp_gdbstub_send_str_as_hex("State: Blocked");
|
|
||||||
break;
|
|
||||||
case eSuspended:
|
|
||||||
esp_gdbstub_send_str_as_hex("State: Suspended");
|
esp_gdbstub_send_str_as_hex("State: Suspended");
|
||||||
break;
|
|
||||||
case eDeleted:
|
|
||||||
esp_gdbstub_send_str_as_hex("State: Deleted");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
esp_gdbstub_send_str_as_hex("State: Invalid");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_gdbstub_send_end();
|
esp_gdbstub_send_end();
|
||||||
}
|
}
|
||||||
@@ -605,4 +571,3 @@ static int handle_task_commands(unsigned char *cmd, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
|
#endif // CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "freertos/xtensa_context.h"
|
#include "freertos/xtensa_context.h"
|
||||||
|
#include "gdbstub_target_config.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@@ -41,4 +41,3 @@ _xt_gdbstub_int:
|
|||||||
mov a6,sp
|
mov a6,sp
|
||||||
call0 gdbstub_handle_uart_int
|
call0 gdbstub_handle_uart_int
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "esp_private/panic_internal.h"
|
#include "esp_private/panic_internal.h"
|
||||||
#include "port/panic_funcs.h"
|
#include "port/panic_funcs.h"
|
||||||
|
#include "esp_rom_sys.h"
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
@@ -58,6 +59,10 @@
|
|||||||
#include "esp_gdbstub.h"
|
#include "esp_gdbstub.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
||||||
|
#include "hal/usb_serial_jtag_ll.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
bool g_panic_abort = false;
|
bool g_panic_abort = false;
|
||||||
static char *s_panic_abort_details = NULL;
|
static char *s_panic_abort_details = NULL;
|
||||||
|
|
||||||
@@ -68,13 +73,13 @@ static wdt_hal_context_t wdt1_context = {.inst = WDT_MWDT1, .mwdt_dev = &TIMERG1
|
|||||||
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
||||||
|
|
||||||
#if CONFIG_ESP_CONSOLE_UART
|
#if CONFIG_ESP_CONSOLE_UART
|
||||||
static uart_hal_context_t s_panic_uart = { .dev = CONFIG_ESP_CONSOLE_UART_NUM == 0 ? &UART0 : &UART1 };
|
static uart_hal_context_t s_panic_uart = { .dev = CONFIG_ESP_CONSOLE_UART_NUM == 0 ? &UART0 :&UART1 };
|
||||||
|
|
||||||
void panic_print_char(const char c)
|
void panic_print_char(const char c)
|
||||||
{
|
{
|
||||||
uint32_t sz = 0;
|
uint32_t sz = 0;
|
||||||
while(!uart_hal_get_txfifo_len(&s_panic_uart));
|
while (!uart_hal_get_txfifo_len(&s_panic_uart));
|
||||||
uart_hal_write_txfifo(&s_panic_uart, (uint8_t*) &c, 1, &sz);
|
uart_hal_write_txfifo(&s_panic_uart, (uint8_t *) &c, 1, &sz);
|
||||||
}
|
}
|
||||||
#endif // CONFIG_ESP_CONSOLE_UART
|
#endif // CONFIG_ESP_CONSOLE_UART
|
||||||
|
|
||||||
@@ -87,6 +92,27 @@ void panic_print_char(const char c)
|
|||||||
}
|
}
|
||||||
#endif // CONFIG_ESP_CONSOLE_USB_CDC
|
#endif // CONFIG_ESP_CONSOLE_USB_CDC
|
||||||
|
|
||||||
|
#if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
||||||
|
//Timeout; if there's no host listening, the txfifo won't ever
|
||||||
|
//be writable after the first packet.
|
||||||
|
|
||||||
|
#define USBSERIAL_TIMEOUT_MAX_US 50000
|
||||||
|
static int s_usbserial_timeout = 0;
|
||||||
|
|
||||||
|
void panic_print_char(const char c)
|
||||||
|
{
|
||||||
|
while (!usb_serial_jtag_ll_txfifo_writable() && s_usbserial_timeout < (USBSERIAL_TIMEOUT_MAX_US / 100)) {
|
||||||
|
esp_rom_delay_us(100);
|
||||||
|
s_usbserial_timeout++;
|
||||||
|
}
|
||||||
|
if (usb_serial_jtag_ll_txfifo_writable()) {
|
||||||
|
usb_serial_jtag_ll_write_txfifo((const uint8_t *)&c, 1);
|
||||||
|
s_usbserial_timeout = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_ESP_CONSOLE_NONE
|
#if CONFIG_ESP_CONSOLE_NONE
|
||||||
void panic_print_char(const char c)
|
void panic_print_char(const char c)
|
||||||
{
|
{
|
||||||
@@ -96,7 +122,7 @@ void panic_print_char(const char c)
|
|||||||
|
|
||||||
void panic_print_str(const char *str)
|
void panic_print_str(const char *str)
|
||||||
{
|
{
|
||||||
for(int i = 0; str[i] != 0; i++) {
|
for (int i = 0; str[i] != 0; i++) {
|
||||||
panic_print_char(str[i]);
|
panic_print_char(str[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +171,7 @@ static void reconfigure_all_wdts(void)
|
|||||||
//Reconfigure TWDT (Timer Group 0)
|
//Reconfigure TWDT (Timer Group 0)
|
||||||
wdt_hal_init(&wdt0_context, WDT_MWDT0, MWDT0_TICK_PRESCALER, false); //Prescaler: wdt counts in ticks of TG0_WDT_TICK_US
|
wdt_hal_init(&wdt0_context, WDT_MWDT0, MWDT0_TICK_PRESCALER, false); //Prescaler: wdt counts in ticks of TG0_WDT_TICK_US
|
||||||
wdt_hal_write_protect_disable(&wdt0_context);
|
wdt_hal_write_protect_disable(&wdt0_context);
|
||||||
wdt_hal_config_stage(&wdt0_context, 0, 1000*1000/MWDT0_TICKS_PER_US, WDT_STAGE_ACTION_RESET_SYSTEM); //1 second before reset
|
wdt_hal_config_stage(&wdt0_context, 0, 1000 * 1000 / MWDT0_TICKS_PER_US, WDT_STAGE_ACTION_RESET_SYSTEM); //1 second before reset
|
||||||
wdt_hal_enable(&wdt0_context);
|
wdt_hal_enable(&wdt0_context);
|
||||||
wdt_hal_write_protect_enable(&wdt0_context);
|
wdt_hal_write_protect_enable(&wdt0_context);
|
||||||
|
|
||||||
@@ -296,7 +322,7 @@ void esp_panic_handler(panic_info_t *info)
|
|||||||
wdt_hal_disable(&rtc_wdt_ctx);
|
wdt_hal_disable(&rtc_wdt_ctx);
|
||||||
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
|
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
|
||||||
panic_print_str("Entering gdb stub now.\r\n");
|
panic_print_str("Entering gdb stub now.\r\n");
|
||||||
esp_gdbstub_panic_handler(info->frame);
|
esp_gdbstub_panic_handler((void *)info->frame);
|
||||||
#else
|
#else
|
||||||
#if CONFIG_ESP_COREDUMP_ENABLE
|
#if CONFIG_ESP_COREDUMP_ENABLE
|
||||||
static bool s_dumping_core;
|
static bool s_dumping_core;
|
||||||
@@ -321,8 +347,7 @@ void esp_panic_handler(panic_info_t *info)
|
|||||||
#if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
#if CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
||||||
|
|
||||||
if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) {
|
if (esp_reset_reason_get_hint() == ESP_RST_UNKNOWN) {
|
||||||
switch (info->exception)
|
switch (info->exception) {
|
||||||
{
|
|
||||||
case PANIC_EXCEPTION_IWDT:
|
case PANIC_EXCEPTION_IWDT:
|
||||||
esp_reset_reason_set_hint(ESP_RST_INT_WDT);
|
esp_reset_reason_set_hint(ESP_RST_INT_WDT);
|
||||||
break;
|
break;
|
||||||
@@ -348,10 +373,10 @@ void esp_panic_handler(panic_info_t *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __attribute__((noreturn)) panic_abort(const char *details)
|
void __attribute__((noreturn, no_sanitize_undefined)) panic_abort(const char *details)
|
||||||
{
|
{
|
||||||
g_panic_abort = true;
|
g_panic_abort = true;
|
||||||
s_panic_abort_details = (char*) details;
|
s_panic_abort_details = (char *) details;
|
||||||
|
|
||||||
#if CONFIG_APPTRACE_ENABLE
|
#if CONFIG_APPTRACE_ENABLE
|
||||||
#if CONFIG_SYSVIEW_ENABLE
|
#if CONFIG_SYSVIEW_ENABLE
|
||||||
@@ -363,7 +388,7 @@ void __attribute__((noreturn)) panic_abort(const char *details)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
*((int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
|
*((int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets
|
||||||
while(1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Weak versions of reset reason hint functions.
|
/* Weak versions of reset reason hint functions.
|
||||||
|
@@ -61,6 +61,10 @@ volatile unsigned port_xSchedulerRunning[portNUM_PROCESSORS] = {0};
|
|||||||
|
|
||||||
static void main_task(void* args);
|
static void main_task(void* args);
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
||||||
|
void esp_gdbstub_init(void);
|
||||||
|
#endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
||||||
|
|
||||||
extern void app_main(void);
|
extern void app_main(void);
|
||||||
|
|
||||||
void esp_startup_start_app_common(void)
|
void esp_startup_start_app_common(void)
|
||||||
@@ -79,6 +83,10 @@ void esp_startup_start_app_common(void)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
||||||
|
esp_gdbstub_init();
|
||||||
|
#endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME
|
||||||
|
|
||||||
portBASE_TYPE res = xTaskCreatePinnedToCore(&main_task, "main",
|
portBASE_TYPE res = xTaskCreatePinnedToCore(&main_task, "main",
|
||||||
ESP_TASK_MAIN_STACK, NULL,
|
ESP_TASK_MAIN_STACK, NULL,
|
||||||
ESP_TASK_MAIN_PRIO, NULL, ESP_TASK_MAIN_CORE);
|
ESP_TASK_MAIN_PRIO, NULL, ESP_TASK_MAIN_CORE);
|
||||||
|
@@ -10,7 +10,6 @@ This tool can be launched from an IDF project by running ``idf.py monitor``.
|
|||||||
|
|
||||||
For the legacy GNU Make system, run ``make monitor``.
|
For the legacy GNU Make system, run ``make monitor``.
|
||||||
|
|
||||||
|
|
||||||
Keyboard Shortcuts
|
Keyboard Shortcuts
|
||||||
==================
|
==================
|
||||||
|
|
||||||
@@ -59,9 +58,9 @@ For easy interaction with IDF Monitor, use the keyboard shortcuts given in the t
|
|||||||
* - * Ctrl+X (or X)
|
* - * Ctrl+X (or X)
|
||||||
- Exit the program
|
- Exit the program
|
||||||
-
|
-
|
||||||
* - Ctrl+]
|
* - Ctrl+C
|
||||||
- Interrupt running application
|
- Interrupt running application
|
||||||
- Pauses IDF monitor and run GDB_ project debugger to debug the application at runtime.
|
- Pauses IDF monitor and run GDB_ project debugger to debug the application at runtime. This requires :ref:CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME option to be enabled.
|
||||||
|
|
||||||
Any keys pressed, other than ``Ctrl-]`` and ``Ctrl-T``, will be sent through the serial port.
|
Any keys pressed, other than ``Ctrl-]`` and ``Ctrl-T``, will be sent through the serial port.
|
||||||
|
|
||||||
@@ -187,6 +186,7 @@ To decode each address, IDF Monitor runs the following command in the background
|
|||||||
Launching GDB with GDBStub
|
Launching GDB with GDBStub
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
By default, if esp-idf crashes, the panic handler prints relevant registers and the stack dump (similar to the ones above) over the serial port. Then it resets the board.
|
By default, if esp-idf crashes, the panic handler prints relevant registers and the stack dump (similar to the ones above) over the serial port. Then it resets the board.
|
||||||
|
|
||||||
Furthermore, the application can be configured to run GDBStub in the background and handle the Ctrl+C event from the monitor.
|
Furthermore, the application can be configured to run GDBStub in the background and handle the Ctrl+C event from the monitor.
|
||||||
|
@@ -6,4 +6,3 @@
|
|||||||
PROJECT_NAME := gdbstub
|
PROJECT_NAME := gdbstub
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
|
||||||
|
@@ -2,4 +2,3 @@
|
|||||||
# "main" pseudo-component makefile.
|
# "main" pseudo-component makefile.
|
||||||
#
|
#
|
||||||
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
|
|
||||||
|
@@ -33,15 +33,13 @@ import json
|
|||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from collections import Counter, OrderedDict
|
from collections import Counter, OrderedDict
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from pkgutil import iter_modules
|
from pkgutil import iter_modules
|
||||||
|
|
||||||
import signal
|
|
||||||
|
|
||||||
|
|
||||||
# pyc files remain in the filesystem when switching between branches which might raise errors for incompatible
|
# pyc files remain in the filesystem when switching between branches which might raise errors for incompatible
|
||||||
# idf.py extensions. Therefore, pyc file generation is turned off:
|
# idf.py extensions. Therefore, pyc file generation is turned off:
|
||||||
sys.dont_write_bytecode = True
|
sys.dont_write_bytecode = True
|
||||||
@@ -726,7 +724,7 @@ def init_cli(verbose_output=None):
|
|||||||
return CLI(help=cli_help, verbose_output=verbose_output, all_actions=all_actions)
|
return CLI(help=cli_help, verbose_output=verbose_output, all_actions=all_actions)
|
||||||
|
|
||||||
|
|
||||||
def signal_handler(signal, frame):
|
def signal_handler(_signal, _frame):
|
||||||
# The Ctrl+C processed by other threads inside
|
# The Ctrl+C processed by other threads inside
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@@ -202,10 +202,10 @@ class Monitor(object):
|
|||||||
elif event_tag == TAG_SERIAL_FLUSH:
|
elif event_tag == TAG_SERIAL_FLUSH:
|
||||||
self.handle_serial_input(data, finalize_line=True)
|
self.handle_serial_input(data, finalize_line=True)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Bad event data %r" % ((event_tag,data),))
|
raise RuntimeError('Bad event data %r' % ((event_tag,data),))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
try:
|
try:
|
||||||
yellow_print("To exit from IDF monitor please use \"Ctrl+]\"")
|
yellow_print('To exit from IDF monitor please use \"Ctrl+]\"')
|
||||||
self.serial.write(codecs.encode('\x03'))
|
self.serial.write(codecs.encode('\x03'))
|
||||||
except serial.SerialException:
|
except serial.SerialException:
|
||||||
pass # this shouldn't happen, but sometimes port has closed in serial thread
|
pass # this shouldn't happen, but sometimes port has closed in serial thread
|
||||||
@@ -232,9 +232,9 @@ class Monitor(object):
|
|||||||
# Remove "+" after Continue command
|
# Remove "+" after Continue command
|
||||||
if self.start_cmd_sent is True:
|
if self.start_cmd_sent is True:
|
||||||
self.start_cmd_sent = False
|
self.start_cmd_sent = False
|
||||||
pos = data.find(b"+")
|
pos = data.find(b'+')
|
||||||
if pos != -1:
|
if pos != -1:
|
||||||
data = data[1:]
|
data = data[(pos + 1):]
|
||||||
|
|
||||||
sp = data.split(b'\n')
|
sp = data.split(b'\n')
|
||||||
if self._last_line_part != b'':
|
if self._last_line_part != b'':
|
||||||
@@ -520,10 +520,9 @@ class Monitor(object):
|
|||||||
self.elf_file]
|
self.elf_file]
|
||||||
|
|
||||||
# Here we handling GDB as a process
|
# Here we handling GDB as a process
|
||||||
if True:
|
|
||||||
# Open GDB process
|
# Open GDB process
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(cmd, cwd=".")
|
process = subprocess.Popen(cmd, cwd='.')
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@@ -50,18 +50,16 @@ class SerialReader(StoppableThread):
|
|||||||
self.serial.baudrate = self.baud
|
self.serial.baudrate = self.baud
|
||||||
# We can come to this thread at startup or from external application line GDB.
|
# We can come to this thread at startup or from external application line GDB.
|
||||||
# If we come from GDB we would like to continue to run without reset.
|
# If we come from GDB we would like to continue to run without reset.
|
||||||
if self.gdb_exit is False:
|
if self.gdb_exit:
|
||||||
|
self.serial.rts = False
|
||||||
|
self.serial.dtr = True
|
||||||
|
else: # if we exit from GDB, we don't need to reset the target
|
||||||
# This sequence of DTR/RTS and open/close set the serial port to
|
# This sequence of DTR/RTS and open/close set the serial port to
|
||||||
# condition when GDB not make reset of the target by switching DTR/RTS.
|
# condition when GDB not make reset of the target by switching DTR/RTS.
|
||||||
self.serial.rts = True # IO0=LOW
|
self.serial.rts = True # IO0=LOW
|
||||||
self.serial.dtr = self.serial.dtr # usbser.sys workaround
|
self.serial.dtr = self.serial.dtr # usbser.sys workaround
|
||||||
self.serial.open()
|
|
||||||
self.serial.close()
|
|
||||||
self.serial.rts = False # IO0=HIGH
|
self.serial.rts = False # IO0=HIGH
|
||||||
self.serial.dtr = False
|
self.serial.dtr = False
|
||||||
else: # if we exit from GDB, we don't need to reset the target
|
|
||||||
self.serial.rts = False
|
|
||||||
self.serial.dtr = True
|
|
||||||
|
|
||||||
# Current state not reset the target!
|
# Current state not reset the target!
|
||||||
self.gdb_exit = False
|
self.gdb_exit = False
|
||||||
|
@@ -16,9 +16,6 @@
|
|||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <strsafe.h>
|
#include <strsafe.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define LINESIZE 1024
|
#define LINESIZE 1024
|
||||||
|
|
||||||
@@ -46,17 +43,6 @@ BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
|
|
||||||
{
|
|
||||||
switch (fdwCtrlType) {
|
|
||||||
// Handle the CTRL-C signal.
|
|
||||||
case CTRL_C_EVENT:
|
|
||||||
return TRUE;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, LPTSTR argv[])
|
int main(int argc, LPTSTR argv[])
|
||||||
{
|
{
|
||||||
/* Print the version of this wrapper tool, but only if invoked as "idf.exe".
|
/* Print the version of this wrapper tool, but only if invoked as "idf.exe".
|
||||||
|
Reference in New Issue
Block a user