Skip to content

Commit

Permalink
Merge branch 'testing' into mass-erase
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightwalker-87 committed May 29, 2024
2 parents 1fbf1d9 + 3520d73 commit 794f889
Show file tree
Hide file tree
Showing 58 changed files with 458 additions and 394 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
build-mingw-32
build-mingw-64
3rdparty

.project
.cmake/
Expand Down
59 changes: 23 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,35 +254,22 @@ add_library(${STLINK_LIB_SHARED} SHARED ${STLINK_HEADERS} ${STLINK_SOURCE})

set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
message(STATUS "STLINK_LIB_SHARED: ${STLINK_LIB_SHARED}")
message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}")
message(STATUS "VERSION: ${STLINK_SHARED_VERSION}")

set_target_properties(${STLINK_LIB_SHARED} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_SHARED_VERSION}
OUTPUT_NAME ${PROJECT_NAME}
)
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_SHARED_VERSION}
OUTPUT_NAME ${PROJECT_NAME}
)

# Link shared library
if (WIN32) # ... with Windows libraries
if (WIN32)
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32)
else ()
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB})
endif()

install(TARGETS ${STLINK_LIB_SHARED}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Copy libusb DLL-library to binary output folder
if (WIN32)
file(COPY ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/dll/libusb-1.0.dll
DESTINATION ${CMAKE_INSTALL_BINDIR})
file(COPY ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/dll/libusb-1.0.dll
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
endif()
install(TARGETS ${STLINK_LIB_SHARED} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})


###
Expand All @@ -300,17 +287,16 @@ add_library(${STLINK_LIB_STATIC} STATIC ${STLINK_HEADERS} ${STLINK_SOURCE})

set(STLINK_STATIC_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
message(STATUS "STLINK_LIB_STATIC: ${STLINK_LIB_STATIC}")
message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}")
message(STATUS "VERSION: ${STLINK_STATIC_VERSION}")

set_target_properties(${STLINK_LIB_STATIC} PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_STATIC_VERSION}
OUTPUT_NAME ${STLINK_LIB_STATIC_OUTPUT_NAME}
)
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${STLINK_STATIC_VERSION}
OUTPUT_NAME ${STLINK_LIB_STATIC_OUTPUT_NAME}
)

# Link static library
if (WIN32) # ... with Windows libraries
if (WIN32)
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32)
else ()
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB})
Expand Down Expand Up @@ -341,15 +327,15 @@ add_executable(st-util ${ST-UTIL_SOURCES})
add_executable(st-trace ${ST-TRACE_SOURCES})

if (WIN32)
target_link_libraries(st-flash ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-info ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-util ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-trace ${STLINK_LIB_STATIC} ${SSP_LIB})
target_link_libraries(st-flash ${STLINK_LIB_STATIC})
target_link_libraries(st-info ${STLINK_LIB_STATIC})
target_link_libraries(st-util ${STLINK_LIB_STATIC})
target_link_libraries(st-trace ${STLINK_LIB_STATIC})
else ()
target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-trace ${STLINK_LIB_SHARED} ${SSP_LIB})
target_link_libraries(st-flash ${STLINK_LIB_SHARED})
target_link_libraries(st-info ${STLINK_LIB_SHARED})
target_link_libraries(st-util ${STLINK_LIB_SHARED})
target_link_libraries(st-trace ${STLINK_LIB_SHARED})
endif()

