From 4ede113ca76d8c84b3e73a5b1b2f7b21a76fb719 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Fri, 5 Jun 2020 16:18:15 +0200 Subject: [PATCH 1/5] hydrabus: Disable DFU file generation untit somebody fixes dfu-convert.py This allows "make all_platforms" to succeed on python3 only systems. --- src/platforms/hydrabus/Makefile.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/hydrabus/Makefile.inc b/src/platforms/hydrabus/Makefile.inc index ac96637d..24d43fa1 100644 --- a/src/platforms/hydrabus/Makefile.inc +++ b/src/platforms/hydrabus/Makefile.inc @@ -23,7 +23,7 @@ SRC += cdcacm.c \ timing.c \ timing_stm32.c \ -all: blackmagic.bin blackmagic.hex blackmagic.dfu +all: blackmagic.bin blackmagic.hex blackmagic.dfu: blackmagic.hex @echo Creating $@ From 5097a231961876bee7af6b000a5410c25091d721 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sat, 6 Jun 2020 14:56:42 +0200 Subject: [PATCH 2/5] jlink: Fix wrong sized array. --- src/platforms/hosted/jlink_adiv5_swdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/hosted/jlink_adiv5_swdp.c b/src/platforms/hosted/jlink_adiv5_swdp.c index 5e7ba3bc..b9deabb2 100644 --- a/src/platforms/hosted/jlink_adiv5_swdp.c +++ b/src/platforms/hosted/jlink_adiv5_swdp.c @@ -92,7 +92,7 @@ static int line_reset(bmp_info_t *info) data[13] = 0xa5; data[18] = 0; - uint8_t res[18]; + uint8_t res[19]; send_recv(info->usb_link, cmd, 42, res, 19); send_recv(info->usb_link, NULL, 0, res, 1); From e35025d214419a2b25987483654a9cf62e675597 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sat, 6 Jun 2020 15:09:17 +0200 Subject: [PATCH 3/5] CMSIS_DAP: Warn when hidapi-libusb is not found. --- src/platforms/hosted/cmsis_dap.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platforms/hosted/cmsis_dap.h b/src/platforms/hosted/cmsis_dap.h index 10b19697..6668ac3e 100644 --- a/src/platforms/hosted/cmsis_dap.h +++ b/src/platforms/hosted/cmsis_dap.h @@ -30,7 +30,12 @@ void dap_adiv5_dp_defaults(ADIv5_DP_t *dp); int cmsis_dap_jtagtap_init(jtag_proc_t *jtag_proc); int dap_jtag_dp_init(ADIv5_DP_t *dp); #else -int dap_init(bmp_info_t *info) {(void)info; return -1;} +int dap_init(bmp_info_t *info) +{ + DEBUG_WARN("FATAL: Missing hidapi-libusb\n"); + (void)info; + return -1; +} int dap_enter_debug_swd(ADIv5_DP_t *dp) {(void)dp; return -1;} void dap_exit_function(void) {return;}; void dap_adiv5_dp_defaults(ADIv5_DP_t *dp) {(void)dp; return; } From eabd69dcdb09b184ca161bc9ddf14b2471216d65 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sat, 6 Jun 2020 18:11:17 +0200 Subject: [PATCH 4/5] Adiv5: Protect DBG/SYSTEM Power-Up request with timeout too. CMSIS-DAP without connected target looped infinite in that situation. --- src/target/adiv5.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/target/adiv5.c b/src/target/adiv5.c index 8b04f013..63e3c75d 100644 --- a/src/target/adiv5.c +++ b/src/target/adiv5.c @@ -468,14 +468,25 @@ void adiv5_dp_init(ADIv5_DP_t *dp) ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT); } + platform_timeout timeout; + platform_timeout_set(&timeout, 201); /* Write request for system and debug power up */ adiv5_dp_write(dp, ADIV5_DP_CTRLSTAT, ctrlstat |= ADIV5_DP_CTRLSTAT_CSYSPWRUPREQ | ADIV5_DP_CTRLSTAT_CDBGPWRUPREQ); /* Wait for acknowledge */ - while(((ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT)) & - (ADIV5_DP_CTRLSTAT_CSYSPWRUPACK | ADIV5_DP_CTRLSTAT_CDBGPWRUPACK)) != - (ADIV5_DP_CTRLSTAT_CSYSPWRUPACK | ADIV5_DP_CTRLSTAT_CDBGPWRUPACK)); + while(1) { + ctrlstat = adiv5_dp_read(dp, ADIV5_DP_CTRLSTAT); + uint32_t check = ctrlstat & (ADIV5_DP_CTRLSTAT_CSYSPWRUPACK | + ADIV5_DP_CTRLSTAT_CDBGPWRUPACK); + if (check == (ADIV5_DP_CTRLSTAT_CSYSPWRUPACK | + ADIV5_DP_CTRLSTAT_CDBGPWRUPACK)) + break; + if (platform_timeout_is_expired(&timeout)) { + DEBUG_INFO("DEBUG Power-Up failed\n"); + return; + } + } /* This AP reset logic is described in ADIv5, but fails to work * correctly on STM32. CDBGRSTACK is never asserted, and we @@ -486,8 +497,6 @@ void adiv5_dp_init(ADIv5_DP_t *dp) adiv5_dp_write(dp, ADIV5_DP_CTRLSTAT, ctrlstat |= ADIV5_DP_CTRLSTAT_CDBGRSTREQ); - platform_timeout timeout; - platform_timeout_set(&timeout, 101); /* Write request for debug reset release */ adiv5_dp_write(dp, ADIV5_DP_CTRLSTAT, ctrlstat &= ~ADIV5_DP_CTRLSTAT_CDBGRSTREQ); From a4cdd6b3103cdf6c1f8454fb81558ff98a8d912d Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Sun, 7 Jun 2020 16:18:28 +0200 Subject: [PATCH 5/5] hosted: Report missing USB access rights only if no debugger found. --- src/platforms/hosted/platform.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platforms/hosted/platform.c b/src/platforms/hosted/platform.c index cd6fe65e..631fa49c 100644 --- a/src/platforms/hosted/platform.c +++ b/src/platforms/hosted/platform.c @@ -213,6 +213,8 @@ static int find_debuggers( BMP_CL_OPTIONS_t *cl_opts,bmp_info_t *info) report = true; goto rescan; } else { + if (found_debuggers > 0) + access_problems = false; found_debuggers = 0; } }