kopia lustrzana https://github.com/stlink-org/stlink
commit
946b7f3b04
|
@ -1,3 +1,4 @@
|
|||
build
|
||||
build-mingw
|
||||
obj-*
|
||||
*.user*
|
||||
|
|
243
CMakeLists.txt
243
CMakeLists.txt
|
@ -1,101 +1,107 @@
|
|||
cmake_minimum_required(VERSION 2.8.7)
|
||||
cmake_minimum_required(VERSION 3.4.2)
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE cmake/c_flag_overrides.cmake)
|
||||
|
||||
project(stlink C)
|
||||
set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics Stlink Tools")
|
||||
set(STLINK_UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "Udev rules directory")
|
||||
set(STLINK_MODPROBED_DIR "/etc/modprobe.d" CACHE PATH "modprobe.d directory")
|
||||
set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools")
|
||||
include(GNUInstallDirs)
|
||||
set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/udev/rules.d" CACHE PATH "udev rules directory")
|
||||
set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory")
|
||||
set(STLINK_STATIC_LIB ON CACHE BOOL "Install static lib")
|
||||
|
||||
if( IS_DIRECTORY ${LIB_INSTALL_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
if (IS_DIRECTORY ${LIB_INSTALL_DIR})
|
||||
set(LIB_INSTALL_DIR ${LIB_INSTALL_DIR} CACHE PATH "Main library directory")
|
||||
set(STLINK_LIBRARY_PATH "${LIB_INSTALL_DIR}")
|
||||
else()
|
||||
else ()
|
||||
set(LIB_INSTALL_DIR "lib" CACHE PATH "Main library directory")
|
||||
set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" )
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if( IS_DIRECTORY ${INCLUDE_INSTALL_DIR})
|
||||
if (IS_DIRECTORY ${INCLUDE_INSTALL_DIR})
|
||||
set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR} CACHE PATH "Main include directory")
|
||||
set(STLINK_INCLUDE_PATH "${INCLUDE_INSTALL_DIR}" )
|
||||
else()
|
||||
else ()
|
||||
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "Main include directory")
|
||||
set(STLINK_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF)
|
||||
option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON)
|
||||
option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON)
|
||||
|
||||
if (POLICY CMP0042)
|
||||
# Newer cmake on MacOS should use @rpath
|
||||
cmake_policy (SET CMP0042 NEW)
|
||||
endif ()
|
||||
# cmake (3.0+) on MacOS should use @rpath
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules")
|
||||
include(cmake/Version.cmake)
|
||||
if(NOT MSVC)
|
||||
include(cmake/CFlags.cmake)
|
||||
endif()
|
||||
include(cmake/version.cmake)
|
||||
if (NOT MSVC)
|
||||
include(cmake/c_flags.cmake)
|
||||
endif ()
|
||||
|
||||
|
||||
###
|
||||
# Dependencies
|
||||
###
|
||||
|
||||
find_package(LibUSB REQUIRED)
|
||||
if (NOT APPLE AND NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(gtk gtk+-3.0)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(gtk gtk+-3.0)
|
||||
endif ()
|
||||
|
||||
include(CheckIncludeFile)
|
||||
CHECK_INCLUDE_FILE(sys/mman.h STLINK_HAVE_SYS_MMAN_H)
|
||||
if (STLINK_HAVE_SYS_MMAN_H)
|
||||
add_definitions(-DSTLINK_HAVE_SYS_MMAN_H)
|
||||
endif()
|
||||
add_definitions(-DSTLINK_HAVE_SYS_MMAN_H)
|
||||
endif ()
|
||||
|
||||
CHECK_INCLUDE_FILE(unistd.h STLINK_HAVE_UNISTD_H)
|
||||
if (STLINK_HAVE_UNISTD_H)
|
||||
add_definitions(-DSTLINK_HAVE_UNISTD_H)
|
||||
endif()
|
||||
add_definitions(-DSTLINK_HAVE_UNISTD_H)
|
||||
endif ()
|
||||
|
||||
include(CheckLibraryExists)
|
||||
CHECK_LIBRARY_EXISTS(ssp __stack_chk_fail "" _stack_chk_fail_exists)
|
||||
|
||||
if(_stack_chk_fail_exists)
|
||||
if (_stack_chk_fail_exists)
|
||||
set(SSP_LIB ssp)
|
||||
else()
|
||||
else ()
|
||||
set(SSP_LIB "")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif()
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
endif ()
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
include(CTest)
|
||||
endif()
|
||||
include(CTest)
|
||||
endif ()
|
||||
|
||||
set(STLINK_HEADERS
|
||||
include/stlink.h
|
||||
include/stlink/usb.h
|
||||
include/stlink/sg.h
|
||||
include/stlink/logging.h
|
||||
include/stlink/mmap.h
|
||||
include/stlink/chipid.h
|
||||
include/stlink/flash_loader.h
|
||||
)
|
||||
include/stlink.h
|
||||
include/stlink/usb.h
|
||||
include/stlink/sg.h
|
||||
include/stlink/logging.h
|
||||
include/stlink/mmap.h
|
||||
include/stlink/chipid.h
|
||||
include/stlink/flash_loader.h
|
||||
)
|
||||
|
||||
set(STLINK_SOURCE
|
||||
src/chipid.c
|
||||
src/common.c
|
||||
src/usb.c
|
||||
src/sg.c
|
||||
src/logging.c
|
||||
src/flash_loader.c
|
||||
)
|
||||
src/chipid.c
|
||||
src/common.c
|
||||
src/usb.c
|
||||
src/sg.c
|
||||
src/logging.c
|
||||
src/flash_loader.c
|
||||
)
|
||||
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
set (STLINK_SOURCE "${STLINK_SOURCE};src/mmap.c;src/mingw/mingw.c")
|
||||
set (STLINK_HEADERS "${STLINK_HEADERS};src/mingw/mingw.h")
|
||||
set (STLINK_SOURCE "${STLINK_SOURCE};src/mmap.c;src/mingw/mingw.c")
|
||||
set (STLINK_HEADERS "${STLINK_HEADERS};src/mingw/mingw.h")
|
||||
endif ()
|
||||
|
||||
include_directories(${LIBUSB_INCLUDE_DIR})
|
||||
|
@ -103,136 +109,155 @@ include_directories(include)
|
|||
include_directories(${PROJECT_BINARY_DIR}/include)
|
||||
include_directories(src/mingw)
|
||||
if (MSVC)
|
||||
include_directories(src/win32)
|
||||
include_directories(src/getopt)
|
||||
# Use string.h rather than strings.h and disable annoying warnings
|
||||
add_definitions(-DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS /wd4710)
|
||||
include_directories(src/win32)
|
||||
include_directories(src/getopt)
|
||||
# Use string.h rather than strings.h and disable annoying warnings
|
||||
add_definitions(-DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS /wd4710)
|
||||
endif ()
|
||||
|
||||
|
||||
###
|
||||
# Shared library
|
||||
###
|
||||
|
||||
if (NOT WIN32)
|
||||
set(STLINK_LIB_SHARED ${PROJECT_NAME})
|
||||
set(STLINK_LIB_SHARED ${PROJECT_NAME})
|
||||
else ()
|
||||
set(STLINK_LIB_SHARED ${PROJECT_NAME}-shared)
|
||||
endif()
|
||||
set(STLINK_LIB_SHARED ${PROJECT_NAME}-shared)
|
||||
endif ()
|
||||
|
||||
add_library(${STLINK_LIB_SHARED} SHARED
|
||||
${STLINK_HEADERS} # header files for ide projects generated by cmake
|
||||
${STLINK_SOURCE}
|
||||
)
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY})
|
||||
add_library(
|
||||
${STLINK_LIB_SHARED} SHARED
|
||||
${STLINK_HEADERS} # header files for ide projects generated by cmake
|
||||
${STLINK_SOURCE}
|
||||
)
|
||||
target_link_libraries(
|
||||
${STLINK_LIB_SHARED}
|
||||
${LIBUSB_LIBRARY}
|
||||
)
|
||||
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
|
||||
else()
|
||||
set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
endif()
|
||||
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}
|
||||
)
|
||||
set_target_properties(
|
||||
${STLINK_LIB_SHARED}
|
||||
PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
VERSION ${STLINK_SHARED_VERSION}
|
||||
)
|
||||
|
||||
# Link shared library with apple OS libraries
|
||||
if (APPLE)
|
||||
find_library(ObjC objc)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
find_library(ObjC objc)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB})
|
||||
else()
|
||||
else ()
|
||||
target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
install(
|
||||
TARGETS ${STLINK_LIB_SHARED}
|
||||
DESTINATION ${STLINK_LIBRARY_PATH}
|
||||
)
|
||||
|
||||
install(TARGETS ${STLINK_LIB_SHARED}
|
||||
DESTINATION ${STLINK_LIBRARY_PATH}
|
||||
)
|
||||
|
||||
###
|
||||
# Static library
|
||||
###
|
||||
|
||||
set(STLINK_LIB_STATIC ${PROJECT_NAME}-static)
|
||||
|
||||
add_library(${STLINK_LIB_STATIC} STATIC
|
||||
${STLINK_HEADERS} # header files for ide projects generated by cmake
|
||||
${STLINK_SOURCE}
|
||||
add_library(
|
||||
${STLINK_LIB_STATIC} STATIC
|
||||
${STLINK_HEADERS} # header files for ide projects generated by cmake
|
||||
${STLINK_SOURCE}
|
||||
)
|
||||
|
||||
# Link shared library with apple OS libraries
|
||||
if (APPLE)
|
||||
find_library(ObjC objc)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
find_library(ObjC objc)
|
||||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB})
|
||||
else()
|
||||
else ()
|
||||
target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
set_target_properties(${STLINK_LIB_STATIC} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
|
||||
|
||||
if (STLINK_STATIC_LIB)
|
||||
install(TARGETS ${STLINK_LIB_STATIC}
|
||||
ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH}
|
||||
)
|
||||
endif()
|
||||
install(TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH})
|
||||
endif ()
|
||||
|
||||
|
||||
###
|
||||
# Tools
|
||||
###
|
||||
|
||||
add_executable(st-flash src/tools/flash.c src/tools/flash_opts.c)
|
||||
if (WIN32 OR APPLE)
|
||||
target_link_libraries(st-flash ${STLINK_LIB_STATIC} ${SSP_LIB})
|
||||
else()
|
||||
else ()
|
||||
target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
add_executable(st-info src/tools/info.c)
|
||||
if (WIN32 OR APPLE)
|
||||
target_link_libraries(st-info ${STLINK_LIB_STATIC} ${SSP_LIB})
|
||||
else()
|
||||
else ()
|
||||
target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
install(TARGETS st-flash st-info
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
install(TARGETS st-flash st-info RUNTIME DESTINATION bin)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
if (STLINK_INSTALL_MODPROBE_CONF)
|
||||
install(FILES etc/modprobe.d/stlink_v1.conf
|
||||
DESTINATION ${STLINK_MODPROBED_DIR}/)
|
||||
endif()
|
||||
if (STLINK_INSTALL_UDEV_RULES)
|
||||
file(GLOB RULES_FILES etc/udev/rules.d/*.rules)
|
||||
install(FILES ${RULES_FILES}
|
||||
DESTINATION ${STLINK_UDEV_RULES_DIR}/)
|
||||
endif()
|
||||
endif()
|
||||
if (STLINK_INSTALL_MODPROBE_CONF)
|
||||
install(FILES etc/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}/)
|
||||
endif ()
|
||||
if (STLINK_INSTALL_UDEV_RULES)
|
||||
file(GLOB RULES_FILES etc/udev/rules.d/*.rules)
|
||||
install(FILES ${RULES_FILES} DESTINATION ${STLINK_UDEV_RULES_DIR}/)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
add_subdirectory(src/gdbserver)
|
||||
add_subdirectory(src/tools/gui)
|
||||
|
||||
|
||||
###
|
||||
# Others
|
||||
###
|
||||
|
||||
add_subdirectory(usr/lib/pkgconfig)
|
||||
add_subdirectory(include)
|
||||
add_subdirectory(doc/man)
|
||||
add_subdirectory(tests)
|
||||
|
||||
include(cmake/CPackConfig.cmake)
|
||||
include(cmake/cpack_config.cmake)
|
||||
include(CPack)
|
||||
|
||||
|
||||
###
|
||||
# Uninstall target
|
||||
###
|
||||
|
||||
if (NOT TARGET uninstall)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY
|
||||
)
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif ()
|
||||
|
|
21
README.md
21
README.md
|
@ -42,11 +42,20 @@ Our [tutorial.md](doc/tutorial.md may help you along with some advanced tasks an
|
|||
|
||||
## Installation
|
||||
|
||||
**Windows**: download [v1.6.0](https://github.com/texane/stlink/releases/tag/v1.6.0) from the releases page.
|
||||
**Windows**:
|
||||
|
||||
Windows pre-compiled binaries are available at http://www.emb4fun.de/archive/stlink/index.html (outdated, not recommended for use)
|
||||
Please compile and install from source as described in our [compiling manual](doc/compiling.md#Windows).
|
||||
|
||||
**macOS**: install [from homebrew](http://brewformulas.org/Stlink) or download [v1.6.0](https://github.com/texane/stlink/releases/tag/v1.6.0) from the releases page.
|
||||
Long awaited binaries will be available soon...
|
||||
|
||||
**macOS**:
|
||||
|
||||
We recommend to install from:
|
||||
|
||||
* [homebrew](https://formulae.brew.sh/formula/stlink) or
|
||||
* [MacPorts](https://ports.macports.org/port/stlink)
|
||||
|
||||
Alternatively one can compile and install from source as described in our [compiling manual](doc/compiling.md#macOS).
|
||||
|
||||
**Linux**:
|
||||
|
||||
|
@ -61,9 +70,9 @@ We recommend to install `stlink-tools` from the package repository of the used d
|
|||
|
||||
**Other Operating Systems**:
|
||||
|
||||
* RedHat/CentOS 7: Users can install [from EPEL repository](https://src.fedoraproject.org/rpms/stlink/branch/epel7)
|
||||
* FreeBSD: Users can install [from freshports](https://www.freshports.org/devel/stlink)
|
||||
* OpenBSD: Users need to install [from source](doc/compiling.md).
|
||||
* RedHat/CentOS 8: Users can install from [EPEL repository](https://src.fedoraproject.org/rpms/stlink/branch/epel8)
|
||||
* FreeBSD: Users can install from [freshports](https://www.freshports.org/devel/stlink)
|
||||
* OpenBSD: Users need to compile and install from source as described in our [compiling manual](doc/compiling.md).
|
||||
|
||||
|
||||
## Installation from source (advanced users)
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set (CPACK_SET_DESTDIR "ON")
|
||||
if (APPLE)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-macosx-amd64")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
set (CPACK_INSTALL_PREFIX "")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
elseif (WIN32)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/windows")
|
||||
set (CPACK_INSTALL_PREFIX "")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/windows")
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "/etc/debian_version")
|
||||
message(STATUS "Debian-based Linux OS detected")
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-amd64" )
|
||||
endif()
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/texane/stlink")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jerry Jacobs")
|
||||
set(CPACK_PACKAGE_CONTACT "jerry.jacobs@xor-gate.org")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "STM32 stlink programmer tools")
|
||||
endif()
|
|
@ -1,6 +1,6 @@
|
|||
if(MSVC)
|
||||
message(STATUS "MSVC C Flags override to /MT")
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL_INIT "/MT /O1 /Ob1 /D NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE_INIT "/MT /O2 /Ob2 /D NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG")
|
||||
|
|
|
@ -14,7 +14,7 @@ function(add_cflag_if_supported flag)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
add_cflag_if_supported("-std=gnu99")
|
||||
add_cflag_if_supported("-std=gnu11")
|
||||
add_cflag_if_supported("-Wall")
|
||||
add_cflag_if_supported("-Wextra")
|
||||
add_cflag_if_supported("-Wshadow")
|
||||
|
@ -34,17 +34,17 @@ add_cflag_if_supported("-Wimplicit-function-declaration")
|
|||
# /usr/include/sys/types.h:218: warning: previous declaration of 'truncate' was here
|
||||
##
|
||||
if (NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
|
||||
add_cflag_if_supported("-Wredundant-decls")
|
||||
add_cflag_if_supported("-Wredundant-decls")
|
||||
endif ()
|
||||
|
||||
if (NOT WIN32)
|
||||
add_cflag_if_supported("-fPIC")
|
||||
add_cflag_if_supported("-fPIC")
|
||||
endif ()
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
add_cflag_if_supported("-ggdb")
|
||||
add_cflag_if_supported("-O0")
|
||||
add_cflag_if_supported("-ggdb")
|
||||
add_cflag_if_supported("-O0")
|
||||
else()
|
||||
add_cflag_if_supported("-O2")
|
||||
add_cflag_if_supported("-O2")
|
||||
add_cflag_if_supported("-Werror")
|
||||
endif()
|
|
@ -0,0 +1,28 @@
|
|||
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
set (CPACK_SET_DESTDIR "ON")
|
||||
|
||||
if (APPLE)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-macosx-amd64")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
set (CPACK_INSTALL_PREFIX "")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
elseif (WIN32)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/windows")
|
||||
set (CPACK_INSTALL_PREFIX "")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/windows")
|
||||
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "/etc/debian_version")
|
||||
message(STATUS "Debian-based Linux OS detected")
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-amd64" )
|
||||
endif()
|
||||
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/texane/stlink")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luca Boccassi")
|
||||
set(CPACK_PACKAGE_CONTACT "bluca@debian.org")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "STM32 STlink programmer tools")
|
||||
endif()
|
|
@ -1,4 +1,4 @@
|
|||
# Sample toolchain file for building for Windows from an Debian/Ubuntu Linux system.
|
||||
# Sample toolchain file for building for Windows from a Debian/Ubuntu Linux system.
|
||||
#
|
||||
# Typical usage:
|
||||
# *) install cross compiler: `sudo apt-get install mingw-w64`
|
||||
|
@ -14,7 +14,7 @@ set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
|||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
|
||||
# target environment on the build host system
|
||||
# set 1st to dir with the cross compiler's C/C++ headers/libs
|
||||
# set 1st to dir with the cross compiler's C/C++ headers/libs
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
# modify default behavior of FIND_XXX() commands to
|
||||
|
@ -22,4 +22,4 @@ set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
|||
# search for programs in the build host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Sample toolchain file for building for Windows from an Ubuntu Linux system.
|
||||
# Sample toolchain file for building for Windows from a Debian/Ubuntu Linux system.
|
||||
#
|
||||
# Typical usage:
|
||||
# *) install cross compiler: `sudo apt-get install mingw-w64`
|
||||
|
@ -14,7 +14,7 @@ set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
|||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
|
||||
# target environment on the build host system
|
||||
# set 1st to dir with the cross compiler's C/C++ headers/libs
|
||||
# set 1st to dir with the cross compiler's C/C++ headers/libs
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
# modify default behavior of FIND_XXX() commands to
|
||||
|
@ -22,4 +22,4 @@ set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
|||
# search for programs in the build host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
find_program(ZIP_EXECUTABLE NAMES 7z.exe p7zip
|
||||
HINTS
|
||||
"C:\\Program Files\\7-Zip\\"
|
||||
"C:\\Program Files (x86)\\7-Zip\\"
|
||||
find_program(
|
||||
ZIP_EXECUTABLE NAMES 7z.exe p7zip
|
||||
HINTS "C:\\Program Files\\7-Zip\\" "C:\\Program Files (x86)\\7-Zip\\"
|
||||
)
|
||||
|
|
|
@ -6,128 +6,132 @@
|
|||
# LIBUSB_LIBRARY - The libraries needed to use libusb
|
||||
# LIBUSB_DEFINITIONS - Compiler switches required for using libusb
|
||||
|
||||
# FreeBSD
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS
|
||||
/usr/include
|
||||
)
|
||||
else ()
|
||||
FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS
|
||||
/usr
|
||||
/usr/local
|
||||
/opt
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set(LIBUSB_NAME libusb-1.0.a)
|
||||
elseif(MSYS OR MINGW)
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
elseif(MSVC)
|
||||
set(LIBUSB_NAME libusb-1.0.lib)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||
set(LIBUSB_NAME usb)
|
||||
else()
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
endif()
|
||||
|
||||
if (MSYS OR MINGW)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/static)
|
||||
else ()
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW32/static)
|
||||
endif ()
|
||||
elseif(MSVC)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS64/dll)
|
||||
else ()
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS32/dll)
|
||||
endif ()
|
||||
else()
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS
|
||||
/usr
|
||||
/usr/local
|
||||
/opt)
|
||||
if (NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")) # all OS apart from FreeBSD
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS /usr /usr/local /opt
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (APPLE) # macOS
|
||||
set(LIBUSB_NAME libusb-1.0.a)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS /usr /usr/local /opt
|
||||
)
|
||||
|
||||
elseif (MINGW OR MSYS) # Windows with MinGW or MSYS
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else () # 32-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW32/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif ()
|
||||
|
||||
elseif (MSVC) # Windows with MSVC
|
||||
set(LIBUSB_NAME libusb-1.0.lib)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS64/dll
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else () # 32-bit
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS32/dll
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif ()
|
||||
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD
|
||||
# libusb is integrated into FreeBSD
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS /usr/include
|
||||
)
|
||||
|
||||
set(LIBUSB_NAME usb)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS /usr /usr/local /opt
|
||||
)
|
||||
|
||||
else () # all other OS
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
find_library(
|
||||
LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS /usr /usr/local /opt
|
||||
)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
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)
|
||||
if(WIN32 OR MSVC OR MINGW OR MSYS)
|
||||
find_package(7Zip REQUIRED)
|
||||
if (NOT LIBUSB_FOUND)
|
||||
if (WIN32 OR MINGW OR MSYS OR MSVC) # Windows
|
||||
|
||||
set(LIBUSB_WIN_VERSION 1.0.22)
|
||||
# Preparations for installing libusb library
|
||||
find_package(7Zip REQUIRED)
|
||||
set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version to 1.0.23 (latest as of Apr 2020)
|
||||
set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z)
|
||||
set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE})
|
||||
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/3thparty/libusb-${LIBUSB_WIN_VERSION})
|
||||
set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION})
|
||||
|
||||
if(EXISTS ${LIBUSB_WIN_ARCHIVE_PATH})
|
||||
# Get libusb package
|
||||
if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there (for whatever reason)
|
||||
message(STATUS "libusb archive already in build folder")
|
||||
else()
|
||||
else () # ... download the package (1.0.23 as of Apr 2020)
|
||||
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}
|
||||
)
|
||||
endif()
|
||||
${LIBUSB_WIN_ARCHIVE_PATH} EXPECTED_MD5 cf3d38d2ff053ef343d10c0b8b0950c2
|
||||
)
|
||||
endif ()
|
||||
|
||||
file(MAKE_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER})
|
||||
|
||||
if(${ZIP_EXECUTABLE} MATCHES "p7zip")
|
||||
#execute_process(COMMAND ${ZIP_EXECUTABLE} -d --keep -f ${LIBUSB_WIN_ARCHIVE_PATH} WORKING_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER})
|
||||
execute_process(COMMAND ${ZIP_EXECUTABLE} -d ${LIBUSB_WIN_ARCHIVE_PATH} WORKING_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER})
|
||||
else()
|
||||
execute_process(COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o${LIBUSB_WIN_OUTPUT_FOLDER})
|
||||
endif()
|
||||
|
||||
FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/include
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
if (MSYS OR MINGW)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW64/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else ()
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW32/static
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif ()
|
||||
elseif(MSVC)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS64/dll
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
else ()
|
||||
find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS32/dll
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
endif ()
|
||||
# Extract libusb package
|
||||
if (${ZIP_EXECUTABLE} MATCHES "p7zip")
|
||||
execute_process(
|
||||
COMMAND ${ZIP_EXECUTABLE} -d ${LIBUSB_WIN_ARCHIVE_PATH}
|
||||
WORKING_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER}
|
||||
)
|
||||
else ()
|
||||
execute_process(
|
||||
COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o ${LIBUSB_WIN_OUTPUT_FOLDER}
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Find path to libusb library
|
||||
FIND_PATH(
|
||||
LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/include
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "found USB")
|
||||
endif()
|
||||
message(STATUS "installed libusb library")
|
||||
else () # all other OS
|
||||
message(FATAL_ERROR "libusb library not found on your system! Compilation terminated.")
|
||||
endif ()
|
||||
else (NOT LIBUSB_FOUND)
|
||||
message(STATUS "found libusb library")
|
||||
endif ()
|
||||
|
|
|
@ -93,6 +93,7 @@ function(pandocology_get_file_extension varname filename)
|
|||
STRING(REGEX MATCH "\\.[^.]*\$" result "${name}")
|
||||
SET(${varname} "${result}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
###############################################################################
|
||||
|
||||
function(pandocology_add_input_dir source_dir dest_parent_dir dir_dest_filelist_var)
|
||||
|
@ -370,4 +371,3 @@ endfunction()
|
|||
function(add_pandoc_document)
|
||||
add_document(${ARGV})
|
||||
endfunction()
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
set(__detect_version 0)
|
||||
|
||||
find_package (Git)
|
||||
find_package(Git)
|
||||
|
||||
if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
# Working off a git repo, using git versioning
|
||||
|
@ -60,8 +60,6 @@ else()
|
|||
message(STATUS "Git or repo not found.")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if(NOT __detect_version)
|
||||
message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file.")
|
||||
if(EXISTS ${PROJECT_SOURCE_DIR}/.version)
|
||||
|
@ -71,7 +69,7 @@ if(NOT __detect_version)
|
|||
|
||||
# TODO create function to extract semver from file or string and check if it is correct instead of copy-pasting
|
||||
string(REGEX REPLACE "^(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-[.0-9A-Za-z-]+)?([+][.0-9A-Za-z-]+)?$"
|
||||
"\\1;\\2;\\3" PROJECT_VERSION_LIST ${PROJECT_VERSION})
|
||||
"\\1;\\2;\\3" PROJECT_VERSION_LIST ${PROJECT_VERSION})
|
||||
list(LENGTH PROJECT_VERSION_LIST len)
|
||||
if(len EQUAL 3)
|
||||
list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR)
|
||||
|
@ -90,6 +88,5 @@ if(NOT __detect_version)
|
|||
message(FATAL_ERROR "Unable to determine project version")
|
||||
endif()
|
||||
|
||||
|
||||
message(STATUS "stlink version: ${PROJECT_VERSION}")
|
||||
message(STATUS " Major ${PROJECT_VERSION_MAJOR} Minor ${PROJECT_VERSION_MINOR} Patch ${PROJECT_VERSION_PATCH}")
|
||||
message(STATUS "Major ${PROJECT_VERSION_MAJOR} Minor ${PROJECT_VERSION_MINOR} Patch ${PROJECT_VERSION_PATCH}")
|
|
@ -0,0 +1,21 @@
|
|||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
endif()
|
||||
|
||||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
|
||||
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}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if (NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif ()
|
||||
else (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif ()
|
||||
endforeach ()
|
|
@ -1,12 +1,11 @@
|
|||
# Warning: This example assumes that you are building on a host
|
||||
# with pkg-config available (e.g. linux). The logic required to
|
||||
# build under windows/mingw and/or mac was intentionally omitted
|
||||
# to keep this CMakeLists as small as possible
|
||||
# Warning: This example assumes that you are building on a host with pkg-config available (e.g. linux).
|
||||
# The logic required to build under windows/mingw and/or mac was intentionally omitted to keep this
|
||||
# CMakeLists as small as possible.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 3.4.2)
|
||||
|
||||
project(st-hello)
|
||||
set(PROJECT_VERSION 0.1)
|
||||
set(PROJECT_VERSION 0.1)
|
||||
set(SRCS main.c)
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
@ -14,15 +13,10 @@ pkg_check_modules(STLINK REQUIRED stlink)
|
|||
|
||||
set(CMAKE_C_FLAGS " ${STLINK_CFLAGS_OTHER} -Wall -Werror")
|
||||
|
||||
include_directories(
|
||||
${STLINK_INCLUDE_DIRS}
|
||||
)
|
||||
include_directories(${STLINK_INCLUDE_DIRS})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SRCS})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
${STLINK_LIBRARIES}
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} ${STLINK_LIBRARIES})
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
DESTINATION bin)
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||
|
|
369
doc/compiling.md
369
doc/compiling.md
|
@ -1,224 +1,203 @@
|
|||
# Compiling from sources
|
||||
## General package requirements
|
||||
|
||||
* cmake (v2.8.7 or later)
|
||||
* C compiler (gcc, clang or mingw)
|
||||
* libusb-1.0 (v1.0.13 or later)
|
||||
* libusb-dev-1.0 (v1.0.13 or later)
|
||||
* pandoc _(optional; for generating manpages from markdown)_
|
||||
## Microsoft Windows (10, 8.1)
|
||||
### Common Requirements
|
||||
|
||||
Run from the root of the source directory:
|
||||
On Windows users should ensure that the following software is installed:
|
||||
|
||||
```
|
||||
$ make release
|
||||
$ make debug
|
||||
```
|
||||
* `7zip`
|
||||
* `git`
|
||||
* `cmake` (3.17.0 or later)
|
||||
* `MinGW-w64` (7.0.0 or later) with GCC toolchain 8.1.0
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install `7zip` from <https://www.7-zip.org>
|
||||
2. Install `git` from <https://git-scm.com/download/win>
|
||||
3. Install `cmake` from <https://cmake.org/download><br />
|
||||
Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant.
|
||||
4. Install
|
||||
- _EITHER_: **MinGW-w64** from <https://sourceforge.net/projects/mingw-w64> (mingw-w64-install.exe)<br />
|
||||
- _OR_: **Visual Studio 2017 CE** (other versions will likely work as well, but are untested; the Community edition is free for open source
|
||||
development)
|
||||
5. Create a new destination folder at a place of your choice
|
||||
6. Open the command-line (cmd.exe) and execute `cd C:\$Path-to-your-destination-folder$\`
|
||||
7. Fetch the project sourcefiles by running `git clone https://github.com/texane/stlink.git`from the command-line (cmd.exe)<br />
|
||||
or download the stlink zip-sourcefolder from the Release page on GitHub
|
||||
|
||||
|
||||
### Building
|
||||
#### MinGW-w64
|
||||
|
||||
1. Use the command-line to move to the `scripts` directory within the source-folder: `cd stlink\scripts\`
|
||||
2. Execute `./mingw64-build.bat`
|
||||
|
||||
NOTE:<br />
|
||||
Per default the build script (currently) uses `C:\Program Files\mingw-w64\x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0\mingw64\bin`.<br />
|
||||
When installing different toolchains make sure to update the path in the `mingw64-build.bat`.<br />
|
||||
This can be achieved by opening the .bat file with a common text editor.
|
||||
|
||||
|
||||
#### Visual Studio (32 bit)
|
||||
|
||||
1. In a command prompt, change the directory to the folder where the stlink files were cloned (or unzipped) to.
|
||||
2. Make sure the build folder exists (`mkdir build` if not).
|
||||
3. From the build folder, run cmake (`cd build; cmake ..`).
|
||||
|
||||
This will create a solution (stlink.sln) in the build folder. Open it in Visual Studio, select the Solution Configuration (Debug or
|
||||
Release) and build the solution normally (F7).
|
||||
|
||||
NOTE:<br />
|
||||
This solution will link to the dll version of libusb-1.0.y<br />
|
||||
To debug or run the executable, the dll version of libusb-1.0 must be either on the path, or in the same folder as the executable.<br />
|
||||
It can be copied from here: `build\3rdparty\libusb-1.0.21\MS32\dll\libusb-1.0.dll`.
|
||||
|
||||
## Linux
|
||||
### Common requirements
|
||||
|
||||
Install the following packages from your package repository:
|
||||
|
||||
* `gcc` or `clang` or `mingw32-gcc` or `mingw64-gcc` (C-compiler; very likely gcc is already present)
|
||||
* `build-essential` (on Debian based distros (debian, ubuntu))
|
||||
* `cmake` (3.4.2 or later, use the latest version available from the repository)
|
||||
* `libusb-1.0`
|
||||
* `libusb-1.0-0-dev` (development headers for building)
|
||||
* `libgtk-3-dev` (_optional_, needed for `stlink-gui`)
|
||||
* `pandoc` (_optional_, needed for generating manpages from markdown)
|
||||
|
||||
or execute (Debian-based systems only): `apt-get install gcc build-essential cmake libusb-1.0 libusb-1.0-0-dev libgtk-3-dev pandoc`
|
||||
|
||||
(Replace gcc with the intended C-compiler if necessary or leave out any optional package not needed.)
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
1. Open a new terminal console
|
||||
2. Create a new destination folder at a place of your choice e.g. at `~/git`: `mkdir $HOME/git`
|
||||
3. Change to this directory: `cd ~/git`
|
||||
4. Fetch the project sourcefiles by running `git clone https://github.com/texane/stlink.git`
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
1. Change into the project source directory: `cd stlink`
|
||||
2. Run `make release` to create the _Release_ target
|
||||
3. Run `make debug` to create the _Debug_ target (_optional_)<br />
|
||||
The debug target is only necessary in order to modify the sources and to run under a debugger.
|
||||
|
||||
The debug target should only be necessary for people who want to modify the sources and run under a debugger.
|
||||
The top level Makefile is just a handy wrapper for:
|
||||
|
||||
```
|
||||
##### MinGW64:
|
||||
|
||||
```sh
|
||||
$ mkdir build && cd build
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
$ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake -S ..
|
||||
$ make
|
||||
```
|
||||
|
||||
You may install to a user folder e.g `$HOME`:
|
||||
##### MinGW32:
|
||||
|
||||
```
|
||||
$ cd build/Release; make install DESTDIR=$HOME
|
||||
```sh
|
||||
$ mkdir build && cd build
|
||||
$ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -S ..
|
||||
$ make
|
||||
```
|
||||
|
||||
Or system-wide:
|
||||
As an alternative you may also install
|
||||
- to a user folder e.g `$HOME` with `cd build/Release && make install DESTDIR=$HOME`
|
||||
- or system wide with `cd build/Release && sudo make install`.
|
||||
|
||||
```
|
||||
$ cd build/Release; sudo make install
|
||||
```
|
||||
When installing system-wide, the dynamic library cache needs to be updated with the command `ldconfig`.
|
||||
|
||||
|
||||
## Linux / Unix
|
||||
## Common requirements
|
||||
### Build a Debian Package
|
||||
|
||||
* `build-essential`
|
||||
* `cmake`
|
||||
* `libusb-1.0`
|
||||
* `libusb-1.0-0-dev` (development headers for building, _only on debian based distros_)
|
||||
* `libgtk-3-dev` _(optional; required for `stlink-gui`)_
|
||||
To build the debian package you need the following extra packages: `devscripts debhelper`.
|
||||
|
||||
As of today several distributions namely:
|
||||
|
||||
- CentOS 6, 7, 8
|
||||
- Debian 8, 9, 10, sid
|
||||
- Fedora 30, 31, Rawhide
|
||||
- NetBSD 7.2, 8.1, 9.0
|
||||
- openSUSE Leap 15.1, Leap 15.2
|
||||
- Ubuntu 14.04 LTS, 16.04 LTS, 18.04 LTS, 19.10
|
||||
|
||||
provide packages for libusb 0.1 and libusb 1.0.
|
||||
|
||||
**Please ensure that the correct version 1.0 is installed.**
|
||||
Other relevant distributions appear to have packages named _libusb-compat-0.1_ or alike to distinguish from libusb packages based on version 1.0.x.
|
||||
|
||||
|
||||
### Fixing cannot open shared object file
|
||||
|
||||
When installing system-wide (`sudo make install`) the dynamic library cache needs to be updated with the command `ldconfig`.
|
||||
|
||||
|
||||
## Permissions with udev
|
||||
|
||||
Make sure you install udev files which are necessary to run the tools without root permissions.
|
||||
By default most distributions don't allow access to USB devices.
|
||||
The udev rules create devices nodes and set the group of this to `stlink`.
|
||||
|
||||
The rules are located in the `etc/udev/rules.d` directory.
|
||||
You will need to copy it to /etc/udev/rules.d, and then either execute as root (or reboot your machine):
|
||||
|
||||
```
|
||||
$ udevadm control --reload-rules
|
||||
$ udevadm trigger
|
||||
```
|
||||
|
||||
Udev will now create device node files `/dev/stlinkv2_XX`, `/dev/stlinkv1_XX`.
|
||||
**You need to make sure the `stlink` group exists and the user, who is trying to access, is added to this group.**
|
||||
|
||||
|
||||
### Note for STLINKv1 usage
|
||||
|
||||
The STLINKv1's SCSI emulation is corrupted, so the best thing to do is tell your operating system to completely ignore it.
|
||||
|
||||
Options (do one of these before you plug it in)
|
||||
|
||||
* `modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i` or
|
||||
1. `echo "options usb-storage quirks=483:3744:i" >> /etc/modprobe.conf`
|
||||
2. `modprobe -r usb-storage && modprobe usb-storage`
|
||||
* or
|
||||
1. `cp stlink_v1.modprobe.conf /etc/modprobe.d`
|
||||
2. `modprobe -r usb-storage && modprobe usb-storage`
|
||||
|
||||
|
||||
### Build Debian Package
|
||||
|
||||
To build the debian package you need the additional packages `devscripts` and `debhelper`.
|
||||
|
||||
```
|
||||
```sh
|
||||
$ git archive --prefix=$(git describe)/ HEAD | bzip2 --stdout > ../libstlink_$(sed -En -e "s/.*\((.*)\).*/\1/" -e "1,1 p" debian/changelog).orig.tar.bz2
|
||||
$ debuild -uc -us
|
||||
```
|
||||
|
||||
|
||||
## macOS
|
||||
### Prerequisites
|
||||
### Set permissions with udev
|
||||
|
||||
When compiling on a mac you need the following:
|
||||
By default most distributions don't allow access to USB devices.
|
||||
Therefore make sure you install udev files which are necessary to run the tools without root permissions.
|
||||
udev rules create devices nodes and set the group of these to `stlink`.
|
||||
|
||||
* A compiler toolchain (XCode)
|
||||
* cmake
|
||||
* **libusb 1.0**
|
||||
|
||||
The best way is to install [homebrew](http://brew.sh) which is a package manager for opensource software which is missing from the Apple App Store. Then install the dependencies:
|
||||
|
||||
```
|
||||
brew install libusb cmake
|
||||
```
|
||||
|
||||
Compile as described in the first section of this document.
|
||||
|
||||
|
||||
## Build using different directories for udev and modprobe
|
||||
|
||||
To put the udev or the modprobe configuration files into a different directory during installation use the following cmake options:
|
||||
|
||||
```
|
||||
$ cmake -DSTLINK_UDEV_RULES_DIR="/usr/lib/udev/rules.d" \
|
||||
-DSTLINK_MODPROBED_DIR="/usr/lib/modprobe.d" ..
|
||||
```
|
||||
|
||||
|
||||
## Build using different directory for shared libs
|
||||
|
||||
To put the compiled shared libs into a different directory during installation you can use the following cmake option:
|
||||
|
||||
```
|
||||
$ cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" ..
|
||||
```
|
||||
|
||||
|
||||
## Windows (MinGW64)
|
||||
### Prerequisites
|
||||
|
||||
* 7zip
|
||||
* cmake 2.8 or higher
|
||||
* MinGW64 GCC toolchain (5.3.0)
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install 7zip from <http://www.7-zip.org>
|
||||
2. Install CMake from <https://cmake.org/download>
|
||||
3. Install MinGW64 from <https://sourceforge.net/projects/mingw-w64> (mingw-w64-install.exe)
|
||||
4. Git clone or download stlink sourcefiles zip
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
Check and execute (in the script folder) `<source-dir>\scripts\mingw64-build.bat`
|
||||
|
||||
**NOTE:** when installing different toolchains make sure you edit the path in the `mingw64-build.bat`.
|
||||
The build script currently uses `C:\Program Files\mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0\mingw64\bin`
|
||||
|
||||
|
||||
## Windows (Visual Studio)
|
||||
### Prerequisites
|
||||
|
||||
* 7zip
|
||||
* cmake (tested with version 3.9.0-rc2)
|
||||
* Visual Studio 2017 Community Edition (other versions will likely work but are untested; the Community Edition is free for open source
|
||||
development)
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install 7zip from <http://www.7-zip.org>
|
||||
2. Install CMake from <https://cmake.org/download>
|
||||
3. Git clone or download stlink sourcefiles zip
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
These instructions are for a 32-bit version.
|
||||
|
||||
In a command prompt, change directory to the folder where the stlink files were cloned (or unzipped).
|
||||
Make sure the build folder exists (`mkdir build` if not).
|
||||
From the build folder, run cmake (`cd build; cmake ..`).
|
||||
|
||||
This will create a solution (stlink.sln) in the build folder.
|
||||
Open it in Visual Studio, select the Solution Configuration (_Debug_ or _Release_) and build the solution normally (F7).
|
||||
|
||||
NOTES: This solution will link to the dll version of libusb-1.0.
|
||||
To debug or run the executable, the dll version of libusb-1.0 must be either on the path, or in the same folder as the executable.
|
||||
It can be copied from here: `build\3thparty\libusb-1.0.21\MS32\dll\libusb-1.0.dll`.
|
||||
|
||||
|
||||
## Linux (MinGW64)
|
||||
### Prerequisites
|
||||
|
||||
* 7zip
|
||||
* cmake 2.8 or higher
|
||||
* MinGW64 GCC toolchain (5.3.0)
|
||||
|
||||
|
||||
### Installation (Debian / Ubuntu)
|
||||
|
||||
sudo apt install p7zip mingw-w64
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
These instructions are for a 32-bit version.
|
||||
The rules are located in the subdirectory `etc/udev/rules.d` within the sourcefolder.
|
||||
Copy them to the directory path `/etc/udev/rules.d` and subsequently reload the udev rules:
|
||||
|
||||
```sh
|
||||
cd <source-dir>
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -S . -B ./build/linux-mingw32
|
||||
cmake --build ./build/linux-mingw32 --target all
|
||||
$ cp etc/udev/rules.d /etc/udev/rules.d
|
||||
$ udevadm control --reload-rules
|
||||
$ udevadm trigger
|
||||
```
|
||||
|
||||
Udev will now create device node files `/dev/stlinkv2_XX`, `/dev/stlinkv1_XX`.
|
||||
You need to ensure that the group `stlink` exists and the user who is trying to access these devices is a member of this group.
|
||||
|
||||
|
||||
### Note on the use of STLink-v1 programmers:
|
||||
|
||||
At the time of writing the STLink-v1 has mostly been replaced with the newer generation STLink-v2 programmers and thus is only rarely used.
|
||||
As there are some caveats as well, we recommend to use the STLink-v2 programmers if possible.
|
||||
|
||||
To be more precise, the STLINKv1's SCSI emulation is somehow broken, so the best advice possibly is to tell your operating system to completely ignore it.
|
||||
|
||||
Choose on of the following options _before_ connecting the device to your computer:
|
||||
|
||||
* `modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i`
|
||||
* _OR_
|
||||
1. `echo "options usb-storage quirks=483:3744:i" >> /etc/modprobe.conf`
|
||||
2. `modprobe -r usb-storage && modprobe usb-storage`
|
||||
* _OR_
|
||||
1. `cp stlink_v1.modprobe.conf /etc/modprobe.d`
|
||||
2. `modprobe -r usb-storage && modprobe usb-storage`
|
||||
|
||||
|
||||
## macOS
|
||||
### Common requirements
|
||||
|
||||
The best way is to install a package manager for open source software,
|
||||
either [homebrew](https://brew.sh) or [MacPorts](https://www.macports.org/).
|
||||
|
||||
Then install the following dependencies from the package repository:
|
||||
|
||||
* `git`
|
||||
* `cmake`
|
||||
* `libusb`
|
||||
|
||||
To do this with only one simple command, type:
|
||||
|
||||
* for homebrew: `sudo brew install git cmake libusb` or
|
||||
* for MacPorts:`sudo port install git cmake libusb`
|
||||
|
||||
Additionally we recommend to install Xcode which delivers the necessary C-compiler toolchain Clang (LLVM).
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
1. Open a new terminal window
|
||||
2. Create a new destination folder at a place of your choice e.g. at `~/git`: `mkdir $HOME/git`
|
||||
3. Change to this directory: `cd ~/git`
|
||||
4. Fetch the project sourcefiles by running `git clone https://github.com/texane/stlink.git`
|
||||
|
||||
|
||||
### Building
|
||||
|
||||
1. Change into the project source directory: `cd stlink`
|
||||
2. Run `make release` to create the _Release_ target
|
||||
3. Run `make debug` to create the _Debug_ target (_optional_)<br />
|
||||
The debug target is only necessary in order to modify the sources and to run under a debugger.
|
||||
|
||||
|
||||
## Build using a different directory for shared libs
|
||||
|
||||
To put the compiled shared libs into a different directory during installation,
|
||||
you can use the cmake option `cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" ..`.
|
||||
|
||||
|
||||
Author: nightwalker-87
|
||||
|
|
|
@ -1,37 +1,32 @@
|
|||
set(MANPAGES
|
||||
st-util
|
||||
st-flash
|
||||
st-info
|
||||
)
|
||||
set(MANPAGES st-util st-flash st-info)
|
||||
|
||||
# Only generate manpages with pandoc in Debug builds
|
||||
if(${STLINK_GENERATE_MANPAGES})
|
||||
include(pandocology)
|
||||
|
||||
foreach(manpage ${MANPAGES})
|
||||
add_document(
|
||||
${manpage}.1
|
||||
SOURCES ${manpage}.md
|
||||
PANDOC_DIRECTIVES -s -t man
|
||||
PRODUCT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
endforeach()
|
||||
else()
|
||||
message(STATUS "Manpage generation disabled")
|
||||
endif()
|
||||
if (${STLINK_GENERATE_MANPAGES})
|
||||
include(pandocology)
|
||||
foreach (manpage ${MANPAGES})
|
||||
add_document(
|
||||
${manpage}.1
|
||||
SOURCES ${manpage}.md
|
||||
PANDOC_DIRECTIVES -s -t man
|
||||
PRODUCT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
endforeach ()
|
||||
else ()
|
||||
message(STATUS "Manpage generation disabled")
|
||||
endif ()
|
||||
|
||||
# Install from output folder or this folder
|
||||
foreach(manpage ${MANPAGES})
|
||||
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${manpage}.1)
|
||||
set(f "${CMAKE_CURRENT_BINARY_DIR}/${manpage}.1")
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1")
|
||||
set(f "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1")
|
||||
else()
|
||||
message(AUTHOR_WARNING "Manpage ${manpage} not generated")
|
||||
endif()
|
||||
foreach (manpage ${MANPAGES})
|
||||
if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${manpage}.1)
|
||||
set(f "${CMAKE_CURRENT_BINARY_DIR}/${manpage}.1")
|
||||
elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1")
|
||||
set(f "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1")
|
||||
else()
|
||||
message(AUTHOR_WARNING "Manpage ${manpage} not generated")
|
||||
endif()
|
||||
|
||||
if (f AND NOT WIN32)
|
||||
install(FILES ${f} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
|
||||
unset(f)
|
||||
endif()
|
||||
endforeach()
|
||||
if (f AND NOT WIN32)
|
||||
install(FILES ${f} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)
|
||||
unset(f)
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
|
||||
Sources: [pkgs.org - libusb](https://pkgs.org/search/?q=libusb) & [pkgs.org - cmake](https://pkgs.org/search/?q=cmake) (as of Mar 2020):
|
||||
|
||||
|
||||
## Supported Operating Systems
|
||||
### Microsoft Windows
|
||||
|
||||
On Windows users should ensure that cmake 3.17.0 is installed.<br />
|
||||
Up on compiling c-make will check **automatically**, whether `libusb` 1.0.20 or later is present.<br />
|
||||
If this is not the case, the installation routine will download the latest version (1.0.23 at the time of writing).<br />
|
||||
Thus no user interaction regarding libusb is necessary.
|
||||
|
||||
* Windows 10
|
||||
* Windows 8.1
|
||||
|
||||
|
||||
### Apple macOS
|
||||
|
||||
| Package Repository | libusb<br />version | cmake<br />version | Supported macOS versions |
|
||||
| --- | --- | --- | --- |
|
||||
| homebrew | 1.0.23 | 3.17.0 | 10.12 (Sierra)- 10.15 (Catalina) |
|
||||
| MacPorts | 1.0.23 | 3.17.0 | 10.6 (Snow Leopard) - 10.15 (Catalina) |
|
||||
|
||||
|
||||
### Linux-/Unix-based:
|
||||
|
||||
| Operating System | libusb<br />version | cmake<br />version | Notes |
|
||||
| --- | --- | --- | --- |
|
||||
| Alpine Edge | 1.0.23 | 3.17.0 | |
|
||||
| ALT Linux Sisyphus | 1.0.23 | 3.17.0 | |
|
||||
| Arch Linux | 1.0.23 | 3.17.0 | |
|
||||
| Fedora Rawhide | 1.0.23 | 3.17.0 | named `libusbx`, but `libusb`-codebase is used |
|
||||
| KaOS | 1.0.23 | 3.17.0 | |
|
||||
| OpenMandriva Cooker | 1.0.23 | 3.17.0 | |
|
||||
| PCLinuxOS | 1.0.23 | 3.17.0 | named `lib64usb1.0_0-1.0.23-1pclos2019.x86_64` |
|
||||
| Slackware Current | 1.0.23 | 3.17.0 | |
|
||||
| Solus | 1.0.23 | 3.16.5 | |
|
||||
| Debian Sid | 1.0.23 | 3.16.3 | |
|
||||
| OpenMandriva Lx 4.1 | 1.0.23 | 3.16.3 | |
|
||||
| Ubuntu 20.04 LTS (Focal Fossa) | 1.0.23 | 3.16.3 | |
|
||||
| openSUSE Tumbleweed | 1.0.23 | 3.16.2 | |
|
||||
| Alpine 3.11 | 1.0.23 | 3.15.5 | |
|
||||
| Ubuntu 19.10 (Eoan Ermine) | 1.0.23 | 3.13.4 | |
|
||||
| Mageia Cauldron | 1.0.22 | 3.17.0 | |
|
||||
| NetBSD 9.0 | 1.0.22 | 3.16.1 | |
|
||||
| NetBSD 8.1 | 1.0.22 | 3.16.1 | |
|
||||
| NetBSD 7.2 | 1.0.22 | 3.16.1 | |
|
||||
| Alpine 3.10 | 1.0.22 | 3.14.5 | |
|
||||
| Fedora 31 | 1.0.22 | 3.14.5 | named `libusbx`, but `libusb`-codebase is used |
|
||||
| Mageia 7.1 | 1.0.22 | 3.14.3 | |
|
||||
| Fedora 30 | 1.0.22 | 3.14.2 | named `libusbx`, but `libusb`-codebase is used |
|
||||
| Debian 10 (Buster) | 1.0.22 | 3.13.4 | |
|
||||
| Alpine 3.9 | 1.0.22 | 3.13.0 | |
|
||||
| CentOS 8 | 1.0.22 | 3.11.4 | named `libusbx`, but `libusb`-codebase is used |
|
||||
| openSUSE Leap 15.2 | 1.0.21 | 3.15.5 | |
|
||||
| openSUSE Leap 15.1 | 1.0.21 | 3.10.2 | |
|
||||
| Ubuntu 18.04 LTS (Bionic Beaver) | 1.0.21 | 3.10.2 | |
|
||||
| Debian 9 (Stretch) | 1.0.21 | 3.7.2 | |
|
||||
| Slackware 14.2 | **1.0.20** | 3.5.2 | |
|
||||
| Ubuntu 16.04 LTS (Xenial Xerus) | **1.0.20** | 3.5.1 | |
|
||||
| OpenMandriva Lx 3.0 | **1.0.20** | **3.4.2** | |
|
||||
| FreeBSD 13 | **1.0.16** - 1.0.18 | 3.15.5 | linux_libusb-13.0r358841 (integrated) |
|
||||
| FreeBSD 12 | **1.0.16** - 1.0.18 | 3.15.5 | linux_libusb-11.0r261448_4 (integrated) |
|
||||
| FreeBSD 11 | **1.0.16** - 1.0.18 | 3.15.5 | linux_libusb-11.0r261448_4 (integrated) |
|
||||
|
||||
|
||||
## Unsupported Operating Systems as of Release 1.6.1 (2020)
|
||||
|
||||
| Operating System | libusb<br />version | cmake<br />version | End of OS-Support | Notes |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| CentOS 7 | 1.0.21 | **2.8.12.2** | | named `libusbx`, but `libusb`-codebase is used |
|
||||
| Debian 8 (Jessie) | 1.0.**19** | 3.0.2 | Jun 2020 |
|
||||
| Ubuntu 14.04 LTS (Trusty Tahr) | 1.0.**17** | **2.8.12.2** | Apr 2019 |
|
||||
| CentOS 6 | 1.0.**9** | **2.8.12.2** | Dec 2020 | named `libusbx`, but `libusb`-codebase is used |
|
||||
| Slackware 14.1 | 1.0.**9** | **2.8.12** | |
|
||||
| Slackware 14.0 | 1.0.**9** | **2.8.8** | |
|
||||
|
||||
_All other operating systems which are not listed are unsupported._
|
||||
|
||||
Author: nightwalker-87
|
|
@ -1,17 +1,8 @@
|
|||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/include/stlink/version.h.in"
|
||||
"${CMAKE_BINARY_DIR}/include/stlink/version.h"
|
||||
)
|
||||
file(GLOB STLINK_HEADERS
|
||||
"stlink/*.h"
|
||||
"${CMAKE_BINARY_DIR}/include/stlink/*.h"
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/include/stlink.h
|
||||
DESTINATION ${STLINK_INCLUDE_PATH}
|
||||
)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/include/stm32.h
|
||||
DESTINATION ${STLINK_INCLUDE_PATH}
|
||||
)
|
||||
install(FILES ${STLINK_HEADERS}
|
||||
DESTINATION ${STLINK_INCLUDE_PATH}/stlink
|
||||
)
|
||||
"${PROJECT_SOURCE_DIR}/include/stlink/version.h.in"
|
||||
"${CMAKE_BINARY_DIR}/include/stlink/version.h"
|
||||
)
|
||||
file(GLOB STLINK_HEADERS "stlink/*.h" "${CMAKE_BINARY_DIR}/include/stlink/*.h")
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/include/stlink.h DESTINATION ${STLINK_INCLUDE_PATH})
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/include/stm32.h DESTINATION ${STLINK_INCLUDE_PATH})
|
||||
install(FILES ${STLINK_HEADERS} DESTINATION ${STLINK_INCLUDE_PATH}/stlink)
|
||||
|
|
|
@ -170,8 +170,8 @@ typedef struct flash_loader {
|
|||
size_t sram_size; // stlink_chipid_params.sram_size, set by stlink_load_device_params()
|
||||
|
||||
// bootloader
|
||||
// sys_base and sys_size are not used by the tools, but are only there to
|
||||
// download the bootloader code (see tests/sg.c)
|
||||
// sys_base and sys_size are not used by the tools, but are only there to
|
||||
// download the bootloader code (see tests/sg.c)
|
||||
stm32_addr_t sys_base; // stlink_chipid_params.bootrom_base, set by stlink_load_device_params()
|
||||
size_t sys_size; // stlink_chipid_params.bootrom_size, set by stlink_load_device_params()
|
||||
|
||||
|
@ -245,6 +245,7 @@ typedef struct flash_loader {
|
|||
#include "stlink/chipid.h"
|
||||
#include "stlink/flash_loader.h"
|
||||
#include "stlink/version.h"
|
||||
#include "stlink/logging.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ enum ugly_loglevel {
|
|||
|
||||
int ugly_init(int maximum_threshold);
|
||||
int ugly_log(int level, const char *tag, const char *format, ...);
|
||||
int ugly_libusb_log_level(enum ugly_loglevel v);
|
||||
|
||||
#define UGLY_LOG_FILE (strstr(__FILE__, "/") != NULL ? \
|
||||
strrchr(__FILE__, '/') + 1 : strstr(__FILE__, "\\") != NULL ? \
|
||||
|
|
|
@ -6,20 +6,12 @@
|
|||
*/
|
||||
|
||||
#ifndef STLINK_SG_H
|
||||
#define STLINK_SG_H
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4200 4255 4668 4820)
|
||||
#include <libusb.h>
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
#include <libusb.h>
|
||||
#endif
|
||||
#define STLINK_SG_H
|
||||
|
||||
#include "stlinkusb.h"
|
||||
#include "stlink.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
@ -49,29 +41,29 @@ extern "C" {
|
|||
|
||||
|
||||
|
||||
struct stlink_libsg {
|
||||
libusb_context* libusb_ctx;
|
||||
libusb_device_handle *usb_handle;
|
||||
unsigned ep_rep;
|
||||
unsigned ep_req;
|
||||
struct stlink_libsg {
|
||||
libusb_context* libusb_ctx;
|
||||
libusb_device_handle *usb_handle;
|
||||
unsigned ep_rep;
|
||||
unsigned ep_req;
|
||||
|
||||
int sg_fd;
|
||||
int do_scsi_pt_err;
|
||||
int sg_fd;
|
||||
int do_scsi_pt_err;
|
||||
|
||||
unsigned char cdb_cmd_blk[CDB_SL];
|
||||
unsigned char cdb_cmd_blk[CDB_SL];
|
||||
|
||||
int q_data_dir; // Q_DATA_IN, Q_DATA_OUT
|
||||
// the start of the query data in the device memory space
|
||||
uint32_t q_addr;
|
||||
int q_data_dir; // Q_DATA_IN, Q_DATA_OUT
|
||||
// the start of the query data in the device memory space
|
||||
uint32_t q_addr;
|
||||
|
||||
// Sense (error information) data
|
||||
// obsolete, this was fed to the scsi tools
|
||||
unsigned char sense_buf[SENSE_BUF_LEN];
|
||||
// Sense (error information) data
|
||||
// obsolete, this was fed to the scsi tools
|
||||
unsigned char sense_buf[SENSE_BUF_LEN];
|
||||
|
||||
struct stlink_reg reg;
|
||||
};
|
||||
struct stlink_reg reg;
|
||||
};
|
||||
|
||||
stlink_t* stlink_v1_open(const int verbose, int reset);
|
||||
stlink_t* stlink_v1_open(const int verbose, int reset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef STLINKUSB_H
|
||||
#define STLINKUSB_H
|
||||
|
||||
#include <libusb.h>
|
||||
|
||||
/*
|
||||
|
||||
libusb ver | LIBUSB_API_VERSION
|
||||
-------------+--------------------
|
||||
v1.0.13 | 0x01000100
|
||||
v1.0.14 | 0x010000FF
|
||||
v1.0.15 | 0x01000101
|
||||
v1.0.16 | 0x01000102
|
||||
v1.0.17 | 0x01000102
|
||||
v1.0.18 | 0x01000102
|
||||
v1.0.19 | 0x01000103
|
||||
v1.0.20 | 0x01000104
|
||||
v1.0.21 | 0x01000105
|
||||
v1.0.22 | 0x01000106
|
||||
v1.0.23 | 0x01000107
|
||||
|
||||
*/
|
||||
|
||||
#if defined (__FreeBSD__)
|
||||
#if !defined ( LIBUSBX_API_VERSION )
|
||||
#define LIBUSBX_API_VERSION LIBUSB_API_VERSION
|
||||
#elif !defined (LIBUSB_API_VERSION)
|
||||
#error unsupported libusb version
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (__FreeBSD__)
|
||||
#define MINIMAL_API_VERSION 0x01000102 // v1.0.16
|
||||
#elif defined (__linux__)
|
||||
#define MINIMAL_API_VERSION 0x01000104 // v1.0.20
|
||||
#elif defined (__APPLE__)
|
||||
#define MINIMAL_API_VERSION 0x01000104 // v1.0.20
|
||||
#elif defined (_WIN32)
|
||||
#define MINIMAL_API_VERSION 0x01000104 // v1.0.20
|
||||
#endif
|
||||
|
||||
#if ( LIBUSB_API_VERSION < MINIMAL_API_VERSION )
|
||||
#error unsupported libusb version
|
||||
#endif
|
||||
|
||||
#endif // STLINKUSB_H
|
|
@ -9,9 +9,9 @@
|
|||
#define STLINK_USB_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libusb.h>
|
||||
|
||||
#include "stlink.h"
|
||||
#include "stlinkusb.h"
|
||||
#include "stlink/logging.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
cd `dirname "$0"`/..
|
||||
if [ "$ARCH" = "i686" ]; then
|
||||
f=i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z
|
||||
if ! [ -e $f ]; then
|
||||
curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/sjlj/$f
|
||||
fi
|
||||
7z x $f > /dev/null
|
||||
mv mingw32 /MinGW
|
||||
else
|
||||
f=x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z
|
||||
if ! [ -e $f ]; then
|
||||
curl -LsSO http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/$f
|
||||
fi
|
||||
7z x $f > /dev/null
|
||||
mv mingw64 /MinGW
|
||||
fi
|
||||
cd build
|
||||
cmake .. -G"$GENERATOR"
|
||||
cmake --build . --config RelWithDebInfo
|
|
@ -1,5 +1,8 @@
|
|||
@echo off
|
||||
set PATH=C:\Program Files (x86)\CMake\bin;C:\Program Files\CMake\bin;C:\Program Files\mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0\mingw64\bin;%PATH%
|
||||
cd ..
|
||||
mkdir build-mingw
|
||||
cd build-mingw
|
||||
set PATH=C:\Program Files (x86)\CMake\bin;C:\Program Files\CMake\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-win32-sjlj-rt_v6-rev0\mingw64\bin;%PATH%
|
||||
cmake -G "MinGW Makefiles" ..
|
||||
mingw32-make
|
||||
mingw32-make install DESTDIR=_install
|
||||
|
|
|
@ -4,21 +4,20 @@ set(STUTIL_SOURCE
|
|||
gdb-server.c
|
||||
gdb-server.h
|
||||
semihosting.c
|
||||
semihosting.h)
|
||||
semihosting.h
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
# We need a getopt from somewhere...
|
||||
set(STUTIL_SOURCE "${STUTIL_SOURCE};../getopt/getopt.c")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
add_executable(st-util ${STUTIL_SOURCE})
|
||||
|
||||
if (WIN32 OR APPLE)
|
||||
target_link_libraries(st-util ${STLINK_LIB_STATIC} ${SSP_LIB})
|
||||
else()
|
||||
else ()
|
||||
target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
install(TARGETS st-util
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
install(TARGETS st-util RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -54,3 +54,24 @@ int ugly_log(int level, const char *tag, const char *format, ...) {
|
|||
va_end(args);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Log message levels.
|
||||
* - LIBUSB_LOG_LEVEL_NONE (0) : no messages ever printed by the library (default)
|
||||
* - LIBUSB_LOG_LEVEL_ERROR (1) : error messages are printed to stderr
|
||||
* - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
|
||||
* - LIBUSB_LOG_LEVEL_INFO (3) : informational messages are printed to stderr
|
||||
* - LIBUSB_LOG_LEVEL_DEBUG (4) : debug and informational messages are printed to stderr
|
||||
*/
|
||||
int ugly_libusb_log_level(enum ugly_loglevel v)
|
||||
{
|
||||
switch (v) {
|
||||
case UDEBUG: return 4;
|
||||
case UINFO: return 3;
|
||||
case UWARN: return 2;
|
||||
case UERROR: return 1;
|
||||
};
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
|
6
src/sg.c
6
src/sg.c
|
@ -936,6 +936,12 @@ static stlink_t* stlink_open(const int verbose) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#if LIBUSB_API_VERSION < 0x01000106
|
||||
libusb_set_debug(slsg->libusb_ctx, ugly_libusb_log_level(verbose));
|
||||
#else
|
||||
libusb_set_option(slsg->libusb_ctx, LIBUSB_OPTION_LOG_LEVEL, ugly_libusb_log_level(verbose));
|
||||
#endif
|
||||
|
||||
slsg->usb_handle = libusb_open_device_with_vid_pid(slsg->libusb_ctx, STLINK_USB_VID_ST, STLINK_USB_PID_STLINK);
|
||||
if (slsg->usb_handle == NULL) {
|
||||
WLOG("Failed to find an stlink v1 by VID:PID\n");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
if (NOT gtk_FOUND)
|
||||
return()
|
||||
endif()
|
||||
message(STATUS "gtk not found!")
|
||||
return()
|
||||
endif ()
|
||||
|
||||
set(GUI_SOURCES stlink-gui.c stlink-gui.h)
|
||||
set(INSTALLED_UI_DIR share/stlink)
|
||||
|
@ -8,26 +9,26 @@ set(INSTALLED_UI_DIR share/stlink)
|
|||
include_directories(SYSTEM ${gtk_INCLUDE_DIRS})
|
||||
|
||||
add_executable(stlink-gui-local ${GUI_SOURCES})
|
||||
set_target_properties(stlink-gui-local PROPERTIES
|
||||
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_target_properties(
|
||||
stlink-gui-local PROPERTIES
|
||||
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${gtk_LDFLAGS} ${SSP_LIB})
|
||||
|
||||
|
||||
add_executable(stlink-gui ${GUI_SOURCES})
|
||||
set_target_properties(stlink-gui PROPERTIES
|
||||
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}")
|
||||
set_target_properties(
|
||||
stlink-gui PROPERTIES
|
||||
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}"
|
||||
)
|
||||
target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${gtk_LDFLAGS} ${SSP_LIB})
|
||||
|
||||
install(TARGETS stlink-gui
|
||||
RUNTIME DESTINATION bin)
|
||||
install(FILES stlink-gui.ui
|
||||
DESTINATION ${INSTALLED_UI_DIR})
|
||||
install(TARGETS stlink-gui RUNTIME DESTINATION bin)
|
||||
install(FILES stlink-gui.ui DESTINATION ${INSTALLED_UI_DIR})
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
# Install desktop entry
|
||||
install(FILES stlink-gui.desktop
|
||||
DESTINATION share/applications)
|
||||
install(FILES stlink-gui.desktop DESTINATION share/applications)
|
||||
# Install icon
|
||||
install(FILES art/stlink-gui.svg
|
||||
DESTINATION share/icons/hicolor/scalable/apps)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
install(FILES art/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps)
|
||||
endif ()
|
||||
|
|
15
src/usb.c
15
src/usb.c
|
@ -2,19 +2,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#if !defined(_MSC_VER)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <mingw.h>
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4200 4255 4668 4820)
|
||||
#include <libusb.h>
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
#include <libusb.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -902,6 +895,12 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST
|
|||
goto on_error;
|
||||
}
|
||||
|
||||
#if LIBUSB_API_VERSION < 0x01000106
|
||||
libusb_set_debug(slu->libusb_ctx, ugly_libusb_log_level(verbose));
|
||||
#else
|
||||
libusb_set_option(slu->libusb_ctx, LIBUSB_OPTION_LOG_LEVEL, ugly_libusb_log_level(verbose));
|
||||
#endif
|
||||
|
||||
libusb_device **list;
|
||||
/** @todo We should use ssize_t and use it as a counter if > 0. As per libusb API: ssize_t libusb_get_device_list (libusb_context *ctx, libusb_device ***list) */
|
||||
int cnt = (int) libusb_get_device_list(slu->libusb_ctx, &list);
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
set(TESTS
|
||||
usb
|
||||
sg
|
||||
)
|
||||
set(TESTS usb sg)
|
||||
|
||||
foreach(test ${TESTS})
|
||||
add_executable(${test} ${test}.c)
|
||||
add_dependencies(${test} ${STLINK_LIB_STATIC})
|
||||
foreach (test ${TESTS})
|
||||
add_executable(${test} ${test}.c)
|
||||
add_dependencies(${test} ${STLINK_LIB_STATIC})
|
||||
target_link_libraries(${test} ${STLINK_LIB_STATIC} ${SSP_LIB})
|
||||
add_test(${test} ${CMAKE_CURRENT_BINARY_DIR}/${test})
|
||||
endforeach()
|
||||
add_test(${test} ${CMAKE_CURRENT_BINARY_DIR}/${test})
|
||||
endforeach ()
|
||||
|
||||
add_executable(flash flash.c "${CMAKE_SOURCE_DIR}/src/tools/flash_opts.c")
|
||||
target_link_libraries(flash ${STLINK_LIB_STATIC} ${SSP_LIB})
|
||||
|
|
|
@ -5,10 +5,11 @@ set(PKG_CONFIG_CFLAGS "-I\${includedir}")
|
|||
set(PKG_CONFIG_REQUIRES "libusb-1.0")
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
)
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
DESTINATION ${STLINK_LIBRARY_PATH}/pkgconfig/
|
||||
)
|
||||
install(
|
||||
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||
DESTINATION ${STLINK_LIBRARY_PATH}/pkgconfig/
|
||||
)
|
||||
|
|
Ładowanie…
Reference in New Issue