From b167d2755e6ec3ada14cef9473f70c299c914d51 Mon Sep 17 00:00:00 2001 From: Jicksaw Date: Mon, 21 Jan 2019 15:15:49 +0200 Subject: [PATCH 1/3] Set SWD clock before using SWD (#107, #568 ?) --- src/usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/usb.c b/src/usb.c index 3e0596f18..66f065ab8 100644 --- a/src/usb.c +++ b/src/usb.c @@ -923,6 +923,9 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16 // Initialize stlink version (sl->version) stlink_version(sl); + // Set the stlink clock speed (default is 1800kHz) + stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); + if (reset) { if( sl->version.stlink_v > 1 ) stlink_jtag_reset(sl, 2); stlink_reset(sl); @@ -931,9 +934,6 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16 ret = stlink_load_device_params(sl); - // Set the stlink clock speed (default is 1800kHz) - stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); - on_libusb_error: if (ret == -1) { stlink_close(sl); From 48e2fcfcabd9904462dd81a44cec33c6e82fa51a Mon Sep 17 00:00:00 2001 From: Jicksaw Date: Mon, 21 Jan 2019 15:28:04 +0200 Subject: [PATCH 2/3] Make st-util -v print more than default --- src/gdbserver/gdb-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 7bf3a275f..6e64dd073 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -151,7 +151,7 @@ int parse_options(int argc, char** argv, st_state_t *st) { if (optarg) { st->logging_level = atoi(optarg); } else { - st->logging_level = DEFAULT_LOGGING_LEVEL; + st->logging_level = DEBUG_LOGGING_LEVEL; } break; case '1': From 08af9422951b759434bca3cbbb274bcb251ef279 Mon Sep 17 00:00:00 2001 From: Jicksaw Date: Mon, 21 Jan 2019 19:31:45 +0200 Subject: [PATCH 3/3] Flush output streams explicitly. Fix #665 On Win32 redirecting streams makes them buffered, therefore without flushing there would be no output before exit. Stdout and stderr are also often buffered differently, making them disordered. --- src/logging.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/logging.c b/src/logging.c index b5e423a3a..d4fb96b2e 100644 --- a/src/logging.c +++ b/src/logging.c @@ -22,6 +22,10 @@ int ugly_log(int level, const char *tag, const char *format, ...) { if (level > max_level) { return 0; } + + // Flush to maintain order of streams + fflush(stdout); + va_list args; va_start(args, format); time_t mytt = time(NULL); @@ -46,6 +50,7 @@ int ugly_log(int level, const char *tag, const char *format, ...) { break; } vfprintf(stderr, format, args); + fflush(stderr); va_end(args); return 1; }