git: 39dcba85b242 - main - devel/stlink: Update to latest version 1.8.0

From: Lev A. Serebryakov <lev_at_FreeBSD.org>
Date: Wed, 02 Apr 2025 17:41:17 UTC
The branch main has been updated by lev:

URL: https://cgit.FreeBSD.org/ports/commit/?id=39dcba85b2423d473cea2cacae64bf903db3591a

commit 39dcba85b2423d473cea2cacae64bf903db3591a
Author:     Lev A. Serebryakov <lev@FreeBSD.org>
AuthorDate: 2025-04-02 17:40:21 +0000
Commit:     Lev A. Serebryakov <lev@FreeBSD.org>
CommitDate: 2025-04-02 17:41:09 +0000

    devel/stlink: Update to latest version 1.8.0
    
     Update to new latest release.
---
 devel/stlink/Makefile                              |  8 +--
 devel/stlink/distinfo                              |  6 +-
 devel/stlink/files/patch-CMakeLists.txt            | 10 ---
 .../files/patch-cmake_modules_c__flags.cmake       | 18 -----
 .../files/patch-doc_dev_pkg-config_CMakeLists.txt  |  9 ---
 devel/stlink/files/patch-src_common.c              | 34 ---------
 .../stlink/files/patch-src_st-flash_flash__opts.c  | 56 +++++++++++++++
 devel/stlink/files/patch-src_st-info_info.c        | 11 +++
 devel/stlink/files/patch-src_st-util_gdb-server.c  | 11 +++
 devel/stlink/files/patch-src_stlink-lib_chipid.c   | 11 +++
 devel/stlink/files/patch-src_stlink-lib_common.c   | 11 +++
 .../files/patch-src_stlink-lib_flash__loader.c     | 11 +++
 .../stlink/files/patch-src_stlink-lib_map__file.c  | 11 +++
 devel/stlink/files/patch-src_stlink-lib_usb.c      | 20 ++++++
 devel/stlink/pkg-plist                             | 84 +++++++++++++++++++++-
 15 files changed, 230 insertions(+), 81 deletions(-)

diff --git a/devel/stlink/Makefile b/devel/stlink/Makefile
index 0006a6ed7d52..9194757ce3e7 100644
--- a/devel/stlink/Makefile
+++ b/devel/stlink/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	stlink
-DISTVERSION=	1.7.0
+DISTVERSION=	1.8.0
 DISTVERSIONPREFIX=	v
-PORTREVISION=	2
+?PORTREVISION=	0
 CATEGORIES=	devel
 
 MAINTAINER=	lev@FreeBSD.org
@@ -18,8 +18,8 @@ USE_LDCONFIG=	yes
 
 PORTDOCS=	${ALLDOCS} README.md
 
-ALLDOCS=	compiling.md dev/developer.txt devices_boards.md \
-		flashloaders.md release.md tutorial.md version_support.md
+ALLDOCS=	compiling.md flashloaders.md release.md supported_devices.md \
+		tutorial.md version_support.md
 
 FLASHLOADERS=	cleanroom.md linker.ld Makefile stm32f0.s stm32f4.s stm32f4lv.s \
 		stm32f7.s stm32f7lv.s stm32l4.s stm32lx.s
