Conversation
jeanthom
left a comment
There was a problem hiding this comment.
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?
| printf("\tApplication is started when called without argument or after firmware load\n\n"); | ||
| } | ||
|
|
||
| #include <string.h> |
There was a problem hiding this comment.
Header should be at the beginning of the file
src/main.c
Outdated
| } | ||
|
|
||
| #include <string.h> | ||
| #define USB_TIMEOUT 5000 |
There was a problem hiding this comment.
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.
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.