From 09c2325ce3132b74217e2afe922b7096417a52a1 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Fri, 26 Feb 2021 20:20:36 +0000 Subject: [PATCH] Add `tcp-serial-redirect` target and add WSL notes on debugging Don't kill terminal when running gdb, it'll kill tcp redirector --- Sming/project.mk | 14 +++++++++++- docs/source/getting-started/windows/wsl.rst | 24 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Sming/project.mk b/Sming/project.mk index 39f0b48561..9833848499 100644 --- a/Sming/project.mk +++ b/Sming/project.mk @@ -486,7 +486,7 @@ cs-dev: ##Apply coding style to all files changed from current upstream develop $(SMING_MAKE) $@ .PHONY: gdb -gdb: kill_term ##Run the debugger console +gdb: ##Run the debugger console $(GDB_CMDLINE) .PHONY: fetch @@ -544,6 +544,18 @@ otaserver: all ##Launch a simple python HTTP server for testing OTA updates $(info Starting OTA server for TESTING) $(Q) cd $(FW_BASE) && $(PYTHON) -m SimpleHTTPServer $(SERVER_OTA_PORT) + +# +.PHONY: tcp-serial-redirect +tcp-serial-redirect: ##Redirect COM port to TCP port + $(info Starting serial redirector) +ifdef WSL_ROOT + $(Q) cmd.exe /c start /MIN python3 $(WSL_ROOT)/$(SMING_HOME)/../Tools/tcp_serial_redirect.py $(COM_PORT) $(COM_SPEED_SERIAL) +else + $(Q) gnome-terminal -- bash -c "$(PYTHON) $(SMING_HOME)/../Tools/tcp_serial_redirect.py $(COM_PORT) $(COM_SPEED_SERIAL)" +endif + + ##@Help .PHONY: list-config diff --git a/docs/source/getting-started/windows/wsl.rst b/docs/source/getting-started/windows/wsl.rst index bdb4a59c45..e062fa2d06 100644 --- a/docs/source/getting-started/windows/wsl.rst +++ b/docs/source/getting-started/windows/wsl.rst @@ -94,6 +94,30 @@ For example:: make flash COM_PORT=COM4 +Serial debugging +---------------- + +Again, as we have no direct access to USB COM ports a workaround is required. +A small python application can be run on Windows to act as a simple bridge between the serial port and a TCP port. +See ``Tools/tcp_serial_redirect.py`` - run without arguments to see available options. + +You can start the server like this:: + + make tcp-serial-redirect + +A new console will be created (minimised) showing something like this:: + + --- TCP/IP to Serial redirect on COM4 115200,8,N,1 --- + --- type Ctrl-C / BREAK to quit + Waiting for connection on 192.168.1.101:7780... + +This uses the current :envvar:`COM_PORT` and :envvar:`COM_SPEED_SERIAL` settings. + +Now we can start the debugger:: + + make gdb COM_PORT_GDB=192.168.1.101:7780 + + Valgrind --------