diff --git a/devel/stlink/distinfo b/devel/stlink/distinfo
index 556583c64ced..0c89b8e9d10d 100644
--- a/devel/stlink/distinfo
+++ b/devel/stlink/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1626176959
-SHA256 (stlink-org-stlink-v1.7.0_GH0.tar.gz) = 57ec1214905aedf59bee7f70ddff02316f64fa9ba5a9b6a3a64952edc5b65855
-SIZE (stlink-org-stlink-v1.7.0_GH0.tar.gz) = 334883
+TIMESTAMP = 1743595374
+SHA256 (stlink-org-stlink-v1.8.0_GH0.tar.gz) = cff760b5c212c2cc480f705b9ca7f3828d6b9c267950c6a547002cd0a1f5f6ac
+SIZE (stlink-org-stlink-v1.8.0_GH0.tar.gz) = 257240
diff --git a/devel/stlink/files/patch-CMakeLists.txt b/devel/stlink/files/patch-CMakeLists.txt
deleted file mode 100644
index c8461f37f41b..000000000000
--- a/devel/stlink/files/patch-CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
---- CMakeLists.txt.orig	2021-09-15 09:54:35 UTC
-+++ CMakeLists.txt
-@@ -298,6 +298,7 @@ endif ()
- # add_subdirectory(src/stlink-gui)  # contains subordinate CMakeLists to build GUI
- add_subdirectory(tests)           # contains subordinate CMakeLists to build test executables
- add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages
-+add_subdirectory(doc/dev/pkg-config) # contains subordinate CMakeLists to build pkg-config descriptor
- 
- option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF)
- add_subdirectory(doc/man)         # contains subordinate CMakeLists to generate manpages
diff --git a/devel/stlink/files/patch-cmake_modules_c__flags.cmake b/devel/stlink/files/patch-cmake_modules_c__flags.cmake
deleted file mode 100644
index 064de12f7844..000000000000
--- a/devel/stlink/files/patch-cmake_modules_c__flags.cmake
+++ /dev/null
@@ -1,18 +0,0 @@
-Work around upstream bug #1175 and make the build more robust
-against minor platform differences.  -Werror should not be
-provided in release builds.
-
---- cmake/modules/c_flags.cmake.orig	2021-04-24 22:24:02 UTC
-+++ cmake/modules/c_flags.cmake
-@@ -44,11 +44,3 @@ endif ()
- if (NOT (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)))
-     add_cflag_if_supported("-fPIC")
- endif ()
--
--if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
--    add_cflag_if_supported("-ggdb")
--    add_cflag_if_supported("-O0")
--else ()
--    add_cflag_if_supported("-O2")
--    add_cflag_if_supported("-Werror")
--endif ()
diff --git a/devel/stlink/files/patch-doc_dev_pkg-config_CMakeLists.txt b/devel/stlink/files/patch-doc_dev_pkg-config_CMakeLists.txt
deleted file mode 100644
index 1bb3871c36ef..000000000000
--- a/devel/stlink/files/patch-doc_dev_pkg-config_CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
---- doc/dev/pkg-config/CMakeLists.txt.orig	2021-04-24 22:24:02 UTC
-+++ doc/dev/pkg-config/CMakeLists.txt
-@@ -11,5 +11,5 @@ configure_file(
- 
- install(
-     FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
--    DESTINATION ${STLINK_LIBRARY_PATH}/pkgconfig
-+    DESTINATION libdata/pkgconfig/
-     )
diff --git a/devel/stlink/files/patch-src_common.c b/devel/stlink/files/patch-src_common.c
deleted file mode 100644
index 28597bb71049..000000000000
--- a/devel/stlink/files/patch-src_common.c
+++ /dev/null
@@ -1,34 +0,0 @@
-Partial application of upstream commit c8fc656, closing
-upstream bug #985 and #1175 and fixing the build on 32
-bit platforms.
-
-https://github.com/stlink-org/stlink/commit/c8fc6561fead79ad49c09d82bab864745086792c
-https://github.com/stlink-org/stlink/issues/985
-https://github.com/stlink-org/stlink/issues/1175
-
---- src/common.c.orig	2021-04-24 22:24:02 UTC
-+++ src/common.c
-@@ -1,4 +1,5 @@
- #define DEBUG_FLASH 0
-+#include <limits.h>
- #include <stdarg.h>
- #include <stdint.h>
- #include <stdio.h>
-@@ -2205,7 +2206,7 @@ static int map_file(mapped_file_t *mf, const char *pat
- 
-   if (sizeof(st.st_size) != sizeof(size_t)) {
-     // on 32 bit systems, check if there is an overflow
--    if (st.st_size > (off_t)INT32_MAX) {
-+    if (st.st_size > (off_t)SSIZE_MAX) {
-       fprintf(stderr, "mmap() size_t overflow for file %s\n", path);
-       goto on_error;
-     }
-@@ -2219,7 +2220,7 @@ static int map_file(mapped_file_t *mf, const char *pat
-     goto on_error;
-   }
- 
--  mf->len = st.st_size;
-+  mf->len = (size_t)st.st_size;
-   error = 0; // success
- 
- on_error:
diff --git a/devel/stlink/files/patch-src_st-flash_flash__opts.c b/devel/stlink/files/patch-src_st-flash_flash__opts.c
new file mode 100644
index 000000000000..d78aca09d46f
--- /dev/null
+++ b/devel/stlink/files/patch-src_st-flash_flash__opts.c
@@ -0,0 +1,56 @@
+--- src/st-flash/flash_opts.c.orig	2025-04-02 12:36:36 UTC
++++ src/st-flash/flash_opts.c
+@@ -17,7 +17,7 @@
+ #include <helper.h>
+ 
+ static bool starts_with(const char * str, const char * prefix) {
+-    uint32_t n = strlen(prefix);
++    size_t n = strlen(prefix);
+ 
+     if (strlen(str) < n) { return (false); }
+ 
+@@ -70,7 +70,7 @@ static int32_t get_integer_from_char_array (const char
+         fprintf (stderr, "*** Error: Integer greater than UINT32_MAX, cannot convert to int32_t\n");
+         return (-1);
+     } else {
+-        *read_value = value;
++        *read_value = (uint32_t)value;
+         return (0);
+     }
+ }
+@@ -199,7 +199,7 @@ int32_t flash_get_opts(struct flash_opts* o, int32_t a
+             if (result != 0) {
+                 return (bad_arg ("--flash"));
+             } else {
+-                o->flash_size = (size_t)flash_size;
++                o->flash_size = flash_size;
+             }
+         } else if (strcmp(av[0], "--connect-under-reset") == 0) {
+             o->connect = CONNECT_UNDER_RESET;
+@@ -259,7 +259,7 @@ int32_t flash_get_opts(struct flash_opts* o, int32_t a
+             if (result != 0) {
+                 return bad_arg ("size");
+             } else {
+-                o->size = (size_t) size;
++                o->size =  size;
+             }
+         }
+ 
+@@ -283,7 +283,7 @@ int32_t flash_get_opts(struct flash_opts* o, int32_t a
+             if (result != 0) {
+                 return bad_arg ("size");
+             } else {
+-                o->size = (size_t) size;
++                o->size = size;
+             }
+ 
+             break;
+@@ -300,7 +300,7 @@ int32_t flash_get_opts(struct flash_opts* o, int32_t a
+                 if (result != 0) {
+                     return bad_arg("option bytes read: invalid size");
+                 } else {
+-                    o->size = (size_t) size;
++                    o->size = size;
+                 }
+             }
+             break;
diff --git a/devel/stlink/files/patch-src_st-info_info.c b/devel/stlink/files/patch-src_st-info_info.c
new file mode 100644
index 000000000000..6252c22a6ff9
--- /dev/null
+++ b/devel/stlink/files/patch-src_st-info_info.c
@@ -0,0 +1,11 @@
+--- src/st-info/info.c.orig	2025-04-02 12:38:55 UTC
++++ src/st-info/info.c
+@@ -55,7 +55,7 @@ static void stlink_probe(enum connect_type connect, in
+     stlink_t **stdevs;
+     uint32_t size;
+ 
+-    size = stlink_probe_usb(&stdevs, connect, freq);
++    size = (uint32_t) stlink_probe_usb(&stdevs, connect, freq);
+ 
+     printf("Found %u stlink programmers\n", size);
+ 
diff --git a/devel/stlink/files/patch-src_st-util_gdb-server.c b/devel/stlink/files/patch-src_st-util_gdb-server.c
new file mode 100644
index 000000000000..1e089ec7952c
--- /dev/null
+++ b/devel/stlink/files/patch-src_st-util_gdb-server.c
@@ -0,0 +1,11 @@
+--- src/st-util/gdb-server.c.orig	2025-04-02 12:39:38 UTC
++++ src/st-util/gdb-server.c
+@@ -1041,7 +1041,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
+                     params = separator + 1;
+                 }
+ 
+-                uint32_t hex_len = strlen(params);
++                uint32_t hex_len = (uint32_t) strlen(params);
+                 uint32_t alloc_size = (hex_len / 2) + 1;
+                 uint32_t cmd_len;
+                 char *cmd = malloc(alloc_size);
diff --git a/devel/stlink/files/patch-src_stlink-lib_chipid.c b/devel/stlink/files/patch-src_stlink-lib_chipid.c
new file mode 100644
index 000000000000..c130a67e8d48
--- /dev/null
+++ b/devel/stlink/files/patch-src_stlink-lib_chipid.c
@@ -0,0 +1,11 @@
+--- src/stlink-lib/chipid.c.orig	2025-04-02 12:25:21 UTC
++++ src/stlink-lib/chipid.c
+@@ -212,7 +212,7 @@ void process_chipfile(char *fname) {
+ 
+ void init_chipids(char *dir_to_scan) {
+   DIR *d;
+-  uint32_t nl; // namelen
++  size_t nl; // namelen
+   struct dirent *dir;
+ 
+   if (!dir_to_scan) {
diff --git a/devel/stlink/files/patch-src_stlink-lib_common.c b/devel/stlink/files/patch-src_stlink-lib_common.c
new file mode 100644
index 000000000000..ffff610cfde6
--- /dev/null
+++ b/devel/stlink/files/patch-src_stlink-lib_common.c
@@ -0,0 +1,11 @@
+--- src/stlink-lib/common.c.orig	2025-04-02 12:21:51 UTC
++++ src/stlink-lib/common.c
+@@ -913,7 +913,7 @@ int32_t stlink_parse_ihex(const char *path, uint8_t er
+         break;
+       }
+ 
+-      uint32_t l = strlen(line);
++      size_t l = strlen(line);
+ 
+       while (l > 0 && (line[l - 1] == '\n' || line[l - 1] == '\r')) {
+         --l;
diff --git a/devel/stlink/files/patch-src_stlink-lib_flash__loader.c b/devel/stlink/files/patch-src_stlink-lib_flash__loader.c
new file mode 100644
index 000000000000..978a4e54eb06
--- /dev/null
+++ b/devel/stlink/files/patch-src_stlink-lib_flash__loader.c
@@ -0,0 +1,11 @@
+--- src/stlink-lib/flash_loader.c.orig	2025-04-02 12:20:17 UTC
++++ src/stlink-lib/flash_loader.c
+@@ -788,7 +788,7 @@ int32_t stlink_flashloader_write(stlink_t *sl, flash_l
+       if (stm32l1_write_half_pages(sl, fl, addr, base, len, pagesize)) {
+         return (-1);
+       } else {
+-        off = (size_t)(len / pagesize) * pagesize;
++        off = (uint32_t)((size_t)(len / pagesize) * pagesize);
+       }
+     }
+ 
diff --git a/devel/stlink/files/patch-src_stlink-lib_map__file.c b/devel/stlink/files/patch-src_stlink-lib_map__file.c
new file mode 100644
index 000000000000..1205567f3e34
--- /dev/null
+++ b/devel/stlink/files/patch-src_stlink-lib_map__file.c
@@ -0,0 +1,11 @@
+--- src/stlink-lib/map_file.c.orig	2025-04-02 12:31:25 UTC
++++ src/stlink-lib/map_file.c
+@@ -95,7 +95,7 @@ int32_t map_file(mapped_file_t *mf, const char *path) 
+     goto on_error;
+   }
+ 
+-  mf->len = (size_t)st.st_size;
++  mf->len = (uint32_t)st.st_size;
+   error = 0; // success
+ 
+ on_error:
diff --git a/devel/stlink/files/patch-src_stlink-lib_usb.c b/devel/stlink/files/patch-src_stlink-lib_usb.c
new file mode 100644
index 000000000000..71794b22a66f
--- /dev/null
+++ b/devel/stlink/files/patch-src_stlink-lib_usb.c
@@ -0,0 +1,20 @@
+--- src/stlink-lib/usb.c.orig	2025-04-02 12:34:33 UTC
++++ src/stlink-lib/usb.c
+@@ -1172,7 +1172,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, 
+ 
+         if (ret) { continue; } // could not open device
+ 
+-        uint32_t serial_len = stlink_serial(handle, &desc, sl->serial);
++        size_t serial_len = stlink_serial(handle, &desc, sl->serial);
+ 
+         libusb_close(handle);
+ 
+@@ -1375,7 +1375,7 @@ static uint32_t stlink_probe_usb_devs(libusb_device **
+             break;
+         }
+ 
+-        uint32_t serial_len = stlink_serial(handle, &desc, serial);
++        size_t serial_len = stlink_serial(handle, &desc, serial);
+ 
+         libusb_close(handle);
+ 
diff --git a/devel/stlink/pkg-plist b/devel/stlink/pkg-plist
index 7538410d56f1..e578e4baf10d 100644
--- a/devel/stlink/pkg-plist
+++ b/devel/stlink/pkg-plist
@@ -3,28 +3,103 @@ bin/st-info
 bin/st-trace
 bin/st-util
 include/stlink/backend.h
+include/stlink/calculate.h
 include/stlink/chipid.h
 include/stlink/commands.h
+include/stlink/common_flash.h
 include/stlink/flash_loader.h
 include/stlink/helper.h
+include/stlink/lib_md5.h
 include/stlink/libusb_settings.h
 include/stlink/logging.h
+include/stlink/map_file.h
 include/stlink/md5.h
-include/stlink/reg.h
+include/stlink/option_bytes.h
+include/stlink/read_write.h
+include/stlink/register.h
 include/stlink/sg.h
+include/stlink/spdlog_wrapper.h
 include/stlink/stlink.h
 include/stlink/stm32.h
+include/stlink/stm32flash.h
 include/stlink/usb.h
 include/stlink/version.h
 lib/libstlink.so
 lib/libstlink.so.1
-lib/libstlink.so.1.7.0
+lib/libstlink.so.1.8.0
 lib/libstlink.a
-libdata/pkgconfig/stlink.pc
 share/man/man1/st-flash.1.gz
 share/man/man1/st-info.1.gz
 share/man/man1/st-util.1.gz
 %%DATADIR%%/Makefile
+%%DATADIR%%/chips/C011xx.chip
+%%DATADIR%%/chips/C031xx.chip
+%%DATADIR%%/chips/F03x.chip
+%%DATADIR%%/chips/F04x.chip
+%%DATADIR%%/chips/F05x.chip
+%%DATADIR%%/chips/F07x.chip
+%%DATADIR%%/chips/F09x.chip
+%%DATADIR%%/chips/F1xx_CL.chip
+%%DATADIR%%/chips/F1xx_HD.chip
+%%DATADIR%%/chips/F1xx_LD.chip
+%%DATADIR%%/chips/F1xx_MD.chip
+%%DATADIR%%/chips/F1xx_VL_HD.chip
+%%DATADIR%%/chips/F1xx_VL_MD_LD.chip
+%%DATADIR%%/chips/F1xx_XLD.chip
+%%DATADIR%%/chips/F2xx.chip
+%%DATADIR%%/chips/F301_F302_F318.chip
+%%DATADIR%%/chips/F302_F303_F358.chip
+%%DATADIR%%/chips/F302_F303_F398_HD.chip
+%%DATADIR%%/chips/F303_F328_F334.chip
+%%DATADIR%%/chips/F37x.chip
+%%DATADIR%%/chips/F401xB_xC.chip
+%%DATADIR%%/chips/F401xD_xE.chip
+%%DATADIR%%/chips/F410.chip
+%%DATADIR%%/chips/F411xC_xE.chip
+%%DATADIR%%/chips/F412.chip
+%%DATADIR%%/chips/F413_F423.chip
+%%DATADIR%%/chips/F42x_F43x.chip
+%%DATADIR%%/chips/F446.chip
+%%DATADIR%%/chips/F46x_F47x.chip
+%%DATADIR%%/chips/F4x5_F4x7.chip
+%%DATADIR%%/chips/F72x_F73x.chip
+%%DATADIR%%/chips/F74x_F75x.chip
+%%DATADIR%%/chips/F76x_F77x.chip
+%%DATADIR%%/chips/G03x_G04x.chip
+%%DATADIR%%/chips/G05x_G06x.chip
+%%DATADIR%%/chips/G07x_G08x.chip
+%%DATADIR%%/chips/G0Bx_G0Cx.chip
+%%DATADIR%%/chips/G43x_G44x.chip
+%%DATADIR%%/chips/G47x_G48x.chip
+%%DATADIR%%/chips/G49x_G4Ax.chip
+%%DATADIR%%/chips/H5xx.chip
+%%DATADIR%%/chips/H72x_H73x.chip
+%%DATADIR%%/chips/H74x_H75x.chip
+%%DATADIR%%/chips/H7Ax_H7Bx.chip
+%%DATADIR%%/chips/L0xxx_Cat_1.chip
+%%DATADIR%%/chips/L0xxx_Cat_2.chip
+%%DATADIR%%/chips/L0xxx_Cat_3.chip
+%%DATADIR%%/chips/L0xxx_Cat_5.chip
+%%DATADIR%%/chips/L1xx_Cat_1.chip
+%%DATADIR%%/chips/L1xx_Cat_2.chip
+%%DATADIR%%/chips/L1xx_Cat_3.chip
+%%DATADIR%%/chips/L1xx_Cat_4.chip
+%%DATADIR%%/chips/L1xx_Cat_5.chip
+%%DATADIR%%/chips/L41x_L42x.chip
+%%DATADIR%%/chips/L43x_L44x.chip
+%%DATADIR%%/chips/L45x_L46x.chip
+%%DATADIR%%/chips/L47x_L48x.chip
+%%DATADIR%%/chips/L496x_L4A6x.chip
+%%DATADIR%%/chips/L4Px_L4Qx.chip
+%%DATADIR%%/chips/L4Rx.chip
+%%DATADIR%%/chips/L5x5xx.chip
+%%DATADIR%%/chips/U535_U545.chip
+%%DATADIR%%/chips/U55Fx_U5Gx.chip
+%%DATADIR%%/chips/U575_U585.chip
+%%DATADIR%%/chips/U59x_U5Ax.chip
+%%DATADIR%%/chips/WBx0_WBx5.chip
+%%DATADIR%%/chips/WLEx.chip
+%%DATADIR%%/chips/unknown_device.chip
 %%DATADIR%%/cleanroom.md
 %%DATADIR%%/linker.ld
 %%DATADIR%%/stm32f0.s
@@ -36,3 +111,6 @@ share/man/man1/st-util.1.gz
 %%DATADIR%%/stm32lx.s
 %%GTK3%%bin/stlink-gui
 %%GTK3%%%%DATADIR%%/stlink-gui.ui
+%%GTK3%%share/applications/stlink-gui.desktop
+%%GTK3%%share/icons/hicolor/scalable/apps/stlink-gui.svg
+%%PORTDOCS%%@dir %%DOCSDIR%%/dev