Skip to content

Commit

Permalink
Allow for 64 Bytes serials (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
DL6AKU authored and xor-gate committed Jun 6, 2019
1 parent d040db5 commit df3c2b0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/stlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ extern "C" {
#define STLINK_SWDCLK_15KHZ_DIVISOR 265
#define STLINK_SWDCLK_5KHZ_DIVISOR 798

#define STLINK_SERIAL_MAX_SIZE 64

/* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/
#define C_BUF_LEN 32

Expand Down Expand Up @@ -144,7 +146,7 @@ typedef struct flash_loader {
uint32_t chip_id;
int core_stat;

char serial[16];
char serial[STLINK_SERIAL_MAX_SIZE];
int serial_size;

enum stlink_flash_type flash_type;
Expand Down
2 changes: 1 addition & 1 deletion include/stlink/tools/flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct flash_opts
{
enum flash_cmd cmd;
const char* devname;
uint8_t serial[16];
uint8_t serial[STLINK_SERIAL_MAX_SIZE];
const char* filename;
stm32_addr_t addr;
size_t size;
Expand Down
2 changes: 1 addition & 1 deletion include/stlink/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extern "C" {
* @retval NULL Error while opening the stlink
* @retval !NULL Stlink found and ready to use
*/
stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16]);
stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE]);
size_t stlink_probe_usb(stlink_t **stdevs[]);
void stlink_probe_usb_free(stlink_t **stdevs[], size_t size);

Expand Down
4 changes: 2 additions & 2 deletions src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ static stlink_backend_t _stlink_usb_backend = {
_stlink_usb_set_swdclk
};

stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16])
stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE])
{
stlink_t* sl = NULL;
struct stlink_libusb* slu = NULL;
Expand Down Expand Up @@ -1003,7 +1003,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
continue;

struct libusb_device_handle* handle;
char serial[16];
char serial[STLINK_SERIAL_MAX_SIZE];
memset(serial, 0, sizeof(serial));

ret = libusb_open(dev, &handle);
Expand Down

0 comments on commit df3c2b0

Please sign in to comment.