8000 GDB support w/new toolchain and UART driver by earlephilhower · Pull Request #5559 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

GDB support w/new toolchain and UART driver #5559

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

Merged
merged 21 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
073299b
Add full gdb support with uart/Serial integration
kylefleming Mar 13, 2018
e618125
Merge branch 'master' into gdb
earlephilhower Dec 26, 2018
c3890bd
Fix GDB merge errors
earlephilhower Dec 26, 2018
211c2f3
Merge branch 'master' of https://github.com/esp8266/Arduino into gdb
earlephilhower Dec 27, 2018
6a714f3
Update to unpatched GDB protocol specification
earlephilhower Dec 27, 2018
a4c8ea4
Fix .iram.literal to come before .iram.text for GDB
earlephilhower Dec 27, 2018
b1d47e6
Move functions to flash, call using wrappers
earlephilhower Dec 27, 2018
b341c07
Remove LWIP2 builder commit
earlephilhower Dec 27, 2018
cc03543
Add documentation and gdbstub_init header
earlephilhower Dec 27, 2018
bb37b27
Merge branch 'master' into gdb
devyte Dec 28, 2018
0e2adcb
Clean up GDB include and library dir
earlephilhower Dec 30, 2018
fc7012f
Undo much of UART refactoring, set fifo IRQ to 16
earlephilhower Dec 31, 2018
33a21cd
Add architecture comments, cleanup uart.c code
earlephilhower Jan 1, 2019
e72291a
Also set the UART flags for HW error in GDB
Jan 2, 2019
bffd385
Merge branch 'master' into gdb
earlephilhower Jan 2, 2019
aef060b
Merge branch 'master' into gdb
earlephilhower Jan 8, 2019
a71d705
Merge branch 'master' into gdb
earlephilhower Jan 9, 2019
99da578
Merge branch 'master' into gdb
earlephilhower Jan 14, 2019
11a338c
Merge branch 'master' into gdb
earlephilhower Jan 17, 2019
06a28bd
Merge branch 'master' into gdb
earlephilhower Jan 18, 2019
a3ed4b4
Merge branch 'master' into gdb
earlephilhower Jan 23, 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
Prev Previous commit
Next Next commit
Undo much of UART refactoring, set fifo IRQ to 16
Remove the refactoring of pin control and other little things not directly
related to GDB processing.  Should greatly reduce the diff size in uart.c.
Should also remove any register value changes (intended or otherwise)
introduced in the original PR from @kylefleming.

Set the FIFO interrupt to 16 chars when in GDB mode, matching the latest
UART configuration for highest speed.
  • Loading branch information
earlephilhower committed Dec 31, 2018
commit fc7012f27cdb265dca802bf01b6808a1ca250d93
153 changes: 75 additions & 78 deletions cores/esp8266/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ uart_get_rx_buffer_size(uart_t* uart)
}


