Merge commit '5aebef4f64d0fd4c19f794fb9725686c39a7e395' into sam-update
This commit is contained in:
commit
bb97e35f82
14
src/Makefile
14
src/Makefile
@ -34,9 +34,6 @@ SRC = \
|
||||
gdb_hostio.c \
|
||||
gdb_packet.c \
|
||||
hex_utils.c \
|
||||
jtag_scan.c \
|
||||
jtagtap.c \
|
||||
jtagtap_generic.c \
|
||||
lmi.c \
|
||||
lpc_common.c \
|
||||
lpc11xx.c \
|
||||
@ -58,15 +55,22 @@ SRC = \
|
||||
stm32h7.c \
|
||||
stm32l0.c \
|
||||
stm32l4.c \
|
||||
swdptap.c \
|
||||
swdptap_generic.c \
|
||||
target.c \
|
||||
|
||||
include $(PLATFORM_DIR)/Makefile.inc
|
||||
|
||||
ifndef TARGET
|
||||
TARGET=blackmagic
|
||||
endif
|
||||
|
||||
ifndef SWD_HL
|
||||
SRC += swdptap.c swdptap_generic.c
|
||||
endif
|
||||
|
||||
ifndef JTAG_HL
|
||||
SRC += jtag_scan.c jtagtap.c jtagtap_generic.c
|
||||
endif
|
||||
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
$(TARGET): include/version.h $(OBJ)
|
||||
|
@ -7,4 +7,5 @@ CFLAGS += -Wno-cast-function-type
|
||||
else ifneq (, $(findstring cygwin, $(SYS)))
|
||||
LDFLAGS += -lusb-1.0 -lws2_32
|
||||
endif
|
||||
VPATH += platforms/pc
|
||||
SRC += timing.c \
|
||||
|
@ -36,12 +36,16 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
|
||||
static int gdb_if_serv, gdb_if_conn;
|
||||
|
||||
#define DEFAULT_PORT 2000
|
||||
#define NUM_GDB_SERVER 4
|
||||
int gdb_if_init(void)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
@ -50,20 +54,40 @@ int gdb_if_init(void)
|
||||
#endif
|
||||
struct sockaddr_in addr;
|
||||
int opt;
|
||||
int port = DEFAULT_PORT - 1;
|
||||
|
||||
do {
|
||||
port ++;
|
||||
if (port > DEFAULT_PORT + NUM_GDB_SERVER)
|
||||
return - 1;
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(2000);
|
||||
addr.sin_port = htons(port);
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
assert((gdb_if_serv = socket(PF_INET, SOCK_STREAM, 0)) != -1);
|
||||
gdb_if_serv = socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (gdb_if_serv == -1)
|
||||
continue;
|
||||
|
||||
opt = 1;
|
||||
assert(setsockopt(gdb_if_serv, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(opt)) != -1);
|
||||
assert(setsockopt(gdb_if_serv, IPPROTO_TCP, TCP_NODELAY, (void*)&opt, sizeof(opt)) != -1);
|
||||
|
||||
assert(bind(gdb_if_serv, (void*)&addr, sizeof(addr)) != -1);
|
||||
assert(listen(gdb_if_serv, 1) != -1);
|
||||
|
||||
DEBUG("Listening on TCP:2000\n");
|
||||
if (setsockopt(gdb_if_serv, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(opt)) == -1) {
|
||||
close(gdb_if_serv);
|
||||
continue;
|
||||
}
|
||||
if (setsockopt(gdb_if_serv, IPPROTO_TCP, TCP_NODELAY, (void*)&opt, sizeof(opt)) == -1) {
|
||||
close(gdb_if_serv);
|
||||
continue;
|
||||
}
|
||||
if (bind(gdb_if_serv, (void*)&addr, sizeof(addr)) == -1) {
|
||||
close(gdb_if_serv);
|
||||
continue;
|
||||
}
|
||||
if (listen(gdb_if_serv, 1) == -1) {
|
||||
close(gdb_if_serv);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
} while(1);
|
||||
DEBUG("Listening on TCP: %4d\n", port);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user