Skip to content

Commit e493109

Browse files
General Project Update
- Fixed compatibility with gcc-14 [-Werror=calloc-transposed-args] - Updated compiling instructions and build script for Windows (Closes #1364) (Closes #1410) - Updated CHANGELOG.md - Minor formatting fixes
1 parent 1f0b95c commit e493109

File tree

6 files changed

+83
-57
lines changed

6 files changed

+83
-57
lines changed

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# stlink Changelog
22

3+
# v1.8.1
4+
5+
Release date: 2024-09-01
6+
7+
This release drops support for some older operating systems. Check project README for details.
8+
9+
Updated system requirements:
10+
- `cmake` >= 3.13.0
11+
- `libusb` >= 1.0.22
12+
- `libgtk-dev` >= 3.22.30
13+
14+
Features:
15+
- Added support for STLINK-V3PWR ([#1388](https://github.com/stlink-org/stlink/pull/1388), [#1389](https://github.com/stlink-org/stlink/pull/1389))
16+
- Dynamic SRAM size for F4 memory map ([#1390](https://github.com/stlink-org/stlink/pull/1390))
17+
- Modifications to allow building of toolset in OpenBSD ([#1392](https://github.com/stlink-org/stlink/pull/1392))
18+
- --mass-erase for st-flash write commands ([#1397](https://github.com/stlink-org/stlink/pull/1397))
19+
- Support for setting option bytes to STM32L41x_L42x (according to RM0394) ([#1405](https://github.com/stlink-org/stlink/pull/1405), [#1412](https://github.com/stlink-org/stlink/pull/1412), [#1413](https://github.com/stlink-org/stlink/pull/1413))
20+
- Improvements for stlink-gui ([#1411](https://github.com/stlink-org/stlink/pull/1411))
21+
- [STM32U575/585]: Added support for OTP bytes ([#1419](https://github.com/stlink-org/stlink/pull/1419))
22+
- [STM32Gx]: Added erase support for multi-bank products ([#1420](https://github.com/stlink-org/stlink/pull/1420))
23+
24+
Updates & changes:
25+
- Debian 11 x64 doesn't work with v1.8.0 because of incompatible glibc ([#1376](https://github.com/stlink-org/stlink/pull/1376), commit [#ece34ef](https://github.com/stlink-org/stlink/commit/ece34efbce579ca7d367c58f903ffa6dc7bd96e6))
26+
- [STM32L4R5ZI]: gdb-multiarch uses wrong osabi ([#1386](https://github.com/stlink-org/stlink/pull/1386), [#1387](https://github.com/stlink-org/stlink/pull/1387), [#1394](https://github.com/stlink-org/stlink/pull/1394))
27+
- [doc] STM32H573 reports chipid 0x000 ([#1398](https://github.com/stlink-org/stlink/pull/1398), commit [#3655871](https://github.com/stlink-org/stlink/commit/3655871f8dd97294bbee191c1c7341c8a129af2f))
28+
29+
Fixes:
30+
31+
- Cmake minimal version mismatch ([#1374](https://github.com/stlink-org/stlink/pull/1374), [#1375](https://github.com/stlink-org/stlink/pull/1375), commit [#1ee7f6b](https://github.com/stlink-org/stlink/commit/1ee7f6b6c05e305112bb070ae571ebbe26c55946))
32+
- Added a graceful way to terminate st-util ([#1395](https://github.com/stlink-org/stlink/pull/1395), [#1396](https://github.com/stlink-org/stlink/pull/1396))
33+
- [st-trace] Bug in function static bool read_trace( ) ([#1400](https://github.com/stlink-org/stlink/pull/1400), commit [#32ce4bf](https://github.com/stlink-org/stlink/commit/32ce4bf88a816fb6a9841a33e6c5f6b593a9b927))
34+
- Fixed STM32H7 FLASH_OPTCR unlock sequence ([#1401](https://github.com/stlink-org/stlink/pull/1401), [#1416](https://github.com/stlink-org/stlink/pull/1416))
35+
- Restored support for STM32G4 Cat4 device STM32G491 ([#1403](https://github.com/stlink-org/stlink/pull/1403), [#1414](https://github.com/stlink-org/stlink/pull/1414))
36+
- Fixed STM32H7 option byte programming ([#1417](https://github.com/stlink-org/stlink/pull/1417))
37+
- Latest release stlink-1.8.0-win32 doesn't run ([#1364](https://github.com/stlink-org/stlink/pull/1364), [#1410](https://github.com/stlink-org/stlink/pull/1410) commit [_commit-ID TBD_])
38+
339
# v1.8.0
440

541
Release date: 2024-02-01

cmake/modules/Findlibusb.cmake

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ include(FindPackageHandleStandardArgs)
1212

1313
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system
1414
# libusb header file
15-
FIND_PATH(
16-
LIBUSB_INCLUDE_DIR NAMES libusb.h
15+
FIND_PATH(LIBUSB_INCLUDE_DIR
16+
NAMES libusb.h
1717
HINTS /usr/include
1818
)
1919

2020
# libusb library
2121
set(LIBUSB_NAME usb)
22-
find_library(
23-
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
22+
find_library(LIBUSB_LIBRARY
23+
NAMES ${LIBUSB_NAME}
2424
HINTS /usr /usr/local /opt
2525
)
2626

@@ -32,16 +32,16 @@ if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libus
3232

3333
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # OpenBSD; libusb is available from ports
3434
# libusb header file
35-
FIND_PATH(
36-
LIBUSB_INCLUDE_DIR NAMES libusb.h
35+
FIND_PATH(LIBUSB_INCLUDE_DIR
36+
NAMES libusb.h
3737
HINTS /usr/local/include
3838
PATH_SUFFIXES libusb-1.0
3939
)
4040

4141
# libusb library
4242
set(LIBUSB_NAME usb-1.0)
43-
find_library(
44-
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
43+
find_library(LIBUSB_LIBRARY
44+
NAMES ${LIBUSB_NAME}
4545
HINTS /usr/local
4646
)
4747

@@ -87,8 +87,8 @@ elseif (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")) # Windows OR cro
8787
)
8888

8989
# libusb header file
90-
FIND_PATH(
91-
LIBUSB_INCLUDE_DIR NAMES libusb.h
90+
FIND_PATH(LIBUSB_INCLUDE_DIR
91+
NAMES libusb.h
9292
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/include
9393
PATH_SUFFIXES libusb-1.0
9494
NO_DEFAULT_PATH
@@ -97,19 +97,19 @@ elseif (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")) # Windows OR cro
9797

9898
if (MINGW OR MSYS)
9999
# libusb library (static)
100-
set(LIBUSB_NAME usb-1.0)
101-
find_library(
102-
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
100+
set(LIBUSB_NAME libusb-1.0)
101+
find_library(LIBUSB_LIBRARY
102+
NAMES ${LIBUSB_NAME}
103103
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static
104104
NO_DEFAULT_PATH
105105
NO_CMAKE_FIND_ROOT_PATH
106106
)
107107
else (MSVC)
108108
# libusb library
109-
set(LIBUSB_NAME libusb-1.0.lib)
110-
find_library(
111-
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
112-
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS${ARCH}/dll
109+
set(LIBUSB_NAME libusb-1.0)
110+
find_library(LIBUSB_LIBRARY
111+
NAMES ${LIBUSB_NAME}
112+
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/dll
113113
NO_DEFAULT_PATH
114114
NO_CMAKE_FIND_ROOT_PATH
115115
)
@@ -122,16 +122,16 @@ elseif (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")) # Windows OR cro
122122

123123
else () # all other OS (unix-based)
124124
# libusb header file
125-
FIND_PATH(
126-
LIBUSB_INCLUDE_DIR NAMES libusb.h
125+
FIND_PATH(LIBUSB_INCLUDE_DIR
126+
NAMES libusb.h
127127
HINTS /usr/include
128128
PATH_SUFFIXES libusb-1.0
129129
)
130130

131131
# libusb library
132132
set(LIBUSB_NAME usb-1.0)
133-
find_library(
134-
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
133+
find_library(LIBUSB_LIBRARY
134+
NAMES ${LIBUSB_NAME}
135135
HINTS /usr /usr/local
136136
)
137137

doc/compiling.md

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,43 @@
11
# Compiling from sources
22

3+
34
## Microsoft Windows (10, 11)
45

56
### Common Requirements
67

78
On Windows users should ensure that the following software is installed:
89

910
- `git` (_optional, but recommended_)
11+
- `7zip`
1012
- `cmake`
11-
- `7-zip`
12-
- `MinGW-w64`
13+
- `MSYS2`
1314

1415
### Installation
1516

1617
1. Install `git` from <https://git-scm.com/download/win>
17-
2. Install `cmake` from <https://cmake.org/download><br />
18+
2. Install `cmake` from <https://cmake.org/download/#latest> --> Binary distributions --> Windows x64 Installer<br />
1819
Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant.
19-
3. Install MinGW-w64<br />
20-
Download **MinGW-w64** from <https://github.com/niXman/mingw-builds-binaries/releases/download/13.2.0-rt_v11-rev1/x86_64-13.2.0-release-win32-seh-msvcrt-rt_v11-rev1.7z>. Extract content to `C:\mingw-w64\` and add `C:\mingw-w64\bin\` to PATH-Variable.<br />
21-
22-
4. Create a new destination folder at a place of your choice
23-
5. Open the command-line (cmd.exe) and execute `cd C:\$Path-to-your-destination-folder$\`
24-
6. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git`from the command-line (cmd.exe)<br />
25-
or download and extract the stlink zip-sourcefolder from the Release page on GitHub.
20+
3. Install `MSYS2` from <https://www.msys2.org/><br />
21+
Follow the installation instructions on the website.
22+
4. Install `mingw-w64` via the MSYS2 UCRT64 Shell: `pacman -S mingw-w64-x86_64-make`
23+
5. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git`from the command-line (cmd.exe)<br />
24+
or download and extract (`7zip`) the stlink zip-sourcefolder from the Release page on GitHub.
2625

2726
### Building
2827

29-
#### MinGW-w64
30-
31-
1. Open command-line with administrator privileges
32-
2. Move to the `stlink` directory
28+
1. Open the command-line (cmd.exe) with administrator privileges
29+
2. Move to the `stlink` directory with `cd C:\$Path-to-your-stlink-folder$\`
3330
3. Execute `mingw64-build.bat`
3431

35-
NOTE:<br />
36-
Per default the build script (currently) uses `C:\mingw-w64\x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0\mingw64\bin`.<br />
37-
When installing different toolchains make sure to update the path in the `mingw64-build.bat`.<br />
38-
This can be achieved by opening the .bat file with a common text editor.
39-
40-
Options:
41-
42-
- `/m` - compilation runs in parallel utilizing multiple cores
43-
- `/p:Configuration=Release` - generates _Release_, optimized build.
44-
45-
Directory `<project_root>\build\Release` contains final executables.
46-
(`st-util.exe` is located in `<project_root>\build\src\gdbserver\Release`).
32+
Depending on the flavour of compilation the final executables will be placed in the following directories:
33+
- Local compilation: `<project_root>\build-mingw\bin`
34+
- Local installation: `C:\Program Files (x86)\stlink\bin`
35+
- Package Generation (portable): `C:\Users\swift\Desktop\stlink\build-mingw\dist`
4736

4837
**NOTE:**
4938

50-
[ST-LINK drivers](https://www.st.com/en/development-tools/stsw-link009.html) are required for `stlink` to work.
39+
[ST-LINK drivers](https://www.st.com/en/development-tools/stsw-link009.html) are required for programmers to work with `stlink`.
40+
5141

5242
## Linux
5343

mingw64-build.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
mkdir build-mingw
44
cd build-mingw
5-
set PATH=C:\Program Files\CMake\bin;C:\mingw-w64\x86_64-13.2.0-release-win32-seh-msvcrt-rt_v11-rev1\mingw64\bin;%PATH%
5+
set PATH=C:\Program Files\CMake\bin;C:\msys64\ucrt64\bin;C:\msys64\mingw64\bin;%PATH%
66
cmake -G "MinGW Makefiles" ..
7-
mingw32-make clean
7+
mingw32-make
88
mingw32-make install
99
mingw32-make package
1010
cd ..

src/st-util/gdb-server.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
989989
}
990990

991991
uint32_t queryNameLength = (uint32_t) (separator - &packet[1]);
992-
char* queryName = calloc(queryNameLength + 1, 1);
992+
char* queryName = calloc(1, queryNameLength + 1);
993993
strncpy(queryName, &packet[1], queryNameLength);
994994

995995
DLOG("query: %s;%s\n", queryName, params);
@@ -1032,7 +1032,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
10321032
if (length == 0) {
10331033
reply = strdup("l");
10341034
} else {
1035-
reply = calloc(length + 2, 1);
1035+
reply = calloc(1, length + 2);
10361036
reply[0] = 'm';
10371037
strncpy(&reply[1], data, length);
10381038
}
@@ -1191,7 +1191,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
11911191

11921192
// Length of decoded data cannot be more than encoded, as escapes are removed.
11931193
// Additional byte is reserved for alignment fix.
1194-
uint8_t *decoded = calloc(data_length + 1, 1);
1194+
uint8_t *decoded = calloc(1, data_length + 1);
11951195
uint32_t dec_index = 0;
11961196

11971197
for (uint32_t i = 0; i < data_length; i++) {
@@ -1347,7 +1347,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
13471347

13481348
if (ret) { DLOG("g packet: read_all_regs failed\n"); }
13491349

1350-
reply = calloc(8 * 16 + 1, 1);
1350+
reply = calloc(1, 8 * 16 + 1);
13511351

13521352
for (int32_t i = 0; i < 16; i++) {
13531353
sprintf(&reply[i * 8], "%08x", (uint32_t) htonl(regp.r[i]));
@@ -1398,7 +1398,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
13981398

13991399
if (reply == NULL) {
14001400
// if reply is set to "E00", skip
1401-
reply = calloc(8 + 1, 1);
1401+
reply = calloc(1, 8 + 1);
14021402
sprintf(reply, "%08x", myreg);
14031403
}
14041404

@@ -1479,7 +1479,7 @@ int32_t serve(stlink_t *sl, st_state_t *st) {
14791479

14801480
// read failed somehow, don't return stale buffer
14811481

1482-
reply = calloc(count * 2 + 1, 1);
1482+
reply = calloc(1, count * 2 + 1);
14831483

14841484
for (uint32_t i = 0; i < count; i++) {
14851485
reply[i * 2 + 0] = hex[sl->q_buf[i + adj_start] >> 4];

src/stlink-lib/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ int32_t stlink_parse_ihex(const char *path, uint8_t erased_pattern, uint8_t **me
879879
}
880880

881881
*size = (end - *begin) + 1;
882-
data = calloc(*size, 1); // use calloc to get NULL if out of memory
882+
data = calloc(1, *size); // use calloc to get NULL if out of memory
883883

884884
if (!data) {
885885
ELOG("Cannot allocate %u bytes\n", (*size));

0 commit comments

Comments
 (0)