Select one of the symbols to view example projects that use it.
 
Outline
#include "esp_gdbstub.h"
#include "esp_gdbstub_common.h"
#include "sdkconfig.h"
#include "hal/usb_serial_jtag_ll.h"
#include "hal/uart_ll.h"
gdb_uart
esp_gdbstub_uart_init()
esp_gdbstub_getchar()
esp_gdbstub_putchar(int)
esp_gdbstub_flush()
Files
loading (4/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp_gdbstub/src/gdbstub_transport.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include "esp_gdbstub.h" #include "esp_gdbstub_common.h" #include "sdkconfig.h" #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG #include "hal/usb_serial_jtag_ll.h" #else #include "hal/uart_ll.h" #endif #if CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG int esp_gdbstub_getchar(void) { uint8_t c; // retry the read until we succeed while (usb_serial_jtag_ll_read_rxfifo(&c, 1) == 0) { ; }{...} return c; }{...} void esp_gdbstub_putchar(int c) { uint8_t cc = c; // retry the write until we succeed while (usb_serial_jtag_ll_write_txfifo(&cc, 1) < 1) { ; }{...} }{...} void esp_gdbstub_flush(void) { usb_serial_jtag_ll_txfifo_flush(); }{...} #ifdef CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME int esp_gdbstub_getfifo(void) { return 0; // TODO: IDF-7264 }{...} /* ... */#endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME /* ... */ #else // CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG static uart_dev_t *gdb_uart = NULL; static inline void esp_gdbstub_uart_init(void) { if (gdb_uart != NULL) { return; }{...} switch (CONFIG_ESP_CONSOLE_UART_NUM) { case 0: gdb_uart = &UART0; break; #if SOC_UART_HP_NUM > 1... case 1: gdb_uart = &UART1; break;/* ... */ #endif #if SOC_UART_HP_NUM > 2 case 2: gdb_uart = &UART2; break;/* ... */ #endif default: gdb_uart = &UART0; break;... }{...} }{ ... } int esp_gdbstub_getchar(void) { esp_gdbstub_uart_init(); unsigned char data; while (uart_ll_get_rxfifo_len(gdb_uart) == 0) { ; }{...} uart_ll_read_rxfifo(gdb_uart, &data, 1); return data; }{ ... } void esp_gdbstub_putchar(int c) { esp_gdbstub_uart_init(); while (uart_ll_get_txfifo_len(gdb_uart) <= 126) { ; }{...} uart_ll_write_txfifo(gdb_uart, (uint8_t *)&c, 1); }{ ... } void esp_gdbstub_flush(void) { esp_gdbstub_uart_init(); // wait until some data in transmition while (false == uart_ll_is_tx_idle(gdb_uart)) { ; }{...} }{ ... } #ifdef CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME int esp_gdbstub_getfifo(void) { esp_gdbstub_uart_init(); int doDebug = 0; int fifolen = uart_ll_get_rxfifo_len(gdb_uart); while (fifolen != 0) { unsigned char data; uart_ll_read_rxfifo(gdb_uart, &data, 1); if (data == 0x3) { doDebug = 1; // Check if any of the chars is Ctrl+C. Throw away rest. }{...} fifolen--; }{...} uart_ll_clr_intsts_mask(gdb_uart, UART_INTR_RXFIFO_FULL | UART_INTR_RXFIFO_TOUT); return doDebug; }{...} /* ... */#endif // CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME/* ... */ #endif // CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
Details