kopia lustrzana https://github.com/stlink-org/stlink
Deprecate autotools
rodzic
57cf59a869
commit
9aac78d184
|
@ -0,0 +1,20 @@
|
|||
version: '{build}'
|
||||
environment:
|
||||
matrix:
|
||||
- GENERATOR: "MSYS Makefiles"
|
||||
ARCH: i686 # this is for 32-bit MinGW-w64
|
||||
- GENERATOR: "MSYS Makefiles"
|
||||
ARCH: 64
|
||||
cache:
|
||||
- i686-4.9.2-release-win32-sjlj-rt_v3-rev1.7z
|
||||
- x86_64-4.9.2-release-win32-seh-rt_v3-rev1.7z
|
||||
build_script:
|
||||
- ps: |
|
||||
mkdir build
|
||||
cd build
|
||||
if ($env:GENERATOR -ne "MSYS Makefiles") {
|
||||
cmake .. -G"$env:GENERATOR"
|
||||
cmake --build . --config Debug
|
||||
}
|
||||
- cmd: |
|
||||
if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/stlink/scripts/appveyor-mingw.sh)
|
21
.travis.sh
21
.travis.sh
|
@ -5,24 +5,15 @@ ls -1 /usr/bin/clang*
|
|||
ls -1 /usr/bin/scan-build*
|
||||
echo "----"
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" != "osx" ]; then
|
||||
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
|
||||
sudo apt-get update -qq || true
|
||||
sudo apt-get install -qq -y --no-install-recommends libusb-1.0.0-dev libgtk-3-dev
|
||||
else
|
||||
brew install libusb
|
||||
fi
|
||||
|
||||
if [ "$BUILD_SYSTEM" == "cmake" ]; then
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
else
|
||||
./autogen.sh
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
./configure
|
||||
else
|
||||
./configure --with-gtk-gui
|
||||
fi
|
||||
make
|
||||
fi
|
||||
echo "=== Building Debug"
|
||||
mkdir -p build/Debug && cd build/Debug && cmake -DCMAKE_BUILD_TYPE=Debug ../../ && make && make package && cd -
|
||||
|
||||
echo "=== Building Release"
|
||||
mkdir -p build/Release && cd build/Release && cmake -DCMAKE_BUILD_TYPE=Release ../../ && make && make package && cd -
|
||||
|
|
14
.travis.yml
14
.travis.yml
|
@ -3,21 +3,25 @@ language: c
|
|||
addons:
|
||||
apt:
|
||||
sources:
|
||||
# - llvm-toolchain-precise-3.8
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang
|
||||
# - clang-3.8
|
||||
- g++-5
|
||||
- gcc-5
|
||||
- clang
|
||||
script:
|
||||
- ./.travis.sh
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: clang-3.8
|
||||
env: "BUILD_SYSTEM=cmake"
|
||||
compiler: clang
|
||||
# - os: linux
|
||||
# compiler: clang-3.8
|
||||
- os: linux
|
||||
compiler: gcc-5
|
||||
env: "BUILD_SYSTEM=cmake"
|
||||
compiler: gcc-5
|
||||
# - os: linux
|
||||
# compiler: clang-3.8
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env: "BUILD_SYSTEM=cmake"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
2.0.0-dev
|
|
@ -1,2 +0,0 @@
|
|||
The development team wants to acknowledge the following people:
|
||||
- STMicroelectronics discovery kit team for their low cost boards and for their help in development process.
|
19
AUTHORS
19
AUTHORS
|
@ -1,19 +0,0 @@
|
|||
m@capitanio.org
|
||||
spen@spen-soft.co.uk
|
||||
texane@gmail.com
|
||||
whitequark@whitequark.org
|
||||
grestm@galexander.org
|
||||
karlp@tweak.net.au
|
||||
h0rr0rrdrag@gmail.com
|
||||
mstempin@com1.fr
|
||||
bon@elektron.ikp.physik.tu-darmstadt.de
|
||||
nelsonjm@macpod.neta
|
||||
ned@bike-nomad.com
|
||||
csamuelson@swingpal.com
|
||||
bravikov@gmail.com
|
||||
jnosky - codegrinder69@hotmail.com
|
||||
marpe@mimuw.edu.pl
|
||||
marco.cassinerio@gmail.com
|
||||
jserv@0xlab.org
|
||||
michael@pratt.im
|
||||
jerry.jacobs@xor-gate.org
|
|
@ -1,14 +1,58 @@
|
|||
project(stlink C)
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
|
||||
project(stlink C)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckIncludeFile)
|
||||
find_package(PkgConfig)
|
||||
|
||||
if (POLICY CMP0042)
|
||||
# Newer cmake on MacOS should use @rpath
|
||||
cmake_policy (SET CMP0042 NEW)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules")
|
||||
|
||||
# Determine package version.
|
||||
find_package (Git QUIET)
|
||||
if (DEFINED ENV{TRAVIS_TAG} AND NOT "$ENV{TRAVIS_TAG}" STREQUAL "")
|
||||
set (STLINK_PACKAGE_VERSION "$ENV{TRAVIS_TAG}")
|
||||
elseif (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||
# Working off a git repo, using git versioning
|
||||
|
||||
# Check if HEAD is pointing to a tag
|
||||
execute_process (
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --always
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE STLINK_PACKAGE_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# If the sources have been changed locally, add -dirty to the version.
|
||||
execute_process (
|
||||
COMMAND "${GIT_EXECUTABLE}" diff --quiet
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res)
|
||||
|
||||
if (res EQUAL 1)
|
||||
set (STLINK_PACKAGE_VERSION "${STLINK_PACKAGE_VERSION}-dirty")
|
||||
endif()
|
||||
elseif (EXISTS ${PROJECT_SOURCE_DIR}/.version)
|
||||
# If git is not available (e.g. when building from source package)
|
||||
# we can extract the package version from .version file.
|
||||
file (STRINGS .version STLINK_PACKAGE_VERSION)
|
||||
else ()
|
||||
set (STLINK_PACKAGE_VERSION "Unknown")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
find_package(7Zip REQUIRED)
|
||||
message(STATUS "7Zip Location: " ${ZIP_LOCATION})
|
||||
endif()
|
||||
|
||||
find_package(LibUSB REQUIRED)
|
||||
pkg_check_modules(gtk gtk+-3.0)
|
||||
if (NOT APPLE AND NOT WIN32)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(gtk gtk+-3.0)
|
||||
endif ()
|
||||
|
||||
function(add_cflag_if_supported flag)
|
||||
string(REPLACE "-" "_" flagclean ${flag})
|
||||
|
@ -38,12 +82,19 @@ add_cflag_if_supported("-Wshorten-64-to-32")
|
|||
add_cflag_if_supported("-Wimplicit-function-declaration")
|
||||
add_cflag_if_supported("-Wredundant-decls")
|
||||
add_cflag_if_supported("-Wundef")
|
||||
add_cflag_if_supported("-fPIC")
|
||||
if (NOT MSYS OR MINGW)
|
||||
add_cflag_if_supported("-fPIC")
|
||||
endif ()
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "")
|
||||
set (CMAKE_BUILD_TYPE "Debug")
|
||||
endif ()
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
include(CTest)
|
||||
add_cflag_if_supported("-ggdb")
|
||||
add_cflag_if_supported("-O0")
|
||||
#set (STLINK_PACKAGE_VERSION "${STLINK_PACKAGE_VERSION}-debug")
|
||||
elseif()
|
||||
add_cflag_if_supported("-O2")
|
||||
endif()
|
||||
|
@ -53,6 +104,8 @@ if (STLINK_HAVE_SYS_MMAN_H)
|
|||
add_definitions(-DSTLINK_HAVE_SYS_MMAN_H)
|
||||
endif()
|
||||
|
||||
message("Building ${PROJECT_NAME} ${STLINK_PACKAGE_VERSION}")
|
||||
|
||||
set(STLINK_HEADERS
|
||||
include/stlink.h
|
||||
include/stlink/usb.h
|
||||
|
@ -72,6 +125,10 @@ set(STLINK_SOURCE
|
|||
src/flash_loader.c
|
||||
)
|
||||
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
set (STLINK_SOURCE "${STLINK_SOURCE};src/mmap.c;src/mingw/mingw.c") # TODO
|
||||
endif ()
|
||||
|
||||
include_directories(${LIBUSB_INCLUDE_DIR})
|
||||
include_directories(include)
|
||||
include_directories(src/mingw)
|
||||
|
@ -86,7 +143,7 @@ if (APPLE)
|
|||
find_library(CoreFoundation CoreFoundation)
|
||||
find_library(IOKit IOKit)
|
||||
target_link_libraries(${PROJECT_NAME} ${CoreFoundation} ${IOKit} ${ObjC})
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
add_executable(st-flash src/tools/flash.c)
|
||||
target_link_libraries(st-flash ${PROJECT_NAME})
|
||||
|
@ -98,7 +155,11 @@ add_executable(st-util src/gdbserver/gdb-remote.c
|
|||
src/gdbserver/gdb-remote.h
|
||||
src/gdbserver/gdb-server.c
|
||||
src/gdbserver/gdb-server.h)
|
||||
target_link_libraries(st-util ${PROJECT_NAME})
|
||||
if (WIN32 OR MSYS OR MINGW)
|
||||
target_link_libraries(st-util ${PROJECT_NAME} wsock32 ws2_32)
|
||||
else ()
|
||||
target_link_libraries(st-util ${PROJECT_NAME})
|
||||
endif ()
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} st-flash st-util st-info
|
||||
RUNTIME DESTINATION bin
|
||||
|
@ -114,20 +175,22 @@ if(NOT MINGW)
|
|||
RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if(gtk_FOUND)
|
||||
if (NOT APPLE AND gtk_FOUND)
|
||||
include_directories(SYSTEM ${gtk_INCLUDE_DIRS})
|
||||
set(GUI_SOURCES src/tools/gui/stlink-gui.c
|
||||
src/tools/gui/stlink-gui.h)
|
||||
|
||||
# TODO REMOVE whole stlink-gui-local target, fixup auto-search of ui file in implementation
|
||||
add_executable(stlink-gui-local ${GUI_SOURCES})
|
||||
set_target_properties(stlink-gui-local PROPERTIES
|
||||
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${CMAKE_CURRENT_SOURCE_DIR}/gui\\")
|
||||
target_link_libraries(stlink-gui-local stlink ${gtk_LDFLAGS})
|
||||
|
||||
set(INSTALLED_UI_DIR ${CMAKE_INSTALL_PREFIX}/share)
|
||||
set(INSTALLED_UI_DIR share/stlink)
|
||||
add_executable(stlink-gui ${GUI_SOURCES})
|
||||
# TODO REMOVE, fixup auto-search of ui file in implementation
|
||||
set_target_properties(stlink-gui PROPERTIES
|
||||
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${INSTALLED_UI_DIR}\\")
|
||||
COMPILE_FLAGS -DSTLINK_UI_DIR=\\"${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}\\")
|
||||
target_link_libraries(stlink-gui stlink ${gtk_LDFLAGS})
|
||||
|
||||
install(TARGETS stlink-gui
|
||||
|
@ -137,3 +200,16 @@ if(gtk_FOUND)
|
|||
endif()
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
|
||||
set (CPACK_PACKAGE_VERSION ${STLINK_PACKAGE_VERSION})
|
||||
set (CPACK_SOURCE_GENERATOR "TBZ2;ZIP")
|
||||
set (CPACK_SOURCE_IGNORE_FILES "/build/;/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
|
||||
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${STLINK_PACKAGE_VERSION}")
|
||||
if (APPLE)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist/osx")
|
||||
endif ()
|
||||
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
||||
include (CPack)
|
||||
|
|
27
COPYING
27
COPYING
|
@ -1,27 +0,0 @@
|
|||
Copyright (c) 2011 The "Capt'ns Missing Link" Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Martin Capitanio nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -1,6 +1,15 @@
|
|||
Stlink ChangeLog
|
||||
================
|
||||
|
||||
v2.0.0
|
||||
======
|
||||
|
||||
Ongoing development
|
||||
|
||||
Major changes:
|
||||
|
||||
* Deprecation of autotools (autoconf, automake)
|
||||
|
||||
v1.2.0
|
||||
======
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
from dandev37:
|
||||
|
||||
Here's a step by step from a clean install to successfully setup MinGW and build
|
||||
libusb-1.0 and stlink for MS Windows. Hopefully this helps someone.
|
||||
|
||||
1. Install MinGW and MSYS to C:\MinGW with the graphical installer from
|
||||
http://sourceforge.net/projects/mingw/files/Installer/mingw-get-setup.exe/download
|
||||
and add these packages:
|
||||
mingw32-base
|
||||
mingw-developer-toolkit
|
||||
|
||||
2. Add C:\MinGW\bin to your path.
|
||||
Note: a user reports she had to use c:\MinGW\msys\1.0\bin
|
||||
|
||||
3. Create the C:\MinGW\msys\1.0\etc\fstab file to mount C:\MinGW as /mingw as per
|
||||
http://www.mingw.org/wiki/MSYS:
|
||||
|
||||
#Win32_Path Mount_Point
|
||||
c:/mingw /mingw
|
||||
|
||||
4. Download these three glib, pkg-config, pkg-config-dev archives and extract
|
||||
contents to C:\MinGW
|
||||
http://win32builder.gnome.org/packages/3.6/glib_2.34.3-1_win32.zip
|
||||
http://win32builder.gnome.org/packages/3.6/pkg-config_0.28-1_win32.zip
|
||||
http://win32builder.gnome.org/packages/3.6/pkg-config-dev_0.28-1_win32.zip
|
||||
|
||||
5. Download latest libusb-1.0 source from
|
||||
https://github.com/libusb/libusb (newer repo, includes USB 3.0 hub support)
|
||||
OR the old git://git.libusb.org/libusb.git (original repo, NO USB 3.0 support)
|
||||
and build (prefix as per http://www.mingw.org/wiki/MSYS)
|
||||
|
||||
./autogen.sh
|
||||
./configure --prefix=/mingw
|
||||
make
|
||||
make install
|
||||
|
||||
6. Repeat for stlink source from https://github.com/texane/stlink
|
||||
|
||||
./autogen.sh
|
||||
./configure --prefix=/mingw
|
||||
make
|
||||
make install
|
||||
|
||||
7. Enjoy the fruits of the stlink developers.
|
59
Makefile.am
59
Makefile.am
|
@ -1,59 +0,0 @@
|
|||
# Makefile.am -- Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = . $(STLINK_HAS_GUI)
|
||||
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
|
||||
if MINGW
|
||||
bin_PROGRAMS = st-flash st-util st-info
|
||||
else
|
||||
bin_PROGRAMS = st-flash st-util st-term st-info
|
||||
endif
|
||||
|
||||
noinst_LIBRARIES = libstlink.a
|
||||
|
||||
st_flash_SOURCES = src/tools/flash.c
|
||||
st_term_SOURCES = src/tools/term.c
|
||||
st_info_SOURCES = src/tools/info.c
|
||||
st_util_SOURCES = src/gdbserver/gdb-remote.c src/gdbserver/gdb-remote.h src/gdbserver/gdb-server.c src/mingw/mingw.c src/mingw/mingw.h
|
||||
|
||||
CFILES = \
|
||||
src/chipid.c \
|
||||
src/common.c \
|
||||
src/usb.c \
|
||||
src/sg.c \
|
||||
src/logging.c \
|
||||
src/flash_loader.c
|
||||
|
||||
if !MINGW
|
||||
CFILES += src/tools/term.c
|
||||
endif
|
||||
|
||||
HFILES = \
|
||||
include/stlink.h \
|
||||
include/stlink/chipid.h \
|
||||
include/stlink/usb.h \
|
||||
include/stlink/flash_loader.h \
|
||||
include/stlink/commands.h \
|
||||
include/stlink/sg.h \
|
||||
include/stlink/logging.h \
|
||||
include/stlink/mmap.h
|
||||
|
||||
libstlink_a_SOURCES = $(CFILES) $(HFILES)
|
||||
|
||||
libstlink_a_LIBADD = $(LIBOBJS)
|
||||
libstlink_a_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/include
|
||||
|
||||
st_flash_LDADD = libstlink.a
|
||||
st_flash_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/include -I$(top_srcdir)/src/mingw
|
||||
|
||||
st_util_LDADD = libstlink.a
|
||||
st_util_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/include -I$(top_srcdir)/src/mingw
|
||||
|
||||
st_term_LDADD = libstlink.a
|
||||
st_term_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/include -I$(top_srcdir)/src/mingw
|
||||
|
||||
st_info_LDADD = libstlink.a
|
||||
st_info_CPPFLAGS = -std=gnu99 -Wall -Wextra -O2 -I$(top_srcdir)/include -I$(top_srcdir)/src/mingw
|
||||
|
||||
EXTRA_DIST = autogen.sh
|
335
README
335
README
|
@ -1,335 +0,0 @@
|
|||
Open source version of the STMicroelectronics Stlink Tools
|
||||
==========================================================
|
||||
|
||||
[](https://travis-ci.org/texane/stlink)
|
||||
|
||||
## HOWTO
|
||||
|
||||
First, you have to know there are several boards supported by the software.
|
||||
Those boards use a chip to translate from USB to JTAG commands. The chip is
|
||||
called stlink and there are 2 versions:
|
||||
|
||||
* STLINKv1, present on STM32VL discovery kits,
|
||||
* STLINKv2, present on STM32L discovery and later kits.
|
||||
|
||||
Two different transport layers are used:
|
||||
|
||||
* STLINKv1 uses SCSI passthru commands over USB
|
||||
* STLINKv2 uses raw USB commands.
|
||||
|
||||
## Common requirements
|
||||
|
||||
* Debian based distros (debian, ubuntu)
|
||||
* `build-essential`
|
||||
|
||||
* `pkg-config`
|
||||
* `intltool`
|
||||
* `cmake` or (`autoconf` && `automake` && `autogen`)
|
||||
* `libusb-1.0` (plus development headers for building, on debian based distros `libusb-1.0.0-dev` package)
|
||||
* (optional) for `stlink-gui` we need libgtk-3-dev
|
||||
|
||||
## For STLINKv1
|
||||
|
||||
The STLINKv1's SCSI emulation is very broken, 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`
|
||||
|
||||
## For STLINKv2
|
||||
|
||||
You're ready to go :)
|
||||
|
||||
## Build from sources
|
||||
|
||||
### Autotools
|
||||
|
||||
This project was converted to Autotools by a well meaning individual. The
|
||||
following steps will build the project for you.
|
||||
|
||||
```
|
||||
$ ./autogen.sh
|
||||
$ ./configure --with-gtk-gui
|
||||
$ make
|
||||
```
|
||||
|
||||
### CMake
|
||||
|
||||
```
|
||||
$ mkdir build && cd build
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
$ make
|
||||
```
|
||||
|
||||
## Using the gdb server
|
||||
|
||||
To run the gdb server: (you do not need sudo if you have set up
|
||||
permissions correctly)
|
||||
|
||||
```
|
||||
$ make && [sudo] ./st-util
|
||||
|
||||
There are a few options:
|
||||
|
||||
./st-util - usage:
|
||||
|
||||
-h, --help Print this help
|
||||
-vXX, --verbose=XX Specify a specific verbosity level (0..99)
|
||||
-v, --verbose Specify generally verbose logging
|
||||
-s X, --stlink_version=X
|
||||
Choose what version of stlink to use, (defaults to 2)
|
||||
-1, --stlinkv1 Force stlink version 1
|
||||
-p 4242, --listen_port=1234
|
||||
Set the gdb server listen port. (default port: 4242)
|
||||
-m, --multi
|
||||
Set gdb server to extended mode.
|
||||
st-util will continue listening for connections after disconnect.
|
||||
-n, --no-reset
|
||||
Do not reset board on connection.
|
||||
```
|
||||
|
||||
The STLINKv2 device to use can be specified in the environment
|
||||
variable STLINK_DEVICE on the format `<USB_BUS>:<USB_ADDR>`.
|
||||
|
||||
Then, in your project directory, someting like this...
|
||||
(remember, you need to run an _ARM_ gdb, not an x86 gdb)
|
||||
|
||||
```
|
||||
$ arm-none-eabi-gdb fancyblink.elf
|
||||
...
|
||||
(gdb) tar extended-remote :4242
|
||||
...
|
||||
(gdb) load
|
||||
Loading section .text, size 0x458 lma 0x8000000
|
||||
Loading section .data, size 0x8 lma 0x8000458
|
||||
Start address 0x80001c1, load size 1120
|
||||
Transfer rate: 1 KB/sec, 560 bytes/write.
|
||||
(gdb)
|
||||
...
|
||||
(gdb) continue
|
||||
```
|
||||
|
||||
Have fun!
|
||||
|
||||
## Resetting the chip from GDB
|
||||
|
||||
You may reset the chip using GDB if you want. You'll need to use `target
|
||||
extended-remote' command like in this session:
|
||||
|
||||
```
|
||||
(gdb) target extended-remote localhost:4242
|
||||
Remote debugging using localhost:4242
|
||||
0x080007a8 in _startup ()
|
||||
(gdb) kill
|
||||
Kill the program being debugged? (y or n) y
|
||||
(gdb) run
|
||||
Starting program: /home/whitequark/ST/apps/bally/firmware.elf
|
||||
```
|
||||
|
||||
Remember that you can shorten the commands. `tar ext :4242' is good enough
|
||||
for GDB.
|
||||
|
||||
## Setting up udev rules
|
||||
|
||||
For convenience, you may install udev rules file, 49-stlinkv*.rules, located
|
||||
in etc/udev/rules.d (from root of repository). You will need to copy it to /etc/udev/rules.d,
|
||||
and then either reboot or execute
|
||||
|
||||
```
|
||||
$ udevadm control --reload-rules
|
||||
$ udevadm trigger
|
||||
```
|
||||
|
||||
Udev will now create a /dev/stlinkv2_XX or /dev/stlinkv1_XX file, with the appropriate permissions.
|
||||
This is currently all the device is for, (only one stlink of each version is supported at
|
||||
any time presently)
|
||||
|
||||
## Running programs from SRAM
|
||||
|
||||
You can run your firmware directly from SRAM if you want to. Just link
|
||||
it at 0x20000000 and do
|
||||
|
||||
```
|
||||
(gdb) load firmware.elf
|
||||
```
|
||||
|
||||
It will be loaded, and pc will be adjusted to point to start of the
|
||||
code, if it is linked correctly (i.e. ELF has correct entry point).
|
||||
|
||||
## Writing to flash
|
||||
|
||||
The GDB stub ships with a correct memory map, including the flash area.
|
||||
If you would link your executable to 0x08000000 and then do
|
||||
(gdb) load firmware.elf
|
||||
then it would be written to the memory.
|
||||
|
||||
## FAQ
|
||||
|
||||
Q: My breakpoints do not work at all or only work once.
|
||||
|
||||
A: Optimizations can cause severe instruction reordering. For example,
|
||||
if you are doing something like `REG = 0x100;' in a loop, the code may
|
||||
be split into two parts: loading 0x100 into some intermediate register
|
||||
and moving that value to REG. When you set up a breakpoint, GDB will
|
||||
hook to the first instruction, which may be called only once if there are
|
||||
enough unused registers. In my experience, -O3 causes that frequently.
|
||||
|
||||
Q: At some point I use GDB command `next', and it hangs.
|
||||
|
||||
A: Sometimes when you will try to use GDB `next' command to skip a loop,
|
||||
it will use a rather inefficient single-stepping way of doing that.
|
||||
Set up a breakpoint manually in that case and do `continue'.
|
||||
|
||||
Q: Load command does not work in GDB.
|
||||
|
||||
A: Some people report XML/EXPAT is not enabled by default when compiling
|
||||
GDB. Memory map parsing thus fail. Use --enable-expat.
|
||||
|
||||
## Currently known working combinations of programmer and target
|
||||
|
||||
STLink v1 (as found on the 32VL Discovery board)
|
||||
|
||||
Known working targets:
|
||||
|
||||
* STM32F100xx (Medium Density VL)
|
||||
* STM32F103 (according to jpa- on ##stm32)
|
||||
|
||||
No information:
|
||||
|
||||
* everything else!
|
||||
|
||||
STLink v2 (as found on the 32L and F4 Discovery boards), known working targets:
|
||||
|
||||
* STM32F030F4P6 (custom board)
|
||||
* STM32F0Discovery (STM32F0 Discovery board)
|
||||
* STM32F100xx (Medium Density VL, as on the 32VL Discovery board)
|
||||
* STM32L1xx (STM32L Discovery board)
|
||||
* STM32F103VC, STM32F107RC, STM32L151RB, STM32F205RE and STM32F405RE on custom boards
|
||||
from [UweBonnes/wiki_fuer_alex](https://github.com/UweBonnes/wiki_fuer_alex/tree/master/layout)
|
||||
* STM32F103VET6 (HY-STM32 board)
|
||||
* STM32F105RCT6 (DecaWave EVB1000 board)
|
||||
* STM32F303xx (STM32F3 Discovery board)
|
||||
* STM32F407xx (STM32F4 Discovery board)
|
||||
* STM32F429I-DISCO (STM32F4 Discovery board with LCD)
|
||||
* STM32F439VIT6 (discovery board reseated CPU)
|
||||
* STM32L052K8T6 (custom board)
|
||||
* STM32L151CB (custom board)
|
||||
* STM32L152RB (STM32L-Discovery board, custom board)
|
||||
* STM32F051R8T6 (STM320518-EVAL board)
|
||||
|
||||
STLink v2-1 (as found on the Nucleo boards), known working targets:
|
||||
|
||||
* STM32F401xx (STM32 Nucleo-F401RE board)
|
||||
* STM32F030R8T6 (STM32 Nucleo-F030R8 board)
|
||||
* STM32F072RBT6 (STM32 Nucleo-F072RB board)
|
||||
* STM32F103RB (STM32 Nucleo-F103RB board)
|
||||
* STM32F303RET6 (STM32 Nucleo-F303RE board)
|
||||
* STM32F334R8 (STM32 Nucleo-F334R8 board)
|
||||
* STM32F411RET6 (STM32 Nucleo-F411RE board)
|
||||
* STM32F756NGHx (STMF7 evaluation board)
|
||||
* STM32L053R8 (STM32 Nucleo-L053R8 board)
|
||||
|
||||
Please report any and all known working combinations so I can update this!
|
||||
|
||||
## Known bugs
|
||||
|
||||
### Sometimes flashing only works after a mass erase
|
||||
|
||||
There is seen a problem sometimes where a flash loader run error occurs and is resolved after mass-erase
|
||||
of the flash:
|
||||
|
||||
```
|
||||
2015-12-09T22:01:57 INFO src/stlink-common.c: Successfully loaded flash loader in sram
|
||||
2015-12-09T22:02:18 ERROR src/stlink-common.c: flash loader run error
|
||||
2015-12-09T22:02:18 ERROR src/stlink-common.c: run_flash_loader(0x8000000) failed! == -1
|
||||
```
|
||||
|
||||
Issue(s): [#356](https://github.com/texane/stlink/issues/356)
|
||||
|
||||
### Stlink serial corrupts after one probe
|
||||
|
||||
`lsusb -v` before `st-info --probe` with STM32 L1 Discovery board. With stlink firmware `V2.J16.S0`:
|
||||
|
||||
```
|
||||
Bus 001 Device 004: ID 0483:3748 STMicroelectronics ST-LINK/V2
|
||||
Device Descriptor:
|
||||
bLength 18
|
||||
bDescriptorType 1
|
||||
bcdUSB 2.00
|
||||
bDeviceClass 0 (Defined at Interface level)
|
||||
bDeviceSubClass 0
|
||||
bDeviceProtocol 0
|
||||
bMaxPacketSize0 64
|
||||
idVendor 0x0483 STMicroelectronics
|
||||
idProduct 0x3748 ST-LINK/V2
|
||||
bcdDevice 1.00
|
||||
iManufacturer 1 STMicroelectronics
|
||||
iProduct 2 STM32 STLink
|
||||
iSerial 3 Pÿk^FPgRUB1^C<U+0087
|
||||
```
|
||||
|
||||
`st-info --probe` :
|
||||
|
||||
```
|
||||
./st-info --probe
|
||||
Found 1 stlink programmers
|
||||
serial: 503f6b06506752554231033f
|
||||
openocd: "\x50\x3f\x6b\x06\x50\x67\x52\x55\x42\x31\x03\x3f"
|
||||
flash: 262144 (pagesize: 256)
|
||||
sram: 32768
|
||||
chipid: 0x0427
|
||||
descr: L1 Medium-Plus-density device
|
||||
```
|
||||
|
||||
`lsusb -v` after probe:
|
||||
|
||||
```
|
||||
Bus 001 Device 004: ID 0483:3748 STMicroelectronics ST-LINK/V2
|
||||
Device Descriptor:
|
||||
bLength 18
|
||||
bDescriptorType 1
|
||||
bcdUSB 2.00
|
||||
bDeviceClass 0 (Defined at Interface level)
|
||||
bDeviceSubClass 0
|
||||
bDeviceProtocol 0
|
||||
bMaxPacketSize0 64
|
||||
idVendor 0x0483 STMicroelectronics
|
||||
idProduct 0x3748 ST-LINK/V2
|
||||
bcdDevice 1.00
|
||||
iManufacturer 1 STMicroelectronics
|
||||
iProduct 2 STM32 STLink
|
||||
iSerial 3 000000000001
|
||||
bNumConfigurations 1
|
||||
```
|
||||
|
||||
`st-info --probe` second time, with "corrupt serial".
|
||||
|
||||
```
|
||||
./st-info --probe
|
||||
Found 1 stlink programmers
|
||||
serial: 303030303030303030303031
|
||||
openocd: "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x31"
|
||||
flash: 262144 (pagesize: 256)
|
||||
sram: 32768
|
||||
chipid: 0x0427
|
||||
descr: L1 Medium-Plus-density device
|
||||
```
|
||||
|
||||
**Solution**
|
||||
|
||||
Upgrade firmware from `V2.J16.S0` to `V2.J25.S0`
|
||||
|
||||
## Contributing and versioning
|
||||
|
||||
* The semantic versioning scheme is used. Read more at [semver.org](http://semver.org)
|
||||
* When creating a pull request, please open first a issue for discussion of new features
|
||||
* TODO: Enforcement of coding style (linux codestyle + checkpatch)
|
||||
|
||||
## License
|
||||
|
||||
The stlink library and tools are licensed under the [BSD license](LICENSE)
|
|
@ -1 +0,0 @@
|
|||
README
|
|
@ -0,0 +1,252 @@
|
|||
Open source version of the STMicroelectronics Stlink Tools
|
||||
==========================================================
|
||||
|
||||
[](https://github.com/texane/stlink/releases/latest)
|
||||
[](https://github.com/texane/stlink/compare/1.2.0...master)
|
||||
[](https://travis-ci.org/texane/stlink)
|
||||
[](https://ci.appveyor.com/project/xor-gate/stlink)
|
||||
[](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE)
|
||||
|
||||
## HOWTO
|
||||
|
||||
First, you have to know there are several boards supported by the software.
|
||||
Those boards use a chip to translate from USB to JTAG commands. The chip is
|
||||
called stlink and there are 2 versions:
|
||||
|
||||
* STLINKv1, present on STM32VL discovery kits,
|
||||
* STLINKv2, present on STM32L discovery and later kits.
|
||||
|
||||
Two different transport layers are used:
|
||||
|
||||
* STLINKv1 uses SCSI passthru commands over USB
|
||||
* STLINKv2 uses raw USB commands.
|
||||
|
||||
## Common requirements
|
||||
|
||||
* Debian based distros (debian, ubuntu)
|
||||
* `build-essential`
|
||||
|
||||
* `cmake`
|
||||
* `libusb-1.0` (plus development headers for building, on debian based distros `libusb-1.0.0-dev` package)
|
||||
* (optional) for `stlink-gui` we need libgtk-3-dev
|
||||
|
||||
## For STLINKv1
|
||||
|
||||
The STLINKv1's SCSI emulation is very broken, 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`
|
||||
|
||||
## For STLINKv2
|
||||
|
||||
You're ready to go :)
|
||||
|
||||
## Build from sources
|
||||
|
||||
```
|
||||
$ mkdir build && cd build
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||
$ make
|
||||
```
|
||||
|
||||
## Using the gdb server
|
||||
|
||||
To run the gdb server: (you do not need sudo if you have set up
|
||||
permissions correctly)
|
||||
|
||||
```
|
||||
$ make && [sudo] ./st-util
|
||||
|
||||
There are a few options:
|
||||
|
||||
./st-util - usage:
|
||||
|
||||
-h, --help Print this help
|
||||
-vXX, --verbose=XX Specify a specific verbosity level (0..99)
|
||||
-v, --verbose Specify generally verbose logging
|
||||
-s X, --stlink_version=X
|
||||
Choose what version of stlink to use, (defaults to 2)
|
||||
-1, --stlinkv1 Force stlink version 1
|
||||
-p 4242, --listen_port=1234
|
||||
Set the gdb server listen port. (default port: 4242)
|
||||
-m, --multi
|
||||
Set gdb server to extended mode.
|
||||
st-util will continue listening for connections after disconnect.
|
||||
-n, --no-reset
|
||||
Do not reset board on connection.
|
||||
```
|
||||
|
||||
The STLINKv2 device to use can be specified in the environment
|
||||
variable STLINK_DEVICE on the format `<USB_BUS>:<USB_ADDR>`.
|
||||
|
||||
Then, in your project directory, someting like this...
|
||||
(remember, you need to run an _ARM_ gdb, not an x86 gdb)
|
||||
|
||||
```
|
||||
$ arm-none-eabi-gdb fancyblink.elf
|
||||
...
|
||||
(gdb) tar extended-remote :4242
|
||||
...
|
||||
(gdb) load
|
||||
Loading section .text, size 0x458 lma 0x8000000
|
||||
Loading section .data, size 0x8 lma 0x8000458
|
||||
Start address 0x80001c1, load size 1120
|
||||
Transfer rate: 1 KB/sec, 560 bytes/write.
|
||||
(gdb)
|
||||
...
|
||||
(gdb) continue
|
||||
```
|
||||
|
||||
Have fun!
|
||||
|
||||
## Resetting the chip from GDB
|
||||
|
||||
You may reset the chip using GDB if you want. You'll need to use `target
|
||||
extended-remote' command like in this session:
|
||||
|
||||
```
|
||||
(gdb) target extended-remote localhost:4242
|
||||
Remote debugging using localhost:4242
|
||||
0x080007a8 in _startup ()
|
||||
(gdb) kill
|
||||
Kill the program being debugged? (y or n) y
|
||||
(gdb) run
|
||||
Starting program: /home/whitequark/ST/apps/bally/firmware.elf
|
||||
```
|
||||
|
||||
Remember that you can shorten the commands. `tar ext :4242' is good enough
|
||||
for GDB.
|
||||
|
||||
## Setting up udev rules
|
||||
|
||||
For convenience, you may install udev rules file, 49-stlinkv*.rules, located
|
||||
in the root of repository. You will need to copy it to /etc/udev/rules.d,
|
||||
and then either reboot or execute
|
||||
|
||||
```
|
||||
$ udevadm control --reload-rules
|
||||
$ udevadm trigger
|
||||
```
|
||||
|
||||
Udev will now create a /dev/stlinkv2_XX or /dev/stlinkv1_XX file, with the appropriate permissions.
|
||||
This is currently all the device is for, (only one stlink of each version is supported at
|
||||
any time presently)
|
||||
|
||||
## Running programs from SRAM
|
||||
|
||||
You can run your firmware directly from SRAM if you want to. Just link
|
||||
it at 0x20000000 and do
|
||||
|
||||
```
|
||||
(gdb) load firmware.elf
|
||||
```
|
||||
|
||||
It will be loaded, and pc will be adjusted to point to start of the
|
||||
code, if it is linked correctly (i.e. ELF has correct entry point).
|
||||
|
||||
## Writing to flash
|
||||
|
||||
The GDB stub ships with a correct memory map, including the flash area.
|
||||
If you would link your executable to 0x08000000 and then do
|
||||
(gdb) load firmware.elf
|
||||
then it would be written to the memory.
|
||||
|
||||
## FAQ
|
||||
|
||||
Q: My breakpoints do not work at all or only work once.
|
||||
|
||||
A: Optimizations can cause severe instruction reordering. For example,
|
||||
if you are doing something like `REG = 0x100;' in a loop, the code may
|
||||
be split into two parts: loading 0x100 into some intermediate register
|
||||
and moving that value to REG. When you set up a breakpoint, GDB will
|
||||
hook to the first instruction, which may be called only once if there are
|
||||
enough unused registers. In my experience, -O3 causes that frequently.
|
||||
|
||||
Q: At some point I use GDB command `next', and it hangs.
|
||||
|
||||
A: Sometimes when you will try to use GDB `next' command to skip a loop,
|
||||
it will use a rather inefficient single-stepping way of doing that.
|
||||
Set up a breakpoint manually in that case and do `continue'.
|
||||
|
||||
Q: Load command does not work in GDB.
|
||||
|
||||
A: Some people report XML/EXPAT is not enabled by default when compiling
|
||||
GDB. Memory map parsing thus fail. Use --enable-expat.
|
||||
|
||||
## Currently known working combinations of programmer and target
|
||||
|
||||
STLink v1 (as found on the 32VL Discovery board)
|
||||
|
||||
Known working targets:
|
||||
|
||||
* STM32F100xx (Medium Density VL)
|
||||
* STM32F103 (according to jpa- on ##stm32)
|
||||
|
||||
No information:
|
||||
|
||||
* everything else!
|
||||
|
||||
STLink v2 (as found on the 32L and F4 Discovery boards), known working targets:
|
||||
|
||||
* STM32F030F4P6 (custom board)
|
||||
* STM32F0Discovery (STM32F0 Discovery board)
|
||||
* STM32F100xx (Medium Density VL, as on the 32VL Discovery board)
|
||||
* STM32L1xx (STM32L Discovery board)
|
||||
* STM32F103VC, STM32F107RC, STM32L151RB, STM32F205RE and STM32F405RE on custom boards
|
||||
from [UweBonnes/wiki_fuer_alex](https://github.com/UweBonnes/wiki_fuer_alex/tree/master/layout)
|
||||
* STM32F103VET6 (HY-STM32 board)
|
||||
* STM32F105RCT6 (DecaWave EVB1000 board)
|
||||
* STM32F303xx (STM32F3 Discovery board)
|
||||
* STM32F407xx (STM32F4 Discovery board)
|
||||
* STM32F429I-DISCO (STM32F4 Discovery board with LCD)
|
||||
* STM32F439VIT6 (discovery board reseated CPU)
|
||||
* STM32L052K8T6 (custom board)
|
||||
* STM32L151CB (custom board)
|
||||
* STM32L152RB (STM32L-Discovery board, custom board)
|
||||
* STM32F051R8T6 (STM320518-EVAL board)
|
||||
|
||||
STLink v2-1 (as found on the Nucleo boards), known working targets:
|
||||
|
||||
* STM32F401xx (STM32 Nucleo-F401RE board)
|
||||
* STM32F030R8T6 (STM32 Nucleo-F030R8 board)
|
||||
* STM32F072RBT6 (STM32 Nucleo-F072RB board)
|
||||
* STM32F103RB (STM32 Nucleo-F103RB board)
|
||||
* STM32F303RET6 (STM32 Nucleo-F303RE board)
|
||||
* STM32F334R8 (STM32 Nucleo-F334R8 board)
|
||||
* STM32F411RET6 (STM32 Nucleo-F411RE board)
|
||||
* STM32F756NGHx (STMF7 evaluation board)
|
||||
* STM32L053R8 (STM32 Nucleo-L053R8 board)
|
||||
|
||||
Please report any and all known working combinations so I can update this!
|
||||
|
||||
## Known bugs
|
||||
|
||||
### Sometimes flashing only works after a mass erase
|
||||
|
||||
There is seen a problem sometimes where a flash loader run error occurs and is resolved after mass-erase
|
||||
of the flash:
|
||||
|
||||
```
|
||||
2015-12-09T22:01:57 INFO src/stlink-common.c: Successfully loaded flash loader in sram
|
||||
2015-12-09T22:02:18 ERROR src/stlink-common.c: flash loader run error
|
||||
2015-12-09T22:02:18 ERROR src/stlink-common.c: run_flash_loader(0x8000000) failed! == -1
|
||||
```
|
||||
|
||||
Issue(s): [#356](https://github.com/texane/stlink/issues/356)
|
||||
|
||||
## Contributing and versioning
|
||||
|
||||
* The semantic versioning scheme is used. Read more at [semver.org](http://semver.org)
|
||||
* When creating a pull request, please open first a issue for discussion of new features
|
||||
* TODO: Enforcement of coding style (linux codestyle + checkpatch)
|
||||
|
||||
## License
|
||||
|
||||
The stlink library and tools are licensed under the [BSD license](LICENSE). With
|
||||
some exceptions on external components.
|
11
TODO.md
11
TODO.md
|
@ -1,11 +0,0 @@
|
|||
# flash tool
|
||||
|
||||
- improve flash writing, still use word fast write... too slow
|
||||
|
||||
# documentation
|
||||
|
||||
- make README points to doc/tutorial
|
||||
|
||||
# testing
|
||||
|
||||
- compile and test a realtime kernel (e.g ChibiOS)
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/sh
|
||||
autoreconf --install --force --verbose
|
|
@ -0,0 +1,5 @@
|
|||
find_program(ZIP_LOCATION NAMES 7z.exe
|
||||
HINTS
|
||||
"C:\\Program Files\\7-Zip\\"
|
||||
"C:\\Program Files (x86)\\7-Zip\\"
|
||||
)
|
|
@ -6,28 +6,61 @@
|
|||
# LIBUSB_LIBRARY - The libraries needed to use libusb
|
||||
# LIBUSB_DEFINITIONS - Compiler switches required for using libusb
|
||||
|
||||
FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS
|
||||
/usr
|
||||
/usr/local
|
||||
/opt
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
if(WIN32 OR MINGW OR MSYS)
|
||||
set(LIBUSB_WIN_VERSION "1.0.20")
|
||||
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}/libusb-${LIBUSB_WIN_VERSION})
|
||||
|
||||
if (APPLE)
|
||||
set(LIBUSB_NAME libusb-1.0.a)
|
||||
else()
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH})
|
||||
message(STATUS "libusb archive already in build folder")
|
||||
else ()
|
||||
message(STATUS "libusb downloading ${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}
|
||||
SHOW_PROGRESS)
|
||||
endif ()
|
||||
|
||||
execute_process(COMMAND ${ZIP_LOCATION} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o${LIBUSB_WIN_OUTPUT_FOLDER})
|
||||
endif()
|
||||
|
||||
FIND_LIBRARY(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME}
|
||||
find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
|
||||
HINTS
|
||||
/usr
|
||||
/usr/local
|
||||
/opt
|
||||
${LIBUSB_WIN_OUTPUT_FOLDER}/include
|
||||
PATH_SUFFIXES libusb-1.0
|
||||
)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
if (APPLE)
|
||||
set(LIBUSB_NAME libusb-1.0.a)
|
||||
elseif(MSYS OR MINGW)
|
||||
set(LIBUSB_NAME usb-1.0)
|
||||
elseif(WIN32)
|
||||
set(LIBUSB_NAME libusb-1.0.lib)
|
||||
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 ()
|
||||
else ()
|
||||
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)
|
||||
mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY)
|
||||
|
|
59
configure.ac
59
configure.ac
|
@ -1,59 +0,0 @@
|
|||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT([stlink],[1.2.0],[davem@devkitpro.org])
|
||||
AC_CONFIG_SRCDIR([src/common.c])
|
||||
AC_CONFIG_LIBOBJ_DIR([src])
|
||||
AM_INIT_AUTOMAKE([1.10])
|
||||
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_INSTALL
|
||||
AC_CANONICAL_HOST
|
||||
AC_CANONICAL_BUILD
|
||||
AC_PROG_RANLIB
|
||||
AM_PROG_CC_C_O
|
||||
|
||||
AC_CHECK_HEADERS(sys/mman.h)
|
||||
AC_CHECK_HEADERS(sys/poll.h)
|
||||
AC_REPLACE_FUNCS(mmap)
|
||||
|
||||
if ! hash pkg-config; then
|
||||
echo "ERROR: pkg-config is needed..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checks for libraries.
|
||||
PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.0,,
|
||||
AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***]))
|
||||
AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb)
|
||||
|
||||
LIBS="$LIBS $USB_LIBS"
|
||||
CFLAGS="$CFLAGS $USB_CFLAGS"
|
||||
|
||||
case "${host}" in
|
||||
*-mingw32*)
|
||||
LIBS="$LIBS -lws2_32"
|
||||
CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CPPFLAGS"
|
||||
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
|
||||
AM_CONDITIONAL(MINGW, true)
|
||||
;;
|
||||
*)
|
||||
AM_CONDITIONAL(MINGW, false)
|
||||
esac
|
||||
|
||||
STLINK_HAS_GUI=
|
||||
AC_ARG_WITH([gtk_gui], AS_HELP_STRING([--with-gtk-gui], [enable GTK3+ gui]))
|
||||
if test "x$with_gtk_gui" = "xyes"; then
|
||||
PKG_CHECK_MODULES([GTK3], [gtk+-3.0])
|
||||
PKG_CHECK_MODULES([GLIB], [glib-2.0 > 2.32.0])
|
||||
STLINK_HAS_GUI=src/tools/gui
|
||||
AC_CONFIG_FILES([src/tools/gui/Makefile])
|
||||
fi
|
||||
AC_SUBST([STLINK_HAS_GUI])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_OUTPUT
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
Building with MinGW under Windows
|
||||
=================================
|
||||
|
||||
## Prequistes
|
||||
|
||||
* 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
|
||||
5. Create build folder in source
|
||||
|
||||
# Building
|
||||
|
||||
Check and execute `<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 uses currently `C:\Program Files\mingw-w64\x86_64-5.3.0-win32-sjlj-rt_v4-rev0\mingw64\bin`
|
|
@ -0,0 +1,10 @@
|
|||
Release
|
||||
=======
|
||||
|
||||
This document describes the steps takes for developers to create a release
|
||||
|
||||
1. Update `.version` with semantic version: `x.x.x`
|
||||
2. Update `README.md` with semantic version `x.x.x` in commits badge
|
||||
2. Create and push git tag and commits `git tag x.x.x`
|
||||
3. Create source tarball/zipfile with `make dist`
|
||||
4. Create binary package with `make package`
|
|
@ -0,0 +1,21 @@
|
|||
#!/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
|
|
@ -0,0 +1,12 @@
|
|||
###
|
||||
# MinGW64 build helper for windows
|
||||
# * Sets the correct PATH to compiler and tools
|
||||
# * Generates MinGW Makefile with CMake
|
||||
# * Build binaries with mingw32-make
|
||||
#
|
||||
# Read documentation about this file in doc/build_mingw.md
|
||||
###
|
||||
@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%
|
||||
cmake -G "MinGW Makefiles" ..
|
||||
mingw32-make
|
|
@ -15,7 +15,7 @@
|
|||
#include "stlink/logging.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#define O_BINARY 0
|
||||
#define O_BINARY 0 //! @todo get rid of this OH MY (@xor-gate)
|
||||
#endif
|
||||
|
||||
/* todo: stm32l15xxx flash memory, pm0062 manual */
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#ifdef __MINGW32__
|
||||
#include "mingw.h"
|
||||
#include <mingw.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef __MINGW32__
|
||||
#include "mingw.h"
|
||||
#include <mingw.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
bin_PROGRAMS = stlink-gui
|
||||
|
||||
stlink_gui_SOURCES = \
|
||||
stlink-gui.c \
|
||||
stlink-gui.h
|
||||
|
||||
stlink_gui_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
$(AM_CPPFLAGS) \
|
||||
-I$(top_srcdir)/src \
|
||||
@GTK3_CFLAGS@
|
||||
|
||||
stlink_gui_CFLAGS = \
|
||||
$(WARN_CFLAGS) \
|
||||
$(AM_CFLAGS) \
|
||||
-DSTLINK_UI_DIR="\"$(uidir)\""
|
||||
|
||||
stlink_gui_LDFLAGS = \
|
||||
$(AM_LDFLAGS)
|
||||
|
||||
stlink_gui_LDADD = \
|
||||
$(INTLLIBS) \
|
||||
$(top_builddir)/libstlink.a \
|
||||
@GTK3_LIBS@
|
||||
|
||||
uidir = $(pkgdatadir)/ui
|
||||
ui_DATA = stlink-gui.ui
|
||||
EXTRA_DIST = $(ui_DATA)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -45,7 +45,7 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate,
|
|||
return -1;
|
||||
} else if ((size_t)res != txsize) {
|
||||
printf("[!] send_recv send request wrote %u bytes (instead of %u).\n",
|
||||
(unsigned int)res, (unsigned int)txsize);
|
||||
(unsigned int)res, (unsigned int)txsize);
|
||||
}
|
||||
|
||||
if (rxsize != 0) {
|
||||
|
|
Ładowanie…
Reference in New Issue