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

J-Link cleanup and Target Power implementation #1548

Merged
merged 19 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
aeb0449
platforms: refactor platform_target_set_power return value, error and…
perigoso Jul 19, 2023
5b7e23b
hosted/jlink: move unused VID/PID macros to platform header
perigoso Jul 19, 2023
b2bd0ab
hosted/jlink: return bool on jlink protocol functions
perigoso Jul 19, 2023
4c6178c
bmp_libusb: add timeout argument for usb transfers
perigoso Jul 27, 2023
f30ed4e
hosted/jlink_protocol: transcribe jlink usb protocol from reference man
perigoso Jul 19, 2023
e612aae
hosted/jlink: cleanup SIGNAL_STATE based commands
perigoso Jul 19, 2023
55b4f9b
hosted/jlink: consolidate jlink static data in a struct jlink_s
perigoso Jul 19, 2023
0c23ca0
hosted/jlink: organize functions by usb protocol, bmda interface, and…
perigoso Jul 19, 2023
db6e64e
hosted/jlink: rewrite jlink_print_version as jlink_get_version
perigoso Jul 19, 2023
c3c41db
hosted/jlink: rewrite jlink_query_caps as jlink_get_capabilities
perigoso Jul 19, 2023
ba86d6d
hosted/jlink: implement interface manipulation functions
perigoso Jul 19, 2023
54bcedb
hosted/jlink: implement jlink_simple_request_16/32
perigoso Jul 19, 2023
2ea7a16
hosted/jlink: rewrite frequency commands
perigoso Jul 19, 2023
07442e3
hosted/jlink: implement target voltage sense
perigoso Jul 19, 2023
a955a1b
hosted/jlink: implement target power through J-Link kickstart power pin
perigoso Jul 19, 2023
d9a1841
hosted/jlink: cleanup constant suffixes
perigoso Jul 19, 2023
de6bf00
hosted/jlink: add extra interface strings
perigoso Jul 20, 2023
5932a14
hosted/jlink: add delay after jlink_select_interface, skip entirely i…
perigoso Jul 20, 2023
8bb8a84
hosted/jlink: rewrite frequency commands with proper interface handling
perigoso Jul 20, 2023
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
3 changes: 2 additions & 1 deletion src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ static bool cmd_target_power(target_s *t, int argc, const char **argv)
/* want to enable target power, but VREF > 0.5V sensed -> cancel */
gdb_outf("Target already powered (%s)\n", platform_target_voltage());
} else {
platform_target_set_power(want_enable);
if (!platform_target_set_power(want_enable))
DEBUG_ERROR("%s target power failed\n", want_enable ? "Enabling" : "Disabling");
gdb_outf("%s target power\n", want_enable ? "Enabling" : "Disabling");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int platform_hwversion(void);
void platform_nrst_set_val(bool assert);
bool platform_nrst_get_val(void);
bool platform_target_get_power(void);
void platform_target_set_power(bool power);
bool platform_target_set_power(bool power);
perigoso marked this conversation as resolved.
Show resolved Hide resolved
void platform_request_boot(void);
void platform_max_frequency_set(uint32_t frequency);
uint32_t platform_max_frequency_get(void);
Expand Down
3 changes: 2 additions & 1 deletion src/platforms/common/blackpill-f4/blackpill-f4.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ bool platform_target_get_power(void)
return gpio_get(PWR_BR_PORT, PWR_BR_PIN);
}

void platform_target_set_power(const bool power)
bool platform_target_set_power(const bool power)
{
gpio_set_val(PWR_BR_PORT, PWR_BR_PIN, power);
return true;
}

/*
Expand Down
3 changes: 2 additions & 1 deletion src/platforms/f4discovery/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ bool platform_target_get_power(void)
return !gpio_get(PWR_BR_PORT, PWR_BR_PIN);
}

void platform_target_set_power(const bool power)
bool platform_target_set_power(const bool power)
{
gpio_set_val(PWR_BR_PORT, PWR_BR_PIN, !power);
return true;
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion src/platforms/hosted/bmp_hosted.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#define TRANSFER_IS_DONE (1U << 0U)
#define TRANSFER_HAS_ERROR (1U << 1U)

#define BMDA_USB_NO_TIMEOUT 0

typedef struct transfer_ctx {
volatile size_t flags;
} transfer_ctx_s;
Expand Down Expand Up @@ -99,7 +101,8 @@ void libusb_exit_function(bmp_info_s *info);
#if HOSTED_BMP_ONLY == 1
bool device_is_bmp_gdb_port(const char *device);
#else
int bmda_usb_transfer(usb_link_s *link, const void *tx_buffer, size_t tx_len, void *rx_buffer, size_t rx_len);
int bmda_usb_transfer(
usb_link_s *link, const void *tx_buffer, size_t tx_len, void *rx_buffer, size_t rx_len, uint16_t timeout);
#endif

#endif /* PLATFORMS_HOSTED_BMP_HOSTED_H */
9 changes: 5 additions & 4 deletions src/platforms/hosted/bmp_libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ int find_debuggers(bmda_cli_options_s *cl_opts, bmp_info_s *info)
* sent/received may be less (per libusb's documentation). If used, rx_buffer must be
* suitably intialised up front to avoid UB reads when accessed.
*/
int bmda_usb_transfer(usb_link_s *link, const void *tx_buffer, size_t tx_len, void *rx_buffer, size_t rx_len)
int bmda_usb_transfer(
usb_link_s *link, const void *tx_buffer, size_t tx_len, void *rx_buffer, size_t rx_len, uint16_t timeout)
{
/* If there's data to send */
if (tx_len) {
Expand All @@ -583,8 +584,8 @@ int bmda_usb_transfer(usb_link_s *link, const void *tx_buffer, size_t tx_len, vo
DEBUG_WIRE("\n");

/* Perform the transfer */
const int result =
libusb_bulk_transfer(link->device_handle, link->ep_tx | LIBUSB_ENDPOINT_OUT, tx_data, (int)tx_len, NULL, 0);
const int result = libusb_bulk_transfer(
link->device_handle, link->ep_tx | LIBUSB_ENDPOINT_OUT, tx_data, (int)tx_len, NULL, timeout);
/* Then decode the result value - if its anything other than LIBUSB_SUCCESS, something went horribly wrong */
if (result != LIBUSB_SUCCESS) {
DEBUG_ERROR(
Expand All @@ -600,7 +601,7 @@ int bmda_usb_transfer(usb_link_s *link, const void *tx_buffer, size_t tx_len, vo
int rx_bytes = 0;
/* Perform the transfer */
const int result = libusb_bulk_transfer(
link->device_handle, link->ep_rx | LIBUSB_ENDPOINT_IN, rx_data, (int)rx_len, &rx_bytes, 0);
link->device_handle, link->ep_rx | LIBUSB_ENDPOINT_IN, rx_data, (int)rx_len, &rx_bytes, timeout);
/* Then decode the result value - if its anything other than LIBUSB_SUCCESS, something went horribly wrong */
if (result != LIBUSB_SUCCESS) {
DEBUG_ERROR(
Expand Down
Loading