static void ICACHE_RAM_ATTR
void ICACHE_RAM_ATTR
uart_isr(void * arg)
{
uart_t* uart = (uart_t*)arg;
Expand Down Expand Up @@ -411,9 +411,9 @@ uart_do_write_char(const int uart_nr, char c)
size_t
uart_write_char(uart_t* uart, char c)
{
if(uart == NULL || !uart->tx_enabled) {
if(uart == NULL || !uart->tx_enabled)
return 0;
}

if(gdbstub_has_uart_isr_control() && uart->uart_nr == UART0) {
gdbstub_write_char(c);
return 1;
Expand Down Expand Up @@ -506,43 +506,6 @@ uart_get_baudrate(uart_t* uart)
return uart->baud_rate;
}

void uart0_enable_tx_pin(uint8_t pin)
{
switch(pin) {
case 1:
pinMode(pin, SPECIAL);
break;
case 2:
case 15:
pinMode(pin, FUNCTION_4);
break;
}
}

void uart0_enable_rx_pin(uint8_t pin)
{
switch(pin) {
case 3:
pinMode(pin, SPECIAL);
break;
case 13:
pinMode(pin, FUNCTION_4);
break;
}
}

void uart1_enable_tx_pin(uint8_t pin)
{
if(pin == 2) {
pinMode(pin, SPECIAL);
}
}

void uart_disable_pin(uint8_t pin)
{
pinMode(pin, INPUT);
}

uart_t*
uart_init(int uart_nr, int baudrate, int config, int mode, int tx_pin, size_t rx_size)
{
Expand Down Expand Up @@ -583,16 +546,20 @@ uart_init(int uart_nr, int baudrate, int config, int mode, int tx_pin, size_t rx
return NULL;
}
uart->rx_buffer = rx_buffer;
uart0_enable_rx_pin(uart->rx_pin);
pinMode(uart->rx_pin, SPECIAL);
}
if(uart->tx_enabled)
{
if (tx_pin == 2) {
uart->tx_pin = 2;
} else {
uart->tx_pin = 1;
}
uart0_enable_tx_pin(uart->tx_pin);
if (tx_pin == 2)
{
uart->tx_pin = 2;
pinMode(uart->tx_pin, FUNCTION_4);
}
else
{
uart->tx_pin = 1;
pinMode(uart->tx_pin, FUNCTION_0);
}
}
else
{
Expand Down Expand Up @@ -646,14 +613,33 @@ uart_uninit(uart_t* uart)
return;

if(uart->tx_enabled && (!gdbstub_has_uart_isr_control() || uart->uart_nr != UART0)) {
uart_disable_pin(uart->tx_pin);
switch(uart->tx_pin)
{
case 1:
pinMode(1, INPUT);
break;
case 2:
pinMode(2, INPUT);
break;
case 15:
pinMode(15, INPUT);
break;
}
}

if(uart->rx_enabled) {
free(uart->rx_buffer->buffer);
free(uart->rx_buffer);
if(!gdbstub_has_uart_isr_control()) {
uart_disable_pin(uart->rx_pin);
switch(uart->rx_pin)
{
case 3:
pinMode(3, INPUT);
break;
case 13:
pinMode(13, INPUT);
break;
}
uart_stop_isr(uart);
}
}
Expand All @@ -669,39 +655,46 @@ uart_swap(uart_t* uart, int tx_pin)
switch(uart->uart_nr)
{
case UART0:
if(uart->tx_enabled) { //TX
uart_disable_pin(uart->tx_pin);
}
if(uart->rx_enabled) { //RX
uart_disable_pin(uart->rx_pin);
}

if(((uart->tx_pin == 1 || uart->tx_pin == 2) && uart->tx_enabled)
|| (uart->rx_pin == 3 && uart->rx_enabled)) {
if(uart->tx_enabled) { //TX
if(((uart->tx_pin == 1 || uart->tx_pin == 2) && uart->tx_enabled) || (uart->rx_pin == 3 && uart->rx_enabled))
{
if(uart->tx_enabled) //TX
{
pinMode(uart->tx_pin, INPUT);
uart->tx_pin = 15;
}
if(uart->rx_enabled) { //RX
if(uart->rx_enabled) //RX
{
pinMode(uart->rx_pin, INPUT);
uart->rx_pin = 13;
}
if(uart->tx_enabled)
pinMode(uart->tx_pin, FUNCTION_4); //TX

if(uart->rx_enabled)
pinMode(uart->rx_pin, FUNCTION_4); //RX

IOSWAP |= (1 << IOSWAPU0);
} else {
if(uart->tx_enabled) { //TX
}
else
{
if(uart->tx_enabled) //TX
{
pinMode(uart->tx_pin, INPUT);
uart->tx_pin = (tx_pin == 2)?2:1;
}
if(uart->rx_enabled) { //RX
if(uart->rx_enabled) //RX
{
pinMode(uart->rx_pin, INPUT);
uart->rx_pin = 3;
}
IOSWAP &= ~(1 << IOSWAPU0);
}
if(uart->tx_enabled)
pinMode(uart->tx_pin, (tx_pin == 2)?FUNCTION_4:SPECIAL); //TX

if(uart->tx_enabled) { //TX
uart0_enable_tx_pin(uart->tx_pin);
}
if(uart->rx_enabled) { //RX
uart0_enable_rx_pin(uart->rx_pin);
}
if(uart->rx_enabled)
pinMode(3, SPECIAL); //RX

IOSWAP &= ~(1 << IOSWAPU0);
}
break;
case UART1:
// Currently no swap possible! See GPIO pins used by UART
Expand All @@ -720,15 +713,19 @@ uart_set_tx(uart_t* uart, int tx_pin)
switch(uart->uart_nr)
{
case UART0:
if(uart->tx_enabled) {
if (uart->tx_pin == 1 && tx_pin == 2) {
uart_disable_pin(uart->tx_pin);
if(uart->tx_enabled)
{
if (uart->tx_pin == 1 && tx_pin == 2)
{
pinMode(uart->tx_pin, INPUT);
uart->tx_pin = 2;
uart0_enable_tx_pin(uart->tx_pin);
} else if (uart->tx_pin == 2 && tx_pin != 2) {
uart_disable_pin(uart->tx_pin);
pinMode(uart->tx_pin, FUNCTION_4);
}
else if (uart->tx_pin == 2 && tx_pin != 2)
{
pinMode(uart->tx_pin, INPUT);
uart->tx_pin = 1;
uart0_enable_tx_pin(uart->tx_pin);
pinMode(uart->tx_pin, SPECIAL);
}
}

Expand Down
8 changes: 5 additions & 3 deletions libraries/GDBStub/src/internal/gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <GDBStub.h>
#include <stddef.h>
#include <Arduino.h>
#include "ets_sys.h"
#include "eagle_soc.h"
#include "c_types.h"
Expand Down Expand Up @@ -781,8 +782,9 @@ static void ATTR_GDBINIT configure_uart() {}
static void ATTR_GDBINIT configure_uart() {

#ifdef ARDUINO
uart0_enable_tx_pin(1);
uart0_enable_rx_pin(3);
// Set the UART input/output pins to TX=1, RX=3
pinMode(3, SPECIAL);
pinMode(1, FUNCTION_0);
#endif

WRITE_PERI_REG(UART_CONF0(0), 0b00011100); //8N1
Expand Down Expand Up @@ -875,7 +877,7 @@ static void ATTR_GDBINIT install_uart_hdlr() {
configure_uart();

WRITE_PERI_REG(UART_CONF1(0),
((100 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) |
((16 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S) |
((0x02 & UART_RX_TOUT_THRHD) << UART_RX_TOUT_THRHD_S) |
UART_RX_TOUT_EN);

Expand Down
0