From 9be910b93b1208ef66ce95d3c24cf0778a81c502 Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Tue, 3 Oct 2023 17:47:24 +0100 Subject: [PATCH 1/6] hosted/jlink: const correctness --- src/platforms/hosted/jlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platforms/hosted/jlink.c b/src/platforms/hosted/jlink.c index 581bf1850d5..1e86bf43f96 100644 --- a/src/platforms/hosted/jlink.c +++ b/src/platforms/hosted/jlink.c @@ -228,7 +228,7 @@ static bool jlink_claim_interface(void) return false; } for (size_t i = 0; i < descriptor->bNumEndpoints; i++) { - const libusb_endpoint_descriptor_s *endpoint = &descriptor->endpoint[i]; + const libusb_endpoint_descriptor_s *const endpoint = &descriptor->endpoint[i]; if (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) bmda_probe_info.usb_link->ep_rx = endpoint->bEndpointAddress; else @@ -240,7 +240,7 @@ static bool jlink_claim_interface(void) /* J-Link command functions and utils */ -static char *jlink_hw_type_to_string(const uint8_t hw_type) +static const char *jlink_hw_type_to_string(const uint8_t hw_type) { switch (hw_type) { case JLINK_HARDWARE_VERSION_TYPE_JLINK: @@ -258,7 +258,7 @@ static char *jlink_hw_type_to_string(const uint8_t hw_type) } } -static char *jlink_interface_to_string(const uint8_t interface) +static const char *jlink_interface_to_string(const uint8_t interface) { switch (interface) { case JLINK_INTERFACE_JTAG: @@ -585,7 +585,7 @@ static bool jlink_set_kickstart_power(const bool enable) */ bool jlink_init(void) { - usb_link_s *link = calloc(1, sizeof(usb_link_s)); + usb_link_s *const link = calloc(1U, sizeof(usb_link_s)); if (!link) return false; bmda_probe_info.usb_link = link; From 3808985063fa1a6aa4973bd2945e875abaf24afc Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Tue, 3 Oct 2023 17:50:17 +0100 Subject: [PATCH 2/6] hosted/jlink: adjust capability warnings some capability warning messages could be missinterpreted as not supported by BMDA or J-Link probes in general, when in reality they are just not available in this particular J-Link probe This should convey the meaning better --- src/platforms/hosted/jlink.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/platforms/hosted/jlink.c b/src/platforms/hosted/jlink.c index 1e86bf43f96..258f5534fd9 100644 --- a/src/platforms/hosted/jlink.c +++ b/src/platforms/hosted/jlink.c @@ -406,7 +406,7 @@ static bool jlink_get_interfaces(void) static bool jlink_get_interface_frequency(const uint8_t interface) { if (!(jlink.capabilities & JLINK_CAPABILITY_INTERFACE_FREQUENCY)) { - DEBUG_WARN("J-Link does not support interface frequency commands\n"); + DEBUG_WARN("J-Link interface frequency commands are not available\n"); return false; } @@ -477,7 +477,7 @@ static bool jlink_get_interface_frequency(const uint8_t interface) static bool jlink_set_interface_frequency(const uint8_t interface, const uint32_t frequency) { if (!(jlink.capabilities & JLINK_CAPABILITY_INTERFACE_FREQUENCY)) { - DEBUG_WARN("J-Link does not support interface frequency command\n"); + DEBUG_WARN("J-Link interface frequency commands are not available\n"); return false; } @@ -550,8 +550,7 @@ static bool jlink_kickstart_power(void) { if (!(jlink.capabilities & JLINK_CAPABILITY_POWER_STATE)) { if (jlink.capabilities & JLINK_CAPABILITY_KICKSTART_POWER) - DEBUG_ERROR("J-Link does not support JLINK_CMD_POWER_GET_STATE command, but does support kickstart power" - ", this is unexpected\n"); + DEBUG_ERROR("J-Link power state command is not available, but kickstart power is, this is unexpected\n"); return false; } From 79e5c702aa84c0488c90806b5d1fc8b29ec9ac2c Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Tue, 3 Oct 2023 17:50:59 +0100 Subject: [PATCH 3/6] hosted/jlink_protocol: fix include guard comment --- src/platforms/hosted/jlink_protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/hosted/jlink_protocol.h b/src/platforms/hosted/jlink_protocol.h index 258d6aafdf6..26faafb22f1 100644 --- a/src/platforms/hosted/jlink_protocol.h +++ b/src/platforms/hosted/jlink_protocol.h @@ -518,4 +518,4 @@ bool jlink_transfer_fixed_tms(uint16_t clock_cycles, bool final_tms, const uint8 bool jlink_transfer_swd(uint16_t clock_cycles, jlink_swd_dir_e direction, const uint8_t *data_in, uint8_t *data_out); bool jlink_select_interface(const uint8_t interface); -#endif /*PLATFORMS_HOSTED_JLINK_PROTOCOL_H*/ +#endif /* PLATFORMS_HOSTED_JLINK_PROTOCOL_H */ From 88549cfb8d774f2dd0edf37c447fcc2de45227eb Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Tue, 3 Oct 2023 18:00:26 +0100 Subject: [PATCH 4/6] hosted: correct jlink documentation naming --- README.md | 12 ++++++------ src/platforms/README.md | 2 +- src/platforms/hosted/README.md | 4 ++-- src/platforms/hosted/bmp_libusb.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 65b0b9112ea..fd031423656 100644 --- a/README.md +++ b/README.md @@ -84,10 +84,10 @@ to connect. Black Magic Debug App can talk to * Black Magic Probe firmware probes via the USB-serial port -* ST-LinkV2 and V3 with recent firmware +* ST-Link v2, v2.1 and v3 with recent firmware * CMSIS-DAP compatible probes -* JLINK probes -* FTDI MPSSE based probe. +* J-Link probes +* FTDI MPSSE based probes When connected to a single BMP supported probe, starting "blackmagic" w/o any arguments starts the server. When several BMP supported probes are connected, @@ -99,10 +99,10 @@ In another terminal: ```console > blackmagic -Black Magic Debug App v1.8.0 - for Black Magic Probe, ST-Link v2 and v3, CMSIS-DAP, JLink and libftdi/MPSSE +Black Magic Debug App v1.9.2 + for Black Magic Probe, ST-Link v2 and v3, CMSIS-DAP, J-Link and FTDI (MPSSE) Using 1d50:6018 8BB20A03 Black Magic Debug - Black Magic Probe v1.8.0 + Black Magic Probe v1.9.2 Listening on TCP: 2000 ``` diff --git a/src/platforms/README.md b/src/platforms/README.md index 11478f3b2e5..3408021b024 100644 --- a/src/platforms/README.md +++ b/src/platforms/README.md @@ -22,7 +22,7 @@ used by (multiple) platforms. * ST-Link v2, v2.1, and v3 * FTDI MPSSE probes * CMSIS-DAP probes and - * JLink probes + * J-Link probes ## Support directories diff --git a/src/platforms/hosted/README.md b/src/platforms/hosted/README.md index c46bf898701..c70f88760d7 100644 --- a/src/platforms/hosted/README.md +++ b/src/platforms/hosted/README.md @@ -1,7 +1,7 @@ # PC-Hosted BMP Compile in src with "make PROBE_HOST=hosted". This needs minimal external support. "make PROBE_HOST=hosted HOSTED_BMP_ONLY=0" will compile support for FTDI, -STLink, CMSIS-DAP and JLINK probes, but requires external libraries. +STLink, CMSIS-DAP and J-Link probes, but requires external libraries. ## Description PC-hosted BMP run on the PC and compiles as "blackmagic". When started, @@ -100,7 +100,7 @@ Probes below only when compiled with HOSTED_BMP_ONLY=0 | ST-Link V2/1 | +++ | Requires recent firmware, Cortex only! | CMSIS-DAP | +++ | Speed varies with MCU implementing CMSIS-DAP | FTDI MPSSE | ++ | Requires a device description -| JLINK | - | Useful to add BMP support for MCUs with built-in JLINK +| J-Link | - | Limited support for hardware prior to v8 ## Device matching As other USB dongles already connected to the host PC may use FTDI chips, diff --git a/src/platforms/hosted/bmp_libusb.c b/src/platforms/hosted/bmp_libusb.c index 6c04a1f3924..663238d5662 100644 --- a/src/platforms/hosted/bmp_libusb.c +++ b/src/platforms/hosted/bmp_libusb.c @@ -73,7 +73,7 @@ static const debugger_device_s debugger_devices[] = { {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV3_NO_MSD, PROBE_TYPE_STLINK_V2, NULL, "ST-Link v2.1 No MSD"}, {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV3, PROBE_TYPE_STLINK_V2, NULL, "ST-Link v3"}, {VENDOR_ID_STLINK, PRODUCT_ID_STLINKV3E, PROBE_TYPE_STLINK_V2, NULL, "ST-Link v3E"}, - {VENDOR_ID_SEGGER, PRODUCT_ID_ANY, PROBE_TYPE_JLINK, NULL, "Segger JLink"}, + {VENDOR_ID_SEGGER, PRODUCT_ID_ANY, PROBE_TYPE_JLINK, NULL, "Segger J-Link"}, {VENDOR_ID_FTDI, PRODUCT_ID_FTDI_FT2232, PROBE_TYPE_FTDI, NULL, "FTDI FT2232"}, {VENDOR_ID_FTDI, PRODUCT_ID_FTDI_FT4232, PROBE_TYPE_FTDI, NULL, "FTDI FT4232"}, {VENDOR_ID_FTDI, PRODUCT_ID_FTDI_FT232, PROBE_TYPE_FTDI, NULL, "FTDI FT232"}, From 54daf1dfc9092a2a84e96d2878234cd59b24d85a Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Wed, 4 Oct 2023 00:28:32 +0100 Subject: [PATCH 5/6] hosted_jlink: adjust comment --- src/platforms/hosted/jlink_swd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platforms/hosted/jlink_swd.c b/src/platforms/hosted/jlink_swd.c index 081fc002199..075e8db530f 100644 --- a/src/platforms/hosted/jlink_swd.c +++ b/src/platforms/hosted/jlink_swd.c @@ -22,8 +22,7 @@ */ /* - * This file implements the SW-DP specific functions of the - * ARM Debug Interface v5 Architecture Specification, ARM doc IHI0031A. + * This file implements SWD specific functions for the J-Link probe. */ #include From 3b95d99fd7bc6d4ce96b9034f93fb573364e62c9 Mon Sep 17 00:00:00 2001 From: Rafael Silva Date: Wed, 4 Oct 2023 00:58:39 +0100 Subject: [PATCH 6/6] readme: use backticks in place of quotes for binary invocation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd031423656..c350ac5fe30 100644 --- a/README.md +++ b/README.md @@ -89,10 +89,10 @@ Black Magic Debug App can talk to * J-Link probes * FTDI MPSSE based probes -When connected to a single BMP supported probe, starting "blackmagic" w/o any +When connected to a single BMP supported probe, starting `blackmagic` w/o any arguments starts the server. When several BMP supported probes are connected, their types, position and serial number is displayed and the program exits. -Add "-P (position)" to the next invocation to select one. +Add `-P (position)` to the next invocation to select one. For the setup from the sample session above: In another terminal: