Skip to content

Commit

Permalink
Merge branch 'deprecate-autotools' into deprecate_autotools
Browse files Browse the repository at this point in the history
* deprecate-autotools:
  Integrate with AppVeyor CI, make MinGW32 and 64 work again
  Add flash loader core id and chipid for STM32F767ZI with nucleo-144
  flash_loader.c: Add STLINK_CHIPID_STM32_F7XXXX
  Check empty TRAVIS_TAG
  Obey to git 1.8
  usb.c: Fix warning in printf format with size_t
  Try again...
  CMakeLists: Fixup tag version fetching
  Initial support for STM32F7x7x, for nucleo-144, STM32F767ZI issue #433
  Blaat
  Deprecate autotools build system
  • Loading branch information
xor-gate committed Jun 19, 2016
2 parents 226e315 + b220d20 commit 4ccf470
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 27 deletions.
20 changes: 20 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 28 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ else ()
endif()

find_package(LibUSB REQUIRED)
if (NOT APPLE)
if(WIN32)
find_package(7Zip REQUIRED)
message(STATUS "7Zip Location: " ${ZIP_LOCATION})
endif()

find_package(LibUSB REQUIRED)
if (NOT APPLE AND NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(gtk gtk+-3.0)
endif ()
Expand Down Expand Up @@ -75,7 +81,17 @@ 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 STREQUAL "")
set (CMAKE_BUILD_TYPE "Debug")
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "")
set (CMAKE_BUILD_TYPE "Debug")
Expand Down Expand Up @@ -111,6 +127,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)
Expand All @@ -125,7 +145,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})
Expand All @@ -137,7 +157,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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Open source version of the STMicroelectronics Stlink Tools

[![GitHub release](https://img.shields.io/github/release/texane/stlink.svg?maxAge=2592000)](https://github.com/texane/stlink/releases/latest)
[![GitHub commits](https://img.shields.io/github/commits-since/texane/stlink/1.2.0.svg?maxAge=2592000)](https://github.com/texane/stlink/compare/1.2.0...master)
[![Build Status](https://travis-ci.org/texane/stlink.svg?branch=master)](https://travis-ci.org/texane/stlink)
[![Linux Status](https://img.shields.io/travis/texane/stlink/master.svg?label=linux)](https://travis-ci.org/texane/stlink)
[![Windows Status](https://ci.appveyor.com/api/projects/status/o659serc9m21n22n/branch/appveyor-integration?svg=true)](https://ci.appveyor.com/project/xor-gate/stlink)
[![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE)

## HOWTO
Expand Down
5 changes: 5 additions & 0 deletions cmake/modules/Find7Zip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
find_program(ZIP_LOCATION NAMES 7z.exe
HINTS
"C:\\Program Files\\7-Zip\\"
"C:\\Program Files (x86)\\7-Zip\\"
)
61 changes: 47 additions & 14 deletions cmake/modules/FindLibUSB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions include/stlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern "C" {
/* cortex core ids */
// TODO clean this up...
#define STM32VL_CORE_ID 0x1ba01477
#define STM32F7_CORE_ID 0x5ba02477

// Constant STM32 memory map figures
#define STM32_FLASH_BASE 0x08000000
Expand Down
1 change: 1 addition & 0 deletions include/stlink/chipid.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum stlink_stm32_chipids {
STLINK_CHIPID_STM32_L0_CAT5 = 0x447,
STLINK_CHIPID_STM32_F0_CAN = 0x448,
STLINK_CHIPID_STM32_F7 = 0x449,
STLINK_CHIPID_STM32_F7XXXX = 0x451,
STLINK_CHIPID_STM32_F410 = 0x458
};

Expand Down
21 changes: 21 additions & 0 deletions scripts/appveyor-mingw.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions src/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
#include "stlink/chipid.h"

static const struct stlink_chipid_params devices[] = {
{
//RM0410 document was used to find these paramaters
.chip_id = STLINK_CHIPID_STM32_F7XXXX,
.description = "F76xxx device",
.flash_type = STLINK_FLASH_TYPE_F4,
.flash_size_reg = 0x1ff0f442, // section 45.2
.flash_pagesize = 0x800, // No flash pages
.sram_size = 0x5C000, // "SRAM" byte size in hex from
.bootrom_base = 0x00200000, //! "System memory" starting address from
.bootrom_size = 0xEDC0 //! @todo "System memory" byte size in hex from
},
{
//RM0385 and DS10916 document was used to find these paramaters
.chip_id = STLINK_CHIPID_STM32_F7,
Expand Down
2 changes: 1 addition & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 5 additions & 3 deletions src/flash_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t*
|| sl->chip_id == STLINK_CHIPID_STM32_L0 || sl->chip_id == STLINK_CHIPID_STM32_L0_CAT5 || sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) { /* stm32l */
loader_code = loader_code_stm32l;
loader_size = sizeof(loader_code_stm32l);
} else if (sl->core_id == STM32VL_CORE_ID
} else if (sl->core_id == STM32VL_CORE_ID
|| sl->chip_id == STLINK_CHIPID_STM32_F3
|| sl->chip_id == STLINK_CHIPID_STM32_F3_SMALL
|| sl->chip_id == STLINK_CHIPID_STM32_F303_HIGH
Expand Down Expand Up @@ -231,7 +231,9 @@ int stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t*
loader_code = loader_code_stm32f4_lv;
loader_size = sizeof(loader_code_stm32f4_lv);
}
} else if (sl->chip_id == STLINK_CHIPID_STM32_F7){
} else if (sl->core_id == STM32F7_CORE_ID ||
sl->chip_id == STLINK_CHIPID_STM32_F7 ||
sl->chip_id == STLINK_CHIPID_STM32_F7XXXX) {
loader_code = loader_code_stm32f7;
loader_size = sizeof(loader_code_stm32f7);
} else if (sl->chip_id == STLINK_CHIPID_STM32_F0 || sl->chip_id == STLINK_CHIPID_STM32_F04 || sl->chip_id == STLINK_CHIPID_STM32_F0_CAN || sl->chip_id == STLINK_CHIPID_STM32_F0_SMALL || sl->chip_id == STLINK_CHIPID_STM32_F09X) {
Expand All @@ -241,7 +243,7 @@ int stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t*
loader_code = loader_code_stm32l4;
loader_size = sizeof(loader_code_stm32l4);
} else {
ELOG("unknown coreid, not sure what flash loader to use, aborting!: %x\n", sl->core_id);
ELOG("unknown coreid, not sure what flash loader to use, aborting! coreid: %x, chipid: %x\n", sl->core_id, sl->chip_id);
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/gdbserver/gdb-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/gdbserver/gdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 4ccf470

Please sign in to comment.