install(TARGETS st-flash DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down Expand Up @@ -380,10 +366,10 @@ endif()

# MCU configuration files
if (WIN32)
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_PREFIX}/config/chips)
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_PREFIX}/config/chips)
else ()
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/chips)
endif ()
set(CMAKE_CHIPS_DIR ${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/config/chips)
endif()
add_definitions( -DSTLINK_CHIPS_DIR="${CMAKE_CHIPS_DIR}" )
file(GLOB CHIP_FILES ${CMAKE_SOURCE_DIR}/config/chips/*.chip)
install(FILES ${CHIP_FILES} DESTINATION ${CMAKE_CHIPS_DIR})
Expand All @@ -396,6 +382,7 @@ 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


###
# Uninstall target
###
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at texane@gmail.com. All
reported by contacting the project team [here](https://github.com/stlink-org/stlink/discussions). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Report a bug by [opening a new issue]() with one of the available templates. It'
1) If using a ST-Link-v2 programmer: Convince yourself that it is recognised as an USB device by your computer, thus reporting device and manufacturer ID. Use a diagnostic tool to probe for enumerated USB devices, e.g [`lsusb -v`](https://linux.die.net/man/8/lsusb) on unix-based systems.
2) **Use the [ST-Link firmware upgrade tool](https://www.st.com/en/development-tools/stsw-link007.html) based on Java to read out the current firmware version and update to the latest available version. This also works for _non-genuine_ ST programmers and boards.**
3) Try to make sure you have a working toolchain before starting to build.
4) **Update to the _latest_ release version or maybe even use the `develop` branch.**
4) **Update to the _latest_ release version or maybe even use the `testing` branch.**
5) Search for your problem in the available open issues, _before_ opening a new ticket.
6) Make sure to **use the available issue templates** to submit a bug-report or a feature-request. **Do not replace the prepared text, edit the placeholders instead. _Describe_ your problem.**
7) Avoid to add new comments to closed issues unless they confirm a solution already available.
Expand Down
58 changes: 33 additions & 25 deletions cmake/modules/Findlibusb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,49 @@

include(FindPackageHandleStandardArgs)

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS /usr/include
)

# libusb library
set(LIBUSB_NAME usb)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
if (NOT LIBUSB_FOUND)
message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.")
endif()

elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # OpenBSD; libusb-1.0 is available from ports
elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") # OpenBSD; libusb is available from ports
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS /usr/local/include
PATH_SUFFIXES libusb-1.0
)

# libusb library
set(LIBUSB_NAME usb-1.0)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr/local
)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
if (NOT LIBUSB_FOUND)
message(FATAL_ERROR "No libusb-1.0 library found on your system! Install libusb-1.0 from ports or packages.")
endif()

elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-toolchain on Debian
# MinGW/MSYS/MSVC: 64-bit or 32-bit?
elseif (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")) # Windows OR cross-build with MinGW-toolchain on Debian
# MinGW: 64-bit or 32-bit?
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
message(STATUS "=== Building for Windows (x86-64) ===")
set(ARCH 64)
Expand All @@ -53,26 +61,20 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
set(ARCH 32)
endif()

if (WIN32 AND NOT EXISTS "/etc/debian_version") # Skip this for Debian...
if (NOT LIBUSB_FOUND)
# Preparations for installing libusb library
set(LIBUSB_WIN_VERSION 1.0.25) # set libusb version
set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z)
if (WIN32 AND NOT EXISTS "/etc/debian_version") # ... on native Windows systems
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE})
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION})
elseif (EXISTS "/etc/debian_version" AND MINGW) # ... only for cross-building on Debian
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_SOURCE_DIR}/build-mingw-${ARCH}/${LIBUSB_WIN_ARCHIVE})
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/build-mingw-${ARCH}/3rdparty/libusb-${LIBUSB_WIN_VERSION})
endif()
set(LIBUSB_WIN_VERSION 1.0.27) # set libusb version
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION}.7z)
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION})

# Get libusb package
if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there (for whatever reason)
if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there
message(STATUS "libusb archive already in build folder")
else () # ... download the package
message(STATUS "downloading libusb ${LIBUSB_WIN_VERSION}")
file(DOWNLOAD
https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${LIBUSB_WIN_VERSION}/libusb-${LIBUSB_WIN_VERSION}.7z/download
${LIBUSB_WIN_ARCHIVE_PATH} EXPECTED_MD5 aabe177bde869bfad34278335eaf8955
${LIBUSB_WIN_ARCHIVE_PATH} EXPECTED_MD5 c72153fc5a32f3b942427b0671897a1a
)
endif()

Expand All @@ -84,7 +86,7 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
WORKING_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER}
)

# Find path to libusb library
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/include
Expand All @@ -94,15 +96,16 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
)

if (MINGW OR MSYS)
# libusb library (static)
set(LIBUSB_NAME usb-1.0)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)

elseif (MSVC)
else (MSVC)
# libusb library
set(LIBUSB_NAME libusb-1.0.lib)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
Expand All @@ -111,23 +114,28 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-to
NO_CMAKE_FIND_ROOT_PATH
)
endif()
message(STATUS "Missing libusb library has been installed")
endif()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
message(STATUS "Missing libusb library has been installed")

else () # all other OS (unix-based)
else () # all other OS (unix-based)
# libusb header file
FIND_PATH(
LIBUSB_INCLUDE_DIR NAMES libusb.h
HINTS /usr /usr/local /opt
HINTS /usr/include
PATH_SUFFIXES libusb-1.0
)

# libusb library
set(LIBUSB_NAME usb-1.0)
find_library(
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
HINTS /usr /usr/local /opt
HINTS /usr /usr/local
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)

if (NOT LIBUSB_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/c_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
add_cflag_if_supported("-Wredundant-decls")
endif()

if (NOT (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)))
if (NOT (WIN32 OR (MINGW AND EXISTS "/etc/debian_version")))
add_cflag_if_supported("-fPIC")
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ elseif (WIN32) # Wi
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${TOOLCHAIN_PREFIX}")
set(CPACK_INSTALL_PREFIX "")

elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is available on Debian/Ubuntu only
elseif (EXISTS "/etc/debian_version" AND (NOT EXISTS WIN32)) # Package-build on Debian/Ubuntu
message(STATUS "Debian-based Linux OS detected")

set(CPACK_GENERATOR "DEB;RPM") # RPM requires package `rpm`
Expand Down
2 changes: 1 addition & 1 deletion cmake/packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ add_subdirectory(deb)
add_subdirectory(rpm)
add_subdirectory(windows)

include(cpack_config.cmake)
include(${CMAKE_MODULE_PATH}/cpack_config.cmake)
6 changes: 3 additions & 3 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ string(REGEX REPLACE "\n" ";" files "${files}")
foreach (file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program("@CMAKE_COMMAND@"
ARGS "-E remove \"$ENV{DESTDIR}${file}\""
execute_process(
COMMAND "@CMAKE_COMMAND@" -E remove \"$ENV{DESTDIR}${file}\"
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
RESULT_VARIABLE rm_retval
)
if (NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
Expand Down
7 changes: 6 additions & 1 deletion config/udev/rules.d/49-stlinkv3.rules
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", \
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374f", \
MODE:="0666", \
SYMLINK+="stlinkv3_%n"


# STLink V3PWR
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3757", \
MODE:="0666", \
SYMLINK+="stlinkv3_%n"

# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
Expand Down
10 changes: 10 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
stlink (1.8.0-1) unstable; urgency=medium

* Switch to gbp workflow, binary OSX blobs no longer included upstream
* Merge tag 'upstream/1.8.0' into debian
* Drop cross.patch, merged upstream
* Install chips definitions in stlink-tools
* Update symbols files for 1.8.0

-- Luca Boccassi <bluca@debian.org> Thu, 08 Feb 2024 19:28:19 +0000

stlink (1.7.0+ds-1) unstable; urgency=medium

* Merge tag 'v1.7.0' into debian. (Closes: #984356)
Expand Down
Loading

0 comments on commit 794f889

Please sign in to comment.