-
Notifications
You must be signed in to change notification settings - Fork 24
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
Handle Stlink V21. #11
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi UweBonnes,
First of all, sorry for reacting so late to your pull request, and thank you very much for your contribution.
I have a few comments regarding your PR, but I don't have much free time currently so I can't for the moment implement the suggested changes.
Btw, I don't have those ST-Link 2.1 devices at home, what should I buy if I want to test stlink-tool on these?
@@ -37,6 +39,71 @@ void print_help(char *argv[]) { | |||
printf("\tApplication is started when called without argument or after firmware load\n\n"); | |||
} | |||
|
|||
#include <string.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header should be at the beginning of the file
src/main.c
Outdated
@@ -37,6 +39,71 @@ void print_help(char *argv[]) { | |||
printf("\tApplication is started when called without argument or after firmware load\n\n"); | |||
} | |||
|
|||
#include <string.h> | |||
#define USB_TIMEOUT 5000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add USB_TIMEOUT then this should be used everywhere a timeout value is needed
src/main.c
Outdated
int test_v21(libusb_context *usb_ctx) | ||
{ | ||
libusb_device_handle *dev_handle; | ||
int res = 0; | ||
dev_handle = libusb_open_device_with_vid_pid(usb_ctx, | ||
STLINK_VID, | ||
STLINK_PIDV21); | ||
if (!dev_handle) { | ||
dev_handle = libusb_open_device_with_vid_pid(usb_ctx, | ||
STLINK_VID, | ||
STLINK_PIDV21_MSD); | ||
if (dev_handle) | ||
fprintf(stderr, "StlinkV21_MSD found\n"); | ||
} else { | ||
fprintf(stderr, "StlinkV21 found\n"); | ||
} | ||
if (dev_handle) { | ||
res = stlink_dfu_mode(dev_handle, 0); | ||
if (res != 0x8000) { | ||
libusb_release_interface(dev_handle, 0); | ||
return 0; | ||
} | ||
stlink_dfu_mode(dev_handle, 1); | ||
libusb_release_interface(dev_handle, 0); | ||
} | ||
usleep(1000000); | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should ideally this kind of check should be performed when trying to connect to the ST-Link interface. Otherwise this causes redundant connections to the device.
Any STM Nucleo board or recent Disco board have a stlinkv2.c. Nucleo32 starts at about 12 Euro. The form of the patch was with the thought in mind to have the changes well localized. It should be cleaner. I will try to have a look at my patch this weekend and try to send a revised version. |
f6bd2ab
to
d981002
Compare
tiny-AES-c contains .gitignore.
From NUCLEO-H723ZG
This patch allow to put the StlinkV2 to put into bootloader mode.