Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: assorted minor J-Link fixes #1638

Merged
merged 6 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
perigoso marked this conversation as resolved.
Show resolved Hide resolved
arguments starts the server. When several BMP supported probes are connected,
Expand All @@ -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
```

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/platforms/hosted/README.md
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/bmp_libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
15 changes: 7 additions & 8 deletions src/platforms/hosted/jlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -585,7 +584,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;
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/hosted/jlink_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
3 changes: 1 addition & 2 deletions src/platforms/hosted/jlink_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <assert.h>
Expand Down