From f04006f05ead1ddde42ac84235664363d806327b Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 14 Nov 2022 16:11:34 +0100 Subject: [PATCH 1/3] change USB vendor string to tinysa.org, add USB product string for Ultra Signed-off-by: Martin --- usbcfg.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/usbcfg.c b/usbcfg.c index 7341b06..b4f16bd 100644 --- a/usbcfg.c +++ b/usbcfg.c @@ -150,21 +150,31 @@ static const uint8_t vcom_string0[] = { * Vendor string. */ static const uint8_t vcom_string1[] = { - USB_DESC_BYTE(38), /* bLength. */ + USB_DESC_BYTE(22), /* bLength. */ USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ - 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0, - 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0, - 'c', 0, 's', 0 + 't', 0, 'i', 0, 'n', 0, 'y', 0, 's', 0, 'a', 0, '.', 0, 'o', 0, 'r', 0, 'g', 0 }; +#ifdef TINYSA4 /* - * Device Description string, use the real name of the device. + * Device Description string, use "tinySA Ultra" + */ +static const uint8_t vcom_string2[] = { + USB_DESC_BYTE(26), /* bLength. */ + USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ + 't', 0, 'i', 0, 'n', 0, 'y', 0, 'S', 0, 'A', 0, + ' ', 0, 'U', 0, 'l', 0, 't', 0, 'r', 0, 'a', 0 +}; +#else +/* + * Device Description string, use "tinySA" */ static const uint8_t vcom_string2[] = { USB_DESC_BYTE(14), /* bLength. */ USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ 't', 0, 'i', 0, 'n', 0, 'y', 0, 'S', 0, 'A', 0 }; +#endif /* * Serial Number string. TODO: use real product version. From 90ce6ca744d8a106a82a4956bc635f20dc76ae82 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 14 Nov 2022 17:40:43 +0100 Subject: [PATCH 2/3] FW version in USB sernum string; change Ultra product string to tinySA4 use same name as PRODUCT from Makefile, either tinySA or tinySA4 report FW version as v1.3-nnn-gxxxxxxx in USB descriptor, see dmesg log: [ +1,567891] usb 1-1: new full-speed USB device number 121 using uhci_hcd [ +0,179094] usb 1-1: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00 [ +0,000008] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ +0,000005] usb 1-1: Product: tinySA [ +0,000005] usb 1-1: Manufacturer: tinysa.org [ +0,000004] usb 1-1: SerialNumber: v1.3-498-gf04006f [ +0,003544] cdc_acm 1-1:1.0: ttyACM0: USB ACM device Signed-off-by: Martin --- usbcfg.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/usbcfg.c b/usbcfg.c index b4f16bd..0d81d2c 100644 --- a/usbcfg.c +++ b/usbcfg.c @@ -157,13 +157,12 @@ static const uint8_t vcom_string1[] = { #ifdef TINYSA4 /* - * Device Description string, use "tinySA Ultra" + * Device Description string, use "tinySA4" as in "VERSION" */ static const uint8_t vcom_string2[] = { - USB_DESC_BYTE(26), /* bLength. */ + USB_DESC_BYTE(16), /* bLength. */ USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ - 't', 0, 'i', 0, 'n', 0, 'y', 0, 'S', 0, 'A', 0, - ' ', 0, 'U', 0, 'l', 0, 't', 0, 'r', 0, 'a', 0 + 't', 0, 'i', 0, 'n', 0, 'y', 0, 'S', 0, 'A', 0, '4', 0 }; #else /* @@ -176,16 +175,59 @@ static const uint8_t vcom_string2[] = { }; #endif +#ifdef TINYSA4 +/* + * Serial Number string. VERSION = 'tinySA4_v1.3-nnn-gxxxxxxx' + * 0123456789012345678901234 + */ +static const uint8_t vcom_string3[] = { + USB_DESC_BYTE(36), /* bLength. */ + USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ + VERSION[8], 0, /* 'v' */ + VERSION[9], 0, /* '1' */ + VERSION[10], 0, /* '.' */ + VERSION[11], 0, /* '3' */ + VERSION[12], 0, /* '-' */ + VERSION[13], 0, /* 'n' */ + VERSION[14], 0, /* 'n' */ + VERSION[15], 0, /* 'n' */ + VERSION[16], 0, /* '-' */ + VERSION[17], 0, /* 'g' */ + VERSION[18], 0, /* 'x' */ + VERSION[19], 0, /* 'x' */ + VERSION[20], 0, /* 'x' */ + VERSION[21], 0, /* 'x' */ + VERSION[22], 0, /* 'x' */ + VERSION[23], 0, /* 'x' */ + VERSION[24], 0 /* 'x' */ +}; +#else /* - * Serial Number string. TODO: use real product version. + * Serial Number string. VERSION = 'tinySA_v1.3-nnn-gxxxxxxx' + * 012345678901234567890123 */ static const uint8_t vcom_string3[] = { - USB_DESC_BYTE(8), /* bLength. */ + USB_DESC_BYTE(36), /* bLength. */ USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ - '0' + CH_KERNEL_MAJOR, 0, - '0' + CH_KERNEL_MINOR, 0, - '0' + CH_KERNEL_PATCH, 0 + VERSION[7], 0, /* 'v' */ + VERSION[8], 0, /* '1' */ + VERSION[9], 0, /* '.' */ + VERSION[10], 0, /* '3' */ + VERSION[11], 0, /* '-' */ + VERSION[12], 0, /* 'n' */ + VERSION[13], 0, /* 'n' */ + VERSION[14], 0, /* 'n' */ + VERSION[15], 0, /* '-' */ + VERSION[16], 0, /* 'g' */ + VERSION[17], 0, /* 'x' */ + VERSION[18], 0, /* 'x' */ + VERSION[19], 0, /* 'x' */ + VERSION[20], 0, /* 'x' */ + VERSION[21], 0, /* 'x' */ + VERSION[22], 0, /* 'x' */ + VERSION[23], 0 /* 'x' */ }; +#endif /* * Strings wrappers array. From de546126548b8ee1d05bf71a2af0a83059b658ff Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 15 Nov 2022 13:21:43 +0100 Subject: [PATCH 3/3] VERSION is always v1.2-345-gxxxxxxx, fix version format on left border get a fixed string format for USB version string parsing fix left border ver display for v1.2-3-g.., 1.2-34-g.. and 1.2-3456-g.. changes to make dfu (build *.dfu) and make flash (switch to dfu mode) Signed-off-by: Martin --- Makefile | 23 ++++++++++++++++------- ui_sa.c | 24 +++++++++++++++++------- usbcfg.c | 14 ++++++-------- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 7d04772..c2bfb4a 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,13 @@ endif # Build global options ############################################################################## +# format va.b-n-gxxxxxxx +# or va.b-nn-gxxxxxxx +# or va.b-nnn-gxxxxxxx +# or ... + ifeq ($(VERSION),) - VERSION="$(PROJECT)_$(shell git describe --tags)" + VERSION="$(PROJECT)_$(shell git describe --tags --long)" endif ############################################################################## @@ -297,15 +302,19 @@ clean: rm -f -rf build/tinySA4.* build/lst/*.* build/obj/*.* else clean: - rm -f -rf build/tinySA.* + rm -f -rf build/$(PROJECT).* endif -flash: build/ch.bin - dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/ch.bin +flash: build/$(PROJECT).bin + -@printf "reset dfu\r" >/dev/cu.usbmodem401 # mac + -@printf "reset dfu\r" >/dev/ttyACM0 # linux + sleep 2 + dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D $< + +dfu: build/$(PROJECT).hex + -@#c:/work/dfu/HEX2DFU $< build/$(PROJECT).dfu # win + -@hex2dfu -i $< -o build/$(PROJECT).dfu # mac / linux -dfu: - c:/work/dfu/HEX2DFU build/ch.hex build/ch.dfu - -@printf "reset dfu\r" >/dev/cu.usbmodem401 TAGS: Makefile ifeq ($(TARGET),F303) diff --git a/ui_sa.c b/ui_sa.c index 245cfe1..1021ac8 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -4386,13 +4386,23 @@ redraw_cal_status: // Version y += YSTEP + YSTEP/2 ; -#ifdef TINYSA4 - strncpy(buf,&TINYSA_VERSION[9], BLEN+1); -#else - strncpy(buf,&TINYSA_VERSION[8], BLEN+1); -#endif - if (buf[7]=='-') { - buf[3] = buf[4]; +#ifdef TINYSA4 // 'tinySA4_v1.2-[0-9]*-gxxxxxxx' + strncpy(buf,&TINYSA_VERSION[9], BLEN+1); // '1.2-...' +#else // 'tinySA_v1.2-[0-9]*-gxxxxxxx' + strncpy(buf,&TINYSA_VERSION[8], BLEN+1); // '1.2-...' +#endif + if (buf[5]=='-' ) { // '1.2-n-g...' + if (buf[4]=='0') // '1.2-0-g...' + buf[3] = 0; // -> '1.2' + else { + buf[5] = buf[4]; // -> '1.200n' + buf[4] = '0'; + buf[3] = '0'; + } + } else if (buf[6]=='-' ) { // 1.2-nn-g... + buf[3] = '0'; // -> '1.20nn' + } else { // 1.2-345-g... (or 1.2-3456...) + buf[3] = buf[4]; // -> '1.2345' buf[4] = buf[5]; buf[5] = buf[6]; } diff --git a/usbcfg.c b/usbcfg.c index 0d81d2c..a57ed3f 100644 --- a/usbcfg.c +++ b/usbcfg.c @@ -178,10 +178,11 @@ static const uint8_t vcom_string2[] = { #ifdef TINYSA4 /* * Serial Number string. VERSION = 'tinySA4_v1.3-nnn-gxxxxxxx' - * 0123456789012345678901234 + * 01234567890123456789012 + * skip last two 'xx' char due to 'tinySA4_v1.3-n-gxxxxxxx' */ static const uint8_t vcom_string3[] = { - USB_DESC_BYTE(36), /* bLength. */ + USB_DESC_BYTE(32), /* bLength. */ USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ VERSION[8], 0, /* 'v' */ VERSION[9], 0, /* '1' */ @@ -198,16 +199,15 @@ static const uint8_t vcom_string3[] = { VERSION[20], 0, /* 'x' */ VERSION[21], 0, /* 'x' */ VERSION[22], 0, /* 'x' */ - VERSION[23], 0, /* 'x' */ - VERSION[24], 0 /* 'x' */ }; #else /* * Serial Number string. VERSION = 'tinySA_v1.3-nnn-gxxxxxxx' - * 012345678901234567890123 + * 0123456789012345678901 + * skip last two 'xx' char due to 'tinySA_v1.3-n-gxxxxxxx' */ static const uint8_t vcom_string3[] = { - USB_DESC_BYTE(36), /* bLength. */ + USB_DESC_BYTE(32), /* bLength. */ USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType. */ VERSION[7], 0, /* 'v' */ VERSION[8], 0, /* '1' */ @@ -224,8 +224,6 @@ static const uint8_t vcom_string3[] = { VERSION[19], 0, /* 'x' */ VERSION[20], 0, /* 'x' */ VERSION[21], 0, /* 'x' */ - VERSION[22], 0, /* 'x' */ - VERSION[23], 0 /* 'x' */ }; #endif