kopia lustrzana https://github.com/stlink-org/stlink
rodzic
8f42f54438
commit
c7041cc2be
|
@ -81,43 +81,41 @@ endif ()
|
|||
## Define include directories to avoid absolute paths for header defines
|
||||
include_directories(${LIBUSB_INCLUDE_DIR})
|
||||
|
||||
# ====
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include) ### TODO: Clean this up...
|
||||
include_directories(${PROJECT_BINARY_DIR}/include/stlink)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include/stlink)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include/stlink/tools)
|
||||
# ====
|
||||
include_directories(${PROJECT_SOURCE_DIR}/inc) # contains top-level header files
|
||||
include_directories(${PROJECT_BINARY_DIR}/inc) # contains version.h
|
||||
|
||||
include_directories(src)
|
||||
include_directories(src/tools) ### TODO: Clean this up...
|
||||
include_directories(src/mmap)
|
||||
include_directories(src/st-flash)
|
||||
include_directories(src/stlink-lib)
|
||||
|
||||
set(STLINK_HEADERS
|
||||
include/stlink.h
|
||||
include/stlink/backend.h
|
||||
include/stlink/chipid.h
|
||||
include/stlink/commands.h
|
||||
include/stlink/flash_loader.h
|
||||
include/stlink/reg.h
|
||||
src/logging.h
|
||||
src/md5.h
|
||||
src/sg.h
|
||||
src/usb.h
|
||||
inc/stlink.h
|
||||
src/backend.h
|
||||
src/commands.h
|
||||
src/reg.h
|
||||
src/stlink-lib/chipid.h
|
||||
src/stlink-lib/flash_loader.h
|
||||
src/stlink-lib/logging.h
|
||||
src/stlink-lib/md5.h
|
||||
src/stlink-lib/sg.h
|
||||
src/stlink-lib/usb.h
|
||||
)
|
||||
|
||||
set(STLINK_SOURCE
|
||||
src/common.c
|
||||
src/chipid.c
|
||||
src/flash_loader.c
|
||||
src/logging.c
|
||||
src/md5.c
|
||||
src/sg.c
|
||||
src/usb.c
|
||||
src/stlink-lib/chipid.c
|
||||
src/stlink-lib/flash_loader.c
|
||||
src/stlink-lib/logging.c
|
||||
src/stlink-lib/md5.c
|
||||
src/stlink-lib/sg.c
|
||||
src/stlink-lib/usb.c
|
||||
)
|
||||
|
||||
if (WIN32 OR MINGW OR MSYS)
|
||||
include_directories(src/mingw)
|
||||
set(STLINK_SOURCE "${STLINK_SOURCE};src/mmap.c;src/mingw/mingw.c")
|
||||
set(STLINK_HEADERS "${STLINK_HEADERS};src/mmap.h;src/mingw/mingw.h")
|
||||
set(STLINK_SOURCE "${STLINK_SOURCE};src/mmap/mmap.c;src/mingw/mingw.c")
|
||||
set(STLINK_HEADERS "${STLINK_HEADERS};src/mmap/mmap.h;src/mingw/mingw.h")
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
|
@ -140,7 +138,7 @@ endif ()
|
|||
set(STLINK_LIBRARY_PATH ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Main library install directory")
|
||||
|
||||
# Set the environment variable LD_LIBRARY_PATH to point to /usr/local/lib (per default).
|
||||
execute_process (COMMAND bash -c "export LD_LIBRARY_PATH="${CMAKE_INSTALL_LIBDIR}" ")
|
||||
execute_process (COMMAND bash -c "export LD_LIBRARY_PATH=${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
|
||||
###
|
||||
|
@ -221,6 +219,8 @@ install(TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH})
|
|||
# Build toolset executables
|
||||
###
|
||||
|
||||
set(ST-FLASH_SOURCES src/st-flash/flash.c src/st-flash/flash_opts.c)
|
||||
set(ST-INFO_SOURCES src/st-info/info.c)
|
||||
set(ST-UTIL_SOURCES src/st-util/gdb-remote.c src/st-util/gdb-server.c src/st-util/semihosting.c)
|
||||
|
||||
if (MSVC)
|
||||
|
@ -228,8 +228,8 @@ if (MSVC)
|
|||
set(ST-UTIL_SOURCES "${ST-UTIL_SOURCES};src/getopt/getopt.c")
|
||||
endif ()
|
||||
|
||||
add_executable(st-flash src/tools/flash.c src/tools/flash_opts.c)
|
||||
add_executable(st-info src/tools/info.c)
|
||||
add_executable(st-flash ${ST-FLASH_SOURCES})
|
||||
add_executable(st-info ${ST-INFO_SOURCES})
|
||||
add_executable(st-util ${ST-UTIL_SOURCES})
|
||||
|
||||
if (WIN32 OR APPLE)
|
||||
|
@ -267,11 +267,7 @@ endif ()
|
|||
# Additional build tasks
|
||||
###
|
||||
|
||||
# ====
|
||||
add_subdirectory(include) # contains subordinate CMakeLists for version config and old header includes
|
||||
### TODO: Clean this up ...
|
||||
# ====
|
||||
|
||||
add_subdirectory(inc) # contains subordinate CMakeLists for version config
|
||||
add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI
|
||||
add_subdirectory(tests) # contains subordinate CMakeLists to build test executables
|
||||
add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages
|
||||
|
|
|
@ -8,9 +8,7 @@ In order to use pkg-config for development purposes, add the following lines to
|
|||
|
||||
## Package configuration (pkg-config) on unix-based systems
|
||||
if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
|
||||
add_subdirectory(doc/dev/pkg-config) # Option A: external tool pkg-config
|
||||
find_package(PkgConfig) # Option B: internal cmake module for pkg-config integration
|
||||
pkg_check_modules(GTK3 gtk+-3.0)
|
||||
add_subdirectory(doc/dev/pkg-config) # external tool pkg-config
|
||||
endif ()
|
||||
|
||||
ToDo: Check for compatibility issues between options A and B.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/inc/version.h.in"
|
||||
"${CMAKE_BINARY_DIR}/inc/version.h"
|
||||
)
|
||||
|
||||
file(GLOB STLINK_HEADERS "src/st-link-lib/*.h" "${CMAKE_BINARY_DIR}/inc/version.h")
|
||||
install(FILES ${STLINK_HEADERS} DESTINATION ${STLINK_INCLUDE_PATH})
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/inc/stlink.h DESTINATION ${STLINK_INCLUDE_PATH})
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/inc/stm32.h DESTINATION ${STLINK_INCLUDE_PATH})
|
|
@ -1,9 +0,0 @@
|
|||
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)
|
|
@ -12,9 +12,9 @@
|
|||
#include <sys/stat.h>
|
||||
|
||||
#include <stlink.h>
|
||||
#include "mmap.h"
|
||||
#include "logging.h"
|
||||
#include "md5.h"
|
||||
#include <mmap.h>
|
||||
#include <logging.h>
|
||||
#include <md5.h>
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include <stlink.h>
|
||||
#include <flash.h>
|
||||
#include "flash.h"
|
||||
|
||||
static stlink_t *connected_stlink = NULL;
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <flash.h>
|
||||
#include "flash.h"
|
||||
|
||||
static bool starts_with(const char * str, const char * prefix) {
|
||||
size_t n = strlen(prefix);
|
|
@ -9,70 +9,52 @@
|
|||
#include <logging.h>
|
||||
#include "semihosting.h"
|
||||
|
||||
static int mem_read_u8(stlink_t *sl, uint32_t addr, uint8_t *data)
|
||||
{
|
||||
static int mem_read_u8(stlink_t *sl, uint32_t addr, uint8_t *data) {
|
||||
int offset = addr % 4;
|
||||
int len = 4;
|
||||
|
||||
if (sl == NULL || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (sl == NULL || data == NULL) return -1;
|
||||
|
||||
/* Read address and length must be aligned */
|
||||
if (stlink_read_mem32(sl, addr - offset, len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (stlink_read_mem32(sl, addr - offset, len) != 0) return -1;
|
||||
|
||||
*data = sl->q_buf[offset];
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef UNUSED
|
||||
static int mem_read_u16(stlink_t *sl, uint32_t addr, uint16_t *data)
|
||||
{
|
||||
static int mem_read_u16(stlink_t *sl, uint32_t addr, uint16_t *data) {
|
||||
int offset = addr % 4;
|
||||
int len = (offset > 2 ? 8 : 4);
|
||||
|
||||
if (sl == NULL || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (sl == NULL || data == NULL) return -1;
|
||||
|
||||
/* Read address and length must be aligned */
|
||||
if (stlink_read_mem32(sl, addr - offset, len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (stlink_read_mem32(sl, addr - offset, len) != 0) return -1;
|
||||
|
||||
memcpy(data, &sl->q_buf[offset], sizeof(*data));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mem_read_u32(stlink_t *sl, uint32_t addr, uint32_t *data)
|
||||
{
|
||||
static int mem_read_u32(stlink_t *sl, uint32_t addr, uint32_t *data) {
|
||||
int offset = addr % 4;
|
||||
int len = (offset > 0 ? 8 : 4);
|
||||
|
||||
if (sl == NULL || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (sl == NULL || data == NULL) return -1;
|
||||
|
||||
/* Read address and length must be aligned */
|
||||
if (stlink_read_mem32(sl, addr - offset, len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (stlink_read_mem32(sl, addr - offset, len) != 0) return -1;
|
||||
|
||||
memcpy(data, &sl->q_buf[offset], sizeof(*data));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mem_read(stlink_t *sl, uint32_t addr, void *data, uint16_t len)
|
||||
{
|
||||
static int mem_read(stlink_t *sl, uint32_t addr, void *data, uint16_t len) {
|
||||
int offset = addr % 4;
|
||||
int read_len = len + offset;
|
||||
|
||||
if (sl == NULL || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (sl == NULL || data == NULL) return -1;
|
||||
|
||||
/* Align read size */
|
||||
if ((read_len % 4) != 0) {
|
||||
|
@ -80,16 +62,13 @@ static int mem_read(stlink_t *sl, uint32_t addr, void *data, uint16_t len)
|
|||
}
|
||||
|
||||
/* Address and length must be aligned */
|
||||
if (stlink_read_mem32(sl, addr - offset, read_len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (stlink_read_mem32(sl, addr - offset, read_len) != 0) return -1;
|
||||
|
||||
memcpy(data, &sl->q_buf[offset], len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mem_write(stlink_t *sl, uint32_t addr, void *data, uint16_t len)
|
||||
{
|
||||
static int mem_write(stlink_t *sl, uint32_t addr, void *data, uint16_t len) {
|
||||
// Note: this function can write more than it is asked to!
|
||||
// If addr is not an even 32 bit boundary, or len is not a multiple of 4.
|
||||
//
|
||||
|
@ -106,9 +85,7 @@ static int mem_write(stlink_t *sl, uint32_t addr, void *data, uint16_t len)
|
|||
int offset = addr % 4;
|
||||
int write_len = len + offset;
|
||||
|
||||
if (sl == NULL || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (sl == NULL || data == NULL) return -1;
|
||||
|
||||
/* Align read size */
|
||||
if ((write_len % 4) != 0) {
|
||||
|
@ -118,9 +95,7 @@ static int mem_write(stlink_t *sl, uint32_t addr, void *data, uint16_t len)
|
|||
memcpy(&sl->q_buf[offset], data, len);
|
||||
|
||||
/* Address and length must be aligned */
|
||||
if (stlink_write_mem32(sl, addr - offset, write_len) != 0) {
|
||||
return -1;
|
||||
}
|
||||
if (stlink_write_mem32(sl, addr - offset, write_len) != 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -162,9 +137,7 @@ static int saved_errno = 0;
|
|||
|
||||
int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) {
|
||||
|
||||
if (sl == NULL || ret == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (sl == NULL || ret == NULL) return -1;
|
||||
|
||||
DLOG("Do semihosting R0=0x%08x R1=0x%08x\n", r0, r1);
|
||||
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
# Build GUI
|
||||
###
|
||||
|
||||
if (NOT WIN32)
|
||||
if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(GTK3 gtk+-3.0)
|
||||
|
||||
## GUI-Building requires the presence of a GTK3 toolset
|
||||
if (NOT GTK3_FOUND)
|
||||
message(STATUS "GTK3 not found!")
|
||||
|
@ -35,7 +38,5 @@ if (NOT WIN32)
|
|||
COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/bin")
|
||||
target_link_libraries(stlink-gui ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS})
|
||||
install(TARGETS stlink-gui DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
|
||||
endif ()
|
||||
endif ()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <stlink.h>
|
||||
#include <chipid.h>
|
||||
#include "chipid.h"
|
||||
|
||||
static const struct stlink_chipid_params devices[] = {
|
||||
{
|
|
@ -3,6 +3,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include <stlink.h>
|
||||
#include "flash_loader.h"
|
||||
|
||||
#define FLASH_REGS_BANK2_OFS 0x40
|
||||
#define FLASH_BANK2_START_ADDR 0x08080000
|
||||
|
@ -11,164 +12,164 @@
|
|||
|
||||
/* flashloaders/stm32f0.s -- compiled with thumb2 */
|
||||
static const uint8_t loader_code_stm32vl[] = {
|
||||
0x16, 0x4f, 0x3c, 0x68,
|
||||
0x16, 0x4f, 0x3e, 0x68,
|
||||
0x36, 0x19, 0x16, 0x4f,
|
||||
0x3d, 0x68, 0x2d, 0x19,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0x33, 0x68, 0x3b, 0x43,
|
||||
0x33, 0x60, 0x03, 0x88,
|
||||
0x0b, 0x80, 0x4f, 0xf0,
|
||||
0x02, 0x07, 0xc0, 0x19,
|
||||
0xc9, 0x19, 0x4f, 0xf0,
|
||||
0x01, 0x07, 0x2b, 0x68,
|
||||
0x3b, 0x42, 0xfa, 0xd0,
|
||||
0x4f, 0xf0, 0x04, 0x07,
|
||||
0x3b, 0x42, 0x04, 0xd1,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0xd2, 0x1b, 0x00, 0x2a,
|
||||
0xe6, 0xd1, 0x4f, 0xf0,
|
||||
0x01, 0x07, 0x33, 0x68,
|
||||
0xbb, 0x43, 0x33, 0x60,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x50, 0x00, 0x00, 0x20,
|
||||
0x54, 0x00, 0x00, 0x20,
|
||||
0x16, 0x4f, 0x3c, 0x68,
|
||||
0x16, 0x4f, 0x3e, 0x68,
|
||||
0x36, 0x19, 0x16, 0x4f,
|
||||
0x3d, 0x68, 0x2d, 0x19,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0x33, 0x68, 0x3b, 0x43,
|
||||
0x33, 0x60, 0x03, 0x88,
|
||||
0x0b, 0x80, 0x4f, 0xf0,
|
||||
0x02, 0x07, 0xc0, 0x19,
|
||||
0xc9, 0x19, 0x4f, 0xf0,
|
||||
0x01, 0x07, 0x2b, 0x68,
|
||||
0x3b, 0x42, 0xfa, 0xd0,
|
||||
0x4f, 0xf0, 0x04, 0x07,
|
||||
0x3b, 0x42, 0x04, 0xd1,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0xd2, 0x1b, 0x00, 0x2a,
|
||||
0xe6, 0xd1, 0x4f, 0xf0,
|
||||
0x01, 0x07, 0x33, 0x68,
|
||||
0xbb, 0x43, 0x33, 0x60,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x50, 0x00, 0x00, 0x20,
|
||||
0x54, 0x00, 0x00, 0x20,
|
||||
0x58, 0x00, 0x00, 0x20
|
||||
};
|
||||
|
||||
/* flashloaders/stm32f0.s -- thumb1 only, same sequence as for STM32VL, bank ignored */
|
||||
static const uint8_t loader_code_stm32f0[] = {
|
||||
0xc0, 0x46, 0xc0, 0x46,
|
||||
0x13, 0x4f, 0x3c, 0x68,
|
||||
0x13, 0x4f, 0x3e, 0x68,
|
||||
0x36, 0x19, 0x13, 0x4f,
|
||||
0x3d, 0x68, 0x2d, 0x19,
|
||||
0x12, 0x4f, 0x33, 0x68,
|
||||
0x3b, 0x43, 0x33, 0x60,
|
||||
0x03, 0x88, 0x0b, 0x80,
|
||||
0x10, 0x4f, 0xc0, 0x19,
|
||||
0xc9, 0x19, 0x0e, 0x4f,
|
||||
0x2b, 0x68, 0x3b, 0x42,
|
||||
0xfb, 0xd0, 0x0e, 0x4f,
|
||||
0x3b, 0x42, 0x03, 0xd1,
|
||||
0x0a, 0x4f, 0xd2, 0x1b,
|
||||
0x00, 0x2a, 0xeb, 0xd1,
|
||||
0x08, 0x4f, 0x33, 0x68,
|
||||
0xbb, 0x43, 0x33, 0x60,
|
||||
0x00, 0xbe, 0xc0, 0x46,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x48, 0x00, 0x00, 0x20,
|
||||
0x4c, 0x00, 0x00, 0x20,
|
||||
0x50, 0x00, 0x00, 0x20,
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00,
|
||||
0xc0, 0x46, 0xc0, 0x46,
|
||||
0x13, 0x4f, 0x3c, 0x68,
|
||||
0x13, 0x4f, 0x3e, 0x68,
|
||||
0x36, 0x19, 0x13, 0x4f,
|
||||
0x3d, 0x68, 0x2d, 0x19,
|
||||
0x12, 0x4f, 0x33, 0x68,
|
||||
0x3b, 0x43, 0x33, 0x60,
|
||||
0x03, 0x88, 0x0b, 0x80,
|
||||
0x10, 0x4f, 0xc0, 0x19,
|
||||
0xc9, 0x19, 0x0e, 0x4f,
|
||||
0x2b, 0x68, 0x3b, 0x42,
|
||||
0xfb, 0xd0, 0x0e, 0x4f,
|
||||
0x3b, 0x42, 0x03, 0xd1,
|
||||
0x0a, 0x4f, 0xd2, 0x1b,
|
||||
0x00, 0x2a, 0xeb, 0xd1,
|
||||
0x08, 0x4f, 0x33, 0x68,
|
||||
0xbb, 0x43, 0x33, 0x60,
|
||||
0x00, 0xbe, 0xc0, 0x46,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x10, 0x00, 0x00, 0x00,
|
||||
0x0c, 0x00, 0x00, 0x00,
|
||||
0x48, 0x00, 0x00, 0x20,
|
||||
0x4c, 0x00, 0x00, 0x20,
|
||||
0x50, 0x00, 0x00, 0x20,
|
||||
0x01, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const uint8_t loader_code_stm32l[] = {
|
||||
// flashloaders/stm32lx.s
|
||||
|
||||
0x03, 0x68, 0x0b, 0x60,
|
||||
0x4f, 0xf0, 0x04, 0x07,
|
||||
0x38, 0x44, 0x39, 0x44,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0xd2, 0x1b, 0x00, 0x2a,
|
||||
0x03, 0x68, 0x0b, 0x60,
|
||||
0x4f, 0xf0, 0x04, 0x07,
|
||||
0x38, 0x44, 0x39, 0x44,
|
||||
0x4f, 0xf0, 0x01, 0x07,
|
||||
0xd2, 0x1b, 0x00, 0x2a,
|
||||
0xf4, 0xd1, 0x00, 0xbe,
|
||||
};
|
||||
|
||||
static const uint8_t loader_code_stm32f4[] = {
|
||||
// flashloaders/stm32f4.s
|
||||
|
||||
0xdf, 0xf8, 0x28, 0xc0,
|
||||
0xdf, 0xf8, 0x28, 0xa0,
|
||||
0xe2, 0x44, 0x03, 0x68,
|
||||
0x0b, 0x60, 0x00, 0xf1,
|
||||
0x04, 0x00, 0x01, 0xf1,
|
||||
0x04, 0x01, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xf0, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0xdf, 0xf8, 0x28, 0xc0,
|
||||
0xdf, 0xf8, 0x28, 0xa0,
|
||||
0xe2, 0x44, 0x03, 0x68,
|
||||
0x0b, 0x60, 0x00, 0xf1,
|
||||
0x04, 0x00, 0x01, 0xf1,
|
||||
0x04, 0x01, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xf0, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0x0e, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const uint8_t loader_code_stm32f4_lv[] = {
|
||||
// flashloaders/stm32f4lv.s
|
||||
0xdf, 0xf8, 0x2c, 0xc0,
|
||||
0xdf, 0xf8, 0x2c, 0xa0,
|
||||
0xe2, 0x44, 0x4f, 0xea,
|
||||
0x82, 0x02, 0x03, 0x78,
|
||||
0x0b, 0x70, 0x00, 0xf1,
|
||||
0x01, 0x00, 0x01, 0xf1,
|
||||
0x01, 0x01, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xf0, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0xdf, 0xf8, 0x2c, 0xc0,
|
||||
0xdf, 0xf8, 0x2c, 0xa0,
|
||||
0xe2, 0x44, 0x4f, 0xea,
|
||||
0x82, 0x02, 0x03, 0x78,
|
||||
0x0b, 0x70, 0x00, 0xf1,
|
||||
0x01, 0x00, 0x01, 0xf1,
|
||||
0x01, 0x01, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xf0, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0x0e, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const uint8_t loader_code_stm32l4[] = {
|
||||
// flashloaders/stm32l4.s
|
||||
0xdf, 0xf8, 0x2c, 0xc0,
|
||||
0xdf, 0xf8, 0x2c, 0xa0,
|
||||
0xe2, 0x44, 0x03, 0x68,
|
||||
0x44, 0x68, 0x0b, 0x60,
|
||||
0x4c, 0x60, 0x00, 0xf1,
|
||||
0x08, 0x00, 0x01, 0xf1,
|
||||
0x08, 0x01, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xee, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0xdf, 0xf8, 0x2c, 0xc0,
|
||||
0xdf, 0xf8, 0x2c, 0xa0,
|
||||
0xe2, 0x44, 0x03, 0x68,
|
||||
0x44, 0x68, 0x0b, 0x60,
|
||||
0x4c, 0x60, 0x00, 0xf1,
|
||||
0x08, 0x00, 0x01, 0xf1,
|
||||
0x08, 0x01, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xee, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x20, 0x02, 0x40,
|
||||
0x12, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const uint8_t loader_code_stm32f7[] = {
|
||||
// flashloaders/stm32f7.s
|
||||
0xdf, 0xf8, 0x2c, 0xc0,
|
||||
0xdf, 0xf8, 0x2c, 0xa0,
|
||||
0xe2, 0x44, 0x03, 0x68,
|
||||
0x0b, 0x60, 0x00, 0xf1,
|
||||
0x04, 0x00, 0x01, 0xf1,
|
||||
0x04, 0x01, 0xbf, 0xf3,
|
||||
0x4f, 0x8f, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xee, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0xdf, 0xf8, 0x2c, 0xc0,
|
||||
0xdf, 0xf8, 0x2c, 0xa0,
|
||||
0xe2, 0x44, 0x03, 0x68,
|
||||
0x0b, 0x60, 0x00, 0xf1,
|
||||
0x04, 0x00, 0x01, 0xf1,
|
||||
0x04, 0x01, 0xbf, 0xf3,
|
||||
0x4f, 0x8f, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xee, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0x0e, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const uint8_t loader_code_stm32f7_lv[] = {
|
||||
// flashloaders/stm32f7lv.s
|
||||
0xdf, 0xf8, 0x30, 0xc0,
|
||||
0xdf, 0xf8, 0x30, 0xa0,
|
||||
0xe2, 0x44, 0x4f, 0xea,
|
||||
0x82, 0x02, 0x03, 0x78,
|
||||
0x0b, 0x70, 0x00, 0xf1,
|
||||
0x01, 0x00, 0x01, 0xf1,
|
||||
0x01, 0x01, 0xbf, 0xf3,
|
||||
0x4f, 0x8f, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xee, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0xdf, 0xf8, 0x30, 0xc0,
|
||||
0xdf, 0xf8, 0x30, 0xa0,
|
||||
0xe2, 0x44, 0x4f, 0xea,
|
||||
0x82, 0x02, 0x03, 0x78,
|
||||
0x0b, 0x70, 0x00, 0xf1,
|
||||
0x01, 0x00, 0x01, 0xf1,
|
||||
0x01, 0x01, 0xbf, 0xf3,
|
||||
0x4f, 0x8f, 0xba, 0xf8,
|
||||
0x00, 0x30, 0x13, 0xf0,
|
||||
0x01, 0x0f, 0xfa, 0xd0,
|
||||
0xa2, 0xf1, 0x01, 0x02,
|
||||
0x00, 0x2a, 0xee, 0xd1,
|
||||
0x00, 0xbe, 0x00, 0xbf,
|
||||
0x00, 0x3c, 0x02, 0x40,
|
||||
0x0e, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
|
@ -84,6 +84,7 @@
|
|||
|
||||
#include <stlink.h>
|
||||
#include "logging.h"
|
||||
#include "sg.h"
|
||||
|
||||
#define STLINK_OK 0x80
|
||||
#define STLINK_FALSE 0x81
|
|
@ -8,8 +8,8 @@
|
|||
#ifndef STLINK_SG_H
|
||||
#define STLINK_SG_H
|
||||
|
||||
#include "libusb_settings.h"
|
||||
#include <stlink.h>
|
||||
#include <libusb_settings.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
|
@ -14,6 +14,7 @@
|
|||
#include <mingw.h>
|
||||
#endif
|
||||
#include <stlink.h>
|
||||
#include "usb.h"
|
||||
|
||||
enum SCSI_Generic_Direction {SG_DXFER_TO_DEV=0, SG_DXFER_FROM_DEV=0x80};
|
||||
|
||||
|
@ -1147,7 +1148,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, int reset, char serial[STL
|
|||
|
||||
if (reset == 2) {
|
||||
stlink_jtag_reset(sl,0);
|
||||
if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl);
|
||||
if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl);
|
||||
stlink_force_debug(sl);
|
||||
stlink_jtag_reset(sl,1);
|
||||
usleep(10000);
|
|
@ -11,7 +11,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#include <stlink.h>
|
||||
#include "libusb_settings.h"
|
||||
#include <libusb_settings.h>
|
||||
#include "logging.h"
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -11,6 +11,6 @@ foreach (test ${TESTEXEC})
|
|||
add_test(test-${test} ${CMAKE_BINARY_DIR}/bin/test-${test})
|
||||
endforeach ()
|
||||
|
||||
add_executable(test-flash flash.c "${CMAKE_SOURCE_DIR}/src/tools/flash_opts.c")
|
||||
add_executable(test-flash flash.c "${CMAKE_SOURCE_DIR}/src/st-flash/flash_opts.c")
|
||||
target_link_libraries(test-flash ${STLINK_LIB_SHARED} ${SSP_LIB})
|
||||
add_test(test-flash ${CMAKE_BINARY_DIR}/bin/test-flash)
|
||||
|
|
Ładowanie…
Reference in New Issue