From 156871d55efc1b53a8efceafb64318198d819252 Mon Sep 17 00:00:00 2001 From: WRR <-@-> Date: Mon, 12 Aug 2019 11:37:00 -0700 Subject: [PATCH 001/236] Add support for STM32G031 and STM32G041 chips. Including the 8-pin STM32G031J6 :D --- include/stlink/chipid.h | 3 ++- src/chipid.c | 13 ++++++++++++- src/common.c | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index a4f4be4c0..9ff8c814f 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -71,7 +71,8 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F410 = 0x458, STLINK_CHIPID_STM32_F413 = 0x463, STLINK_CHIPID_STM32_L4RX = 0x470, // taken from the STM32L4R9I-DISCO board - STLINK_CHIPID_STM32_G0X1 = 0x460, + STLINK_CHIPID_STM32_G0_CAT1 = 0x466, // G031/041 + STLINK_CHIPID_STM32_G0_CAT2 = 0x460, // G071/081 STLINK_CHIPID_STM32_WB55 = 0x495 }; diff --git a/src/chipid.c b/src/chipid.c index d627849a3..7b7bc88d0 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -521,9 +521,20 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1ff00000, .bootrom_size = 0x2000 }, + { + // STM32G031/041 (from RM0444) + .chip_id = STLINK_CHIPID_STM32_G0_CAT1, + .description = "G031/G041 device", + .flash_type = STLINK_FLASH_TYPE_G0, + .flash_size_reg = 0x1FFF75E0, // Section 38.2 + .flash_pagesize = 0x800, // 2K (sec 3.2) + .sram_size = 0x2000, // 8K (sec 2.3) + .bootrom_base = 0x1fff0000, + .bootrom_size = 0x7800 // 30K (table 3) + }, { // STM32G071/081 (from RM0444) - .chip_id = STLINK_CHIPID_STM32_G0X1, + .chip_id = STLINK_CHIPID_STM32_G0_CAT2, .description = "G071/G081 device", .flash_type = STLINK_FLASH_TYPE_G0, .flash_size_reg = 0x1FFF75E0, // Section 38.2 diff --git a/src/common.c b/src/common.c index b4741a585..f974d77ab 100644 --- a/src/common.c +++ b/src/common.c @@ -2520,7 +2520,7 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui stlink_core_id(sl); /* Check if chip is supported and for correct address */ - if((sl->chip_id != STLINK_CHIPID_STM32_G0X1) || (addr != STM32_G0_OPTION_BYTES_BASE)) { + if((sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2 && sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1) || (addr != STM32_G0_OPTION_BYTES_BASE)) { ELOG("Option bytes writing is currently only supported for the STM32G0\n"); return -1; } From 302dc872f4b73f13a94ff2e9f0359c4195f6279c Mon Sep 17 00:00:00 2001 From: zx81a Date: Tue, 5 Nov 2019 10:24:22 +0100 Subject: [PATCH 002/236] Support for STM31L4, SM32L1 option bytes write. --- debian/rules | 2 +- include/stm32.h | 3 + src/common.c | 191 +++++++++++++++++++++++++++++++++++++++++++++- src/tools/flash.c | 2 +- 4 files changed, 194 insertions(+), 4 deletions(-) diff --git a/debian/rules b/debian/rules index e228a7087..e183fffb7 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,7 @@ #!/usr/bin/make -f # See debhelper(7) (uncomment to enable) # output every command that modifies files on the build system. -#DH_VERBOSE = 1 +DH_VERBOSE = 1 # see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/* DPKG_EXPORT_BUILDFLAGS = 1 diff --git a/include/stm32.h b/include/stm32.h index 8f8e7eba1..9a01baaf4 100644 --- a/include/stm32.h +++ b/include/stm32.h @@ -17,4 +17,7 @@ #define STM32_G0_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) #define STM32_L0_CAT2_OPTION_BYTES_BASE ((uint32_t)0x1FF80000) #define STM32_F2_OPTION_BYTES_BASE ((uint32_t)0x1FFFC000) +#define STM32_L496X_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) +#define STM32_L1_OPTION_BYTES_BASE ((uint32_t)0x1FF80000) + #endif /* STM32_H */ diff --git a/src/common.c b/src/common.c index 99bd7a842..4d976f49f 100644 --- a/src/common.c +++ b/src/common.c @@ -137,6 +137,7 @@ //32L4 register base is at FLASH_REGS_ADDR (0x40022000) #define STM32L4_FLASH_KEYR (FLASH_REGS_ADDR + 0x08) +#define STM32L4_FLASH_OPTKEYR (FLASH_REGS_ADDR + 0x0C) #define STM32L4_FLASH_SR (FLASH_REGS_ADDR + 0x10) #define STM32L4_FLASH_CR (FLASH_REGS_ADDR + 0x14) #define STM32L4_FLASH_OPTR (FLASH_REGS_ADDR + 0x20) @@ -145,13 +146,16 @@ #define STM32L4_FLASH_SR_ERRMASK 0x3f8 /* SR [9:3] */ #define STM32L4_FLASH_CR_LOCK 31 /* Lock control register */ +#define STM32L4_FLASH_CR_OPTLOCK 30 /* Lock option bytes */ #define STM32L4_FLASH_CR_PG 0 /* Program */ #define STM32L4_FLASH_CR_PER 1 /* Page erase */ #define STM32L4_FLASH_CR_MER1 2 /* Bank 1 erase */ #define STM32L4_FLASH_CR_MER2 15 /* Bank 2 erase */ #define STM32L4_FLASH_CR_STRT 16 /* Start command */ +#define STM32L4_FLASH_CR_OPTSTRT 17 /* Start writing option bytes */ #define STM32L4_FLASH_CR_BKER 11 /* Bank select for page erase */ #define STM32L4_FLASH_CR_PNB 3 /* Page number (8 bits) */ +#define STM32L4_FLASH_CR_OBL_LAUNCH 27 /* Option bytes reload */ // Bits requesting flash operations (useful when we want to clear them) #define STM32L4_FLASH_CR_OPBITS \ ((1lu<chip_id,addr); + /* Check if chip is supported and for correct address */ if((sl->chip_id == STLINK_CHIPID_STM32_G0X1) && (addr == STM32_G0_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_g0x1(sl, base, len); @@ -2847,8 +3027,15 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui else if((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_l0_cat2(sl, base, len); } + else if((sl->chip_id == STLINK_CHIPID_STM32_L496X) && (addr == STM32_L496X_OPTION_BYTES_BASE)) { + return stlink_write_option_bytes_l496x(sl, base, len); + } + else if( ( (sl->chip_id == STLINK_CHIPID_STM32_L152_RE) || (sl->chip_id == STLINK_CHIPID_STM32_L1_HIGH) ) + && ( (addr == STM32_L1_OPTION_BYTES_BASE) || (addr == STM32_L1_OPTION_BYTES_BASE+4) ) ) { + return stlink_write_option_bytes_l1(sl, base, addr, len); + } else { - ELOG("Option bytes writing is currently only supported for the STM32F2, STM32G0 and STM32L0\n"); + ELOG("Option bytes writing is currently only supported for the STM32F2, STM32G0, STM32L496x/L4A6x, STM32L1 and STM32L0\n"); return -1; } diff --git a/src/tools/flash.c b/src/tools/flash.c index f5fd1a386..1b63b1696 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -164,7 +164,7 @@ int main(int ac, char** av) goto on_error; } } - else if (o.addr == STM32_G0_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE){ + else if (o.addr == STM32_G0_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE + 4){ err = stlink_fwrite_option_bytes(sl, o.filename, o.addr); if (err == -1) { From 8f6314078b6fe3221008518888474aa008cfda3d Mon Sep 17 00:00:00 2001 From: Mark Odell Date: Mon, 23 Dec 2019 14:25:37 -0500 Subject: [PATCH 003/236] Improved support for STM32G0xx series parts - Now properly distinguish between the smaller and larger variants - Added support for the smaller variants, 'G030, 'G031, and 'G041 - Now flashes and debugs STM32G031K8 MCU --- include/stlink/chipid.h | 3 ++- src/chipid.c | 17 ++++++++++++++--- src/common.c | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index a4f4be4c0..ae665efd3 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -71,7 +71,8 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F410 = 0x458, STLINK_CHIPID_STM32_F413 = 0x463, STLINK_CHIPID_STM32_L4RX = 0x470, // taken from the STM32L4R9I-DISCO board - STLINK_CHIPID_STM32_G0X1 = 0x460, + STLINK_CHIPID_STM32_G07X = 0x460, // Actually, 'G070 and 'G071/081 + STLINK_CHIPID_STM32_G03X = 0x466, // Actually, 'G030 and 'G031/041 STLINK_CHIPID_STM32_WB55 = 0x495 }; diff --git a/src/chipid.c b/src/chipid.c index d627849a3..2fd860223 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -522,9 +522,9 @@ static const struct stlink_chipid_params devices[] = { .bootrom_size = 0x2000 }, { - // STM32G071/081 (from RM0444) - .chip_id = STLINK_CHIPID_STM32_G0X1, - .description = "G071/G081 device", + // STM32G071/081 (from RM0454 & RM0444) + .chip_id = STLINK_CHIPID_STM32_G07X, + .description = "G070/G071/G081 device", .flash_type = STLINK_FLASH_TYPE_G0, .flash_size_reg = 0x1FFF75E0, // Section 38.2 .flash_pagesize = 0x800, // 2K (sec 3.2) @@ -532,6 +532,17 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7800 // 30K (table 2) }, + { + // STM32G031/041 (from RM0454 & RM0444) + .chip_id = STLINK_CHIPID_STM32_G03X, + .description = "G030/G031/G041 device", + .flash_type = STLINK_FLASH_TYPE_G0, + .flash_size_reg = 0x1FFF75E0, // Section 38.2 + .flash_pagesize = 0x800, // 2K (sec 3.2) + .sram_size = 0x2000, // 8K (sec 2.3) + .bootrom_base = 0x1fff0000, + .bootrom_size = 0x2000 // 8k (table 2) + }, { // STM32WB55 (from RM0434) .chip_id = STLINK_CHIPID_STM32_WB55, diff --git a/src/common.c b/src/common.c index 99bd7a842..ee65018ba 100644 --- a/src/common.c +++ b/src/common.c @@ -2535,7 +2535,7 @@ static int stlink_write_option_bytes_g0x1(stlink_t *sl, uint8_t* base, uint32_t uint32_t val; if(len != 4) { - ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); + ELOG("Wrong length for writing option bytes, must be 4 is %d\n", len); return -1; } @@ -2841,7 +2841,7 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui stlink_core_id(sl); /* Check if chip is supported and for correct address */ - if((sl->chip_id == STLINK_CHIPID_STM32_G0X1) && (addr == STM32_G0_OPTION_BYTES_BASE)) { + if (((sl->chip_id == STLINK_CHIPID_STM32_G07X) || (sl->chip_id == STLINK_CHIPID_STM32_G03X)) && (addr == STM32_G0_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_g0x1(sl, base, len); } else if((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { From 5a5c3d71d7568070bc108e7501ff977ad94d653c Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Fri, 21 Feb 2020 06:53:28 +0200 Subject: [PATCH 004/236] --- --- src/common.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/common.c b/src/common.c index bef3a5e3d..018e01c4c 100644 --- a/src/common.c +++ b/src/common.c @@ -2631,15 +2631,6 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l return -1; } - // Make sure we've loaded the context with the chip details - stlink_core_id(sl); - - /* Check if chip is supported and for correct address */ - if((sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2 && sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1) || (addr != STM32_G0_OPTION_BYTES_BASE)) { - ELOG("Option bytes writing is currently only supported for the STM32G0\n"); - return -1; - } - /* Unlock flash if necessary (ref manuel page 52) */ stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); if ((val & (1u << STM32Gx_FLASH_CR_LOCK))) { From afaded2782ca193841198a5451b2bec89998a7e3 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 22 Feb 2020 17:50:31 +0100 Subject: [PATCH 005/236] General Project Update - Formatting fixes in CHANGELOG.md - Added comment in .travis.sh - Update for .travis.yml: gcc/g++ v5->v6 --- .travis.sh | 2 +- .travis.yml | 13 ++++++++----- CHANGELOG.md | 14 +++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.travis.sh b/.travis.sh index 06e95ef80..05568d37d 100755 --- a/.travis.sh +++ b/.travis.sh @@ -8,7 +8,7 @@ echo "----" if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq || true sudo apt-get install -qq -y --no-install-recommends libgtk-3-dev -else +else #("$TRAVIS_OS_NAME" == "osx") brew install libusb fi diff --git a/.travis.yml b/.travis.yml index c878be799..b0f985012 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,24 @@ -language: c + compiler: - gcc - clang + +language: c + os: - linux - osx + addons: apt: sources: -# - llvm-toolchain-precise-3.8 - sourceline: 'ppa:ubuntu-toolchain-r/test' packages: - clang -# - clang-3.8 - - g++-5 - - gcc-5 + - g++-6 + - gcc-6 - libusb-1.0.0-dev + script: - git fetch --tags - printenv diff --git a/CHANGELOG.md b/CHANGELOG.md index f122e77ec..25abd0a54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Release date: 2020-02-20 Major changes and added features: * Added O_BINARY option to open file ([#753](https://github.com/texane/stlink/pull/753)) -* Added preliminary support for some STM32G0 chips ([#759](https://github.com/texane/stlink/pull/759)) ([#760](https://github.com/texane/stlink/pull/760)) +* Added preliminary support for some STM32G0 chips ([#759](https://github.com/texane/stlink/pull/759), [#760](https://github.com/texane/stlink/pull/760)) * Added support for mass erasing second bank on STM32F10x_XL ([#767](https://github.com/texane/stlink/pull/767)) * Added call to clear PG bit after writing to flash ([#773](https://github.com/texane/stlink/pull/773)) * Added howto for sending NRST signal through GDB ([#776](https://github.com/texane/stlink/pull/776)) @@ -39,7 +39,7 @@ Updates and fixes: * Fixed package name "devscripts" in doc/compiling.md ([#775](https://github.com/texane/stlink/pull/775)) * Fixed apparent STM32G0 flashing issue ([#797](https://github.com/texane/stlink/pull/797)) * Fixed few potential memory/resource leaks ([#803](https://github.com/texane/stlink/pull/803)) -* Fixed flash verification error on STM32WB55RG ([#810](https://github.com/texane/stlink/pull/810)) ([#816](https://github.com/texane/stlink/pull/816)) +* Fixed flash verification error on STM32WB55RG ([#810](https://github.com/texane/stlink/pull/810), [#816](https://github.com/texane/stlink/pull/816)) * Do not issue JTAG reset on stlink-v1 (Gwenhael Goavec-Merou) * Fixed flash size of STM32 Discovery vl (Gwenhael Goavec-Merou) * Added support for writing option bytes on STM32L0 (Adrian Imboden) @@ -63,10 +63,10 @@ Major changes and added features: * Updated libusb to 1.0.22 ([#695](https://github.com/texane/stlink/pull/695)) * Added desktop file for linux ([#688](https://github.com/texane/stlink/pull/688)) * Added icons for stlink GUI ([#697](https://github.com/texane/stlink/pull/697)) -* Added support for STM32L4R9 target ([#694](https://github.com/texane/stlink/pull/694), [#699](https://github.com/texane/stlink/pull/699) +* Added support for STM32L4R9 target ([#694](https://github.com/texane/stlink/pull/694), [#699](https://github.com/texane/stlink/pull/699)) * Added creation of icons for .desktop file ([#708](https://github.com/texane/stlink/pull/708)) * Added memory map for STM32F411RE target ([#709](https://github.com/texane/stlink/pull/709)) -* Added reset through AIRCR ([#540](https://github.com/texane/stlink/pull/540), [#712](https://github.com/texane/stlink/pull/712) +* Added reset through AIRCR ([#540](https://github.com/texane/stlink/pull/540), [#712](https://github.com/texane/stlink/pull/712)) * Implemented intel hex support for GTK GUI ([#718](https://github.com/texane/stlink/pull/718)) Fixes: @@ -74,12 +74,12 @@ Fixes: * Fixed missing flash_loader for L011 ([#675](https://github.com/texane/stlink/pull/675)) * Fixed serial number size mismatch with stlink_open_usb() ([#680](https://github.com/texane/stlink/pull/680)) * Debian packaging, CMake and README.md fixes ([#683](https://github.com/texane/stlink/pull/683)) -* Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696) -* Fix for libusb deprecation ([#703](https://github.com/texane/stlink/pull/703), [#704](https://github.com/texane/stlink/pull/704) +* Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696)) +* Fix for libusb deprecation ([#703](https://github.com/texane/stlink/pull/703), [#704](https://github.com/texane/stlink/pull/704)) * Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX ([#706](https://github.com/texane/stlink/pull/706)) * Fixed flash memory map for F72XXX target ([#711](https://github.com/texane/stlink/pull/711)) * Proper flash page size calculation for F412 target ([#721](https://github.com/texane/stlink/pull/721)) -* Return correct value on EOF for Semihosting SYS_READ ([#725](https://github.com/texane/stlink/pull/725), [#726](https://github.com/texane/stlink/pull/726, [#729](https://github.com/texane/stlink/pull/729, [#731](https://github.com/texane/stlink/pull/731) +* Return correct value on EOF for Semihosting SYS_READ ([#725](https://github.com/texane/stlink/pull/725), [#726](https://github.com/texane/stlink/pull/726), [#729](https://github.com/texane/stlink/pull/729), [#731](https://github.com/texane/stlink/pull/731)) * Fix for mem_write() ([#730](https://github.com/texane/stlink/pull/730)) * FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733)) From 83a31a09b358021a3b6b65962f7ea4c6550f0289 Mon Sep 17 00:00:00 2001 From: Slyshyk Oleksiy Date: Sat, 29 Feb 2020 16:23:22 +0200 Subject: [PATCH 006/236] Add win32 travis build (#2) * add mingw64 build to travis CI * Make .travis-lin-mingw.sh executable * .travis-lin-mingw.sh: make build dir * show $PWD in travis-lin-mingw * update .travis-lin-mingw.sh * --- * update .travis-lin-mingw.sh * update p7zip cmd * fix sign/unsign comparioson in usb.c * revert call .travis.sh * clean up .travis-lin-mingw.sh --- .travis-lin-mingw.sh | 14 ++++++++++++++ .travis.yml | 3 +++ cmake/modules/FindLibUSB.cmake | 3 ++- src/usb.c | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 .travis-lin-mingw.sh diff --git a/.travis-lin-mingw.sh b/.travis-lin-mingw.sh new file mode 100755 index 000000000..0422a06f6 --- /dev/null +++ b/.travis-lin-mingw.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DIR=$PWD + +if [ "$TRAVIS_OS_NAME" == "linux" ]; then + echo "WORK DIR:$DIR" + mkdir -p $DIR/build/linux-mingw32-release + cd $DIR/build/linux-mingw32-release + echo "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + echo "make" + make +fi + diff --git a/.travis.yml b/.travis.yml index b0f985012..b1832d57f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,9 +18,12 @@ addons: - g++-6 - gcc-6 - libusb-1.0.0-dev + - p7zip + - mingw-w64 script: - git fetch --tags - printenv - cmake --version - ./.travis.sh + - ./.travis-lin-mingw.sh diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index 5233e489d..2ad35b3d8 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -84,7 +84,8 @@ if(NOT LIBUSB_FOUND) 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 --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() diff --git a/src/usb.c b/src/usb.c index 9df9d7296..81bd7ae2c 100644 --- a/src/usb.c +++ b/src/usb.c @@ -189,7 +189,7 @@ int _stlink_usb_version(stlink_t *sl) { cmd[i++] = STLINK_APIV3_GET_VERSION_EX; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); - if (size != rep_len) { + if (size != (ssize_t)rep_len) { printf("[!] send_recv STLINK_APIV3_GET_VERSION_EX\n"); return (int) size; } From 4d55b6b3bf2bfecab3251fbe966c86eaad4e027a Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sun, 1 Mar 2020 18:47:59 +0200 Subject: [PATCH 007/236] make Version.cmake more error-resistant. fix #772 --- cmake/Version.cmake | 103 +++++++++++++++++++++++++++++--------------- 1 file changed, 69 insertions(+), 34 deletions(-) diff --git a/cmake/Version.cmake b/cmake/Version.cmake index e74d775d6..e5ce9f4c6 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -1,7 +1,11 @@ # Determine project version # * Using Git # * Local .version file -find_package (Git QUIET) + +set(__detect_version 0) + +find_package (Git) + if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") # Working off a git repo, using git versioning # Check if HEAD is pointing to a tag @@ -9,43 +13,74 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") COMMAND "${GIT_EXECUTABLE}" describe --always --tag WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" OUTPUT_VARIABLE PROJECT_VERSION + RESULT_VARIABLE GIT_DESCRIBE_RESULT + ERROR_VARIABLE GIT_DESCRIBE_ERROR 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 (PROJECT_VERSION "${PROJECT_VERSION}-dirty") - endif() - - # strip a leading v off of the version as proceeding code expectes just the version numbering. - string(REGEX REPLACE "^v" "" PROJECT_VERSION ${PROJECT_VERSION}) - - 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}) - list(LENGTH PROJECT_VERSION_LIST len) - if(len EQUAL 3) - list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR) - list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) - list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) - 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 PROJECT_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}) - list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR) - list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) - list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) + if(GIT_DESCRIBE_RESULT EQUAL 0) + # 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 (PROJECT_VERSION "${PROJECT_VERSION}-dirty") + endif() + + # strip a leading v off of the version as proceeding code expectes just the version numbering. + string(REGEX REPLACE "^v" "" PROJECT_VERSION ${PROJECT_VERSION}) + + 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}) + list(LENGTH PROJECT_VERSION_LIST len) + if(len EQUAL 3) + list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR) + list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) + list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) + set(__detect_version 1) + else() + message(STATUS "Fail to extract version's parts from \"${PROJECT_VERSION}\"") + endif() + + else(GIT_DESCRIBE_RESULT EQUAL 0) + message(WARNING "git describe failed.") + message(WARNING "${GIT_DESCRIBE_ERROR}") + endif(GIT_DESCRIBE_RESULT EQUAL 0) else() - message(FATAL_ERROR "Unable to determine project version") + 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) + # If git is not available (e.g. when building from source package) + # we can extract the package version from .version file. + file (STRINGS .version PROJECT_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}) + list(LENGTH PROJECT_VERSION_LIST len) + if(len EQUAL 3) + list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR) + list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) + list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) + set(__detect_version 1) + else() + message(STATUS "Fail to extract version's parts from \"${PROJECT_VERSION}\"") + endif() + else() + message(STATUS "File \"${PROJECT_SOURCE_DIR}/.version\" did not exists.") + endif() +endif() + +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}") From ecf86c735bdcdb82b098de52b5656c0d8ca94302 Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sun, 1 Mar 2020 22:39:43 +0200 Subject: [PATCH 008/236] compare git version with .version --- .version | 2 +- cmake/Version.cmake | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.version b/.version index dc1e644a1..ce6a70b9d 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.6.0 +1.6.0 \ No newline at end of file diff --git a/cmake/Version.cmake b/cmake/Version.cmake index e5ce9f4c6..2ca1c0ff8 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -39,6 +39,15 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) set(__detect_version 1) + set(__version_str "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + if(EXISTS "${PROJECT_SOURCE_DIR}/.version") + file(READ "${PROJECT_SOURCE_DIR}/.version" __version_file) + if(NOT __version_str STREQUAL __version_file) + message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}") + endif() + else() + file(WRITE "${PROJECT_SOURCE_DIR}/.version" ${__version_str}) + endif() else() message(STATUS "Fail to extract version's parts from \"${PROJECT_VERSION}\"") endif() From 268313bcabec25086eb7be51abd0012722bd0d48 Mon Sep 17 00:00:00 2001 From: Lutz Freitag Date: Sun, 15 Mar 2020 11:19:03 +0100 Subject: [PATCH 009/236] clear the PG bit before setting the PER bit after the flash loader ran the PG bit is still set in the CR register. in order to program the next page that page needs to be erased first and to get that working the PG bit has to be cleared so the flash controller knows what to do. this fixes #579 --- src/common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common.c b/src/common.c index 6226c893b..95e504f9e 100644 --- a/src/common.c +++ b/src/common.c @@ -1893,6 +1893,9 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) /* unlock if locked */ unlock_flash_if(sl); + /* clear the pg bit */ + clear_flash_cr_pg(sl); + /* set the page erase bit */ set_flash_cr_per(sl); From b40c2436b68a35544a1eae10f4b6a3de7648a566 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 27 Feb 2020 01:56:59 +0100 Subject: [PATCH 010/236] Hotfix: Reverts commit 6692fdc. CKS32-Clone-Patch broke flashing on STM32 F3xx, F4xx and L1xx. (#761) --- include/stm32.h | 1 - src/flash_loader.c | 1 - 2 files changed, 2 deletions(-) diff --git a/include/stm32.h b/include/stm32.h index 858d2b22a..9a01baaf4 100644 --- a/include/stm32.h +++ b/include/stm32.h @@ -9,7 +9,6 @@ // cortex core ids #define STM32VL_CORE_ID 0x1ba01477 -#define CS32VL_CORE_ID 0x2ba01477 #define STM32F7_CORE_ID 0x5ba02477 // Constant STM32 memory map figures diff --git a/src/flash_loader.c b/src/flash_loader.c index 9f6e3a79d..f88a42eca 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -267,7 +267,6 @@ int stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* loader_code = loader_code_stm32l; loader_size = sizeof(loader_code_stm32l); } else if (sl->core_id == STM32VL_CORE_ID || - sl->core_id == CS32VL_CORE_ID || sl->chip_id == STLINK_CHIPID_STM32_F1_MEDIUM || sl->chip_id == STLINK_CHIPID_STM32_F3 || sl->chip_id == STLINK_CHIPID_STM32_F3_SMALL || From 01ab4a979102d4812d11d037ec0041cdcce981b1 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 16 Mar 2020 12:15:23 +0100 Subject: [PATCH 011/236] Merged PR #825 Added support for G031/G041 chips. Closes #825. --- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index 6226c893b..0b80035f4 100644 --- a/src/common.c +++ b/src/common.c @@ -2637,7 +2637,7 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l /* Check if chip is supported and for correct address */ if(sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1 && - sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2) { + sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2) { ELOG("Option bytes writing is currently only supported for the STM32G0\n"); return -1; } From 5e70eb3dae66046d5e7b8a7e433480ed5e06c46f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 16 Mar 2020 12:57:38 +0100 Subject: [PATCH 012/236] Removed duplicated chip IDs. --- include/stlink/chipid.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index c0b0f3e13..368e157a7 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -75,8 +75,6 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_G4_CAT2 = 0x468, // See: RM 0440 s46.6.1 "MCU device ID code". STLINK_CHIPID_STM32_G4_CAT3 = 0x469, STLINK_CHIPID_STM32_L4RX = 0x470, // taken from the STM32L4R9I-DISCO board - STLINK_CHIPID_STM32_G0_CAT1 = 0x466, // G031/041 - STLINK_CHIPID_STM32_G0_CAT2 = 0x460, // G071/081 STLINK_CHIPID_STM32_WB55 = 0x495 }; From 1873ec70ffeb997ad355561070c87b270d31e674 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 16 Mar 2020 13:34:17 +0100 Subject: [PATCH 013/236] Removed duplicated chip IDs. --- include/stlink/chipid.h | 6 ++---- src/chipid.c | 13 +------------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index be5836990..f179db779 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -69,14 +69,12 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F72XXX = 0x452, /* This ID is found on the NucleoF722ZE board */ STLINK_CHIPID_STM32_L011 = 0x457, STLINK_CHIPID_STM32_F410 = 0x458, - STLINK_CHIPID_STM32_G0_CAT2 = 0x460, // G071/081 + STLINK_CHIPID_STM32_G0_CAT2 = 0x460, // G070/G071/081 STLINK_CHIPID_STM32_F413 = 0x463, - STLINK_CHIPID_STM32_G0_CAT1 = 0x466, // G031/041 + STLINK_CHIPID_STM32_G0_CAT1 = 0x466, // G030/G031/041 STLINK_CHIPID_STM32_G4_CAT2 = 0x468, // See: RM 0440 s46.6.1 "MCU device ID code". STLINK_CHIPID_STM32_G4_CAT3 = 0x469, STLINK_CHIPID_STM32_L4RX = 0x470, // taken from the STM32L4R9I-DISCO board - STLINK_CHIPID_STM32_G07X = 0x460, // Actually, 'G070 and 'G071/081 - STLINK_CHIPID_STM32_G03X = 0x466, // Actually, 'G030 and 'G031/041 STLINK_CHIPID_STM32_WB55 = 0x495 }; diff --git a/src/chipid.c b/src/chipid.c index f595a7bf3..a978d91ef 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -522,7 +522,7 @@ static const struct stlink_chipid_params devices[] = { .bootrom_size = 0x2000 }, { - // STM32GG030/031/041 (from RM0444) + // STM32G030/031/041 (from RM0454 & RM0444) .chip_id = STLINK_CHIPID_STM32_G0_CAT1, .description = "G030/G031/G041 device", .flash_type = STLINK_FLASH_TYPE_G0, @@ -554,17 +554,6 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000 // 28K (table 2) }, - { - // STM32G031/041 (from RM0454 & RM0444) - .chip_id = STLINK_CHIPID_STM32_G03X, - .description = "G030/G031/G041 device", - .flash_type = STLINK_FLASH_TYPE_G0, - .flash_size_reg = 0x1FFF75E0, // Section 38.2 - .flash_pagesize = 0x800, // 2K (sec 3.2) - .sram_size = 0x2000, // 8K (sec 2.3) - .bootrom_base = 0x1fff0000, - .bootrom_size = 0x2000 // 8k (table 2) - }, { // STM32WB55 (from RM0434) .chip_id = STLINK_CHIPID_STM32_WB55, From 44e2c375766f71f9a051ffaa5f2ba5b68af2ad86 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 16 Mar 2020 19:01:19 +0100 Subject: [PATCH 014/236] Whitespace cleanup. --- src/sg.c | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/sg.c b/src/sg.c index e7ff5d14e..8fa351cf6 100644 --- a/src/sg.c +++ b/src/sg.c @@ -109,8 +109,7 @@ void _stlink_sg_close(stlink_t *sl) { } } -static int get_usb_mass_storage_status(libusb_device_handle *handle, uint8_t endpoint, uint32_t *tag) -{ +static int get_usb_mass_storage_status(libusb_device_handle *handle, uint8_t endpoint, uint32_t *tag) { unsigned char csw[13]; memset(csw, 0, sizeof(csw)); int transferred; @@ -229,9 +228,7 @@ int send_usb_mass_storage_command(libusb_device_handle *handle, uint8_t endpoint * @param endpoint_in * @param endpoint_out */ - static void -get_sense(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t endpoint_out) -{ +static void get_sense(libusb_device_handle *handle, uint8_t endpoint_in, uint8_t endpoint_out) { DLOG("Fetching sense...\n"); uint8_t cdb[16]; memset(cdb, 0, sizeof(cdb)); @@ -324,7 +321,6 @@ int send_usb_data_only(libusb_device_handle *handle, unsigned char endpoint_out, return real_transferred; } - int stlink_q(stlink_t *sl) { struct stlink_libsg* sg = sl->backend_data; //uint8_t cdb_len = 6; // FIXME varies!!! @@ -385,7 +381,6 @@ int stlink_q(stlink_t *sl) { } // TODO thinking, cleanup - void stlink_stat(stlink_t *stl, char *txt) { if (stl->q_len <= 0) return; @@ -404,7 +399,6 @@ void stlink_stat(stlink_t *stl, char *txt) { } } - int _stlink_sg_version(stlink_t *stl) { struct stlink_libsg *sl = stl->backend_data; clear_cdb(sl); @@ -417,7 +411,6 @@ int _stlink_sg_version(stlink_t *stl) { // Get stlink mode: // STLINK_DEV_DFU_MODE || STLINK_DEV_MASS_MODE || STLINK_DEV_DEBUG_MODE // usb dfu || usb mass || jtag or swd - int _stlink_sg_current_mode(stlink_t *stl) { struct stlink_libsg *sl = stl->backend_data; clear_cdb(sl); @@ -431,7 +424,6 @@ int _stlink_sg_current_mode(stlink_t *stl) { } // Exit the mass mode and enter the swd debug mode. - int _stlink_sg_enter_swd_mode(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -443,7 +435,6 @@ int _stlink_sg_enter_swd_mode(stlink_t *sl) { // Exit the mass mode and enter the jtag debug mode. // (jtag is disabled in the discovery's stlink firmware) - int _stlink_sg_enter_jtag_mode(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; DLOG("\n*** stlink_enter_jtag_mode ***\n"); @@ -525,7 +516,6 @@ int _stlink_sg_core_id(stlink_t *sl) { } // Arm-core reset -> halted state. - int _stlink_sg_reset(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -545,7 +535,6 @@ int _stlink_sg_reset(stlink_t *sl) { } // Arm-core reset -> halted state. - int _stlink_sg_jtag_reset(stlink_t *sl, int value) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -562,7 +551,6 @@ int _stlink_sg_jtag_reset(stlink_t *sl, int value) { } // Arm-core status: halted or running. - int _stlink_sg_status(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -573,7 +561,6 @@ int _stlink_sg_status(stlink_t *sl) { } // Force the core into the debug mode -> halted state. - int _stlink_sg_force_debug(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -588,7 +575,6 @@ int _stlink_sg_force_debug(stlink_t *sl) { } // Read all arm-core registers. - int _stlink_sg_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { struct stlink_libsg *sg = sl->backend_data; @@ -696,7 +682,6 @@ int _stlink_sg_write_reg(stlink_t *sl, uint32_t reg, int idx) { // Write a register of the debug module of the core. // XXX ?(atomic writes) // TODO test - void stlink_write_dreg(stlink_t *sl, uint32_t reg, uint32_t addr) { struct stlink_libsg *sg = sl->backend_data; DLOG("\n*** stlink_write_dreg ***\n"); @@ -713,7 +698,6 @@ void stlink_write_dreg(stlink_t *sl, uint32_t reg, uint32_t addr) { } // Force the core exit the debug mode. - int _stlink_sg_run(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -729,7 +713,6 @@ int _stlink_sg_run(stlink_t *sl) { } // Step the arm-core. - int _stlink_sg_step(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -764,7 +747,6 @@ void stlink_set_hw_bp(stlink_t *sl, int fp_nr, uint32_t addr, int fp) { } // TODO test - // TODO make delegate! void stlink_clr_hw_bp(stlink_t *sl, int fp_nr) { struct stlink_libsg *sg = sl->backend_data; @@ -779,7 +761,6 @@ void stlink_clr_hw_bp(stlink_t *sl, int fp_nr) { } // Read a "len" bytes to the sl->q_buf from the memory, max 6kB (6144 bytes) - int _stlink_sg_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -804,7 +785,6 @@ int _stlink_sg_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { } // Write a "len" bytes from the sl->q_buf to the memory, max 64 Bytes. - int _stlink_sg_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len) { struct stlink_libsg *sg = sl->backend_data; int ret; @@ -833,7 +813,6 @@ int _stlink_sg_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len) { } // Write a "len" bytes from the sl->q_buf to the memory, max Q_BUF_LEN bytes. - int _stlink_sg_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { struct stlink_libsg *sg = sl->backend_data; int ret; @@ -862,7 +841,6 @@ int _stlink_sg_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { } // Write one DWORD data to memory - int _stlink_sg_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -875,7 +853,6 @@ int _stlink_sg_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data) { } // Read one DWORD data from memory - int _stlink_sg_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); @@ -891,9 +868,7 @@ int _stlink_sg_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data) { } // Exit the jtag or swd mode and enter the mass mode. - -int _stlink_sg_exit_debug_mode(stlink_t *stl) -{ +int _stlink_sg_exit_debug_mode(stlink_t *stl) { if (stl) { struct stlink_libsg* sl = stl->backend_data; clear_cdb(sl); @@ -905,7 +880,6 @@ int _stlink_sg_exit_debug_mode(stlink_t *stl) return 0; } - // 1) open a sg device, switch the stlink from dfu to mass mode // 2) wait 5s until the kernel driver stops reseting the broken device // 3) reopen the device @@ -943,7 +917,6 @@ static stlink_backend_t _stlink_sg_backend = { }; static stlink_t* stlink_open(const int verbose) { - stlink_t *sl = malloc(sizeof (stlink_t)); struct stlink_libsg *slsg = malloc(sizeof (struct stlink_libsg)); if (sl == NULL || slsg == NULL) { @@ -965,7 +938,7 @@ static stlink_t* stlink_open(const int verbose) { #if defined (__FreeBSD__) #define LIBUSBX_API_VERSION LIBUSB_API_VERSION -#endif +#endif #if LIBUSBX_API_VERSION < 0x01000106 libusb_set_debug(slsg->libusb_ctx, 3); #else @@ -984,7 +957,6 @@ static stlink_t* stlink_open(const int verbose) { // TODO // Could read the interface config descriptor, and assert lots of the assumptions - // assumption: numInterfaces is always 1... if (libusb_kernel_driver_active(slsg->usb_handle, 0) == 1) { int r = libusb_detach_kernel_driver(slsg->usb_handle, 0); From 946f8638c1e5cf0e0f487c04ab3d1d2e69a70322 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 17 Mar 2020 20:48:45 +0100 Subject: [PATCH 015/236] Updated CHANGELOG.md for Release v1.3.0 --- CHANGELOG.md | 57 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2832464a2..022701580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,13 +117,13 @@ Major changes and added features: Updates and fixes: +* Fixed gdb-server: L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/texane/stlink/pull/273)) * Fixed compilation with GCC 7 ([#590](https://github.com/texane/stlink/pull/590)) * Skipped GTK detection if we're cross-compiling ([#588](https://github.com/texane/stlink/pull/588)) * Fixed possible memory leak ([#570](https://github.com/texane/stlink/pull/570)) * Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#610](https://github.com/texane/stlink/pull/610)) * Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) * Fixed low-voltage flashing on STM32F7 parts. ([#567](https://github.com/texane/stlink/pull/567)) -* Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) v1.3.1 ====== @@ -151,36 +151,48 @@ Release date: 2017-01-28 Major changes and added features: * Deprecation of autotools (autoconf, automake) ([#83](https://github.com/texane/stlink/pull/83), [#431](https://github.com/texane/stlink/pull/431), [#434](https://github.com/texane/stlink/pull/434)) -* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#3fd0f09](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) -* Added support for native debian packaging ([#444](https://github.com/texane/stlink/pull/444), [#485](https://github.com/texane/stlink/pull/485)) * Added intel hex file reading for `st-flash` ([#110](https://github.com/texane/stlink/pull/110), [#157](https://github.com/texane/stlink/pull/157), [#200](https://github.com/texane/stlink/pull/200), [#239](https://github.com/texane/stlink/pull/239), [#457](https://github.com/texane/stlink/pull/547), [#459](https://github.com/texane/stlink/pull/549)) -* Added `--reset` command to `st-flash` ([#505](https://github.com/texane/stlink/pull/505)) -* Support serial numbers argument for `st-util` and `st-flash` for multi-programmer setups ([#541](https://github.com/texane/stlink/pull/541)) -* Added kill ('k') command to gdb-server for `st-util` ([#9804416](https://github.com/texane/stlink/commit/98044163ab34bf5159f121d1c49ffb3550321ca0)) -* Added manpages (generated with pandoc from Markdown) ([#464](https://github.com/texane/stlink/pull/464)) -* Rewritten commandline parsing for `st-flash` ([#459](https://github.com/texane/stlink/pull/459)) +* Added manpages (generated with pandoc from Markdown) ([#208](https://github.com/texane/stlink/pull/208), [#464](https://github.com/texane/stlink/pull/464), [#466](https://github.com/texane/stlink/pull/466), [#467](https://github.com/texane/stlink/pull/467)) +* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/texane/stlink/pull/228), ([#507](https://github.com/texane/stlink/pull/507), commit [#2c0ab7f](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) +* Support serial numbers argument for `st-util` and `st-flash` to probe and control multiple connected programmers ([#318](https://github.com/texane/stlink/pull/318), [#398](https://github.com/texane/stlink/pull/398), [#541](https://github.com/texane/stlink/pull/541)) +* Merge st-probe tool into st-info ([#398](https://github.com/texane/stlink/pull/398)) +* Added support for native debian packaging ([#444](https://github.com/texane/stlink/pull/444), [#472](https://github.com/texane/stlink/pull/472), [#473](https://github.com/texane/stlink/pull/473), [#482](https://github.com/texane/stlink/pull/482), [#483](https://github.com/texane/stlink/pull/483), [#484](https://github.com/texane/stlink/pull/484), [#485](https://github.com/texane/stlink/pull/485)) * Added support for ARM semihosting to `st-util` ([#454](https://github.com/texane/stlink/pull/454), [#455](https://github.com/texane/stlink/pull/455)) +* Rewritten commandline parsing for `st-flash` ([#459](https://github.com/texane/stlink/pull/459)) +* Added `--reset` command to `st-flash` ([#505](https://github.com/texane/stlink/pull/505)) +* st-util should detect when USB commands fail ([#525](https://github.com/texane/stlink/pull/525), ([#527](https://github.com/texane/stlink/pull/527), ([#528](https://github.com/texane/stlink/pull/528)) + Chip support added for: -* STM32L432 ([#501](https://github.com/texane/stlink/pull/501)) -* STM32F412 ([#538](https://github.com/texane/stlink/pull/538)) -* STM32F410 ([#9c635e4](https://github.com/texane/stlink/commit/9c635e419deca697ff823000aad2e39d47ec8d6c)) -* Added memory map for STM32F401XE ([#460](https://github.com/texane/stlink/pull/460)) -* L0x Category 5 devices ([#406](https://github.com/texane/stlink/pull/406)) -* Added L0 Category 2 device (chip id: 0x425) ([#72b8e5e](https://github.com/texane/stlink/commit/72b8e5ec87e4fa386a8e94fe68df29467d4354ce)) +* STM32F401XE: Added memory map for device ([#460](https://github.com/texane/stlink/pull/460)) +* STM32F410RBTx ([#418](https://github.com/texane/stlink/pull/418)) +* STM32F412 ([#537](https://github.com/texane/stlink/pull/537), [#538](https://github.com/texane/stlink/pull/538)) +* STM32F7xx ([#324](https://github.com/texane/stlink/pull/324), [#326](https://github.com/texane/stlink/pull/326), [#327](https://github.com/texane/stlink/pull/327), [#337](https://github.com/texane/stlink/pull/337)) +* STM32F767ZI ([#509](https://github.com/texane/stlink/pull/509)) +* STM32L0xx Cat2 devices (chip id: 0x425) ([#414](https://github.com/texane/stlink/pull/414)) +* STM32L0xx Cat5 devices (chip id: 0x447) ([#406](https://github.com/texane/stlink/pull/406)) +* STM32L4xx ([#321](https://github.com/texane/stlink/pull/321)) +* STM32L432 ([#500](https://github.com/texane/stlink/pull/500), [#501](https://github.com/texane/stlink/pull/501)) + Updates and fixes: * Set SWDCLK and fixed jtag_reset bug ([#254](https://github.com/texane/stlink/pull/254), [#291](https://github.com/texane/stlink/pull/291), [#475](https://github.com/texane/stlink/pull/475), [#533](https://github.com/texane/stlink/pull/533), [#534](https://github.com/texane/stlink/pull/534)) -* Fixed STM32F030 erase error ([#442](https://github.com/texane/stlink/pull/442)) -* Fixed Cygwin build ([#68b0f3b](https://github.com/texane/stlink/commit/68b0f3bddc3c4aaffe34caa6a3201029edd8ad56)) -* Reset flash mass erase (MER) bit after mass erase for safety ([#489](https://github.com/texane/stlink/pull/489)) -* Fixed memory map for STM32F4 (@zulusw) +* Fixed "unaligned addr or size" when trying to write a program in RAM ([#323](https://github.com/texane/stlink/pull/323)) +* Fixed flashing on STM32_F3_SMALL ([#325](https://github.com/texane/stlink/pull/325)) * Fixed STM32L-problem with flash loader ([#390](https://github.com/texane/stlink/pull/390)) -* `st-util` don't read target voltage on startup as it crashes STM32F100 (probably stlink/v1) (Greg Alexander) -* Do a JTAG reset prior to reading CPU information when processor is in deep sleep (@andyg24) +* Don't read the target voltage on startup, because it crashes STM32F100 ([#423](https://github.com/texane/stlink/pull/423), [#424](https://github.com/texane/stlink/pull/424)) +* Added a useful error message instead of "[!] send_recv" ([#425](https://github.com/texane/stlink/pull/425), [#426](https://github.com/texane/stlink/pull/426)) +* Do a JTAG reset prior to reading CPU information when processor is in deep sleep ([#428](https://github.com/texane/stlink/pull/428), [#430](https://github.com/texane/stlink/pull/430), [#451](https://github.com/texane/stlink/pull/451)) +* Fixed STM32F030 erase error ([#442](https://github.com/texane/stlink/pull/442)) +* Fixed memory map for STM32F7xx ([#453](https://github.com/texane/stlink/pull/453), [#456](https://github.com/texane/stlink/pull/456)) * Redesign of `st-flash` commandline options parsing ([#459](https://github.com/texane/stlink/pull/459)) +* Fixed Release target to generate the man-pages with pandoc ([#479](https://github.com/texane/stlink/pull/479)) +* Fixed Cygwin build ([#487](https://github.com/texane/stlink/pull/487), ([#506](https://github.com/texane/stlink/pull/506)) +* Reset flash mass erase (MER) bit after mass erase for safety ([#489](https://github.com/texane/stlink/pull/489)) +* Wrong extract command in FindLibUSB.cmake ([#510](https://github.com/texane/stlink/pull/510), [#511](https://github.com/texane/stlink/pull/511)) + v1.2.0 ====== @@ -193,12 +205,9 @@ Features added: * Added stlink usb probe API functions (Jerry Jacobs) * Added parameter to specify one stlink v2 of many (Georg von Zengen) -Changes: - -* Refactoring/fixes of flash loader (Maxime Coquelin) - Updates and fixes: +* Refactoring/fixes of flash loader (Maxime Coquelin) * Synchronized cache for stm32f7 (Tristan Gingold) * Allow flashing of STM32L4 down to 1.71 V (Greg Meiste) * Fix on stm32l4 to clear flash mass erase flags on CR (Bruno Dal Bo) From 35fff921f572d520359c89966dbc0212218b9666 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 18 Mar 2020 00:27:40 +0100 Subject: [PATCH 016/236] Updated CHANGELOG.md for Release v1.3.1 --- CHANGELOG.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 022701580..3d453a2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -132,15 +132,17 @@ Release date: 2017-02-25 Major changes and added features: -* Added preliminary support for STM32L011 to see it after probe (chipid `0x457`) (@xor-gate) -* Stripped full paths to source files in log (commit [#2c0ab7f](https://github.com/texane/stlink/commit/2c0ab7f0eb6cfda5cfbdc08bb9f6760d27c2b667)) -* Added support for STM32F413 target ([#549](https://github.com/texane/stlink/pull/549)) * Added support for Semihosting `SYS_READC` ([#546](https://github.com/texane/stlink/pull/546)) +* Added support for STM32F413 ([#549](https://github.com/texane/stlink/pull/549), [#550](https://github.com/texane/stlink/pull/550)) +* Added preliminary support for STM32L011 to see it after probe (chipid `0x457`) ([#558](https://github.com/texane/stlink/pull/558)) Updates and fixes: -* Updated documentation markdown files -* Compilation fixes ([#552](https://github.com/texane/stlink/pull/552)) +* cmake/CPackConfig.cmake: Fixup OSX zip filename +* Updated source repositories in README.md: Windows, macOS, Alpine Linux +* Stripped full paths to source files in log ([#548](https://github.com/texane/stlink/pull/548)) +* Compilation fixes ([#551](https://github.com/texane/stlink/pull/551), [#552](https://github.com/texane/stlink/pull/552)) +* Fixed incorrect release folder name in docs ([#560](https://github.com/texane/stlink/pull/560)) * Fixed compilation when path includes spaces ([#561](https://github.com/texane/stlink/pull/561)) v1.3.0 @@ -162,7 +164,6 @@ Major changes and added features: * Added `--reset` command to `st-flash` ([#505](https://github.com/texane/stlink/pull/505)) * st-util should detect when USB commands fail ([#525](https://github.com/texane/stlink/pull/525), ([#527](https://github.com/texane/stlink/pull/527), ([#528](https://github.com/texane/stlink/pull/528)) - Chip support added for: * STM32F401XE: Added memory map for device ([#460](https://github.com/texane/stlink/pull/460)) @@ -175,7 +176,6 @@ Chip support added for: * STM32L4xx ([#321](https://github.com/texane/stlink/pull/321)) * STM32L432 ([#500](https://github.com/texane/stlink/pull/500), [#501](https://github.com/texane/stlink/pull/501)) - Updates and fixes: * Set SWDCLK and fixed jtag_reset bug ([#254](https://github.com/texane/stlink/pull/254), [#291](https://github.com/texane/stlink/pull/291), [#475](https://github.com/texane/stlink/pull/475), [#533](https://github.com/texane/stlink/pull/533), [#534](https://github.com/texane/stlink/pull/534)) From ff8334f0ee34243834327da08e0432890b0a8920 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 18 Mar 2020 11:46:37 +0100 Subject: [PATCH 017/236] Updated CHANGELOG.md for Release v1.4.0 --- CHANGELOG.md | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d453a2d6..f1d45ce2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ General project updates: * Fixed travis build config file (Nightwalker-87) * Archived page from github project wiki to doc/wiki_old.md (Nightwalker-87) + v1.5.1 ====== @@ -84,6 +85,7 @@ Fixes: * Fix for mem_write() ([#730](https://github.com/texane/stlink/pull/730)) * FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733)) + v1.5.0 ====== @@ -102,6 +104,7 @@ Fixes: * Fixed verification of flash error for STM32L496x device ([#618](https://github.com/texane/stlink/pull/618)) * Fixed build on Fedora with GCC 8 ([#666](https://github.com/texane/stlink/pull/668)) + v1.4.0 ====== @@ -109,21 +112,28 @@ Release date: 2017-07-01 Major changes and added features: -* Added support for STM32L452 target ([#608](https://github.com/texane/stlink/pull/608)) -* Initial support to compile with Microsoft Visual Studio 2017 ([#602](https://github.com/texane/stlink/pull/602)) +* Allow building of debian package with CPack ([#554](https://github.com/texane/stlink/pull/554), commit [#2c0ab7f](https://github.com/texane/stlink/commit/5b69f25198a1a8f34e2ee48d1ad20f79447e3d55)) +* Added support for STM32L011 target ([#564](https://github.com/texane/stlink/pull/564), [#565](https://github.com/texane/stlink/pull/565), [#572](https://github.com/texane/stlink/pull/572)) * Added support for flashing second bank on STM32F10x_XL ([#592](https://github.com/texane/stlink/pull/592)) -* Added support for STM32L011 target ([#572](https://github.com/texane/stlink/pull/572)) -* Allow building of debian package with CPack (@xor-gate) +* Initial support to compile with Microsoft Visual Studio 2017 ([#602](https://github.com/texane/stlink/pull/602)) +* Added support for STM32L452 target ([#603](https://github.com/texane/stlink/pull/603), [#608](https://github.com/texane/stlink/pull/608)) Updates and fixes: * Fixed gdb-server: L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/texane/stlink/pull/273)) -* Fixed compilation with GCC 7 ([#590](https://github.com/texane/stlink/pull/590)) -* Skipped GTK detection if we're cross-compiling ([#588](https://github.com/texane/stlink/pull/588)) -* Fixed possible memory leak ([#570](https://github.com/texane/stlink/pull/570)) -* Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#610](https://github.com/texane/stlink/pull/610)) * Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) -* Fixed low-voltage flashing on STM32F7 parts. ([#567](https://github.com/texane/stlink/pull/567)) +* Fixed low-voltage flashing on STM32F7 devices ([#566](https://github.com/texane/stlink/pull/566), [#567](https://github.com/texane/stlink/pull/567)) +* Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#573](https://github.com/texane/stlink/pull/573), [#578](https://github.com/texane/stlink/pull/578), [#584](https://github.com/texane/stlink/pull/584), [#610](https://github.com/texane/stlink/pull/610)) +* Fixed possible memory leak ([#570](https://github.com/texane/stlink/pull/570), [#571](https://github.com/texane/stlink/pull/571)) +* Added --flash=n[k][m] command line option to override device model ([#576](https://github.com/texane/stlink/pull/576)) +* Fixed installation path for shared objects ([#581](https://github.com/texane/stlink/pull/581)) +* Fixed a few -Wformat warnings ([#582](https://github.com/texane/stlink/pull/582)) +* Removed unused defines in mimgw.h ([#583](https://github.com/texane/stlink/pull/583)) +* Skip GTK detection when cross-compiling ([#588](https://github.com/texane/stlink/pull/588)) +* Fixed compilation with GCC 7 ([#590](https://github.com/texane/stlink/pull/590), [#591](https://github.com/texane/stlink/pull/591)) +* Fixed flashing to 'f0 device' targets ([#594](https://github.com/texane/stlink/pull/594), [#595](https://github.com/texane/stlink/pull/595)) +* Fix wrong counting when flashing ([#605](https://github.com/texane/stlink/pull/605)) + v1.3.1 ====== @@ -134,17 +144,18 @@ Major changes and added features: * Added support for Semihosting `SYS_READC` ([#546](https://github.com/texane/stlink/pull/546)) * Added support for STM32F413 ([#549](https://github.com/texane/stlink/pull/549), [#550](https://github.com/texane/stlink/pull/550)) -* Added preliminary support for STM32L011 to see it after probe (chipid `0x457`) ([#558](https://github.com/texane/stlink/pull/558)) +* Added preliminary support for STM32L011 to see it after probe (chipid `0x457`) ([#558](https://github.com/texane/stlink/pull/558), [#598](https://github.com/texane/stlink/pull/598)) Updates and fixes: * cmake/CPackConfig.cmake: Fixup OSX zip filename * Updated source repositories in README.md: Windows, macOS, Alpine Linux +* Compilation fixes ([#547](https://github.com/texane/stlink/pull/547), [#551](https://github.com/texane/stlink/pull/551), [#552](https://github.com/texane/stlink/pull/552)) * Stripped full paths to source files in log ([#548](https://github.com/texane/stlink/pull/548)) -* Compilation fixes ([#551](https://github.com/texane/stlink/pull/551), [#552](https://github.com/texane/stlink/pull/552)) * Fixed incorrect release folder name in docs ([#560](https://github.com/texane/stlink/pull/560)) * Fixed compilation when path includes spaces ([#561](https://github.com/texane/stlink/pull/561)) + v1.3.0 ====== From b1f143ad30547e694010aa52bd34e0aeff2dbe26 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:19:41 +0100 Subject: [PATCH 018/236] Updated CHANGELOG.md for Release v1.5.0 --- CHANGELOG.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d45ce2c..7079f8b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,17 +93,21 @@ Release date: 2018-02-16 Major changes and added features: -* STM32F72xx73xx support ([#1969148](https://github.com/texane/stlink/commit/19691485359afef1a256964afcbb8dcf4b733209)) * Added support of STM32L496xx/4A6xx devices ([#615](https://github.com/texane/stlink/pull/615)) +* Added unknown chip dummy to obtain the serial of the ST-link by a call to st-info --probe ([#641](https://github.com/texane/stlink/pull/641)) +* Added support for STM32F72xx (chip id: 0x452) devices (commit [#1969148](https://github.com/texane/stlink/commit/19691485359afef1a256964afcbb8dcf4b733209)) -Fixes: +Updates and fixes: -* Fixed memory map for stm32l496xx boards ([#639](https://github.com/texane/stlink/pull/639)) +* Fixed verification of flash error for STM32L496x device ([#617](https://github.com/texane/stlink/pull/617), [#618](https://github.com/texane/stlink/pull/618)) +* Updated Linux source repositories in README.md: Gentoo, Fedora and RedHat/CentOS ([#622](https://github.com/texane/stlink/pull/622), [#635](https://github.com/texane/stlink/pull/635)) +* Updated changelog in debian package ([#630](https://github.com/texane/stlink/pull/630)) +* Added LIB_INSTALL_DIR to correct libs install on 64-bit systems ([#633](https://github.com/texane/stlink/pull/633), [#636](https://github.com/texane/stlink/pull/636)) * Fixed write for microcontroller with RAM size less or equal to 32K ([#637](https://github.com/texane/stlink/pull/637)) -* Added LIB_INSTALL_DIR to correct libs install on 64-bit systems ([#636](https://github.com/texane/stlink/pull/636)) -* Fixed verification of flash error for STM32L496x device ([#618](https://github.com/texane/stlink/pull/618)) -* Fixed build on Fedora with GCC 8 ([#666](https://github.com/texane/stlink/pull/668)) - +* Fixed memory map for stm32l496xx boards ([#639](https://github.com/texane/stlink/pull/639)) +* Fixed __FILE__ base name extraction ([#624](https://github.com/texane/stlink/pull/624), [#628](https://github.com/texane/stlink/pull/628), [#648](https://github.com/texane/stlink/pull/648)) +* Added debian/triggers to run ldconfig ([#664](https://github.com/texane/stlink/pull/664)) +* Fixed build on Fedora with GCC 8 ([#666](https://github.com/texane/stlink/pull/666), [#667](https://github.com/texane/stlink/pull/667), [#668](https://github.com/texane/stlink/pull/668)) v1.4.0 ====== From 975fcb06728927ae9428f5babe727724f09c8c69 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 18 Mar 2020 19:27:04 +0100 Subject: [PATCH 019/236] Updated CHANGELOG.md for Release v1.5.1 --- CHANGELOG.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7079f8b15..f19a443b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,28 +61,31 @@ Release date: 2018-09-13 Major changes and added features: +* Added reset through AIRCR ([#540](https://github.com/texane/stlink/pull/540), [#712](https://github.com/texane/stlink/pull/712)) +* Added creation of icons for .desktop file ([#684](https://github.com/texane/stlink/pull/684), [#708](https://github.com/texane/stlink/pull/708)) +* Added desktop file for linux ([#688](https://github.com/texane/stlink/pull/688)) * Added button to export stm32 flash memory to a file ([#691](https://github.com/texane/stlink/pull/691)) * Updated libusb to 1.0.22 ([#695](https://github.com/texane/stlink/pull/695)) -* Added desktop file for linux ([#688](https://github.com/texane/stlink/pull/688)) * Added icons for stlink GUI ([#697](https://github.com/texane/stlink/pull/697)) * Added support for STM32L4R9 target ([#694](https://github.com/texane/stlink/pull/694), [#699](https://github.com/texane/stlink/pull/699)) -* Added creation of icons for .desktop file ([#708](https://github.com/texane/stlink/pull/708)) * Added memory map for STM32F411RE target ([#709](https://github.com/texane/stlink/pull/709)) -* Added reset through AIRCR ([#540](https://github.com/texane/stlink/pull/540), [#712](https://github.com/texane/stlink/pull/712)) -* Implemented intel hex support for GTK GUI ([#718](https://github.com/texane/stlink/pull/718)) +* Implemented intel hex support for GTK GUI ([#713](https://github.com/texane/stlink/pull/713), [#718](https://github.com/texane/stlink/pull/718)) -Fixes: +Updates and fixes: -* Fixed missing flash_loader for L011 ([#675](https://github.com/texane/stlink/pull/675)) -* Fixed serial number size mismatch with stlink_open_usb() ([#680](https://github.com/texane/stlink/pull/680)) -* Debian packaging, CMake and README.md fixes ([#683](https://github.com/texane/stlink/pull/683)) +* Fixed missing flash_loader for L011 ([#356](https://github.com/texane/stlink/pull/356), [#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) * Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696)) +* Added semihosting parameter documentation in doc/man ([#674](https://github.com/texane/stlink/pull/674)) +* Fixed reference to non-exisiting st-term tool in doc/man ([#676](https://github.com/texane/stlink/pull/676)) +* Fixed serial number size mismatch with stlink_open_usb() ([#680](https://github.com/texane/stlink/pull/680)) +* Debian packaging, CMake and README.md fixes ([#682](https://github.com/texane/stlink/pull/682), [#683](https://github.com/texane/stlink/pull/683)) +* Disabled static library installation by default ([#702](https://github.com/texane/stlink/pull/702)) * Fix for libusb deprecation ([#703](https://github.com/texane/stlink/pull/703), [#704](https://github.com/texane/stlink/pull/704)) * Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX ([#706](https://github.com/texane/stlink/pull/706)) -* Fixed flash memory map for F72XXX target ([#711](https://github.com/texane/stlink/pull/711)) -* Proper flash page size calculation for F412 target ([#721](https://github.com/texane/stlink/pull/721)) -* Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/texane/stlink/pull/726), [#729](https://github.com/texane/stlink/pull/729), [#731](https://github.com/texane/stlink/pull/731)) -* Fix for mem_write() ([#730](https://github.com/texane/stlink/pull/730)) +* Regression: stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/texane/stlink/pull/700), [#701](https://github.com/texane/stlink/pull/701), [#707](https://github.com/texane/stlink/pull/707)) +* Fixed flash memory map for F72xxx target ([#711](https://github.com/texane/stlink/pull/711)) +* Proper flash page size calculation for F412xx target ([#721](https://github.com/texane/stlink/pull/721)) +* Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/texane/stlink/pull/726), [#727](https://github.com/texane/stlink/pull/727), [#729](https://github.com/texane/stlink/pull/729), [#730](https://github.com/texane/stlink/pull/730), [#731](https://github.com/texane/stlink/pull/731)) * FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733)) @@ -109,6 +112,7 @@ Updates and fixes: * Added debian/triggers to run ldconfig ([#664](https://github.com/texane/stlink/pull/664)) * Fixed build on Fedora with GCC 8 ([#666](https://github.com/texane/stlink/pull/666), [#667](https://github.com/texane/stlink/pull/667), [#668](https://github.com/texane/stlink/pull/668)) + v1.4.0 ====== From bc423e2e26a6b9de843a2170bfd78fd70464fec4 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 18 Mar 2020 23:00:51 +0100 Subject: [PATCH 020/236] Added missing tickets to CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f19a443b6..30cd219f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -85,7 +85,7 @@ Updates and fixes: * Regression: stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/texane/stlink/pull/700), [#701](https://github.com/texane/stlink/pull/701), [#707](https://github.com/texane/stlink/pull/707)) * Fixed flash memory map for F72xxx target ([#711](https://github.com/texane/stlink/pull/711)) * Proper flash page size calculation for F412xx target ([#721](https://github.com/texane/stlink/pull/721)) -* Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/texane/stlink/pull/726), [#727](https://github.com/texane/stlink/pull/727), [#729](https://github.com/texane/stlink/pull/729), [#730](https://github.com/texane/stlink/pull/730), [#731](https://github.com/texane/stlink/pull/731)) +* Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/texane/stlink/pull/726), [#727](https://github.com/texane/stlink/pull/727), [#728](https://github.com/texane/stlink/pull/728), [#729](https://github.com/texane/stlink/pull/729), [#730](https://github.com/texane/stlink/pull/730), [#731](https://github.com/texane/stlink/pull/731), [#732](https://github.com/texane/stlink/pull/732)) * FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733)) @@ -211,6 +211,7 @@ Updates and fixes: * Fixed Cygwin build ([#487](https://github.com/texane/stlink/pull/487), ([#506](https://github.com/texane/stlink/pull/506)) * Reset flash mass erase (MER) bit after mass erase for safety ([#489](https://github.com/texane/stlink/pull/489)) * Wrong extract command in FindLibUSB.cmake ([#510](https://github.com/texane/stlink/pull/510), [#511](https://github.com/texane/stlink/pull/511)) +* Fixed compilation error on Ubuntu 16.10 ([#514](https://github.com/texane/stlink/pull/514), [#525](https://github.com/texane/stlink/pull/525)) v1.2.0 From 116f4e58f62c15e24fd7c48613873c483ec9b968 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 18 Mar 2020 23:11:46 +0100 Subject: [PATCH 021/236] Removed CKS32F103 in tested-boards.md --- doc/tested-boards.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/tested-boards.md b/doc/tested-boards.md index b28163a30..ebc47c2ac 100644 --- a/doc/tested-boards.md +++ b/doc/tested-boards.md @@ -7,7 +7,6 @@ Known working targets: * STM32F100xx (Medium Density VL) * STM32F103 (according to jpa- on ##stm32) -* CKS32F103 (chinese STM32F103-Clone) No information: From 13c62114393f12a9b4d3cfc574cfabedfed50d5c Mon Sep 17 00:00:00 2001 From: "R.E. Wolff" Date: Thu, 19 Mar 2020 15:21:27 +0100 Subject: [PATCH 022/236] changed text for F72/F73 --- src/chipid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chipid.c b/src/chipid.c index df07d524f..f04c3eaa6 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -27,7 +27,7 @@ static const struct stlink_chipid_params devices[] = { { //RM0431 and DS document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F72XXX, - .description = "F72 device", + .description = "F72/F73 device", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1ff07a22, // section 35.2 .flash_pagesize = 0x800, // No flash pages From b8813fab9734521a1857189aab5dbf2a30d37ea4 Mon Sep 17 00:00:00 2001 From: "R.E. Wolff" Date: Thu, 19 Mar 2020 17:47:34 +0100 Subject: [PATCH 023/236] Fixed long wait when the loader refuses to run. Fixes #290 --- src/flash_loader.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/flash_loader.c b/src/flash_loader.c index f88a42eca..9c24ff9e8 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -384,10 +384,20 @@ int stlink_flash_loader_run(stlink_t *sl, flash_loader_t* fl, stm32_addr_t targe /* run loader */ stlink_run(sl); -#define WAIT_ROUNDS 10000 +// This piece of code used to try to spin for .1 second by waiting +// doing 10000 rounds of 10 microseconds. But because this usually runs +// on Unix-like OSes, the 10 microseconds get rounded up to the "tick" +// (actually almost two ticks) of the system. 1 milisecond. Thus, the +// ten thousand attempts, when "something goes wrong" that requires +// the error message "flash loader run error" would wait for something +// like 20 seconds before coming up with the error. +// by increasing the sleep-per-round to the same order-of-magnitude as +// the tick-rounding that the OS uses, the wait until the error message is +// reduced to the same order of magnitude as what was intended. -- REW. +#define WAIT_ROUNDS 100 /* wait until done (reaches breakpoint) */ for (i = 0; i < WAIT_ROUNDS; i++) { - usleep(10); + usleep(1000); if (stlink_is_core_halted(sl)) break; } From 60db4e56dcded849b453c74e9d00aa8dd070bce6 Mon Sep 17 00:00:00 2001 From: petertorelli Date: Fri, 20 Mar 2020 08:43:58 -0700 Subject: [PATCH 024/236] Added more error info to WLOGs during probe. --- src/usb.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/usb.c b/src/usb.c index 9df9d7296..ad062735d 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1102,9 +1102,9 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { /* Count stlink */ while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; - int r = libusb_get_device_descriptor(dev, &desc); - if (r < 0) { - WLOG("failed to get libusb device descriptor\n"); + ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) { + WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret); break; } @@ -1133,7 +1133,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { struct libusb_device_descriptor desc; ret = libusb_get_device_descriptor(dev, &desc); if (ret < 0) { - WLOG("failed to get libusb device descriptor\n"); + WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret); break; } @@ -1148,7 +1148,11 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { ret = libusb_open(dev, &handle); if (ret < 0) { - WLOG("failed to get libusb device descriptor\n"); + if (ret == LIBUSB_ERROR_ACCESS) { + WLOG("failed to open USB device (LIBUSB_ERROR_ACCESS), try running as root?\n"); + } else { + WLOG("failed to open USB device (libusb error: %d)\n", ret); + } break; } @@ -1159,7 +1163,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { libusb_close(handle); stlink_t *sl = NULL; - sl = stlink_open_usb(0, 1, serial); + sl = stlink_open_usb(0, 1, serial); if (!sl) continue; From c9efcba111171c8e03beeec81e93f55075204722 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 21 Mar 2020 00:26:59 +0100 Subject: [PATCH 025/236] Updated CHANGELOG.md for Release v1.6.0 --- CHANGELOG.md | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30cd219f5..3e3824a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,49 +8,47 @@ Release date: 2020-02-20 Major changes and added features: -* Added O_BINARY option to open file ([#753](https://github.com/texane/stlink/pull/753)) -* Added preliminary support for some STM32G0 chips ([#759](https://github.com/texane/stlink/pull/759), [#760](https://github.com/texane/stlink/pull/760)) +* Initial support for STM32L41X ([#754](https://github.com/texane/stlink/pull/754), [#799](https://github.com/texane/stlink/pull/799)) +* Added preliminary support for some STM32G0 chips ([#759](https://github.com/texane/stlink/pull/759), [#760](https://github.com/texane/stlink/pull/760), [#797](https://github.com/texane/stlink/pull/797)) * Added support for mass erasing second bank on STM32F10x_XL ([#767](https://github.com/texane/stlink/pull/767), [#768](https://github.com/texane/stlink/pull/768)) * Added call to clear PG bit after writing to flash ([#773](https://github.com/texane/stlink/pull/773)) -* Added howto for sending NRST signal through GDB ([#774](https://github.com/texane/stlink/pull/774), [#776](https://github.com/texane/stlink/pull/776)) * Added support to write option bytes for the STM32G0 ([#778](https://github.com/texane/stlink/pull/778)) -* Added simple read/write support for STM32WB55 chips ([#786](https://github.com/texane/stlink/pull/786)) +* Added support for STM32WB55 chips ([#786](https://github.com/texane/stlink/pull/786), [#810](https://github.com/texane/stlink/pull/810), [#816](https://github.com/texane/stlink/pull/816)) * Added STLink V3SET VID:PIDs to the udev rules ([#789](https://github.com/texane/stlink/pull/789)) * Support for "STM32+Audio" v2-1 firmware ([#790](https://github.com/texane/stlink/pull/790)) -* Initial support for STM32L41X ([#799](https://github.com/texane/stlink/pull/799)) * Build for Windows under Debian/Ubuntu ([#802](https://github.com/texane/stlink/pull/802)) * Allow for 64 bytes serials ([#809](https://github.com/texane/stlink/pull/809)) -* Added support to read and write option bytes for STM32F2 series (Orie22) -* Added full support for STLINK CHIP ID L4RX (Brad Natelborg) -* Added support to write option bytes to STM32F4 devices (Davey Struijk) +* Added full support for STLINK CHIP ID L4RX ([#814](https://github.com/texane/stlink/pull/814), [#839](https://github.com/texane/stlink/pull/839)) +* Added support for writing option bytes on STM32L0 ([#830](https://github.com/texane/stlink/pull/830)) +* Added support to read and write option bytes for STM32F2 series ([#836](https://github.com/texane/stlink/pull/836), [#837](https://github.com/texane/stlink/pull/837)) +* Added support to read and write option bytes for STM32F446 ([#843](https://github.com/texane/stlink/pull/843)) Updates and fixes: -* Build failure when platform is 32 bit, but stuct stat.st_size is 64 bit. ([#629](https://github.com/texane/stlink/pull/629)) +* Updated STM32F3xx chip ID that covers a few different devices ([#685](https://github.com/texane/stlink/pull/685), [#758](https://github.com/texane/stlink/pull/758)) * Made udev rules and modprobe conf installation optional ([#741](https://github.com/texane/stlink/pull/741)) -* Fixed case when __FILE__ don't contain "/" nor "\\". ([#745](https://github.com/texane/stlink/pull/745)) -* Fixed double dash issue in doc/man ([#746](https://github.com/texane/stlink/pull/746)) -* Fixed Debug error on line 123 in CMakeLists.txt (@xor-gate) -* Only do bank calculation on STM32L4 devices with dual banked flash ([#751](https://github.com/texane/stlink/pull/751)) -* Updated STM32F3xx chip ID that covers a few different devices ([#758](https://github.com/texane/stlink/pull/758)) +* Fixed case when __FILE__ don't contain "/" nor "\\" ([#745](https://github.com/texane/stlink/pull/745)) +* Fixed double dash issue in doc/man ([#746](https://github.com/texane/stlink/pull/746), [#747](https://github.com/texane/stlink/pull/747)) +* Compiling documentation: package is called libusb-1.0-0-dev on Debian ([#748](https://github.com/texane/stlink/pull/748)) +* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip ID 0x464 for STM32L41xxx/L42xxx devices ([#751](https://github.com/texane/stlink/pull/751)) +* Added O_BINARY option to open file ([#753](https://github.com/texane/stlink/pull/753)) * Fixed versioning when compiling from the checked out git-repo ([#762](https://github.com/texane/stlink/pull/762)) -* Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/texane/stlink/pull/107), [#763](https://github.com/texane/stlink/pull/763)) +* Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/texane/stlink/pull/107), [#665](https://github.com/texane/stlink/pull/665), [#763](https://github.com/texane/stlink/pull/763)) * win32: move usleep definition to unistd.h ([#765](https://github.com/texane/stlink/pull/765)) * Fixed relative path to the UI files needed by stlink-gui-local (GUI) ([#770](https://github.com/texane/stlink/pull/770), [#771](https://github.com/texane/stlink/pull/771)) +* Added howto for sending NRST signal through GDB ([#774](https://github.com/texane/stlink/pull/774), [#776](https://github.com/texane/stlink/pull/776), [#779](https://github.com/texane/stlink/pull/779)) * Fixed package name "devscripts" in doc/compiling.md ([#775](https://github.com/texane/stlink/pull/775)) -* Fixed apparent STM32G0 flashing issue ([#797](https://github.com/texane/stlink/pull/797)) * Fixed few potential memory/resource leaks ([#803](https://github.com/texane/stlink/pull/803)) -* Fixed flash verification error on STM32WB55RG ([#810](https://github.com/texane/stlink/pull/810), [#816](https://github.com/texane/stlink/pull/816)) -* Do not issue JTAG reset on stlink-v1 (Gwenhael Goavec-Merou) -* Fixed flash size of STM32 Discovery vl (Gwenhael Goavec-Merou) -* Added support for writing option bytes on STM32L0 (Adrian Imboden) +* Do not issue JTAG reset on stlink-v1 ([#828](https://github.com/texane/stlink/pull/828)) +* Fixed flash size of STM32 Discovery vl ([#829](https://github.com/texane/stlink/pull/829)) +* Updated Linux source repositories in README.md: Debian and Ubuntu ([#821](https://github.com/texane/stlink/pull/821), [#835](https://github.com/texane/stlink/pull/835), [#859](https://github.com/texane/stlink/pull/859)) * Updated documentation on software structure ([#851](https://github.com/texane/stlink/pull/851)) General project updates: -* Updated issue templates, README.md and CHANGELOG.md (Nightwalker-87) -* Added CODE_OF_CONDUCT (Nightwalker-87) +* Updated README.md, CHANGELOG.md and issue templates (Nightwalker-87) * Fixed travis build config file (Nightwalker-87) +* Added CODE_OF_CONDUCT (Nightwalker-87) * Archived page from github project wiki to doc/wiki_old.md (Nightwalker-87) @@ -140,7 +138,7 @@ Updates and fixes: * Skip GTK detection when cross-compiling ([#588](https://github.com/texane/stlink/pull/588)) * Fixed compilation with GCC 7 ([#590](https://github.com/texane/stlink/pull/590), [#591](https://github.com/texane/stlink/pull/591)) * Fixed flashing to 'f0 device' targets ([#594](https://github.com/texane/stlink/pull/594), [#595](https://github.com/texane/stlink/pull/595)) -* Fix wrong counting when flashing ([#605](https://github.com/texane/stlink/pull/605)) +* Fixed wrong counting when flashing ([#605](https://github.com/texane/stlink/pull/605)) v1.3.1 @@ -171,7 +169,7 @@ Release date: 2017-01-28 Major changes and added features: -* Deprecation of autotools (autoconf, automake) ([#83](https://github.com/texane/stlink/pull/83), [#431](https://github.com/texane/stlink/pull/431), [#434](https://github.com/texane/stlink/pull/434)) +* Deprecation of autotools (autoconf, automake) and fixed build with MinGW ([#83](https://github.com/texane/stlink/pull/83), [#431](https://github.com/texane/stlink/pull/431), [#434](https://github.com/texane/stlink/pull/434), [#465](https://github.com/texane/stlink/pull/465)) * Added intel hex file reading for `st-flash` ([#110](https://github.com/texane/stlink/pull/110), [#157](https://github.com/texane/stlink/pull/157), [#200](https://github.com/texane/stlink/pull/200), [#239](https://github.com/texane/stlink/pull/239), [#457](https://github.com/texane/stlink/pull/547), [#459](https://github.com/texane/stlink/pull/549)) * Added manpages (generated with pandoc from Markdown) ([#208](https://github.com/texane/stlink/pull/208), [#464](https://github.com/texane/stlink/pull/464), [#466](https://github.com/texane/stlink/pull/466), [#467](https://github.com/texane/stlink/pull/467)) * Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/texane/stlink/pull/228), ([#507](https://github.com/texane/stlink/pull/507), commit [#2c0ab7f](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) From c8a2f133f0703a434da05e89148526806225e364 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 21 Mar 2020 01:59:05 +0100 Subject: [PATCH 026/236] General Project Update - Minor documentation fixes - HOWTO and FAQ --> tutorial.md --- CHANGELOG.md | 2 +- README.md | 123 ------------------------------------------ doc/release.md | 2 +- doc/tutorial.md | 138 +++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 134 insertions(+), 131 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e3824a01..e6356caf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,9 +39,9 @@ Updates and fixes: * Added howto for sending NRST signal through GDB ([#774](https://github.com/texane/stlink/pull/774), [#776](https://github.com/texane/stlink/pull/776), [#779](https://github.com/texane/stlink/pull/779)) * Fixed package name "devscripts" in doc/compiling.md ([#775](https://github.com/texane/stlink/pull/775)) * Fixed few potential memory/resource leaks ([#803](https://github.com/texane/stlink/pull/803)) +* Updated Linux source repositories in README.md: Debian and Ubuntu ([#821](https://github.com/texane/stlink/pull/821), [#835](https://github.com/texane/stlink/pull/835), [#859](https://github.com/texane/stlink/pull/859)) * Do not issue JTAG reset on stlink-v1 ([#828](https://github.com/texane/stlink/pull/828)) * Fixed flash size of STM32 Discovery vl ([#829](https://github.com/texane/stlink/pull/829)) -* Updated Linux source repositories in README.md: Debian and Ubuntu ([#821](https://github.com/texane/stlink/pull/821), [#835](https://github.com/texane/stlink/pull/835), [#859](https://github.com/texane/stlink/pull/859)) * Updated documentation on software structure ([#851](https://github.com/texane/stlink/pull/851)) General project updates: diff --git a/README.md b/README.md index 3bc6c2c80..6a6fd4ae3 100644 --- a/README.md +++ b/README.md @@ -142,126 +142,3 @@ openocd: "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x31" Try to remove the write protection (probably only possible with ST Link Utility from ST itself). Issue related to this bug: [#545](https://github.com/texane/stlink/issues/545) - - -# HOWTO -## Using the gdb server - -To run the gdb server: - -``` -$ 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` in the format `:`. - -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 -``` - - -## 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. - -If you need to send a hard reset signal through `NRST` pin, you can use the following command: - -``` -(gdb) monitor jtag_reset -``` - - -## 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. - - -## Writing Option Bytes - -Example to read and write option bytes (currently writing only supported for STM32G0 and STM32L0) -``` -./st-flash --debug --reset --format binary --flash=128k read option_bytes_dump.bin 0x1FFF7800 4 -./st-flash --debug --reset --format binary --flash=128k write option_bytes_dump.bin 0x1FFF7800 -``` - - -## 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. diff --git a/doc/release.md b/doc/release.md index c2dca87b2..ae8b864ee 100644 --- a/doc/release.md +++ b/doc/release.md @@ -1,7 +1,7 @@ Release ======= -This document describes the steps takes for developers to create a release +This document describes the steps it 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 diff --git a/doc/tutorial.md b/doc/tutorial.md index 35c607ac0..af4bae849 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -37,7 +37,7 @@ Before continuing, the following dependencies must be met: Also make sure `gtk+` version 3.0 is installed. (`sudo apt-get install gtk+-3.0` or similiar) -STLINK should run on any system meeting the above constraints. +STLINK should run on any system meeting the above constraints. The STLINK software source code is retrieved using: @@ -62,7 +62,6 @@ It includes: Using the GDB server ==================== - This assumes you have got the libopencm3 project downloaded in `ocm3`. The libopencm3 project has some good, reliable examples for each of the @@ -85,11 +84,11 @@ the discovery kit you are using, you must run one of the 2 commands: $> ./st-util --stlinkv1 # STM32L or STM32F4 discovery kit (onboard ST-link/V2) -$> ./st-util +$> ./st-util # Full help for other options (listen port, version) $> ./st-util --help -``` +``` Then, GDB can be used to interact with the kit: @@ -113,7 +112,7 @@ command line, now we can simply “load” the target: ``` (gdb) load -``` +``` st-util will load all sections into their appropriate addresses, and “correctly” set the PC register. So, to run your freshly loaded program, @@ -127,6 +126,7 @@ Your program should now be running, and, if you used one of the blinking examples from libopencm3, the LEDs on the board should be blinking for you. + Building and flashing a program =============================== @@ -154,7 +154,7 @@ It is also possible to write a hexfile which is more convinient: $> ./st-flash --format ihex write myapp.hex ``` -#### +#### Of course, you can use this instead of the gdb server, if you prefer. Just remember to use the “.bin” image, rather than the .elf file. @@ -167,6 +167,132 @@ $> [sudo] ./st-flash write fancy_blink.bin 0x08000000 Upon reset, the board LEDs should be blinking. + +HOWTO +===== +## Using the gdb server + +To run the gdb server: + +``` +$ 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` in the format `:`. + +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 +``` + + +## 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. + +If you need to send a hard reset signal through `NRST` pin, you can use the following command: + +``` +(gdb) monitor jtag_reset +``` + + +## 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. + + +## Writing Option Bytes + +Example to read and write option bytes (currently writing only supported for STM32G0 and STM32L0) +``` +./st-flash --debug --reset --format binary --flash=128k read option_bytes_dump.bin 0x1FFF7800 4 +./st-flash --debug --reset --format binary --flash=128k write option_bytes_dump.bin 0x1FFF7800 +``` + + +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. + + Notes ===== From 784fdde0ae238bcb385be4d13850c3b78bbe602f Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 21 Mar 2020 14:48:40 +0200 Subject: [PATCH 027/236] check if app's need for libssp. --- CMakeLists.txt | 29 +++++++++++++++++++---------- src/gdbserver/CMakeLists.txt | 4 ++-- src/tools/gui/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 4 ++-- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90378f9ed..d9e2bf6bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,15 @@ if (STLINK_HAVE_UNISTD_H) 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) + set(SSP_LIB ssp) +else() + set(SSP_LIB "") +endif() + if (CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE "Debug") endif() @@ -135,13 +144,13 @@ if (APPLE) find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) - target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC}) + target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) endif() if (WIN32 OR MSYS OR MINGW) - target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32) + target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else() - target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY}) + target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif() @@ -164,13 +173,13 @@ if (APPLE) find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) - target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC}) + target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) endif() if (WIN32 OR MSYS OR MINGW) - target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32) + target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else() - target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY}) + target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif() set_target_properties(${STLINK_LIB_STATIC} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) @@ -186,16 +195,16 @@ endif() ### 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}) + target_link_libraries(st-flash ${STLINK_LIB_STATIC} ${SSP_LIB}) else() - target_link_libraries(st-flash ${STLINK_LIB_SHARED}) + target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB}) endif() add_executable(st-info src/tools/info.c) if (WIN32 OR APPLE) - target_link_libraries(st-info ${STLINK_LIB_STATIC}) + target_link_libraries(st-info ${STLINK_LIB_STATIC} ${SSP_LIB}) else() - target_link_libraries(st-info ${STLINK_LIB_SHARED}) + target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB}) endif() install(TARGETS st-flash st-info diff --git a/src/gdbserver/CMakeLists.txt b/src/gdbserver/CMakeLists.txt index 2393690ce..b4674ebbb 100644 --- a/src/gdbserver/CMakeLists.txt +++ b/src/gdbserver/CMakeLists.txt @@ -14,9 +14,9 @@ endif() add_executable(st-util ${STUTIL_SOURCE}) if (WIN32 OR APPLE) - target_link_libraries(st-util ${STLINK_LIB_STATIC}) + target_link_libraries(st-util ${STLINK_LIB_STATIC} ${SSP_LIB}) else() - target_link_libraries(st-util ${STLINK_LIB_SHARED}) + target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB}) endif() install(TARGETS st-util diff --git a/src/tools/gui/CMakeLists.txt b/src/tools/gui/CMakeLists.txt index c619a0547..91aabc53b 100644 --- a/src/tools/gui/CMakeLists.txt +++ b/src/tools/gui/CMakeLists.txt @@ -10,13 +10,13 @@ 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}") -target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${gtk_LDFLAGS}) +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}") -target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${gtk_LDFLAGS}) +target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${gtk_LDFLAGS} ${SSP_LIB}) install(TARGETS stlink-gui RUNTIME DESTINATION bin) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8df28ce7e..9d0bdffaf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,10 +6,10 @@ set(TESTS foreach(test ${TESTS}) add_executable(${test} ${test}.c) add_dependencies(${test} ${STLINK_LIB_STATIC}) - target_link_libraries(${test} ${STLINK_LIB_STATIC}) + target_link_libraries(${test} ${STLINK_LIB_STATIC} ${SSP_LIB}) 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}) +target_link_libraries(flash ${STLINK_LIB_STATIC} ${SSP_LIB}) add_test(flash ${CMAKE_CURRENT_BINARY_DIR}/flash) From e75a5d22ef50c2cd6bd49e77b83c4ebd5b0b81ac Mon Sep 17 00:00:00 2001 From: Rogier Wolff Date: Sat, 21 Mar 2020 16:08:09 +0100 Subject: [PATCH 028/236] reduce clutter in output messages --- src/chipid.c | 96 +++++++++++++++++++------------------- src/common.c | 12 ++++- src/gdbserver/gdb-server.c | 5 +- src/usb.c | 4 +- 4 files changed, 65 insertions(+), 52 deletions(-) diff --git a/src/chipid.c b/src/chipid.c index f04c3eaa6..f296f2509 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -5,7 +5,7 @@ static const struct stlink_chipid_params devices[] = { { //RM0410 document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F7XXXX, - .description = "F76xxx device", + .description = "F76xxx", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1ff0f442, // section 45.2 .flash_pagesize = 0x800, // No flash pages @@ -16,7 +16,7 @@ static const struct stlink_chipid_params devices[] = { { //RM0385 and DS10916 document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F7, - .description = "F7 device", + .description = "F7xx", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1ff0f442, // section 41.2 .flash_pagesize = 0x800, // No flash pages @@ -27,7 +27,7 @@ static const struct stlink_chipid_params devices[] = { { //RM0431 and DS document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F72XXX, - .description = "F72/F73 device", + .description = "F72x/F73x", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1ff07a22, // section 35.2 .flash_pagesize = 0x800, // No flash pages @@ -37,7 +37,7 @@ static const struct stlink_chipid_params devices[] = { }, { // table 2, PM0063 .chip_id = STLINK_CHIPID_STM32_F1_MEDIUM, - .description = "F1 Medium-density device", + .description = "F1xx Medium-density", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7e0, .flash_pagesize = 0x400, @@ -47,7 +47,7 @@ static const struct stlink_chipid_params devices[] = { }, { // table 1, PM0059 .chip_id = STLINK_CHIPID_STM32_F2, - .description = "F2 device", + .description = "F2xx", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1fff7a22, /* As in RM0033 Rev 5*/ .flash_pagesize = 0x20000, @@ -67,7 +67,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F4, - .description = "F4 device", + .description = "F4xx", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, /* As in rm0090 since Rev 2*/ .flash_pagesize = 0x4000, @@ -77,7 +77,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F4_DSI, - .description = "F46x and F47x device", + .description = "F46x/F47x", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, /* As in rm0090 since Rev 2*/ .flash_pagesize = 0x4000, @@ -87,7 +87,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F4_HD, - .description = "F42x and F43x device", + .description = "F42x/F43x", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, /* As in rm0090 since Rev 2*/ .flash_pagesize = 0x4000, @@ -97,7 +97,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F4_LP, - .description = "F4 device (low power)", + .description = "F4xx (low power)", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, .flash_pagesize = 0x4000, @@ -107,7 +107,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F411RE, - .description = "F4 device (low power) - stm32f411re", + .description = "stm32f411re", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, .flash_pagesize = 0x4000, @@ -117,7 +117,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F4_DE, - .description = "F4 device (Dynamic Efficency)", + .description = "F4xx (Dynamic Efficency)", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, .flash_pagesize = 0x4000, @@ -127,7 +127,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F1_HIGH, - .description = "F1 High-density device", + .description = "F1xx High-density", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7e0, .flash_pagesize = 0x800, @@ -139,7 +139,7 @@ static const struct stlink_chipid_params devices[] = { // This ignores the EEPROM! (and uses the page erase size, // not the sector write protection...) .chip_id = STLINK_CHIPID_STM32_L1_MEDIUM, - .description = "L1 Med-density device", + .description = "L1xx Medium-density", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff8004c, .flash_pagesize = 0x100, @@ -149,7 +149,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_L1_CAT2, - .description = "L1 Cat.2 device", + .description = "L1xx Cat.2", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff8004c, .flash_pagesize = 0x100, @@ -159,7 +159,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_L1_MEDIUM_PLUS, - .description = "L1 Medium-Plus-density device", + .description = "L1xx Medium-Plus-density", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff800cc, .flash_pagesize = 0x100, @@ -169,7 +169,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_L1_HIGH, - .description = "L1 High-density device", + .description = "L1xx High-density", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff800cc, .flash_pagesize = 0x100, @@ -189,7 +189,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F1_CONN, - .description = "F1 Connectivity line device", + .description = "F1 Connectivity line", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7e0, .flash_pagesize = 0x800, @@ -199,7 +199,7 @@ static const struct stlink_chipid_params devices[] = { }, {//Low and Medium density VL have same chipid. RM0041 25.6.1 .chip_id = STLINK_CHIPID_STM32_F1_VL_MEDIUM_LOW, - .description = "F1 Medium/Low-density Value Line device", + .description = "F1xx Value Line", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7e0, .flash_pagesize = 0x400, @@ -210,7 +210,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32F446x family. Support based on DM00135183.pdf (RM0390) document. .chip_id = STLINK_CHIPID_STM32_F446, - .description = "F446 device", + .description = "F446", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1fff7a22, .flash_pagesize = 0x20000, @@ -221,7 +221,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32F410 MCUs. Support based on DM00180366.pdf (RM0401) document. .chip_id = STLINK_CHIPID_STM32_F410, - .description = "F410 device", + .description = "F410", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1fff7a22, .flash_pagesize = 0x4000, @@ -233,7 +233,7 @@ static const struct stlink_chipid_params devices[] = { // This is STK32F303VCT6 device from STM32 F3 Discovery board. // Support based on DM00043574.pdf (RM0316) document. .chip_id = STLINK_CHIPID_STM32_F3, - .description = "F3 device", + .description = "F3xx", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, .flash_pagesize = 0x800, @@ -245,7 +245,7 @@ static const struct stlink_chipid_params devices[] = { // This is STK32F373VCT6 device from STM32 F373 eval board // Support based on 303 above (37x and 30x have same memory map) .chip_id = STLINK_CHIPID_STM32_F37x, - .description = "F3 device", + .description = "F3xx", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, .flash_pagesize = 0x800, @@ -255,7 +255,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F1_VL_HIGH, - .description = "F1 High-density value line device", + .description = "F1xx High-density value line", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7e0, .flash_pagesize = 0x800, @@ -265,7 +265,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F1_XL, - .description = "F1 XL-density device", + .description = "F1xx XL-density", .flash_type = STLINK_FLASH_TYPE_F1_XL, .flash_size_reg = 0x1ffff7e0, .flash_pagesize = 0x800, @@ -277,7 +277,7 @@ static const struct stlink_chipid_params devices[] = { //Use this as an example for mapping future chips: //RM0091 document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F0_CAN, - .description = "F07x device", + .description = "F07x", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, // "Flash size data register" (pg735) .flash_pagesize = 0x800, // Page sizes listed in Table 4 @@ -289,7 +289,7 @@ static const struct stlink_chipid_params devices[] = { //Use this as an example for mapping future chips: //RM0091 document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F0, - .description = "F0 device", + .description = "F0xx", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, // "Flash size data register" (pg735) .flash_pagesize = 0x400, // Page sizes listed in Table 4 @@ -301,7 +301,7 @@ static const struct stlink_chipid_params devices[] = { // RM0402 document was used to find these parameters // Table 4. .chip_id = STLINK_CHIPID_STM32_F412, - .description = "F4 device", + .description = "F412", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, // "Flash size data register" (pg1135) .flash_pagesize = 0x4000, // Table 5. Flash module organization ? @@ -313,7 +313,7 @@ static const struct stlink_chipid_params devices[] = { // RM0430 DocID029473 Rev 2 document was used to find these parameters // Figure 2, Table 4, Table 5, Section 35.2 .chip_id = STLINK_CHIPID_STM32_F413, - .description = "F4 device", + .description = "F413", .flash_type = STLINK_FLASH_TYPE_F4, .flash_size_reg = 0x1FFF7A22, // "Flash size data register" Section 35.2 .flash_pagesize = 0x4000, // Table 5. Flash module organization (variable sector sizes, but 0x4000 is smallest) @@ -323,7 +323,7 @@ static const struct stlink_chipid_params devices[] = { }, { .chip_id = STLINK_CHIPID_STM32_F09X, - .description = "F09X device", + .description = "F09X", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, // "Flash size data register" (pg735) .flash_pagesize = 0x800, // Page sizes listed in Table 4 (pg 56) @@ -335,7 +335,7 @@ static const struct stlink_chipid_params devices[] = { //Use this as an example for mapping future chips: //RM0091 document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F04, - .description = "F04x device", + .description = "F04x", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, // "Flash size data register" (pg735) .flash_pagesize = 0x400, // Page sizes listed in Table 4 @@ -347,7 +347,7 @@ static const struct stlink_chipid_params devices[] = { //Use this as an example for mapping future chips: //RM0091 document was used to find these paramaters .chip_id = STLINK_CHIPID_STM32_F0_SMALL, - .description = "F0 small device", + .description = "F0xx small", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, // "Flash size data register" (pg735) .flash_pagesize = 0x400, // Page sizes listed in Table 4 @@ -358,7 +358,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32F30x .chip_id = STLINK_CHIPID_STM32_F3_SMALL, - .description = "F3 small device", + .description = "F3xx small", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, .flash_pagesize = 0x800, @@ -370,7 +370,7 @@ static const struct stlink_chipid_params devices[] = { // STM32L0x // RM0367,RM0377 documents was used to find these parameters .chip_id = STLINK_CHIPID_STM32_L0, - .description = "L0x3 device", + .description = "L0x3", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff8007c, .flash_pagesize = 0x80, @@ -382,7 +382,7 @@ static const struct stlink_chipid_params devices[] = { // STM32L0x Category 5 // RM0367,RM0377 documents was used to find these parameters .chip_id = STLINK_CHIPID_STM32_L0_CAT5, - .description = "L0x Category 5 device", + .description = "L0xx Category 5", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff8007c, .flash_pagesize = 0x80, @@ -394,7 +394,7 @@ static const struct stlink_chipid_params devices[] = { // STM32L0x Category 2 // RM0367,RM0377 documents was used to find these parameters .chip_id = STLINK_CHIPID_STM32_L0_CAT2, - .description = "L0x Category 2 device", + .description = "L0xx Category 2", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff8007c, .flash_pagesize = 0x80, @@ -406,7 +406,7 @@ static const struct stlink_chipid_params devices[] = { // STM32F334, STM32F303x6/8, and STM32F328 // From RM0364 and RM0316 .chip_id = STLINK_CHIPID_STM32_F334, - .description = "F3xx medium density device", // (RM0316 sec 33.6.1) + .description = "F334 medium density", // (RM0316 sec 33.6.1) .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, .flash_pagesize = 0x800, @@ -418,7 +418,7 @@ static const struct stlink_chipid_params devices[] = { // This is STK32F303RET6 device from STM32 F3 Nucelo board. // Support based on DM00043574.pdf (RM0316) document rev 5. .chip_id = STLINK_CHIPID_STM32_F303_HIGH, - .description = "F303 high density device", + .description = "F303 high density", .flash_type = STLINK_FLASH_TYPE_F0, .flash_size_reg = 0x1ffff7cc, // 34.2.1 Flash size data register .flash_pagesize = 0x800, // 4.2.1 Flash memory organization @@ -430,7 +430,7 @@ static const struct stlink_chipid_params devices[] = { // STM32L4x6 // From RM0351. .chip_id = STLINK_CHIPID_STM32_L4, - .description = "L4 device", + .description = "L4xx", .flash_type = STLINK_FLASH_TYPE_L4, .flash_size_reg = 0x1FFF75e0, // "Flash size data register" (sec 45.2, page 1671) .flash_pagesize = 0x800, // 2K (sec 3.2, page 78; also appears in sec 3.3.1 and tables 4-6 on pages 79-81) @@ -445,7 +445,7 @@ static const struct stlink_chipid_params devices[] = { // STM32L4RX // From DM00310109.pdf .chip_id = STLINK_CHIPID_STM32_L4RX, - .description = "L4Rx device", + .description = "L4Rx", .flash_type = STLINK_FLASH_TYPE_L4, .flash_size_reg = 0x1fff75e0, // "Flash size data register" (sec 52.2, page 2049) .flash_pagesize = 0x1000, // 4k, section 3.3, pg 97 @@ -457,7 +457,7 @@ static const struct stlink_chipid_params devices[] = { // STLINK_CHIPID_STM32_L41X // From RM0394 Rev 4 and DS12469 Rev 5 .chip_id = STLINK_CHIPID_STM32_L41X, - .description = "L41x device", + .description = "L41x", .flash_type = STLINK_FLASH_TYPE_L4, .flash_size_reg = 0x1fff75e0, // "Flash size data register" (RM0394, sec 47.2, page 1586) .flash_pagesize = 0x800, // 2K (DS12469, sec 3.4, page 17) @@ -471,7 +471,7 @@ static const struct stlink_chipid_params devices[] = { // STLINK_CHIPID_STM32_L43X // From RM0392. .chip_id = STLINK_CHIPID_STM32_L43X, - .description = "L43x/L44x device", + .description = "L43x/L44x", .flash_type = STLINK_FLASH_TYPE_L4, .flash_size_reg = 0x1fff75e0, // "Flash size data register" (sec 43.2, page 1410) .flash_pagesize = 0x800, // 2K (sec 3.2, page 74; also appears in sec 3.3.1 and tables 7-8 on pages 75-76) @@ -486,7 +486,7 @@ static const struct stlink_chipid_params devices[] = { // STLINK_CHIPID_STM32_L496X // Support based on en.DM00083560.pdf (RM0351) document rev 5. .chip_id = STLINK_CHIPID_STM32_L496X, - .description = "L496x/L4A6x device", + .description = "L496x/L4A6x", .flash_type = STLINK_FLASH_TYPE_L4, .flash_size_reg = 0x1fff75e0, // "Flash size data register" (sec 49.2, page 1809) .flash_pagesize = 0x800, // Page erase (2 Kbyte) (sec 3.2, page 93) @@ -500,7 +500,7 @@ static const struct stlink_chipid_params devices[] = { // STLINK_CHIPID_STM32_L46X // From RM0394 (updated version of RM0392?). .chip_id = STLINK_CHIPID_STM32_L46X, - .description = "L45x/46x device", + .description = "L45x/46x", .flash_type = STLINK_FLASH_TYPE_L4, .flash_size_reg = 0x1fff75e0, // "Flash size data register" (sec 45.2, page 1463) .flash_pagesize = 0x800, // 2K (sec 3.2, page 73; also appears in sec 3.3.1 and tables 7 on pages 73-74) @@ -513,7 +513,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32L011 .chip_id = STLINK_CHIPID_STM32_L011, - .description = "L011 device", + .description = "L011", .flash_type = STLINK_FLASH_TYPE_L0, .flash_size_reg = 0x1ff8007c, .flash_pagesize = 0x80, @@ -524,7 +524,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32GG030/031/041 (from RM0444) .chip_id = STLINK_CHIPID_STM32_G0_CAT1, - .description = "G030/G031/G041 device", + .description = "G030/G031/G041", .flash_type = STLINK_FLASH_TYPE_G0, .flash_size_reg = 0x1FFF75E0, // Section 38.2 .flash_pagesize = 0x800, // 2K (sec 3.2) @@ -535,7 +535,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32G071/081 (from RM0444) .chip_id = STLINK_CHIPID_STM32_G0_CAT2, - .description = "G070/G071/G081 device", + .description = "G070/G071/G081", .flash_type = STLINK_FLASH_TYPE_G0, .flash_size_reg = 0x1FFF75E0, // Section 38.2 .flash_pagesize = 0x800, // 2K (sec 3.2) @@ -546,7 +546,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32G431/441 (from RM0440) .chip_id = STLINK_CHIPID_STM32_G4_CAT2, - .description = "G4 Category-2 device", + .description = "G4 Category-2", .flash_type = STLINK_FLASH_TYPE_G4, .flash_size_reg = 0x1FFF75E0, // Section 47.2 .flash_pagesize = 0x800, // 2K (sec 3.3.1) @@ -557,7 +557,7 @@ static const struct stlink_chipid_params devices[] = { { // STM32WB55 (from RM0434) .chip_id = STLINK_CHIPID_STM32_WB55, - .description = "WB55 device", + .description = "WB55", .flash_type = STLINK_FLASH_TYPE_WB, .flash_size_reg = 0x1FFF75E0, .flash_pagesize = 0x1000, // 4K diff --git a/src/common.c b/src/common.c index 6226c893b..a6d60c552 100644 --- a/src/common.c +++ b/src/common.c @@ -830,7 +830,9 @@ int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid) { * @return 0 for success, or -1 for unsupported core type. */ int stlink_load_device_params(stlink_t *sl) { - ILOG("Loading device parameters....\n"); + // This seems to normally work so is unnecessary info for a normal + // user. Demoted to debug. -- REW + DLOG("Loading device parameters....\n"); const struct stlink_chipid_params *params = NULL; stlink_core_id(sl); uint32_t chip_id; @@ -894,11 +896,19 @@ int stlink_load_device_params(stlink_t *sl) { sl->sram_size = 0x1000; } +#if 0 + // Old code -- REW ILOG("Device connected is: %s, id %#x\n", params->description, chip_id); // TODO make note of variable page size here..... ILOG("SRAM size: %#x bytes (%d KiB), Flash: %#x bytes (%d KiB) in pages of %u bytes\n", sl->sram_size, sl->sram_size / 1024, sl->flash_size, sl->flash_size / 1024, (unsigned int)sl->flash_pgsz); +#else + ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n", + params->description, sl->sram_size / 1024, sl->flash_size / 1024, + (sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024, + (sl->flash_pgsz < 1024)? "byte" : "KiB"); +#endif return 0; } diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index a874a81da..72f676bb2 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -246,8 +246,9 @@ int main(int argc, char** argv) { } - - ILOG("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id); + // This is low-level information for debugging, not useful for normal use. + // So: Demoted to a debug meesage. -- REW + DLOG("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id); sl->verbose=0; current_memory_map = make_memory_map(sl); diff --git a/src/usb.c b/src/usb.c index 9df9d7296..85f5727a4 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1049,7 +1049,9 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST stlink_version(sl); if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE) { - ILOG("-- exit_dfu_mode\n"); + // This seems to work, and is unnecessary information for the user. + // Demoted to debug -- REW + DLOG("-- exit_dfu_mode\n"); stlink_exit_dfu_mode(sl); } From d439956cb2ce5222fa8cfaa7992a90f4cef98eae Mon Sep 17 00:00:00 2001 From: Rogier Wolff Date: Sat, 21 Mar 2020 17:34:54 +0100 Subject: [PATCH 029/236] now return error in probe when things go bad. --- src/usb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/usb.c b/src/usb.c index 9df9d7296..8c932e71e 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1069,15 +1069,17 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } ret = stlink_load_device_params(sl); - -on_libusb_error: if (ret == -1) { - stlink_close(sl); - return NULL; + // This one didn't have any message. + goto on_libusb_error; } - return sl; +on_libusb_error: + stlink_close(sl); + return NULL; + + on_error: if (slu->libusb_ctx) libusb_exit(slu->libusb_ctx); From e49ad2770ede3377cd4865210c6f88a42ce48378 Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 21 Mar 2020 21:31:12 +0200 Subject: [PATCH 030/236] fix intendation in Version.cmake --- cmake/Version.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 2ca1c0ff8..71859015c 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -7,15 +7,15 @@ set(__detect_version 0) find_package (Git) if (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 --tag - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" - OUTPUT_VARIABLE PROJECT_VERSION + # Working off a git repo, using git versioning + # Check if HEAD is pointing to a tag + execute_process ( + COMMAND "${GIT_EXECUTABLE}" describe --always --tag + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + OUTPUT_VARIABLE PROJECT_VERSION RESULT_VARIABLE GIT_DESCRIBE_RESULT ERROR_VARIABLE GIT_DESCRIBE_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE) if(GIT_DESCRIBE_RESULT EQUAL 0) # If the sources have been changed locally, add -dirty to the version. From 4df1caf4f4f463b69276136b648c693586896ba1 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 22 Mar 2020 00:47:39 +0100 Subject: [PATCH 031/236] Minor fixes in CHANGELOG.md --- CHANGELOG.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6356caf3..586e44206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ Major changes and added features: * Build for Windows under Debian/Ubuntu ([#802](https://github.com/texane/stlink/pull/802)) * Allow for 64 bytes serials ([#809](https://github.com/texane/stlink/pull/809)) * Added full support for STLINK CHIP ID L4RX ([#814](https://github.com/texane/stlink/pull/814), [#839](https://github.com/texane/stlink/pull/839)) -* Added support for writing option bytes on STM32L0 ([#830](https://github.com/texane/stlink/pull/830)) +* Added support for writing option bytes on STM32L0xx ([#830](https://github.com/texane/stlink/pull/830)) * Added support to read and write option bytes for STM32F2 series ([#836](https://github.com/texane/stlink/pull/836), [#837](https://github.com/texane/stlink/pull/837)) * Added support to read and write option bytes for STM32F446 ([#843](https://github.com/texane/stlink/pull/843)) @@ -62,16 +62,16 @@ Major changes and added features: * Added reset through AIRCR ([#540](https://github.com/texane/stlink/pull/540), [#712](https://github.com/texane/stlink/pull/712)) * Added creation of icons for .desktop file ([#684](https://github.com/texane/stlink/pull/684), [#708](https://github.com/texane/stlink/pull/708)) * Added desktop file for linux ([#688](https://github.com/texane/stlink/pull/688)) -* Added button to export stm32 flash memory to a file ([#691](https://github.com/texane/stlink/pull/691)) +* Added button to export STM32 flash memory to a file ([#691](https://github.com/texane/stlink/pull/691)) * Updated libusb to 1.0.22 ([#695](https://github.com/texane/stlink/pull/695)) -* Added icons for stlink GUI ([#697](https://github.com/texane/stlink/pull/697)) +* Added icons for STLink GUI ([#697](https://github.com/texane/stlink/pull/697)) * Added support for STM32L4R9 target ([#694](https://github.com/texane/stlink/pull/694), [#699](https://github.com/texane/stlink/pull/699)) * Added memory map for STM32F411RE target ([#709](https://github.com/texane/stlink/pull/709)) * Implemented intel hex support for GTK GUI ([#713](https://github.com/texane/stlink/pull/713), [#718](https://github.com/texane/stlink/pull/718)) Updates and fixes: -* Fixed missing flash_loader for L011 ([#356](https://github.com/texane/stlink/pull/356), [#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) +* Fixed missing flash_loader for STM32L011 ([#356](https://github.com/texane/stlink/pull/356), [#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) * Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696)) * Added semihosting parameter documentation in doc/man ([#674](https://github.com/texane/stlink/pull/674)) * Fixed reference to non-exisiting st-term tool in doc/man ([#676](https://github.com/texane/stlink/pull/676)) @@ -81,8 +81,8 @@ Updates and fixes: * Fix for libusb deprecation ([#703](https://github.com/texane/stlink/pull/703), [#704](https://github.com/texane/stlink/pull/704)) * Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX ([#706](https://github.com/texane/stlink/pull/706)) * Regression: stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/texane/stlink/pull/700), [#701](https://github.com/texane/stlink/pull/701), [#707](https://github.com/texane/stlink/pull/707)) -* Fixed flash memory map for F72xxx target ([#711](https://github.com/texane/stlink/pull/711)) -* Proper flash page size calculation for F412xx target ([#721](https://github.com/texane/stlink/pull/721)) +* Fixed flash memory map for STM32F72xxx target ([#711](https://github.com/texane/stlink/pull/711)) +* Proper flash page size calculation for STM32F412xx target ([#721](https://github.com/texane/stlink/pull/721)) * Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/texane/stlink/pull/726), [#727](https://github.com/texane/stlink/pull/727), [#728](https://github.com/texane/stlink/pull/728), [#729](https://github.com/texane/stlink/pull/729), [#730](https://github.com/texane/stlink/pull/730), [#731](https://github.com/texane/stlink/pull/731), [#732](https://github.com/texane/stlink/pull/732)) * FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733)) @@ -105,7 +105,7 @@ Updates and fixes: * Updated changelog in debian package ([#630](https://github.com/texane/stlink/pull/630)) * Added LIB_INSTALL_DIR to correct libs install on 64-bit systems ([#633](https://github.com/texane/stlink/pull/633), [#636](https://github.com/texane/stlink/pull/636)) * Fixed write for microcontroller with RAM size less or equal to 32K ([#637](https://github.com/texane/stlink/pull/637)) -* Fixed memory map for stm32l496xx boards ([#639](https://github.com/texane/stlink/pull/639)) +* Fixed memory map for STM32L496xx boards ([#639](https://github.com/texane/stlink/pull/639)) * Fixed __FILE__ base name extraction ([#624](https://github.com/texane/stlink/pull/624), [#628](https://github.com/texane/stlink/pull/628), [#648](https://github.com/texane/stlink/pull/648)) * Added debian/triggers to run ldconfig ([#664](https://github.com/texane/stlink/pull/664)) * Fixed build on Fedora with GCC 8 ([#666](https://github.com/texane/stlink/pull/666), [#667](https://github.com/texane/stlink/pull/667), [#668](https://github.com/texane/stlink/pull/668)) @@ -126,7 +126,7 @@ Major changes and added features: Updates and fixes: -* Fixed gdb-server: L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/texane/stlink/pull/273)) +* Fixed gdb-server: STM32L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/texane/stlink/pull/273)) * Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) * Fixed low-voltage flashing on STM32F7 devices ([#566](https://github.com/texane/stlink/pull/566), [#567](https://github.com/texane/stlink/pull/567)) * Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#573](https://github.com/texane/stlink/pull/573), [#578](https://github.com/texane/stlink/pull/578), [#584](https://github.com/texane/stlink/pull/584), [#610](https://github.com/texane/stlink/pull/610)) @@ -226,9 +226,9 @@ Features added: Updates and fixes: * Refactoring/fixes of flash loader (Maxime Coquelin) -* Synchronized cache for stm32f7 (Tristan Gingold) +* Synchronized cache for STM32F7 (Tristan Gingold) * Allow flashing of STM32L4 down to 1.71 V (Greg Meiste) -* Fix on stm32l4 to clear flash mass erase flags on CR (Bruno Dal Bo) +* Fix on STM32L4 to clear flash mass erase flags on CR (Bruno Dal Bo) * Proper writing of page 0 of second bank for stm32l476xe (Tobias Badertscher) * Trace the read data in stlink_read_debug32 and not the address of the variable (Tobias Badertscher) * Mac OS X El Capitan platform support confirmation (Nikolay) @@ -238,8 +238,8 @@ Updates and fixes: * Make sure MCU is halted before running RAM based flashloaders (mlundinse) * Could not flash STM32_F3_SMALL (Max Chen) * STM32F4 8-bit support for 1.8v operation (Andy Isaacson) -* Fixed F2 memory map (Nicolas Schodet) -* Memory map for stm32f42xxx and stm32f43xxx devices (Craig Lilley) +* Fixed STM32F2xx memory map (Nicolas Schodet) +* Memory map for STM32F42xxx and STM32F43xxx devices (Craig Lilley) * Stm32l0x flash loader (Robin Kreis) Chip support added for: @@ -247,7 +247,7 @@ Chip support added for: * STM32L053R8 (Jean-Luc Béchennec) * STM32F7 Support (mlundinse) * Added STM32L4 to CHIPID #defines and devices[], flash driver and loader (Dave Vandervies) -* Basic support for F446 (Pavel Kirienko) +* Basic support for STM32F446 (Pavel Kirienko) * STM32F303 High Density * STM32L1xx Cat.2 devices (Nicolas Schodet) From 10ae5294cd03aacfc07312010f026d3cb12ea56c Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 23 Mar 2020 19:11:18 +0100 Subject: [PATCH 032/236] Updated /doc/compiling.md (Closes #113) - Added note on correct libusb version. - Formatting improvements - Corrections to grammar and wording --- doc/compiling.md | 151 +++++++++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 65 deletions(-) diff --git a/doc/compiling.md b/doc/compiling.md index 61bb12e6e..2728c153b 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -1,12 +1,11 @@ # Compiling from sources +## General package requirements -## Package requirements - -* CMake (v2.8.7 or later) +* 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) -* (optional) pandoc for generating manpages from markdown +* libusb-1.0 (v1.0.13 or later) +* libusb-dev-1.0 (v1.0.13 or later) +* pandoc _(optional; for generating manpages from markdown)_ Run from the root of the source directory: @@ -15,8 +14,7 @@ $ make release $ make debug ``` -The debug target should only be necessary for people who want - to modify the sources and 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: ``` @@ -25,83 +23,100 @@ $ cmake -DCMAKE_BUILD_TYPE=Debug .. $ make ``` -You could install to a user folder e.g `$HOME`: +You may install to a user folder e.g `$HOME`: ``` $ cd build/Release; make install DESTDIR=$HOME ``` -Or system wide: +Or system-wide: ``` $ cd build/Release; sudo make install ``` -## Linux +## Linux / Unix ## Common requirements -* Debian based distros (debian, ubuntu) - * `build-essential` +* `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 +* `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`)_ + +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. +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): +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 must - make sure the `stlink` group exists and the user who is trying to access is added - to this group. +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 very broken, so the best thing to do -is tell your operating system to completely ignore it. +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` +* `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 following extra packages: `devscripts debhelper`. +To build the debian package you need the additional packages `devscripts` and `debhelper`. ``` $ 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 ``` -## Mac OS X + +## macOS +### Prerequisites When compiling on a mac you need the following: * A compiler toolchain (XCode) -* CMake -* Libusb 1.0 +* 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: +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 @@ -109,92 +124,98 @@ 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 you can use the following cmake options: +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: +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" .. +$ cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" .. ``` -## Windows (MinGW64) -### Prequistes +## Windows (MinGW64) +### Prerequisites -* 7Zip -* CMake 2.8 or higher +* 7zip +* cmake 2.8 or higher * MinGW64 GCC toolchain (5.3.0) + ### Installation -1. Install 7Zip from +1. Install 7zip from 2. Install CMake from 3. Install MinGW64 from (mingw-w64-install.exe) 4. Git clone or download stlink sourcefiles zip + ### Building Check and execute (in the script folder) `\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` +**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) +## Windows (Visual Studio) ### Prerequisites -* 7Zip -* CMake (tested with version 3.9.0-rc2) -* Visual Studio 2017 Community (other versions will likely work but are untested; the Community edition is free for open source +* 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 +1. Install 7zip from 2. Install CMake from 3. Git clone or download stlink sourcefiles zip + ### Building -These instructions are for a 32bit version. +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). +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`. +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) -### Prequistes +## Linux (MinGW64) +### Prerequisites -* 7Zip -* CMake 2.8 or higher +* 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 32bit version. +These instructions are for a 32-bit version. ```sh cd From e3c76aa67315db32bd303303023d6c74c51e900b Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 24 Mar 2020 02:21:03 +0100 Subject: [PATCH 033/236] Removed deprecated LIBUSBX_API Closes #211 #782. See also #733. --- src/sg.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/sg.c b/src/sg.c index 8fa351cf6..8633b1d4d 100644 --- a/src/sg.c +++ b/src/sg.c @@ -936,15 +936,6 @@ static stlink_t* stlink_open(const int verbose) { return NULL; } -#if defined (__FreeBSD__) - #define LIBUSBX_API_VERSION LIBUSB_API_VERSION -#endif -#if LIBUSBX_API_VERSION < 0x01000106 - libusb_set_debug(slsg->libusb_ctx, 3); -#else - libusb_set_option(slsg->libusb_ctx, LIBUSB_OPTION_LOG_LEVEL, 3); -#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"); From c3f2b6b9714493b7d1d7a078b180b90db586c7a9 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 24 Mar 2020 13:33:32 +0100 Subject: [PATCH 034/236] Update for README.md - Updated "known missing features" - Removed section "known bugs" Note: Users should use the github ticket system to submit failures instead, otherwise they may not be fixed. --- README.md | 50 +------------------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/README.md b/README.md index 6a6fd4ae3..0219d0d7f 100644 --- a/README.md +++ b/README.md @@ -88,57 +88,9 @@ Some features are currently missing from the `texane/stlink` toolset. Here we would appreciate any help and would love to welcome new contributors who want to get involved: * Instrumentation Trace Macro (ITM) Cell ([#136](https://github.com/texane/stlink/issues/136)) -* OTP area programming ([#202](https://github.com/texane/stlink/issues/202)) -* EEPROM area programming ([#318](https://github.com/texane/stlink/issues/218)) +* OTP & EEPROM area programming ([#202](https://github.com/texane/stlink/issues/202), [#333](https://github.com/texane/stlink/issues/333), [#686](https://github.com/texane/stlink/issues/686)) * Protection bits area reading ([#346](https://github.com/texane/stlink/issues/346)) * Writing external memory connected to an STM32 controller (e.g Quad SPI NOR flash) ([#412](https://github.com/texane/stlink/issues/412)) * MCU hotplug ([#449](https://github.com/texane/stlink/issues/449)) * Writing options bytes (region) ([#458](https://github.com/texane/stlink/issues/458)) -* Control programming speed ([#462](https://github.com/texane/stlink/issues/462)) * Support for STLINKv3 programmer ([#820](https://github.com/texane/stlink/issues/820)) - - -## 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 related to this bug: [#356](https://github.com/texane/stlink/issues/356) - - -### Flash size is detected as zero bytes size - -It is possible that the STM32 flash is write protected, the st-flash tool will show something like this: - -``` -st-flash write prog.bin 0x8000000 -2017-01-24T18:44:14 INFO src/stlink-common.c: Loading device parameters.... -2017-01-24T18:44:14 INFO src/stlink-common.c: Device connected is: F1 High-density device, id 0x10036414 -2017-01-24T18:44:14 INFO src/stlink-common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0 bytes (0 KiB) in pages of 2048 bytes -``` - -As you can see, it gives out something unexpected like -``` -Flash: 0 bytes (0 KiB) in pages of 2048 bytes -``` - -``` -st-info --probe -Found 1 stlink programmers - serial: 303030303030303030303031 -openocd: "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x31" - flash: 0 (pagesize: 2048) - sram: 65536 - chipid: 0x0414 - descr: F1 High-density device -``` - -Try to remove the write protection (probably only possible with ST Link Utility from ST itself). - -Issue related to this bug: [#545](https://github.com/texane/stlink/issues/545) From c783d0e777ccc83a7a8be26a4f4d3414e0478560 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 24 Mar 2020 17:09:14 +0100 Subject: [PATCH 035/236] Refactoring for tool "st-info" - Resorted cmds to the order they appear. --- doc/man/st-info.md | 30 +++++++++++++++--------------- src/tools/info.c | 38 +++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/man/st-info.md b/doc/man/st-info.md index 67d9373d7..ca2579785 100644 --- a/doc/man/st-info.md +++ b/doc/man/st-info.md @@ -12,7 +12,7 @@ st-info - Provides information about connected STLink and STM32 devices # DESCRIPTION Provides information about connected STLink programmers and STM32 devices: -Serial code, openocd, flash, sram, page size, chipid, description. +Serial code, OpenOCD hla-serial, flash, page size, sram, chipid, description. # OPTIONS @@ -20,29 +20,29 @@ Serial code, openocd, flash, sram, page size, chipid, description. \--version : Print version information -\--flash -: Display amount of flash memory available in the device +\--probe +: Display the summarized information of the connected programmers and devices -\--sram -: Display amount of sram memory available in device +\--serial +: Display the serial code of the device -\--descr -: Display textual description of the device +\--hla-serial +: Display the hex escaped serial code of the device + +\--flash +: Display amount of flash memory available in the device \--pagesize : Display the page size of the device +\--sram +: Display amount of sram memory available in device + \--chipid : Display the chip ID of the device -\--serial -: Display the serial code of the device - -\--hla-serial -: Display the hex escaped serial code of the device - -\--probe -: Display the summarized information of the connected programmers and devices +\--descr +: Display textual description of the device # EXAMPLES diff --git a/src/tools/info.c b/src/tools/info.c index 2ad8f2c09..3ebbba8de 100644 --- a/src/tools/info.c +++ b/src/tools/info.c @@ -8,14 +8,14 @@ static void usage(void) { puts("st-info --version"); + puts("st-info --probe"); + puts("st-info --serial"); + puts("st-info --hla-serial"); puts("st-info --flash"); - puts("st-info --sram"); - puts("st-info --descr"); puts("st-info --pagesize"); + puts("st-info --sram"); puts("st-info --chipid"); - puts("st-info --serial"); - puts("st-info --hla-serial"); - puts("st-info --probe"); + puts("st-info --descr"); } /* Print normal or OpenOCD hla_serial with newline */ @@ -45,20 +45,20 @@ static void stlink_print_info(stlink_t *sl) if (!sl) return; - printf(" serial: "); + printf(" serial: "); stlink_print_serial(sl, false); - printf("openocd: "); + printf(" hla-serial: "); stlink_print_serial(sl, true); - printf(" flash: %u (pagesize: %u)\n", - (unsigned int)sl->flash_size, (unsigned int)sl->flash_pgsz); + printf(" flash: %u (pagesize: %u)\n", + (unsigned int)sl->flash_size, (unsigned int)sl->flash_pgsz); - printf(" sram: %u\n", (unsigned int)sl->sram_size); - printf(" chipid: 0x%.4x\n", sl->chip_id); + printf(" sram: %u\n", (unsigned int)sl->sram_size); + printf(" chipid: 0x%.4x\n", sl->chip_id); params = stlink_chipid_get_params(sl->chip_id); if (params) - printf(" descr: %s\n", params->description); + printf(" descr: %s\n", params->description); } static void stlink_probe(void) @@ -113,18 +113,18 @@ static int print_data(char **av) if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl); - if (strcmp(av[1], "--flash") == 0) + if (strcmp(av[1], "--serial") == 0) + stlink_print_serial(sl, false); + else if (strcmp(av[1], "--hla-serial") == 0) + stlink_print_serial(sl, true); + else if (strcmp(av[1], "--flash") == 0) printf("0x%x\n", (unsigned int)sl->flash_size); - else if (strcmp(av[1], "--sram") == 0) - printf("0x%x\n", (unsigned int)sl->sram_size); else if (strcmp(av[1], "--pagesize") == 0) printf("0x%x\n", (unsigned int)sl->flash_pgsz); + else if (strcmp(av[1], "--sram") == 0) + printf("0x%x\n", (unsigned int)sl->sram_size); else if (strcmp(av[1], "--chipid") == 0) printf("0x%.4x\n", sl->chip_id); - else if (strcmp(av[1], "--serial") == 0) - stlink_print_serial(sl, false); - else if (strcmp(av[1], "--hla-serial") == 0) - stlink_print_serial(sl, true); else if (strcmp(av[1], "--descr") == 0) { const struct stlink_chipid_params *params = stlink_chipid_get_params(sl->chip_id); if (params == NULL) From 562cd2496e696dbd22950925866aac662d81ee5f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 24 Mar 2020 19:00:49 +0100 Subject: [PATCH 036/236] Refactoring for tool "st-flash" - Fixed formatting for options display. --- src/tools/flash.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/flash.c b/src/tools/flash.c index f87b65940..82b5c349e 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -29,17 +29,17 @@ static void cleanup(int signum) { static void usage(void) { - puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--format ] [--flash=] {read|write} /dev/sgX "); - puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--serial ] [--format ] [--flash=] {read|write} "); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] erase"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] reset"); - puts(" Use hex format for addr, and ."); - puts(" fsize: Use decimal, octal or hex by prefix 0xXXX for hex, optionally followed by k=KB, or m=MB (eg. --flash=128k)"); - puts(" Format may be 'binary' (default) or 'ihex', although must be specified for binary format only."); - puts(" ./st-flash [--version]"); + puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--format ] [--flash=] {read|write} /dev/sgX "); + puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--serial ] [--format ] [--flash=] {read|write} "); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] erase"); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] reset"); + puts(" , and : Use hex format."); + puts(" : Use decimal, octal or hex (prefix 0xXXX) format, optionally followed by k=KB, or m=MB (eg. --flash=128k)"); + puts(" : Can be 'binary' (default) or 'ihex', although must be specified for binary format only."); + puts("print tool version info: ./st-flash [--version]"); puts("example write option byte: ./st-flash --debug --reset --area=option write 0xXXXXXXXX"); - puts("example read option byte: ./st-flash --debug --reset --area=option read > option_byte"); + puts("example read option byte: ./st-flash --debug --reset --area=option read > option_byte"); } int main(int ac, char** av) From a09ef54cf53f0e8c194ef33c49dfe96622e5c127 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 24 Mar 2020 21:11:38 +0100 Subject: [PATCH 037/236] General Project Update - Whitespace cleanup - Recycled content of old wiki page. --- README.md | 1 + doc/tutorial.md | 98 +++++++++++++++++++++++++++++++ doc/wiki_old.md | 108 ----------------------------------- include/stlink/tools/flash.h | 1 - src/common.c | 10 ++-- src/tools/flash.c | 6 +- src/tools/flash_opts.c | 22 +------ 7 files changed, 111 insertions(+), 135 deletions(-) delete mode 100644 doc/wiki_old.md diff --git a/README.md b/README.md index 0219d0d7f..b26a147e9 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ Currently known working combinations of programmers and targets are listed in [d **Windows**: download [v1.6.0](https://github.com/texane/stlink/releases/tag/v1.6.0) from the releases page. +Windows pre-compiled binaries are available at http://www.emb4fun.de/archive/stlink/index.html (outdated, not recommended for use) **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. diff --git a/doc/tutorial.md b/doc/tutorial.md index af4bae849..100d9a641 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -276,6 +276,42 @@ Example to read and write option bytes (currently writing only supported for STM ./st-flash --debug --reset --format binary --flash=128k write option_bytes_dump.bin 0x1FFF7800 ``` +## Installation of openOCD on Mac OS X with STlink-v2: + +`sudo port install openocd +jlink +stlink +ft2232` + +`/opt/local/bin/openocd --version` + +> Open On-Chip Debugger 0.7.0 (2014-08-11-22:12) + +`openocd -f /opt/local/share/openocd/scripts/interface/stlink-v2.cfg -f /opt/local/share/openocd/scripts/target/stm32f1x_stlink.cfg ` + +> Open On-Chip Debugger 0.8.0 (2014-08-11-15:36) +> +> Licensed under GNU GPL v2 +> +> For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html +> +> Info : This adapter doesn't support configurable speed +> +> Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748 +> +> Info : using stlink api v2 +> +> Info : Target voltage: 3.244269 +> +> Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints + +and connecting to the server through telnet yields a successful installation + +`telnet localhost 4444` + +> Connected to localhost. +> +> Escape character is '^]'. +> +> Open On-Chip Debugger + FAQ === @@ -292,6 +328,68 @@ 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. +Q: How can I install stlink and flash binaries on Mac OS X ? + +A: Installed on Mac OS X 10.9.4 with ports method, + however STlink v2 does not seem to work with libusb if you upgrade to the newest firmware !! + Only older firmware on STlink v2 works. + +[https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q) + +`sudo port install libusb automake autoconf pkgconfig` + +`aclocal --force -I /opt/local/share/aclocal` + +`git clone https://github.com/texane/stlink.git stlink-utility` + +`cd stlink-utility` + +`./autogen.sh` + +`./configure` + +`make` + +Then trying to flash the image with STLINK v2 : + +`./st-flash write ~/Downloads/irq.bin 0x8000000` + +> libusb_handle_events() timeout +> +> [!] send_recv + +ST-Link/V2 debugger with downgraded V2.14.3 firmware: + +https://drive.google.com/folderview?id=0Bzv7UpKpOQhnbXJVVEg4VUo2M1k + +After downgrading the firmware, flashing works as described here: + +http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103-chip/3906 + +`./st-flash write ~/Downloads/irq.bin 0x8000000` + +> 2014-08-11T23:14:52 INFO src/stlink-common.c: Loading device parameters.... +> +> 2014-08-11T23:14:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410 +> +> 2014-08-11T23:14:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in +> pages of 1024 bytes +> +> 2014-08-11T23:14:52 INFO src/stlink-common.c: Attempting to write 24904 (0x6148) bytes to stm32 address: 134217728 +> (0x8000000) +> +> Flash page at addr: 0x08006000 erased +> +> 2014-08-11T23:14:53 INFO src/stlink-common.c: Finished erasing 25 pages of 1024 (0x400) bytes +> +> 2014-08-11T23:14:53 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id +> +> 2014-08-11T23:14:53 INFO src/stlink-common.c: Successfully loaded flash loader in sram 24/24 pages written +> +> 2014-08-11T23:14:54 INFO src/stlink-common.c: Starting verification of write complete +> +> 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good! + Notes ===== diff --git a/doc/wiki_old.md b/doc/wiki_old.md deleted file mode 100644 index 81e70a277..000000000 --- a/doc/wiki_old.md +++ /dev/null @@ -1,108 +0,0 @@ -Welcome to the stlink wiki! (Archived: 2014-08-11) - -Misc: -Windows pre-compiled binaries are available at http://www.emb4fun.de/archive/stlink/index.html - -FAQ: -Q: Where can I get help? Is there a forum or maybe a mailing list? - -A: todo - -Q: How can I install stlink and flash binaries on Mac OS X ? - -A: **20140811: ** installed on Mac OS X 10.9.4 with ports method, however STlink v2 does not seem to work with libusb if you upgrade to the newest firmware !! Only older firmware on STlink v2 works. - -[https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q) - -`sudo port install libusb automake autoconf pkgconfig` - -`aclocal --force -I /opt/local/share/aclocal` - -`git clone https://github.com/texane/stlink.git stlink-utility` - -`cd stlink-utility` - -`./autogen.sh` - -`./configure` - -`make` - - -Then trying to flash the image with STLINK v2 : - -`./st-flash write ~/Downloads/irq.bin 0x8000000` - -> libusb_handle_events() timeout -> -> [!] send_recv - -After downgrading the firmware, flashing works -ST-Link/V2 debugger with downgraded V2.14.3 firmware: - -https://drive.google.com/folderview?id=0Bzv7UpKpOQhnbXJVVEg4VUo2M1k - -as described here: - -http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103-chip/3906 - -`./st-flash write ~/Downloads/irq.bin 0x8000000` - -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Loading device parameters.... -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410 -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in -> pages of 1024 bytes -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Attempting to write 24904 (0x6148) bytes to stm32 address: 134217728 -> (0x8000000) -> -> Flash page at addr: 0x08006000 erased -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Finished erasing 25 pages of 1024 (0x400) bytes -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Successfully loaded flash loader in sram 24/24 pages written -> -> 2014-08-11T23:14:54 INFO src/stlink-common.c: Starting verification of write complete -> -> 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good! - - -Installation of openOCD on Mac OS X with STlink-v2 has been successful: - -`sudo port install openocd +jlink +stlink +ft2232` - -`/opt/local/bin/openocd --version` - -> Open On-Chip Debugger 0.7.0 (2014-08-11-22:12) - -`openocd -f /opt/local/share/openocd/scripts/interface/stlink-v2.cfg -f /opt/local/share/openocd/scripts/target/stm32f1x_stlink.cfg ` - -> Open On-Chip Debugger 0.8.0 (2014-08-11-15:36) -> -> Licensed under GNU GPL v2 -> -> For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html -> -> Info : This adapter doesn't support configurable speed -> -> Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748 -> -> Info : using stlink api v2 -> -> Info : Target voltage: 3.244269 -> -> Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints - -and connecting to the server through telnet yields a successful installation - -`telnet localhost 4444` - -> Connected to localhost. -> -> Escape character is '^]'. -> -> Open On-Chip Debugger diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index 8ca1eddf9..a73d7aee4 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -31,4 +31,3 @@ struct flash_opts int flash_get_opts(struct flash_opts* o, int ac, char** av); #endif // STLINK_FLASH_H_ - diff --git a/src/common.c b/src/common.c index 134921341..913d70e35 100644 --- a/src/common.c +++ b/src/common.c @@ -904,9 +904,9 @@ int stlink_load_device_params(stlink_t *sl) { sl->sram_size, sl->sram_size / 1024, sl->flash_size, sl->flash_size / 1024, (unsigned int)sl->flash_pgsz); #else - ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n", - params->description, sl->sram_size / 1024, sl->flash_size / 1024, - (sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024, + ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n", + params->description, sl->sram_size / 1024, sl->flash_size / 1024, + (sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024, (sl->flash_pgsz < 1024)? "byte" : "KiB"); #endif return 0; @@ -1905,7 +1905,7 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) /* clear the pg bit */ clear_flash_cr_pg(sl); - + /* set the page erase bit */ set_flash_cr_per(sl); @@ -2855,7 +2855,7 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ stlink_read_debug32(sl, addr+4, &val); WLOG("2nd option bytes is 0x%08x\n",val); } - } + } /* Reload options */ stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); diff --git a/src/tools/flash.c b/src/tools/flash.c index 82b5c349e..e1e9f41f6 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -164,7 +164,9 @@ int main(int ac, char** av) goto on_error; } } - else if (o.addr == STM32_G0_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE || o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE + 4){ + else if (o.addr == STM32_G0_OPTION_BYTES_BASE || + o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE || + o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE + 4){ err = stlink_fwrite_option_bytes(sl, o.filename, o.addr); if (err == -1) { @@ -219,7 +221,7 @@ int main(int ac, char** av) err = stlink_read_option_bytes_f4(sl,&option_byte); printf("%x\n",option_byte); }else{ - printf("This format is available for STM32F2 and STM32F4 Only\n"); + printf("This format is available for STM32F2 and STM32F4 only\n"); } }else{ if ((o.addr >= sl->flash_base) && (o.size == 0) && diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 3f74ac057..ef41601a5 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -6,22 +6,19 @@ static bool starts_with(const char * str, const char * prefix) { size_t n = strlen(prefix); - if(strlen(str) < n) return false; + if (strlen(str) < n) return false; return (0 == strncmp(str, prefix, n)); } -int flash_get_opts(struct flash_opts* o, int ac, char** av) -{ +int flash_get_opts(struct flash_opts* o, int ac, char** av) { bool serial_specified = false; // defaults - memset(o, 0, sizeof(*o)); o->log_level = STND_LOG_LEVEL; // options - while(ac >= 1) { if (strcmp(av[0], "--version") == 0) { printf("v%s\n", STLINK_VERSION); @@ -44,18 +41,15 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) else { serial = av[0] + strlen("--serial="); } - /** @todo This is not really portable, as strlen really returns size_t we need to obey and not cast it to a signed type. */ int j = (int)strlen(serial); - int length = j / 2; //the length of the destination-array + int length = j / 2; // the length of the destination-array if(j % 2 != 0) return -1; - for(size_t k = 0; j >= 0 && k < sizeof(o->serial); ++k, j -= 2) { char buffer[3] = {0}; memcpy(buffer, serial + j, 2); o->serial[length - k] = (uint8_t)strtol(buffer, NULL, 16); } - serial_specified = true; } else if (strcmp(av[0], "--area") == 0 || starts_with(av[0], "--area=")) { @@ -92,7 +86,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) else { format = av[0] + strlen("--format="); } - if (strcmp(format, "binary") == 0) o->format = FLASH_FORMAT_BINARY; else if (strcmp(format, "ihex") == 0) @@ -132,7 +125,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) } // command and (optional) device name - while(ac >= 1) { // looks like for stlinkv1 the device name and command may be swaped - check both positions in all cases if (strcmp(av[0], "erase") == 0) { if (o->cmd != FLASH_CMD_NONE) return -1; @@ -174,32 +166,26 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) case FLASH_CMD_READ: // expect filename, addr and size if((o->area == FLASH_OPTION_BYTES) &&(ac == 0)) break; if (ac != 3) return -1; - o->filename = av[0]; o->addr = (uint32_t) strtoul(av[1], &tail, 16); if(tail[0] != '\0') return -1; - o->size = strtoul(av[2], &tail, 16); if(tail[0] != '\0') return -1; - break; case FLASH_CMD_WRITE: if(o->area == FLASH_OPTION_BYTES){ if(ac != 1) return -1; - o->val = (uint32_t)strtoul(av[0], &tail, 16); } else if(o->format == FLASH_FORMAT_BINARY) { // expect filename and addr if (ac != 2) return -1; - o->filename = av[0]; o->addr = (uint32_t) strtoul(av[1], &tail, 16); if(tail[0] != '\0') return -1; } else if(o->format == FLASH_FORMAT_IHEX) { // expect filename if (ac != 1) return -1; - o->filename = av[0]; } else { @@ -211,9 +197,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) } // some constistence checks - if(serial_specified && o->devname != NULL) return -1; // serial not supported for v1 return 0; } - From 49f887d5247fdd28f163b6317790c4f087e652cc Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Wed, 25 Mar 2020 11:55:44 +0200 Subject: [PATCH 038/236] setting up a libusb log level accordingly to verbosity. --- include/stlink.h | 5 +++-- include/stlink/logging.h | 1 + src/logging.c | 21 +++++++++++++++++++++ src/sg.c | 6 ++++++ src/usb.c | 6 ++++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index a69e357b5..f7eb9c69a 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -168,8 +168,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() @@ -243,6 +243,7 @@ typedef struct flash_loader { #include "stlink/chipid.h" #include "stlink/flash_loader.h" #include "stlink/version.h" +#include "stlink/logging.h" #ifdef __cplusplus } diff --git a/include/stlink/logging.h b/include/stlink/logging.h index da5f7d19d..1083b2c55 100644 --- a/include/stlink/logging.h +++ b/include/stlink/logging.h @@ -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 ? \ diff --git a/src/logging.c b/src/logging.c index d4fb96b2e..59c2ea298 100644 --- a/src/logging.c +++ b/src/logging.c @@ -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; +} diff --git a/src/sg.c b/src/sg.c index 8633b1d4d..d1ee5aea1 100644 --- a/src/sg.c +++ b/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"); diff --git a/src/usb.c b/src/usb.c index 7832612cf..b99e04b27 100644 --- a/src/usb.c +++ b/src/usb.c @@ -902,6 +902,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); From c27b8f4616c335ed32ff58a2749c0f167a9ce657 Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Wed, 25 Mar 2020 12:16:52 +0200 Subject: [PATCH 039/236] update libusb to 1.0.23 --- cmake/modules/FindLibUSB.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index 2ad35b3d8..fb122db3e 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -67,7 +67,7 @@ if(NOT LIBUSB_FOUND) if(WIN32 OR MSVC OR MINGW OR MSYS) find_package(7Zip REQUIRED) - set(LIBUSB_WIN_VERSION 1.0.22) + set(LIBUSB_WIN_VERSION 1.0.23) 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}) From eb4175e4fb43870c1553cb6a4bc6b53c166e049f Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 28 Mar 2020 20:41:41 +0200 Subject: [PATCH 040/236] include for INT_MAX --- src/usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/usb.c b/src/usb.c index 7832612cf..d373f1997 100644 --- a/src/usb.c +++ b/src/usb.c @@ -2,6 +2,7 @@ #include #include #include +#include #if !defined(_MSC_VER) #include #endif From 18735deb1b96c37ce73a89b625e6020726dd45bb Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 28 Mar 2020 21:00:30 +0200 Subject: [PATCH 041/236] check LIBUSB_API_VERSION --- CMakeLists.txt | 1 + include/stlink/sg.h | 48 ++++++++++++++++---------------------- include/stlink/stlinkusb.h | 38 ++++++++++++++++++++++++++++++ include/stlink/usb.h | 2 +- src/usb.c | 8 ------- 5 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 include/stlink/stlinkusb.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d9e2bf6bd..c319bda4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ set(STLINK_HEADERS include/stlink/mmap.h include/stlink/chipid.h include/stlink/flash_loader.h + include/stlink/stlinkusb.h ) set(STLINK_SOURCE diff --git a/include/stlink/sg.h b/include/stlink/sg.h index e521ba217..98efd4e58 100644 --- a/include/stlink/sg.h +++ b/include/stlink/sg.h @@ -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 -#pragma warning(pop) -#else -#include -#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 } diff --git a/include/stlink/stlinkusb.h b/include/stlink/stlinkusb.h new file mode 100644 index 000000000..a5d664472 --- /dev/null +++ b/include/stlink/stlinkusb.h @@ -0,0 +1,38 @@ +#ifndef STLINKUSB_H +#define STLINKUSB_H + +#include + +/* + + libusb ver | LIBUSB_API_VERSION +-------------+-------------------- + v1.0.13 | 0x01000100 + v1.0.14 | 0x010000FF + v1.0.15 | 0x01000101 + v1.0.16 | 0x01000102 < MINIMAL_API_VERSION + 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 ( LIBUSBX_API_VERSION ) +#if defined (__FreeBSD__) +#define LIBUSBX_API_VVERSION LIBUSB_API_VERSION +#elif !defined (LIBUSB_API_VERSION) +#error unsupported libusb version +#endif +#endif + +#define MINIMAL_API_VERSION 0x01000102 + +#if ( LIBUSB_API_VERSION < MINIMAL_API_VERSION ) +#error unsupported libusb version +#endif + +#endif // STLINKUSB_H diff --git a/include/stlink/usb.h b/include/stlink/usb.h index 4bf28c355..2d5ff731c 100644 --- a/include/stlink/usb.h +++ b/include/stlink/usb.h @@ -9,9 +9,9 @@ #define STLINK_USB_H #include -#include #include "stlink.h" +#include "stlinkusb.h" #include "stlink/logging.h" #ifdef __cplusplus diff --git a/src/usb.c b/src/usb.c index d373f1997..bfa5fd2f4 100644 --- a/src/usb.c +++ b/src/usb.c @@ -8,14 +8,6 @@ #endif #include #include -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable: 4200 4255 4668 4820) -#include -#pragma warning(pop) -#else -#include -#endif #include #include From cefcb7316c8987f705c6b08d1ac4f5b1c2cb468f Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 28 Mar 2020 21:16:32 +0200 Subject: [PATCH 042/236] check MD5 while download libusb --- cmake/modules/FindLibUSB.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index fb122db3e..9569fe133 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -79,6 +79,7 @@ if(NOT LIBUSB_FOUND) file(DOWNLOAD https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${LIBUSB_WIN_VERSION}/libusb-${LIBUSB_WIN_VERSION}.7z/download ${LIBUSB_WIN_ARCHIVE_PATH} + EXPECTED_MD5 750e64b45aca94fafbdff07171004d03 ) endif() file(MAKE_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER}) From 04630e4302d7447aa6e981f7fe1a38d0f21e3017 Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 28 Mar 2020 21:31:44 +0200 Subject: [PATCH 043/236] fix intendation --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c319bda4d..306d3d6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ set(STLINK_HEADERS include/stlink/mmap.h include/stlink/chipid.h include/stlink/flash_loader.h - include/stlink/stlinkusb.h + include/stlink/stlinkusb.h ) set(STLINK_SOURCE From f36d45ab922c0ccf80472205fd6f17dd478fd833 Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sat, 28 Mar 2020 21:57:08 +0200 Subject: [PATCH 044/236] specify correct MD5 for libusb-1.0.23.7z --- cmake/modules/FindLibUSB.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index 9569fe133..f88556205 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -79,7 +79,7 @@ if(NOT LIBUSB_FOUND) file(DOWNLOAD https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${LIBUSB_WIN_VERSION}/libusb-${LIBUSB_WIN_VERSION}.7z/download ${LIBUSB_WIN_ARCHIVE_PATH} - EXPECTED_MD5 750e64b45aca94fafbdff07171004d03 + EXPECTED_MD5 cf3d38d2ff053ef343d10c0b8b0950c2 ) endif() file(MAKE_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER}) From 085ccae6a3e75368b75a14cd3553efcd70f27d70 Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Sun, 29 Mar 2020 08:28:38 +0300 Subject: [PATCH 045/236] fix typo --- include/stlink/stlinkusb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/stlink/stlinkusb.h b/include/stlink/stlinkusb.h index a5d664472..5e1220c34 100644 --- a/include/stlink/stlinkusb.h +++ b/include/stlink/stlinkusb.h @@ -23,7 +23,7 @@ #if !defined ( LIBUSBX_API_VERSION ) #if defined (__FreeBSD__) -#define LIBUSBX_API_VVERSION LIBUSB_API_VERSION +#define LIBUSBX_API_VERSION LIBUSB_API_VERSION #elif !defined (LIBUSB_API_VERSION) #error unsupported libusb version #endif From 61de93ff76aa32b300c8d0f0d2506b8872b950a4 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 30 Mar 2020 02:11:38 +0200 Subject: [PATCH 046/236] Update for CHANGELOG.md & minor fixes --- CHANGELOG.md | 29 +++++++----- doc/tested-boards.md | 2 +- doc/wiki_old.md | 108 ------------------------------------------- 3 files changed, 18 insertions(+), 121 deletions(-) delete mode 100644 doc/wiki_old.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 586e44206..d88d83098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Release date: 2020-02-20 Major changes and added features: * Initial support for STM32L41X ([#754](https://github.com/texane/stlink/pull/754), [#799](https://github.com/texane/stlink/pull/799)) +* Working support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 ([#756](https://github.com/texane/stlink/pull/756), [#757](https://github.com/texane/stlink/pull/757), [#805](https://github.com/texane/stlink/pull/805), [#834](https://github.com/texane/stlink/pull/834), Regression-Fixes: [#761](https://github.com/texane/stlink/pull/761), [#766](https://github.com/texane/stlink/pull/766)) * Added preliminary support for some STM32G0 chips ([#759](https://github.com/texane/stlink/pull/759), [#760](https://github.com/texane/stlink/pull/760), [#797](https://github.com/texane/stlink/pull/797)) * Added support for mass erasing second bank on STM32F10x_XL ([#767](https://github.com/texane/stlink/pull/767), [#768](https://github.com/texane/stlink/pull/768)) * Added call to clear PG bit after writing to flash ([#773](https://github.com/texane/stlink/pull/773)) @@ -30,9 +31,9 @@ Updates and fixes: * Fixed case when __FILE__ don't contain "/" nor "\\" ([#745](https://github.com/texane/stlink/pull/745)) * Fixed double dash issue in doc/man ([#746](https://github.com/texane/stlink/pull/746), [#747](https://github.com/texane/stlink/pull/747)) * Compiling documentation: package is called libusb-1.0-0-dev on Debian ([#748](https://github.com/texane/stlink/pull/748)) -* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip ID 0x464 for STM32L41xxx/L42xxx devices ([#751](https://github.com/texane/stlink/pull/751)) +* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip-ID 0x464 for STM32L41xxx/L42xxx devices ([#751](https://github.com/texane/stlink/pull/751)) * Added O_BINARY option to open file ([#753](https://github.com/texane/stlink/pull/753)) -* Fixed versioning when compiling from the checked out git-repo ([#762](https://github.com/texane/stlink/pull/762)) +* Fixed versioning when compiling from the checked out git-repo ([#762](https://github.com/texane/stlink/pull/762), [#772](https://github.com/texane/stlink/pull/772)) * Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/texane/stlink/pull/107), [#665](https://github.com/texane/stlink/pull/665), [#763](https://github.com/texane/stlink/pull/763)) * win32: move usleep definition to unistd.h ([#765](https://github.com/texane/stlink/pull/765)) * Fixed relative path to the UI files needed by stlink-gui-local (GUI) ([#770](https://github.com/texane/stlink/pull/770), [#771](https://github.com/texane/stlink/pull/771)) @@ -71,7 +72,7 @@ Major changes and added features: Updates and fixes: -* Fixed missing flash_loader for STM32L011 ([#356](https://github.com/texane/stlink/pull/356), [#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) +* Fixed missing flash_loader for STM32L011 ([#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) * Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696)) * Added semihosting parameter documentation in doc/man ([#674](https://github.com/texane/stlink/pull/674)) * Fixed reference to non-exisiting st-term tool in doc/man ([#676](https://github.com/texane/stlink/pull/676)) @@ -94,9 +95,9 @@ Release date: 2018-02-16 Major changes and added features: -* Added support of STM32L496xx/4A6xx devices ([#615](https://github.com/texane/stlink/pull/615)) +* Added support of STM32L496xx/4A6xx devices ([#615](https://github.com/texane/stlink/pull/615), [#657](https://github.com/texane/stlink/pull/657)) * Added unknown chip dummy to obtain the serial of the ST-link by a call to st-info --probe ([#641](https://github.com/texane/stlink/pull/641)) -* Added support for STM32F72xx (chip id: 0x452) devices (commit [#1969148](https://github.com/texane/stlink/commit/19691485359afef1a256964afcbb8dcf4b733209)) +* Added support for STM32F72xx (chip-ID: 0x452) devices (commit [#1969148](https://github.com/texane/stlink/commit/19691485359afef1a256964afcbb8dcf4b733209)) Updates and fixes: @@ -118,7 +119,7 @@ Release date: 2017-07-01 Major changes and added features: -* Allow building of debian package with CPack ([#554](https://github.com/texane/stlink/pull/554), commit [#2c0ab7f](https://github.com/texane/stlink/commit/5b69f25198a1a8f34e2ee48d1ad20f79447e3d55)) +* Allow building of debian package with CPack ([#554](https://github.com/texane/stlink/pull/554), commit [#5b69f25](https://github.com/texane/stlink/commit/5b69f25198a1a8f34e2ee48d1ad20f79447e3d55)) * Added support for STM32L011 target ([#564](https://github.com/texane/stlink/pull/564), [#565](https://github.com/texane/stlink/pull/565), [#572](https://github.com/texane/stlink/pull/572)) * Added support for flashing second bank on STM32F10x_XL ([#592](https://github.com/texane/stlink/pull/592)) * Initial support to compile with Microsoft Visual Studio 2017 ([#602](https://github.com/texane/stlink/pull/602)) @@ -150,7 +151,7 @@ Major changes and added features: * Added support for Semihosting `SYS_READC` ([#546](https://github.com/texane/stlink/pull/546)) * Added support for STM32F413 ([#549](https://github.com/texane/stlink/pull/549), [#550](https://github.com/texane/stlink/pull/550)) -* Added preliminary support for STM32L011 to see it after probe (chipid `0x457`) ([#558](https://github.com/texane/stlink/pull/558), [#598](https://github.com/texane/stlink/pull/598)) +* Added preliminary support for STM32L011 to see it after probe (chip-ID 0x457) ([#558](https://github.com/texane/stlink/pull/558), [#598](https://github.com/texane/stlink/pull/598)) Updates and fixes: @@ -171,12 +172,12 @@ Major changes and added features: * Deprecation of autotools (autoconf, automake) and fixed build with MinGW ([#83](https://github.com/texane/stlink/pull/83), [#431](https://github.com/texane/stlink/pull/431), [#434](https://github.com/texane/stlink/pull/434), [#465](https://github.com/texane/stlink/pull/465)) * Added intel hex file reading for `st-flash` ([#110](https://github.com/texane/stlink/pull/110), [#157](https://github.com/texane/stlink/pull/157), [#200](https://github.com/texane/stlink/pull/200), [#239](https://github.com/texane/stlink/pull/239), [#457](https://github.com/texane/stlink/pull/547), [#459](https://github.com/texane/stlink/pull/549)) +* Added support for ARM semihosting to `st-util` ([#147](https://github.com/texane/stlink/pull/147), [#227](https://github.com/texane/stlink/pull/227), [#454](https://github.com/texane/stlink/pull/454), [#455](https://github.com/texane/stlink/pull/455)) * Added manpages (generated with pandoc from Markdown) ([#208](https://github.com/texane/stlink/pull/208), [#464](https://github.com/texane/stlink/pull/464), [#466](https://github.com/texane/stlink/pull/466), [#467](https://github.com/texane/stlink/pull/467)) -* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/texane/stlink/pull/228), ([#507](https://github.com/texane/stlink/pull/507), commit [#2c0ab7f](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) +* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/texane/stlink/pull/228), ([#507](https://github.com/texane/stlink/pull/507), commit [#3fd0f09](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) * Support serial numbers argument for `st-util` and `st-flash` to probe and control multiple connected programmers ([#318](https://github.com/texane/stlink/pull/318), [#398](https://github.com/texane/stlink/pull/398), [#541](https://github.com/texane/stlink/pull/541)) * Merge st-probe tool into st-info ([#398](https://github.com/texane/stlink/pull/398)) * Added support for native debian packaging ([#444](https://github.com/texane/stlink/pull/444), [#472](https://github.com/texane/stlink/pull/472), [#473](https://github.com/texane/stlink/pull/473), [#482](https://github.com/texane/stlink/pull/482), [#483](https://github.com/texane/stlink/pull/483), [#484](https://github.com/texane/stlink/pull/484), [#485](https://github.com/texane/stlink/pull/485)) -* Added support for ARM semihosting to `st-util` ([#454](https://github.com/texane/stlink/pull/454), [#455](https://github.com/texane/stlink/pull/455)) * Rewritten commandline parsing for `st-flash` ([#459](https://github.com/texane/stlink/pull/459)) * Added `--reset` command to `st-flash` ([#505](https://github.com/texane/stlink/pull/505)) * st-util should detect when USB commands fail ([#525](https://github.com/texane/stlink/pull/525), ([#527](https://github.com/texane/stlink/pull/527), ([#528](https://github.com/texane/stlink/pull/528)) @@ -188,14 +189,13 @@ Chip support added for: * STM32F412 ([#537](https://github.com/texane/stlink/pull/537), [#538](https://github.com/texane/stlink/pull/538)) * STM32F7xx ([#324](https://github.com/texane/stlink/pull/324), [#326](https://github.com/texane/stlink/pull/326), [#327](https://github.com/texane/stlink/pull/327), [#337](https://github.com/texane/stlink/pull/337)) * STM32F767ZI ([#509](https://github.com/texane/stlink/pull/509)) -* STM32L0xx Cat2 devices (chip id: 0x425) ([#414](https://github.com/texane/stlink/pull/414)) -* STM32L0xx Cat5 devices (chip id: 0x447) ([#406](https://github.com/texane/stlink/pull/406)) +* STM32L0xx Cat2 devices (chip-ID: 0x425) ([#414](https://github.com/texane/stlink/pull/414)) +* STM32L0xx Cat5 devices (chip-ID: 0x447) ([#406](https://github.com/texane/stlink/pull/406)) * STM32L4xx ([#321](https://github.com/texane/stlink/pull/321)) * STM32L432 ([#500](https://github.com/texane/stlink/pull/500), [#501](https://github.com/texane/stlink/pull/501)) Updates and fixes: -* Set SWDCLK and fixed jtag_reset bug ([#254](https://github.com/texane/stlink/pull/254), [#291](https://github.com/texane/stlink/pull/291), [#475](https://github.com/texane/stlink/pull/475), [#533](https://github.com/texane/stlink/pull/533), [#534](https://github.com/texane/stlink/pull/534)) * Fixed "unaligned addr or size" when trying to write a program in RAM ([#323](https://github.com/texane/stlink/pull/323)) * Fixed flashing on STM32_F3_SMALL ([#325](https://github.com/texane/stlink/pull/325)) * Fixed STM32L-problem with flash loader ([#390](https://github.com/texane/stlink/pull/390)) @@ -205,6 +205,8 @@ Updates and fixes: * Fixed STM32F030 erase error ([#442](https://github.com/texane/stlink/pull/442)) * Fixed memory map for STM32F7xx ([#453](https://github.com/texane/stlink/pull/453), [#456](https://github.com/texane/stlink/pull/456)) * Redesign of `st-flash` commandline options parsing ([#459](https://github.com/texane/stlink/pull/459)) +* Set SWDCLK and fixed jtag_reset bug ([#475](https://github.com/texane/stlink/pull/475), [#534](https://github.com/texane/stlink/pull/534)) +* doc/compiling.md: Add note about installation and ldconfig ([#478](https://github.com/texane/stlink/pull/478), commit [#be66bbf](https://github.com/texane/stlink/commit/be66bbf200c718904514b044ba84d64a36456218)) * Fixed Release target to generate the man-pages with pandoc ([#479](https://github.com/texane/stlink/pull/479)) * Fixed Cygwin build ([#487](https://github.com/texane/stlink/pull/487), ([#506](https://github.com/texane/stlink/pull/506)) * Reset flash mass erase (MER) bit after mass erase for safety ([#489](https://github.com/texane/stlink/pull/489)) @@ -241,6 +243,8 @@ Updates and fixes: * Fixed STM32F2xx memory map (Nicolas Schodet) * Memory map for STM32F42xxx and STM32F43xxx devices (Craig Lilley) * Stm32l0x flash loader (Robin Kreis) +* Send F4 memory-map and features for STM32F429 ([#188](https://github.com/texane/stlink/pull/188), [#196](https://github.com/texane/stlink/pull/196), [#250](https://github.com/texane/stlink/pull/250), [#251](https://github.com/texane/stlink/pull/251)) (Release v1.1.0) +* Added AHB3 Peripherals definition for STM32F4 ([#218](https://github.com/texane/stlink/pull/218), [#288](https://github.com/texane/stlink/pull/288)) (Release v1.1.0) Chip support added for: @@ -250,6 +254,7 @@ Chip support added for: * Basic support for STM32F446 (Pavel Kirienko) * STM32F303 High Density * STM32L1xx Cat.2 devices (Nicolas Schodet) +* STM32L1xx (chip-ID 0x427) ([#152](https://github.com/texane/stlink/pull/152), [#163](https://github.com/texane/stlink/pull/163), [#165](https://github.com/texane/stlink/pull/165)) (Release v1.0.0) Board support added for: diff --git a/doc/tested-boards.md b/doc/tested-boards.md index ebc47c2ac..a9fa2f1c6 100644 --- a/doc/tested-boards.md +++ b/doc/tested-boards.md @@ -18,7 +18,7 @@ STLink v2 (as found on the 32L and F4 Discovery boards), known working targets: * STM32F030F4P6 (custom board) * STM32F051R8T6 (STM320518-EVAL board) * STM32F100xx (Medium Density VL, as on the 32VL Discovery board) -* STM32F103VET6 (HY-STM32 board) +* STM32F103VET6 (HY-STM32 board) ([#149](https://github.com/texane/stlink/pull/149)) * STM32F105RCT6 (DecaWave EVB1000 board) * STM32F303xx (STM32F3 Discovery board) * STM32F407xx (STM32F4 Discovery board) diff --git a/doc/wiki_old.md b/doc/wiki_old.md deleted file mode 100644 index 81e70a277..000000000 --- a/doc/wiki_old.md +++ /dev/null @@ -1,108 +0,0 @@ -Welcome to the stlink wiki! (Archived: 2014-08-11) - -Misc: -Windows pre-compiled binaries are available at http://www.emb4fun.de/archive/stlink/index.html - -FAQ: -Q: Where can I get help? Is there a forum or maybe a mailing list? - -A: todo - -Q: How can I install stlink and flash binaries on Mac OS X ? - -A: **20140811: ** installed on Mac OS X 10.9.4 with ports method, however STlink v2 does not seem to work with libusb if you upgrade to the newest firmware !! Only older firmware on STlink v2 works. - -[https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q) - -`sudo port install libusb automake autoconf pkgconfig` - -`aclocal --force -I /opt/local/share/aclocal` - -`git clone https://github.com/texane/stlink.git stlink-utility` - -`cd stlink-utility` - -`./autogen.sh` - -`./configure` - -`make` - - -Then trying to flash the image with STLINK v2 : - -`./st-flash write ~/Downloads/irq.bin 0x8000000` - -> libusb_handle_events() timeout -> -> [!] send_recv - -After downgrading the firmware, flashing works -ST-Link/V2 debugger with downgraded V2.14.3 firmware: - -https://drive.google.com/folderview?id=0Bzv7UpKpOQhnbXJVVEg4VUo2M1k - -as described here: - -http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103-chip/3906 - -`./st-flash write ~/Downloads/irq.bin 0x8000000` - -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Loading device parameters.... -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410 -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in -> pages of 1024 bytes -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Attempting to write 24904 (0x6148) bytes to stm32 address: 134217728 -> (0x8000000) -> -> Flash page at addr: 0x08006000 erased -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Finished erasing 25 pages of 1024 (0x400) bytes -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Successfully loaded flash loader in sram 24/24 pages written -> -> 2014-08-11T23:14:54 INFO src/stlink-common.c: Starting verification of write complete -> -> 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good! - - -Installation of openOCD on Mac OS X with STlink-v2 has been successful: - -`sudo port install openocd +jlink +stlink +ft2232` - -`/opt/local/bin/openocd --version` - -> Open On-Chip Debugger 0.7.0 (2014-08-11-22:12) - -`openocd -f /opt/local/share/openocd/scripts/interface/stlink-v2.cfg -f /opt/local/share/openocd/scripts/target/stm32f1x_stlink.cfg ` - -> Open On-Chip Debugger 0.8.0 (2014-08-11-15:36) -> -> Licensed under GNU GPL v2 -> -> For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html -> -> Info : This adapter doesn't support configurable speed -> -> Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748 -> -> Info : using stlink api v2 -> -> Info : Target voltage: 3.244269 -> -> Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints - -and connecting to the server through telnet yields a successful installation - -`telnet localhost 4444` - -> Connected to localhost. -> -> Escape character is '^]'. -> -> Open On-Chip Debugger From f57954ab87d27a96183782b9e72633943e6fc597 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 31 Mar 2020 14:52:45 +0200 Subject: [PATCH 047/236] add usb pid for st-link v2.1, found on nucleo l432kc and nucleo l552ze. --- include/stlink/usb.h | 1 + src/usb.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/stlink/usb.h b/include/stlink/usb.h index 4bf28c355..239c5b4ef 100644 --- a/include/stlink/usb.h +++ b/include/stlink/usb.h @@ -23,6 +23,7 @@ extern "C" { #define STLINK_USB_PID_STLINK_32L 0x3748 #define STLINK_USB_PID_STLINK_32L_AUDIO 0x374a #define STLINK_USB_PID_STLINK_NUCLEO 0x374b +#define STLINK_USB_PID_STLINK_V2_1 0x3752 #define STLINK_USB_PID_STLINK_V3_USBLOADER 0x374d #define STLINK_USB_PID_STLINK_V3E_PID 0x374e #define STLINK_USB_PID_STLINK_V3S_PID 0x374f diff --git a/src/usb.c b/src/usb.c index 7832612cf..c5a314d45 100644 --- a/src/usb.c +++ b/src/usb.c @@ -941,6 +941,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) || + (desc.idProduct == STLINK_USB_PID_STLINK_V2_1) || (desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER) || (desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID) || (desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID) || @@ -957,7 +958,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) - || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO)) { + || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) + || (desc.idProduct == STLINK_USB_PID_STLINK_V2_1)) { sl->version.stlink_v = 2; } else if ((desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER) || (desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID) @@ -1032,6 +1034,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST slu->ep_rep = 1 /* ep rep */ | LIBUSB_ENDPOINT_IN; if (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO || desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO || + desc.idProduct == STLINK_USB_PID_STLINK_V2_1 || desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER || desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID || desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID || @@ -1115,6 +1118,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { if (desc.idProduct != STLINK_USB_PID_STLINK_32L && desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO && desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO && + desc.idProduct != STLINK_USB_PID_STLINK_V2_1 && desc.idProduct != STLINK_USB_PID_STLINK_V3_USBLOADER && desc.idProduct != STLINK_USB_PID_STLINK_V3E_PID && desc.idProduct != STLINK_USB_PID_STLINK_V3S_PID && From 140a03e7fd230798806328fe05bea5cda614a047 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 31 Mar 2020 15:26:27 +0200 Subject: [PATCH 048/236] update udev rules for stlinkv2-1 --- etc/udev/rules.d/49-stlinkv2-1.rules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/udev/rules.d/49-stlinkv2-1.rules b/etc/udev/rules.d/49-stlinkv2-1.rules index 15a797a05..b89b84012 100644 --- a/etc/udev/rules.d/49-stlinkv2-1.rules +++ b/etc/udev/rules.d/49-stlinkv2-1.rules @@ -10,6 +10,10 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ MODE:="0666", \ SYMLINK+="stlinkv2-1_%n" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3752", \ + MODE:="0666", \ + SYMLINK+="stlinkv2-1_%n" + # If you share your linux system with other users, or just don't like the # idea of write permission for everybody, you can replace MODE:="0666" with # OWNER:="yourusername" to create the device owned by you, or with From ac4775623df9ef74b3bd86c2939482c99cf01f80 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 31 Mar 2020 09:43:50 +0200 Subject: [PATCH 049/236] add stm32g4 cat3 (dual flash bank) devices. --- src/chipid.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/chipid.c b/src/chipid.c index 75448e01b..4659a55c9 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -554,6 +554,20 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000 // 28K (table 2) }, + { + // STM32G471/473/474/483/484 (from RM0440) + .chip_id = STLINK_CHIPID_STM32_G4_CAT3, + .description = "G4 Category-3", + .flash_type = STLINK_FLASH_TYPE_G4, + .flash_size_reg = 0x1FFF75E0, // Section 47.2 + .flash_pagesize = 0x800, // 2K (sec 3.3.1) + // SRAM1 is 80k at 0x20000000 + // SRAM2 is 16k at 0x20014000 + // SRAM3/CCM is 32k at 0x10000000, aliased at 0x20018000 + .sram_size = 0x18000, // 128K (sec 2.4) + .bootrom_base = 0x1fff0000, + .bootrom_size = 0x7000 // 28K (table 2) + }, { // STM32WB55 (from RM0434) .chip_id = STLINK_CHIPID_STM32_WB55, From 0cd94a9adcce03406db887842badd6ac82c71e1b Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 31 Mar 2020 09:43:03 +0200 Subject: [PATCH 050/236] stm32g0431/441: update doc --- src/chipid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/chipid.c b/src/chipid.c index 4659a55c9..426780cf7 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -550,6 +550,9 @@ static const struct stlink_chipid_params devices[] = { .flash_type = STLINK_FLASH_TYPE_G4, .flash_size_reg = 0x1FFF75E0, // Section 47.2 .flash_pagesize = 0x800, // 2K (sec 3.3.1) + // SRAM1 is 16k at 0x20000000 + // SRAM2 is 6k at 0x20014000 + // SRAM3/CCM is 10k at 0x10000000, aliased at 0x20018000 .sram_size = 0x8000, // 32K (sec 2.4) .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000 // 28K (table 2) From db6e93e52aa86add8ff0453ca2d26ca13310fa8e Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Wed, 1 Apr 2020 20:40:34 +0300 Subject: [PATCH 051/236] set minimal LIBUSBX_API_VERSION to depend on OS --- include/stlink/stlinkusb.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/stlink/stlinkusb.h b/include/stlink/stlinkusb.h index 5e1220c34..4d904b0c5 100644 --- a/include/stlink/stlinkusb.h +++ b/include/stlink/stlinkusb.h @@ -10,7 +10,7 @@ v1.0.13 | 0x01000100 v1.0.14 | 0x010000FF v1.0.15 | 0x01000101 - v1.0.16 | 0x01000102 < MINIMAL_API_VERSION + v1.0.16 | 0x01000102 v1.0.17 | 0x01000102 v1.0.18 | 0x01000102 v1.0.19 | 0x01000103 @@ -21,15 +21,23 @@ */ -#if !defined ( LIBUSBX_API_VERSION ) #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 +#elif defined (__linux__) +#define MINIMAL_API_VERSION 0x01000104 +#elif defined (__APPLE__) +#define MINIMAL_API_VERSION 0x01000104 +#elif defined (_WIN32) +#define MINIMAL_API_VERSION 0x01000106 +#endif #if ( LIBUSB_API_VERSION < MINIMAL_API_VERSION ) #error unsupported libusb version From a76f468587713ee7bc1cf959d50c55446918a878 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 2 Apr 2020 02:18:49 +0200 Subject: [PATCH 052/236] [doc] Updated list of supported devices --- README.md | 2 +- doc/devices_boards.md | 258 ++++++++++++++++++++++++++++++++++++++++ doc/tested-boards.md | 57 --------- include/stlink/chipid.h | 32 ++--- 4 files changed, 269 insertions(+), 80 deletions(-) create mode 100644 doc/devices_boards.md delete mode 100644 doc/tested-boards.md diff --git a/README.md b/README.md index b26a147e9..5c601f36c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ These programmer boards are available in four versions: ## Supported hardware combinations -Currently known working combinations of programmers and targets are listed in [doc/tested-boards.md](doc/tested-boards.md). +Currently known working combinations of programmers and targets are listed in [doc/devices_boards.md](doc/tested-boards.md). ## Installation diff --git a/doc/devices_boards.md b/doc/devices_boards.md new file mode 100644 index 000000000..d9e106503 --- /dev/null +++ b/doc/devices_boards.md @@ -0,0 +1,258 @@ +Boards supported by the STlink toolset +====================================== + +The following devices are supported by the STlink tools. + +All Boards are expected to work with ST-Link-v2 programmers. + + +**STM32F0 / ARM Cortex M0 / Core-ID: 0x0bb11477 (STM32F0_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x440 | STM32F0**30**x**8** | +| 0x442 | STM32F0**30**x**C** | +| 0x444 | STM32F0**3**xx**4** | +| 0x444 | STM32F0**3**xx**6** | +| 0x445 | STM32F0**4**xxx | +| 0x440 | STM32F0**5**xxx | +| 0x445 | STM32F0**70**x**6** | +| 0x448 | STM32F0**70**x**B** | +| 0x448 | STM32F0**71**xx | +| 0x448 | STM32F0**72**xx | +| 0x442 | STM32F0**9**xxx | + +Tested boards [incl. STLink programmers]: +* Nucleo-F030R8 [v2-1] +* Nucleo-32 [v2-1] +* STM32F0-Discovery [v2] +* STM320518-EVAL +* Nucleo-F072RB [v2-1] +* Nucleo-F091RC [v2-1] + + +**STM32F1 / ARM Cortex M3 / Core-ID: 0x1ba01477 (STM32F1_CORE_ID)** + +| Product-Code | Product Line | +| --- | --- | +| STM32F10**0**yyxx | Value line (V) | +| STM32F10**1**yyxx | Access line (A) | +| STM32F10**2**yyxx | USB Access line (USB-A) | +| STM32F10**3**yyxx | Performance line (P) | +| STM32F10**5**yyxx | Connectivity line (C) | +| STM32F10**7**yyxx | Connectivity line (C) | + +| Chip-ID | Product Line | Code (yy) | V | A | USB-A | P | C | +| --- | --- | --- | --- | --- | --- | --- | --- | +| 0x412 | Low-Density | x4 x6 | F100 | F101 | F102 | F103 | | +| 0x410 | Medium Density | x8 xB | | F101 | F102 | F103 | | +| 0x414 | High density | xC xD xE | | F101 | F103 | | | +| 0x418 | STM32F105xx/107xx | x8 xB xC | | | | | F105
F107 | +| 0x420 | Medium density value | x8 xB | F100 | | | | | +| 0x428 | High density Value | xC xD xE | F100 | | | | | +| 0x430 | XL-Density | xF XG | | F101 | | F103 | | + +Tested boards [incl. STLink programmers]: +* 32VL-Discovery (STM32F100RBT6) with STLink-v1 [v1, v2] +* STM32F103-Bluepill: C8Tx & R8xx [v2] +* Nucleo-F103RB [v2-1] +* HY-STM32 (STM32F103VETx) [v1, v2] +* DecaWave EVB1000 (STM32F105RCTx) [v1, v2] + + +**STM32F2 / ARM Cortex M3 / Core-ID: 0x2ba01477 (STM32F2_CORE_ID)** + +| Chip-ID | Product-Code | Product Line | +| --- | --- | --- | +| 0x411 | STM32F2yyxx | (all devices) | + + +**STM32F1 / ARM Cortex M3 / Core-ID: 0x2ba01477 (STM3F1c_CORE_ID)** + +| Product-Code | Chip-ID | STLink
Programmer | Boards | +| --- | --- | --- | --- | +| CKS32F103C8Tx | 0x410 | v2 | "STM32"-Bluepill ( _**Fake-Marking !**_ )
STM32F103C8T6 clone from China Key Systems (CKS) | +| CKS32F103C8Tx | 0x410 | v2 | CKS32-Bluepill (Clone)
STM32F103C8T6 clone from China Key Systems (CKS) | + + +**STM32F3 / ARM Cortex M4F / Core-ID: 0x2ba01477 (STM32F3_CORE_ID)** + +| Product-Code | Product Line | +| --- | --- | +| STM32F3**01**yyxx | Access line (A) | +| STM32F3**02**yyxx | USB & CAN line (USB/CAN) | +| STM32F3**03**yyxx | Performance line (P) | +| STM32F3**34**yy | Digital Power line (DP) | +| STM32F3**73**yy | Precision Measurement line (PM) 64k/16k / 128k/24k / 265k/32k | +| STM32F3**18**yy | General Purpose line (GP) 64k/16k | +| STM32F3**28**yy | General Purpose line (GP) 64k/16k | +| STM32F3**58**yy | General Purpose line (GP) 265k/48k | +| STM32F3**78**yy | Precision Measurement line (PM) 265k/32k | +| STM32F3**98**yy | General Purpose line (GP) 512k/80k | + +| Chip-ID | Product Line | Code (yy) | A | USB/CAN | P | others | +| --- | --- | --- | --- | --- | --- | --- | +| 0x422 | _N/A_ | xB xC | | F302 | F303 | | +| 0x422 | _N/A_ | - | | | | F358 | +| 0x432 | _N/A_ | - | | | | F373
F378 | +| 0x438 | _N/A_ | x4 x6 x8 | | | F303 | | +| 0x438 | _N/A_ | - | | | | F334
F328 | +| 0x439 | _N/A_ | x4 x6 x8 | F301 | F302 | | | +| 0x439 | _N/A_ | - | | | | F318 | +| 0x446 | _N/A_ | xD xE | | F302 | F303 | | +| 0x446 | _N/A_ | - | | | | F398 | + +Tested boards [incl. STLink programmers]: +* Nucleo-F302K8 [v2-1] +* Nucleo-F303K8 [v2-1] +* STM32F3348-Discovery [v2-1] +* Nucleo-F334R8 [v2-1] +* STM32F303-Discovery [v2] +* Nucleo-F303RE [v2-1] + + +**STM32F3 / ARM Cortex M4F / Core-ID: 0x2ba01477 (STM32F3c_CORE_ID)** + +| Product-Code | Chip-ID | STLink
Programmer | Boards | +| --- | --- | --- | --- | +| GD32F303VGT6 | 0x430 | _N/A_ | STM32F303 clone from GigaDevice GD)
_unsupported_ | + + +**STM32F4 / ARM Cortex M4F / Core-ID: 0x2ba01477 (STM32F4_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x413 | STM32F4**0**xxx | +| 0x413 | STM32F4**1**xxx | +| 0x419 | STM32F4**2**xxx | +| 0x419 | STM32F4**3**xxx | +| 0x423 | STM32F4**01**x**B** | +| 0x423 | STM32F4**01**x**C** | +| 0x433 | STM32F4**01**x**D** | +| 0x433 | STM32F4**01**x**E** | +| 0x458 | STM32F4**10**xx | +| 0x431 | STM32F4**11**xx | +| 0x441 | STM32F4**12**xx | +| 0x421 | STM32F4**46**xx | +| 0x434 | STM32F4**69**xx | +| 0x434 | STM32F4**79**xx | +| 0x463 | STM32F4**13**xx | +| 0x463 | STM32F4**23**xx | + +Tested boards [incl. STLink programmers]: +* STM32F407-Discovery [v2] +* 32F411E-Discovery with gyro, audio [v2] +* 32F429I-Discovery with LCD [v2] +* 32F439VIT6-Discovery [v2] (reseated MCU) +* Nucleo-F401RE [v2-1] +* Nucleo-F411RE [v2-1] +* 32F413H-Discovery [v2-1] + + +**STM32F7 / ARM Cortex M7F / Core-ID: 0x5ba02477 (STM32F7_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x452 | STM32F7**2**xxx | +| 0x452 | STM32F7**3**xxx | +| 0x449 | STM32F7**4**xxx | +| 0x449 | STM32F7**5**xxx | +| 0x451 | STM32F7**6**xxx | +| 0x451 | STM32F7**7**xxx | + +Tested boards [incl. STLink programmers]: +* STM32F756NGHx evaluation board [v2-1] +* 32F769I-Discovery [v2-1] +* Nucleo-F722ZE [v2-1] +* Nucleo-F746ZG [v2-1] + + +**STM32G0 / ARM Cortex M0+ / Core-ID: 0x0bc11477 (STM32G0_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x466 | STM32G0**3**xxx | +| 0x466 | STM32G0**4**xxx | +| 0x460 | STM32G0**7**xxx | +| 0x460 | STM32G0**8**xxx | + + +**STM32G4 / ARM Cortex M4F / Core-ID: 0x2ba01477 (STM32G4_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x468 | STM32G4**31**xx | +| 0x468 | STM32G4**41**xx | +| 0x469 | STM32G4**7**xxx | +| 0x469 | STM32G4**8**xxx | + + +**STM32L0 / ARM Cortex M0+ / Core-ID: 0x0bc11477 (STM32L0_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x457 | STM32L0**1**xxx | +| 0x457 | STM32L0**2**xxx | +| 0x425 | STM32L0**31**xx | +| 0x425 | STM32L0**41**xx | +| 0x417 | STM32L0**5**xxx | +| 0x417 | STM32L0**6**xxx | +| 0x447 | STM32L0**7**xxx | +| 0x447 | STM32L0**8**xxx | + +Tested boards [incl. STLink programmers]: +* Nucleo-L053R8 [v2-1] + + +**STM32L1 / ARM Cortex M3 / Core-ID: 0x2ba01477 (STM32L1_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x416 | STM32L1xxx**6** | +| 0x416 | STM32L1xxx**8** | +| 0x416 | STM32L1xxx**B** | +| 0x429 | STM32L1xxx**6A** | +| 0x429 | STM32L1xxx**8A** | +| 0x429 | STM32L1xxx**BA** | +| 0x427 | STM32L1xxx**C** | +| 0x436 | STM32L1xxx**D** | +| 0x437 | STM32L1xxx**E** | + +Tested boards [incl. STLink programmers]: +* Nucleo-L152RE [v2-1] +* 32L152C-Discovery [v2] + + +**STM32L4 / ARM Cortex M4F / Core-ID: 0x2ba01477 (STM32L4_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x464 | STM32L4**12**xx | +| 0x464 | STM32L4**22**xx | +| 0x435 | STM32L4**3**xxx | +| 0x435 | STM32L4**4**xxx | +| 0x462 | STM32L4**5**xxx | +| 0x462 | STM32L4**6**xxx | +| 0x415 | STM32L4**7**xxx | +| 0x415 | STM32L4**8**xxx | +| 0x461 | STM32L4**96**xx | +| 0x461 | STM32L4**A6**xx | +| 0x470 | STM32L4**R**xx | +| 0x470 | STM32L4**S**xx | +| 0x471 | STM32L4**P5**xx | +| 0x471 | STM32L4**Q5**xx | + +Tested boards [incl. STLink programmers]: +* Nucleo-L452RE [v2-1] +* Nucleo-L476RG [v2-1] +* Nucleo-L496ZG [v2-1] +* 32L4R9I-Discovery [v2-1] + + +**STM32W / ARM Cortex M3 / Core-ID: 0x2ba01477 (STM32W_CORE_ID)** + +| Chip-ID | Product-Code | +| --- | --- | +| 0x495 | STM32WB**50**xx | +| 0x495 | STM32WB**55**xx | +| 0x497 | STM32WLE**5**xx | diff --git a/doc/tested-boards.md b/doc/tested-boards.md deleted file mode 100644 index ebc47c2ac..000000000 --- a/doc/tested-boards.md +++ /dev/null @@ -1,57 +0,0 @@ -Stlink tested and compatible boards -=================================== - -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: - -* STM32F0 (STM32F0 Discovery board) -* STM32F030F4P6 (custom board) -* STM32F051R8T6 (STM320518-EVAL board) -* STM32F100xx (Medium Density VL, as on the 32VL Discovery board) -* STM32F103VET6 (HY-STM32 board) -* STM32F105RCT6 (DecaWave EVB1000 board) -* STM32F303xx (STM32F3 Discovery board) -* STM32F407xx (STM32F4 Discovery board) -* STM32F411E-DISCO (STM32F4 Discovery board with gyro, audio) -* STM32F429I-DISCO (STM32F4 Discovery board with LCD) -* STM32F439VIT6 (Discovery board reseated CPU) -* STM32L052K8T6 (custom board) -* STM32L1xx (STM32L Discovery board) -* STM32L151CB (custom board) -* STM32L152RB (STM32L-Discovery board, custom board) -* STM32L496ZG (STM32-Nucleo-L496ZG 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) - - -STLink v2-1 (as found on the Nucleo boards), known working targets: - -* STM32F030R8T6 (STM32 Nucleo-F030R8 board) -* STM32F042K6 (STM32 Nucleo-32 Board) -* STM32F072RBT6 (STM32 Nucleo-F072RB board) -* STM32F103RB (STM32 Nucleo-F103RB board) -* STM32F303RET6 (STM32 Nucleo-F303RE board) -* STM32F334R8 (STM32 Nucleo-F334R8 board) -* STM32F401xx (STM32 Nucleo-F401RE board) -* STM32F411RET6 (STM32 Nucleo-F411RE board) -* STM32F756NGHx (STM32F7 evaluation board) -* STM32F769NI (STM32F7 discovery board) -* STM32L053R8 (STM32 Nucleo-L053R8 board) -* STM32L152RE (STM32-Nucleo-L152RE board -* STM32L452RET6 (STM32 Nucleo-L452RE board) -* STM32L476RG (STM32 Nucleo-L476RG board) - - -Please report any and all known working combinations so I can update this! diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index f179db779..8895cd4f8 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -28,7 +28,7 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F3 = 0x422, STLINK_CHIPID_STM32_F4_LP = 0x423, STLINK_CHIPID_STM32_L0_CAT2 = 0x425, - STLINK_CHIPID_STM32_L1_MEDIUM_PLUS = 0x427, + STLINK_CHIPID_STM32_L1_MEDIUM_PLUS = 0x427, /* assigned to some L1 "Medium-plus" chips */ STLINK_CHIPID_STM32_F1_VL_HIGH = 0x428, STLINK_CHIPID_STM32_L1_CAT2 = 0x429, STLINK_CHIPID_STM32_F1_XL = 0x430, @@ -36,23 +36,11 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F37x = 0x432, STLINK_CHIPID_STM32_F4_DE = 0x433, STLINK_CHIPID_STM32_F4_DSI = 0x434, - /* - * 0x435 covers STM32L43xxx and STM32L44xxx devices - * 0x461 covers STM32L496xx and STM32L4A6xx devices - * 0x462 covers STM32L45xxx and STM32L46xxx devices - * 0x464 covers STM32L41xxx and STM32L42xxx devices - */ - STLINK_CHIPID_STM32_L43X = 0x435, - STLINK_CHIPID_STM32_L496X = 0x461, - STLINK_CHIPID_STM32_L46X = 0x462, - STLINK_CHIPID_STM32_L41X = 0x464, - /* - * 0x436 is actually assigned to some L1 chips that are called "Medium-Plus" - * and some that are called "High". 0x427 is assigned to the other "Medium- - * plus" chips. To make it a bit simpler we just call 427 MEDIUM_PLUS and - * 0x436 HIGH. - */ - STLINK_CHIPID_STM32_L1_HIGH = 0x436, + STLINK_CHIPID_STM32_L43X = 0x435, /* covers STM32L43xxx and STM32L44xxx devices */ + STLINK_CHIPID_STM32_L496X = 0x461, /* covers STM32L496xx and STM32L4A6xx devices */ + STLINK_CHIPID_STM32_L46X = 0x462, /* covers STM32L45xxx and STM32L46xxx devices */ + STLINK_CHIPID_STM32_L41X = 0x464, /* covers STM32L41xxx and STM32L42xxx devices */ + STLINK_CHIPID_STM32_L1_HIGH = 0x436, /* assigned to some L1 chips called "Medium-Plus" and to some called "High" */ STLINK_CHIPID_STM32_L152_RE = 0x437, STLINK_CHIPID_STM32_F334 = 0x438, STLINK_CHIPID_STM32_F3_SMALL = 0x439, @@ -69,12 +57,12 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F72XXX = 0x452, /* This ID is found on the NucleoF722ZE board */ STLINK_CHIPID_STM32_L011 = 0x457, STLINK_CHIPID_STM32_F410 = 0x458, - STLINK_CHIPID_STM32_G0_CAT2 = 0x460, // G070/G071/081 + STLINK_CHIPID_STM32_G0_CAT2 = 0x460, /* G070/G071/081 */ STLINK_CHIPID_STM32_F413 = 0x463, - STLINK_CHIPID_STM32_G0_CAT1 = 0x466, // G030/G031/041 - STLINK_CHIPID_STM32_G4_CAT2 = 0x468, // See: RM 0440 s46.6.1 "MCU device ID code". + STLINK_CHIPID_STM32_G0_CAT1 = 0x466, /* G030/G031/041 */ + STLINK_CHIPID_STM32_G4_CAT2 = 0x468, /* See: RM 0440 s46.6.1 "MCU device ID code" */ STLINK_CHIPID_STM32_G4_CAT3 = 0x469, - STLINK_CHIPID_STM32_L4RX = 0x470, // taken from the STM32L4R9I-DISCO board + STLINK_CHIPID_STM32_L4RX = 0x470, /* taken from the STM32L4R9I-DISCO board */ STLINK_CHIPID_STM32_WB55 = 0x495 }; From d3c11fbef6d8205742152f646b223323dc4c0913 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 2 Apr 2020 20:55:27 +0200 Subject: [PATCH 053/236] General Project Update - [doc] Updated list of supported devices - [doc] verify udev-rules (Closes #764) - Removed old issue-templates. - Updated BSD-3 license file. --- .github/ISSUE_TEMPLATE/bug_report.md | 32 -------------- .github/ISSUE_TEMPLATE/feature_request.md | 32 -------------- .github/ISSUE_TEMPLATE/support_question.md | 32 -------------- LICENSE.md | 48 ++++++++++----------- doc/devices_boards.md | 1 + doc/tutorial.md | 49 ++++++++++++++++++++++ 6 files changed, 74 insertions(+), 120 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/support_question.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 821b406bc..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,32 +0,0 @@ -# Bug Report - -Thank you for giving feedback to the stlink project. - -In order to allow developers and other contributors to isolate and target your respective issue, please take some time to fill out the check boxes below by setting a 'x' into the checkboxes ( [x] ) and edit each item appropriate to your specific problem. - -- [ ] Programmer/board type: e.g Stlink/v1, Stlink/v2, Stlink/v2-onboard -- [ ] Programmer firmware version: e.g STSW-LINK007 2.27.15 -- [ ] Operating system: e.g Linux, Mac OS X, Windows (with specific version) -- [ ] Stlink tools version and/or git commit hash: e.g v1.1.0/git-c722056 -- [ ] Stlink commandline tool name: e.g `st-info`, `st-flash`, `st-util` -- [ ] Target chip (and optional board): e.g STM32F402VG (STM32Fxxx Discovery) - -Futher we kindly ask you to describe the detected problem as detailled as possible and to add debug output if available, by using the following template: - -Commandline-Output: - -``` -OUTPUT/ERROR of the commandline tool(s) -``` - -Expected/description: - -`short description of the expected value` - - -**NOTICE: The bug report may be closed without notice when not enough information is provided!** - - -Thank you for your support. - -The stlink project maintainers diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bf626eb97..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,32 +0,0 @@ -# Feature Request - -Thank you for giving feedback to the stlink project. - -In order to allow developers and other contributors to isolate and target your respective issue, please take some time to fill out the check boxes below by setting a 'x' into the checkboxes ( [x] ) and edit each item appropriate to your specific problem. - -- [ ] Programmer/board type: e.g Stlink/v1, Stlink/v2, Stlink/v2-onboard -- [ ] Programmer firmware version: e.g STSW-LINK007 2.27.15 -- [ ] Operating system: e.g Linux, Mac OS X, Windows (with specific version) -- [ ] Stlink tools version and/or git commit hash: e.g v1.1.0/git-c722056 -- [ ] Stlink commandline tool name: e.g `st-info`, `st-flash`, `st-util` -- [ ] Target chip (and optional board): e.g STM32F402VG (STM32Fxxx Discovery) - -Futher we kindly ask you to describe the detected problem as detailled as possible and to add debug output if available, by using the following template: - -Commandline-Output: - -``` -OUTPUT/ERROR of the commandline tool(s) -``` - -Expected/description: - -`short description of the expected value` - - -**NOTICE: This feature request may be closed without notice when not enough information is provided!** - - -Thank you for your support. - -The stlink project maintainers diff --git a/.github/ISSUE_TEMPLATE/support_question.md b/.github/ISSUE_TEMPLATE/support_question.md deleted file mode 100644 index 795c13a6e..000000000 --- a/.github/ISSUE_TEMPLATE/support_question.md +++ /dev/null @@ -1,32 +0,0 @@ -# Support question - -Thank you for giving feedback to the stlink project. - -In order to allow developers and other contributors to help you with your question, please take some time to fill out the check boxes below by setting a 'x' into the checkboxes ( [x] ) and edit each item appropriate to your specific problem. - -- [ ] Programmer/board type: e.g Stlink/v1, Stlink/v2, Stlink/v2-onboard -- [ ] Programmer firmware version: e.g STSW-LINK007 2.27.15 -- [ ] Operating system: e.g Linux, Mac OS X, Windows (with specific version) -- [ ] Stlink tools version and/or git commit hash: e.g v1.1.0/git-c722056 -- [ ] Stlink commandline tool name: e.g `st-info`, `st-flash`, `st-util` -- [ ] Target chip (and optional board): e.g STM32F402VG (STM32Fxxx Discovery) - -Futher we kindly ask you to describe the detected problem as detailled as possible and to add debug output if available, by using the following template: - -Commandline-Output: - -``` -OUTPUT/ERROR of the commandline tool(s) -``` - -Expected/description: - -`short description of the expected value` - - -**NOTICE: This support question may be closed without notice when not enough information is provided!** - - -Thank you for your support. - -The stlink project maintainers diff --git a/LICENSE.md b/LICENSE.md index 3d464ca1e..0a3ddd1f7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,29 +1,29 @@ -Copyright (c) 2011 The stlink project (github.com/texane/stlink) contributors. - All rights reserved. -Copyright (c) 2011 The "Capt'ns Missing Link" Authors. All rights reserved. +BSD 3-Clause License + +Copyright (c) 2020, The stlink project (github.com/texane/stlink) & "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: +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. 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. - * 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. +3. Neither the name of the copyright holder 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 +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 HOLDER 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. diff --git a/doc/devices_boards.md b/doc/devices_boards.md index d9e106503..00acdd2cf 100644 --- a/doc/devices_boards.md +++ b/doc/devices_boards.md @@ -243,6 +243,7 @@ Tested boards [incl. STLink programmers]: | 0x471 | STM32L4**Q5**xx | Tested boards [incl. STLink programmers]: +* Nucleo-L432KC [v2-1] * Nucleo-L452RE [v2-1] * Nucleo-L476RG [v2-1] * Nucleo-L496ZG [v2-1] diff --git a/doc/tutorial.md b/doc/tutorial.md index 100d9a641..4d870d11b 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -170,6 +170,55 @@ Upon reset, the board LEDs should be blinking. HOWTO ===== + +## Verify if udev rules are set correctly (by Dave Hylands) + +To investigate, start by plugging your STLINK device into the usb port. Then run lsusb. You should see an entry something like the following: + +``` +Bus 005 Device 017: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB) +``` + +Note the bus number (005) and the Device (017). You should then do: +`ls -l /dev/bus/usb/005/017` (replacing 005 and 017 appropriately). + +On my system I see the following: + +``` +crw-rw-rw- 1 root root 189, 528 Jan 24 17:52 /dev/bus/usb/005/017 +``` + +which is world writable (this is from the MODE:="0666" below). I have several files in my `/etc/udev/rules.d` directory. In this particular case, the `49-stlinkv2-1.rules` file contains the following: + +``` +# stm32 nucleo boards, with onboard st/linkv2-1 +# ie, STM32F0, STM32F4. +# STM32VL has st/linkv1, which is quite different + +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ + MODE:="0666", \ + SYMLINK+="stlinkv2-1_%n" + +# If you share your linux system with other users, or just don't like the +# idea of write permission for everybody, you can replace MODE:="0666" with +# OWNER:="yourusername" to create the device owned by you, or with +# GROUP:="somegroupname" and mange access using standard unix groups. +``` + +and the idVendor of 0483 and idProduct of 374b matches the vendor id from the lsusb output. + +Make sure that you have all 3 files from here: https://github.com/texane/stlink/tree/master/etc/udev/rules.d in your `/etc/udev/rules.d` directory. After copying new files or editing excisting files in `/etc/udev/ruled.d` you should run the following: + +``` +sudo udevadm control --reload-rules +sudo udevadm trigger +``` + +to ensure that the rules actually take effect. Using the trigger command means that you shouldn't need to unplug and replug the device, but you might want to try that for good measure as well. + +If the VID:PID of your device doesn't match those in any of the 3 files, then you may need to create a custom rule file to match your VID:PID. + + ## Using the gdb server To run the gdb server: From 7d4822d03ba758bc4013cf74e91ba44070b6b81c Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 2 Apr 2020 21:29:02 +0200 Subject: [PATCH 054/236] [doc] Added st-flash --flash CL option (Closes #902) --- doc/tutorial.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index 4d870d11b..1d48eaa38 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1,3 +1,20 @@ +stlink Tools Tutorial +===================== + +## Useful tool options +### st-flash + +#### --flash=n[k][m] + +(since v1.4.0) + +You can specify `--flash=128k` for example, to override the STM32F103C8T6 to assume 128k of flash instead of the default of 64k. +This option accepts decimal (128k), octal 0200k, or hex 0x80k. +Obviously leaving the multiplier out is equally valid, for example: `--flash=0x20000`. +The size may be followed by an optional "k" or "m" to multiply the given value by 1k (1024) or 1M respectively. + +------ + Using STM32 discovery kits with open source tools ======== From 3bc5e6f69944cef9f44e3c56b31beb2609f67722 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 3 Apr 2020 11:49:31 +0200 Subject: [PATCH 055/236] [doc] Added reference to tutorial --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c601f36c..1f9771982 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,12 @@ These programmer boards are available in four versions: ## Supported hardware combinations -Currently known working combinations of programmers and targets are listed in [doc/devices_boards.md](doc/tested-boards.md). +Currently known working combinations of programmers and targets are listed in [devices_boards.md](doc/devices_boards.md). + + +## Tutorial & HOWTO + +Our [tutorial.md](doc/tutorial.md may help you along with some advanced tasks and additional info. ## Installation @@ -77,7 +82,7 @@ When there is no executable available for your platform or you need the latest ( ## License -The stlink library and tools are licensed under the [BSD license](LICENSE.md). +The stlink library and tools are licensed under the [BSD-3 license](LICENSE.md). The flashloaders/stm32l0x.s and flashloaders/stm32lx.s source files are licensed under the GPLv2+. From 27aa88821197d3ffe82baff4e971c3488ec39899 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 4 Apr 2020 13:03:22 +0200 Subject: [PATCH 056/236] Updated compiling doc & version support - Added info on version support - Updated compiling instructions - Updated minGW-w64 gcc-TC to v8.1.0 - Minor formatting fixes (Closes #896, #897, #899) --- cmake/modules/FindLibUSB.cmake | 8 +- doc/compiling.md | 284 +++++++++++++++------------------ doc/version_support.md | 82 ++++++++++ include/stlink/stlinkusb.h | 20 +-- scripts/mingw64-build.bat | 2 +- 5 files changed, 230 insertions(+), 166 deletions(-) create mode 100644 doc/version_support.md diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index f88556205..c8f467902 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -6,13 +6,13 @@ # LIBUSB_LIBRARY - The libraries needed to use libusb # LIBUSB_DEFINITIONS - Compiler switches required for using libusb -# FreeBSD -if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + +if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h HINTS /usr/include ) -else () +else () # other OS FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h HINTS /usr @@ -22,6 +22,8 @@ else () ) endif() + +# macOS if (APPLE) set(LIBUSB_NAME libusb-1.0.a) elseif(MSYS OR MINGW) diff --git a/doc/compiling.md b/doc/compiling.md index 2728c153b..0133981b1 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -1,224 +1,204 @@ # 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 -``` - -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: +* `7zip` +* `git` +* `cmake` (3.17.0 or later) +* `MinGW-w64` (7.0.0 or later) with GCC toolchain 8.1.0 -``` -$ mkdir build && cd build -$ cmake -DCMAKE_BUILD_TYPE=Debug .. -$ make -``` -You may install to a user folder e.g `$HOME`: +### Installation -``` -$ cd build/Release; make install DESTDIR=$HOME -``` +1. Install `7zip` from +2. Install `git` from +3. Install `cmake` from +4. Install + - _EITHER_: **MinGW-w64** from (mingw-w64-install.exe)
+ Ensure that you add MinGW to the $PATH system variable when following the instructions by the setup assistant.
+ - _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)
+ or download the stlink zip-sourcefolder from the Release page on GitHub -Or system-wide: -``` -$ cd build/Release; sudo make install -``` +### Building +#### MinGW64 +1. Use the command-line to move to the `scripts` directory within the source-folder: `cd stlink\scripts\` +2. Execute `./mingw64-build.bat` -## Linux / Unix -## Common requirements +NOTE:
+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`.
+When installing different toolchains make sure to update the path in the `mingw64-build.bat`.
+This can be achieved by opening the .bat file with a common text editor. -* `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`)_ -As of today several distributions namely: +#### Visual Studio (32 bit) -- 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 +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 ..`). -provide packages for libusb 0.1 and libusb 1.0. +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). -**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. +NOTE:
+This solution will link to the dll version of libusb-1.0.y
+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 +### Common requirements -### Fixing cannot open shared object file +Install the following packages from your package repository: -When installing system-wide (`sudo make install`) the dynamic library cache needs to be updated with the command `ldconfig`. +* `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` -## Permissions with udev +(Replace gcc with the intended C-compiler if necessary or leave out any optional package not needed.) -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 +### Installation -The STLINKv1's SCSI emulation is corrupted, so the best thing to do is tell your operating system to completely ignore it. +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` -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` +### 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_)
+ The debug target is only necessary in order to modify the sources and to run under a debugger. -### Build Debian Package +The top level Makefile is just a handy wrapper for: -To build the debian package you need the additional packages `devscripts` and `debhelper`. +##### MinGW64: +```sh +$ mkdir build && cd build +$ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake -S .. +$ make ``` -$ 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 +##### MinGW32: -When compiling on a mac you need the following: - -* 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 +```sh +$ mkdir build && cd build +$ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -S .. +$ make ``` -Compile as described in the first section of this document. - - -## Build using different directories for udev and modprobe +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`. -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" .. -``` +When installing system-wide, the dynamic library cache needs to be updated with the command `ldconfig`. -## Build using different directory for shared libs +### Build a Debian Package -To put the compiled shared libs into a different directory during installation you can use the following cmake option: +To build the debian package you need the following extra packages: `devscripts 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 ``` -$ cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" .. -``` - -## Windows (MinGW64) -### Prerequisites -* 7zip -* cmake 2.8 or higher -* MinGW64 GCC toolchain (5.3.0) +### Set permissions with udev +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`. -### Installation - -1. Install 7zip from -2. Install CMake from -3. Install MinGW64 from (mingw-w64-install.exe) -4. Git clone or download stlink sourcefiles zip +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 +$ cp etc/udev/rules.d /etc/udev/rules.d +$ udevadm control --reload-rules +$ udevadm trigger +``` -### Building +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. -Check and execute (in the script folder) `\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` +### 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. -## Windows (Visual Studio) -### Prerequisites +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. -* 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) +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` -### Installation -1. Install 7zip from -2. Install CMake from -3. Git clone or download stlink sourcefiles zip +Author: nightwalker-87 +----- -### Building +---- **The following content is outdated and unrevised!** ---- -These instructions are for a 32-bit version. +## Mac OS X -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 ..`). +When compiling on a mac you need the following: -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). +* A compiler toolchain (XCode) +* CMake +* Libusb 1.0 -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`. +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 +``` -## Linux (MinGW64) -### Prerequisites +Compile as described in the first section of this document. -* 7zip -* cmake 2.8 or higher -* MinGW64 GCC toolchain (5.3.0) +## Build using different directories for udev and modprobe -### Installation (Debian / Ubuntu) +To put the udev or the modprobe configuration files into a different directory +during installation you can use the following cmake options: -sudo apt install p7zip mingw-w64 +``` +$ cmake -DSTLINK_UDEV_RULES_DIR="/usr/lib/udev/rules.d" \ + -DSTLINK_MODPROBED_DIR="/usr/lib/modprobe.d" .. +``` -### Building +## Build using different directory for shared libs -These instructions are for a 32-bit version. +To put the compiled shared libs into a different directory during installation +you can use the following cmake option: -```sh -cd -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -S . -B ./build/linux-mingw32 -cmake --build ./build/linux-mingw32 --target all +``` +$ cmake -DLIB_INSTALL_DIR:PATH="/usr/lib64" .. ``` diff --git a/doc/version_support.md b/doc/version_support.md new file mode 100644 index 000000000..963ca2988 --- /dev/null +++ b/doc/version_support.md @@ -0,0 +1,82 @@ + +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.
+Up on compiling c-make will check **automatically**, whether `libusb` 1.0.20 or later is present.
+If this is not the case, the installation routine will download the latest version (1.0.23 at the time of writing).
+Thus no user interaction regarding libusb is necessary. + +* Windows 10 +* Windows 8.1 + +### Apple macOS + +On macOS users should ensure that cmake 3.17.0 is installed. + +--> libusb Installation routine: (TBD) Work in progress... + +* macOS 10.15 Catalina +* macOS 10.14 Mojave +* macOS 10.13 High Sierra + +### Linux-/Unix-based: + +| Operating System | libusb
version | cmake
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
version | cmake
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 diff --git a/include/stlink/stlinkusb.h b/include/stlink/stlinkusb.h index 4d904b0c5..633d82bd0 100644 --- a/include/stlink/stlinkusb.h +++ b/include/stlink/stlinkusb.h @@ -22,25 +22,25 @@ */ #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 + #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 + #define MINIMAL_API_VERSION 0x01000102 // v1.0.16 #elif defined (__linux__) -#define MINIMAL_API_VERSION 0x01000104 + #define MINIMAL_API_VERSION 0x01000104 // v1.0.20 #elif defined (__APPLE__) -#define MINIMAL_API_VERSION 0x01000104 + #define MINIMAL_API_VERSION 0x01000104 // v1.0.20 #elif defined (_WIN32) -#define MINIMAL_API_VERSION 0x01000106 + #define MINIMAL_API_VERSION 0x01000104 // v1.0.20 #endif #if ( LIBUSB_API_VERSION < MINIMAL_API_VERSION ) -#error unsupported libusb version + #error unsupported libusb version #endif #endif // STLINKUSB_H diff --git a/scripts/mingw64-build.bat b/scripts/mingw64-build.bat index 3f92ae8e0..773195410 100644 --- a/scripts/mingw64-build.bat +++ b/scripts/mingw64-build.bat @@ -1,5 +1,5 @@ @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% +set PATH=C:\Program Files (x86)\CMake\bin;C:\Program Files\CMake\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0\mingw64\bin;%PATH% cmake -G "MinGW Makefiles" .. mingw32-make mingw32-make install DESTDIR=_install From 587fb48ce4db923cf683b7e9d58471d8166457d3 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 5 Apr 2020 14:25:45 +0200 Subject: [PATCH 057/236] Updated cmake configuration - Alligned formatting - Updated version requirement - Updated pkg-maintainer - [doc] Added note in compiling manual - Fixed install paths in build script - Updated C-flag -std=gnu99 to gnu11 --- .gitignore | 1 + CMakeLists.txt | 173 ++++++++++++------------- cmake/CPackConfig.cmake | 27 ---- cmake/c_flag_overrides.cmake | 2 +- cmake/{CFlags.cmake => c_flags.cmake} | 12 +- cmake/cpack_config.cmake | 28 ++++ cmake/linux-mingw32.cmake | 6 +- cmake/linux-mingw64.cmake | 6 +- cmake/modules/Find7Zip.cmake | 7 +- cmake/modules/FindLibUSB.cmake | 88 +++++++------ cmake/modules/pandocology.cmake | 2 +- cmake/{Version.cmake => version.cmake} | 7 +- doc/app-example/CMakeLists.txt | 22 ++-- doc/compiling.md | 6 +- doc/man/CMakeLists.txt | 50 +++---- include/CMakeLists.txt | 23 +--- scripts/mingw64-build.bat | 5 +- src/gdbserver/CMakeLists.txt | 7 +- src/tools/gui/CMakeLists.txt | 29 +++-- tests/CMakeLists.txt | 12 +- usr/lib/pkgconfig/CMakeLists.txt | 13 +- 21 files changed, 259 insertions(+), 267 deletions(-) delete mode 100644 cmake/CPackConfig.cmake rename cmake/{CFlags.cmake => c_flags.cmake} (86%) create mode 100644 cmake/cpack_config.cmake rename cmake/{Version.cmake => version.cmake} (94%) diff --git a/.gitignore b/.gitignore index 3a3a5f38a..23e7ddc07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build +build-mingw obj-* *.user* diff --git a/CMakeLists.txt b/CMakeLists.txt index 306d3d6ff..4c53f05ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,78 +1,81 @@ -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(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK 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(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 @@ -82,7 +85,6 @@ set(STLINK_HEADERS include/stlink/mmap.h include/stlink/chipid.h include/stlink/flash_loader.h - include/stlink/stlinkusb.h ) set(STLINK_SOURCE @@ -95,8 +97,8 @@ set(STLINK_SOURCE ) 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}) @@ -104,55 +106,56 @@ 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} + ) + +set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) -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() 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} -) + 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} @@ -165,31 +168,29 @@ install(TARGETS ${STLINK_LIB_SHARED} 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} -) + ${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() 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 @@ -197,32 +198,28 @@ endif() 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) @@ -235,5 +232,5 @@ add_subdirectory(include) add_subdirectory(doc/man) add_subdirectory(tests) -include(cmake/CPackConfig.cmake) +include(cmake/cpack_config.cmake) include(CPack) diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake deleted file mode 100644 index 20768453b..000000000 --- a/cmake/CPackConfig.cmake +++ /dev/null @@ -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() diff --git a/cmake/c_flag_overrides.cmake b/cmake/c_flag_overrides.cmake index 663e08175..c15815e17 100644 --- a/cmake/c_flag_overrides.cmake +++ b/cmake/c_flag_overrides.cmake @@ -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") diff --git a/cmake/CFlags.cmake b/cmake/c_flags.cmake similarity index 86% rename from cmake/CFlags.cmake rename to cmake/c_flags.cmake index b76856d24..fbadd6d9e 100644 --- a/cmake/CFlags.cmake +++ b/cmake/c_flags.cmake @@ -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() diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake new file mode 100644 index 000000000..72a98a821 --- /dev/null +++ b/cmake/cpack_config.cmake @@ -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() diff --git a/cmake/linux-mingw32.cmake b/cmake/linux-mingw32.cmake index 2044a7e22..2b4799037 100644 --- a/cmake/linux-mingw32.cmake +++ b/cmake/linux-mingw32.cmake @@ -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) \ No newline at end of file +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/linux-mingw64.cmake b/cmake/linux-mingw64.cmake index db4bd70d0..f8b523965 100644 --- a/cmake/linux-mingw64.cmake +++ b/cmake/linux-mingw64.cmake @@ -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) \ No newline at end of file +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/modules/Find7Zip.cmake b/cmake/modules/Find7Zip.cmake index e4d33dfce..c462f73de 100644 --- a/cmake/modules/Find7Zip.cmake +++ b/cmake/modules/Find7Zip.cmake @@ -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\\" ) diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index c8f467902..a8b65cba3 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -8,56 +8,60 @@ if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD - FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h - HINTS - /usr/include - ) + FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h + HINTS + /usr/include + ) else () # other OS - FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h - HINTS - /usr - /usr/local - /opt - PATH_SUFFIXES libusb-1.0 - ) + FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h + HINTS + /usr + /usr/local + /opt + PATH_SUFFIXES libusb-1.0 + ) endif() # macOS if (APPLE) - set(LIBUSB_NAME libusb-1.0.a) + set(LIBUSB_NAME libusb-1.0.a) elseif(MSYS OR MINGW) - set(LIBUSB_NAME usb-1.0) + set(LIBUSB_NAME usb-1.0) elseif(MSVC) - set(LIBUSB_NAME libusb-1.0.lib) + set(LIBUSB_NAME libusb-1.0.lib) elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") - set(LIBUSB_NAME usb) + set(LIBUSB_NAME usb) else() - set(LIBUSB_NAME usb-1.0) + 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} + 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 ${LIBUSB_WIN_OUTPUT_FOLDER}/MS32/dll) + endif () else() - find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} - HINTS - /usr - /usr/local - /opt) + find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + HINTS + /usr + /usr/local + /opt) endif () include(FindPackageHandleStandardArgs) @@ -72,7 +76,7 @@ if(NOT LIBUSB_FOUND) set(LIBUSB_WIN_VERSION 1.0.23) 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}) message(STATUS "libusb archive already in build folder") @@ -102,13 +106,15 @@ if(NOT LIBUSB_FOUND) if (MSYS OR MINGW) if (CMAKE_SIZEOF_VOID_P EQUAL 8) - find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + 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} + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW32/static NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH @@ -116,13 +122,15 @@ if(NOT LIBUSB_FOUND) endif () elseif(MSVC) if (CMAKE_SIZEOF_VOID_P EQUAL 8) - find_library(LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + 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} + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS32/dll NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH diff --git a/cmake/modules/pandocology.cmake b/cmake/modules/pandocology.cmake index f39f8d952..763eae558 100644 --- a/cmake/modules/pandocology.cmake +++ b/cmake/modules/pandocology.cmake @@ -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() - diff --git a/cmake/Version.cmake b/cmake/version.cmake similarity index 94% rename from cmake/Version.cmake rename to cmake/version.cmake index 71859015c..bdfe95ace 100644 --- a/cmake/Version.cmake +++ b/cmake/version.cmake @@ -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}") diff --git a/doc/app-example/CMakeLists.txt b/doc/app-example/CMakeLists.txt index 0e91bed6f..a7697720c 100644 --- a/doc/app-example/CMakeLists.txt +++ b/doc/app-example/CMakeLists.txt @@ -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) diff --git a/doc/compiling.md b/doc/compiling.md index 0133981b1..bcaf7d567 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -15,10 +15,10 @@ On Windows users should ensure that the following software is installed: 1. Install `7zip` from 2. Install `git` from -3. Install `cmake` from +3. Install `cmake` from
+ Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant. 4. Install - _EITHER_: **MinGW-w64** from (mingw-w64-install.exe)
- Ensure that you add MinGW to the $PATH system variable when following the instructions by the setup assistant.
- _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 @@ -51,7 +51,7 @@ Release) and build the solution normally (F7). NOTE:
This solution will link to the dll version of libusb-1.0.y
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`. +It can be copied from here: `build\3rdparty\libusb-1.0.21\MS32\dll\libusb-1.0.dll`. ## Linux ### Common requirements diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 949cd2fcf..dce8fbfa6 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,37 +1,37 @@ set(MANPAGES - st-util - st-flash - st-info -) + st-util + st-flash + st-info + ) # Only generate manpages with pandoc in Debug builds if(${STLINK_GENERATE_MANPAGES}) - include(pandocology) + include(pandocology) - foreach(manpage ${MANPAGES}) - add_document( - ${manpage}.1 - SOURCES ${manpage}.md - PANDOC_DIRECTIVES -s -t man - PRODUCT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - endforeach() + 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") + 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() + 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() + if (f AND NOT WIN32) + install(FILES ${f} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1) + unset(f) + endif() endforeach() diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index a5121aee5..94df89958 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -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) diff --git a/scripts/mingw64-build.bat b/scripts/mingw64-build.bat index 773195410..15ec21cd0 100644 --- a/scripts/mingw64-build.bat +++ b/scripts/mingw64-build.bat @@ -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-8.1.0-release-win32-sjlj-rt_v6-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 diff --git a/src/gdbserver/CMakeLists.txt b/src/gdbserver/CMakeLists.txt index b4674ebbb..5fb0c1ab8 100644 --- a/src/gdbserver/CMakeLists.txt +++ b/src/gdbserver/CMakeLists.txt @@ -4,7 +4,8 @@ set(STUTIL_SOURCE gdb-server.c gdb-server.h semihosting.c - semihosting.h) + semihosting.h + ) if (MSVC) # We need a getopt from somewhere... @@ -19,6 +20,4 @@ else() target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB}) endif() -install(TARGETS st-util - RUNTIME DESTINATION bin -) +install(TARGETS st-util RUNTIME DESTINATION bin) diff --git a/src/tools/gui/CMakeLists.txt b/src/tools/gui/CMakeLists.txt index 91aabc53b..850f483a9 100644 --- a/src/tools/gui/CMakeLists.txt +++ b/src/tools/gui/CMakeLists.txt @@ -1,5 +1,6 @@ if (NOT gtk_FOUND) - return() + message(STATUS "gtk not found!") + return() endif() set(GUI_SOURCES stlink-gui.c stlink-gui.h) @@ -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) + install(FILES art/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps) endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d0bdffaf..e8ec5fec0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,13 +1,13 @@ set(TESTS - usb - sg -) + usb + sg + ) foreach(test ${TESTS}) - add_executable(${test} ${test}.c) - add_dependencies(${test} ${STLINK_LIB_STATIC}) + 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}) + add_test(${test} ${CMAKE_CURRENT_BINARY_DIR}/${test}) endforeach() add_executable(flash flash.c "${CMAKE_SOURCE_DIR}/src/tools/flash_opts.c") diff --git a/usr/lib/pkgconfig/CMakeLists.txt b/usr/lib/pkgconfig/CMakeLists.txt index a656ff623..5a8227125 100644 --- a/usr/lib/pkgconfig/CMakeLists.txt +++ b/usr/lib/pkgconfig/CMakeLists.txt @@ -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/ + ) From 1818d9375d324cb4c02809e9204abe419805be30 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 5 Apr 2020 14:57:59 +0200 Subject: [PATCH 058/236] Fixed indentation & whitespace. --- CMakeLists.txt | 103 +++++++++++++++++-------------- doc/man/CMakeLists.txt | 59 ++++++++---------- include/CMakeLists.txt | 4 +- src/gdbserver/CMakeLists.txt | 6 +- src/tools/gui/CMakeLists.txt | 10 +-- tests/CMakeLists.txt | 15 ++--- usr/lib/pkgconfig/CMakeLists.txt | 6 +- 7 files changed, 103 insertions(+), 100 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c53f05ea..5d5dab72e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,9 +40,11 @@ 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) @@ -78,27 +80,27 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug") 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_HEADERS "${STLINK_HEADERS};src/mingw/mingw.h") endif () include_directories(${LIBUSB_INCLUDE_DIR}) @@ -106,15 +108,17 @@ 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}) else () @@ -123,8 +127,8 @@ endif () add_library( ${STLINK_LIB_SHARED} SHARED - ${STLINK_HEADERS} # header files for ide projects generated by cmake - ${STLINK_SOURCE} + ${STLINK_HEADERS} # header files for ide projects generated by cmake + ${STLINK_SOURCE} ) target_link_libraries( ${STLINK_LIB_SHARED} @@ -133,21 +137,21 @@ target_link_libraries( 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} +set_target_properties( + ${STLINK_LIB_SHARED} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} - VERSION ${STLINK_SHARED_VERSION} + 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 () @@ -157,28 +161,31 @@ else () target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB}) 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}) @@ -192,9 +199,11 @@ if (STLINK_STATIC_LIB) 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}) @@ -212,21 +221,23 @@ endif () 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 () + 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) diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index dce8fbfa6..5b435c022 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -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 () diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 94df89958..6e5e3c279 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,6 +1,6 @@ configure_file( - "${PROJECT_SOURCE_DIR}/include/stlink/version.h.in" - "${CMAKE_BINARY_DIR}/include/stlink/version.h" + "${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}) diff --git a/src/gdbserver/CMakeLists.txt b/src/gdbserver/CMakeLists.txt index 5fb0c1ab8..ff9bde165 100644 --- a/src/gdbserver/CMakeLists.txt +++ b/src/gdbserver/CMakeLists.txt @@ -10,14 +10,14 @@ set(STUTIL_SOURCE 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) diff --git a/src/tools/gui/CMakeLists.txt b/src/tools/gui/CMakeLists.txt index 850f483a9..d7add834b 100644 --- a/src/tools/gui/CMakeLists.txt +++ b/src/tools/gui/CMakeLists.txt @@ -1,7 +1,7 @@ if (NOT gtk_FOUND) message(STATUS "gtk not found!") - return() -endif() + return() +endif () set(GUI_SOURCES stlink-gui.c stlink-gui.h) set(INSTALLED_UI_DIR share/stlink) @@ -12,7 +12,7 @@ add_executable(stlink-gui-local ${GUI_SOURCES}) 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}) @@ -20,7 +20,7 @@ add_executable(stlink-gui ${GUI_SOURCES}) 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) @@ -31,4 +31,4 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 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") +endif () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e8ec5fec0..c6b04ddb3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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}) diff --git a/usr/lib/pkgconfig/CMakeLists.txt b/usr/lib/pkgconfig/CMakeLists.txt index 5a8227125..02e80cb72 100644 --- a/usr/lib/pkgconfig/CMakeLists.txt +++ b/usr/lib/pkgconfig/CMakeLists.txt @@ -5,11 +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/ + DESTINATION ${STLINK_LIBRARY_PATH}/pkgconfig/ ) From e7ed76bd12ab6cb022b4c011fa706eae69ad77f8 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 5 Apr 2020 18:01:49 +0200 Subject: [PATCH 059/236] Added cmake uninstall target (Fixes #619) --- CMakeLists.txt | 15 +++++++++++++++ cmake_uninstall.cmake.in | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d5dab72e..df5033f7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,3 +245,18 @@ add_subdirectory(tests) 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 () diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000..ed17c45cd --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -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 () From 41f8417eaa196a7f8247b52f604bf8eb946e5f30 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 5 Apr 2020 18:12:39 +0200 Subject: [PATCH 060/236] Integrated module GNUInstallDirs.cmake (Fixes #557) --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df5033f7e..f46a5f591 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,9 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE cmake/c_flag_overrides.cmake) project(stlink C) set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK 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") +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") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) From 7158df1de436ba7bec96181bc853e685ca27062a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 5 Apr 2020 22:02:47 +0200 Subject: [PATCH 061/236] Update for CHANGELOG.md & minor fixes --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d88d83098..c33bcbb47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,7 +72,7 @@ Major changes and added features: Updates and fixes: -* Fixed missing flash_loader for STM32L011 ([#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) +* Fixed missing flash_loader for STM32L0x ([#269](https://github.com/texane/stlink/pull/269), [#274](https://github.com/texane/stlink/pull/274), [#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) * Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696)) * Added semihosting parameter documentation in doc/man ([#674](https://github.com/texane/stlink/pull/674)) * Fixed reference to non-exisiting st-term tool in doc/man ([#676](https://github.com/texane/stlink/pull/676)) @@ -128,11 +128,11 @@ Major changes and added features: Updates and fixes: * Fixed gdb-server: STM32L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/texane/stlink/pull/273)) +* Added --flash=n[k][m] command line option to override device model ([#305](https://github.com/texane/stlink/pull/305), [#516](https://github.com/texane/stlink/pull/516), [#576](https://github.com/texane/stlink/pull/576)) * Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) * Fixed low-voltage flashing on STM32F7 devices ([#566](https://github.com/texane/stlink/pull/566), [#567](https://github.com/texane/stlink/pull/567)) * Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#573](https://github.com/texane/stlink/pull/573), [#578](https://github.com/texane/stlink/pull/578), [#584](https://github.com/texane/stlink/pull/584), [#610](https://github.com/texane/stlink/pull/610)) * Fixed possible memory leak ([#570](https://github.com/texane/stlink/pull/570), [#571](https://github.com/texane/stlink/pull/571)) -* Added --flash=n[k][m] command line option to override device model ([#576](https://github.com/texane/stlink/pull/576)) * Fixed installation path for shared objects ([#581](https://github.com/texane/stlink/pull/581)) * Fixed a few -Wformat warnings ([#582](https://github.com/texane/stlink/pull/582)) * Removed unused defines in mimgw.h ([#583](https://github.com/texane/stlink/pull/583)) @@ -150,7 +150,7 @@ Release date: 2017-02-25 Major changes and added features: * Added support for Semihosting `SYS_READC` ([#546](https://github.com/texane/stlink/pull/546)) -* Added support for STM32F413 ([#549](https://github.com/texane/stlink/pull/549), [#550](https://github.com/texane/stlink/pull/550)) +* Added support for STM32F413 ([#549](https://github.com/texane/stlink/pull/549), [#550](https://github.com/texane/stlink/pull/550), [#758](https://github.com/texane/stlink/pull/758)) * Added preliminary support for STM32L011 to see it after probe (chip-ID 0x457) ([#558](https://github.com/texane/stlink/pull/558), [#598](https://github.com/texane/stlink/pull/598)) Updates and fixes: From e9c8135675d701198f2df22e50bc3062242fcb09 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 6 Apr 2020 19:20:04 +0800 Subject: [PATCH 062/236] Fix int length issues --- src/common.c | 11 +++++++++-- src/usb.c | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common.c b/src/common.c index 6226c893b..ffc6057bb 100644 --- a/src/common.c +++ b/src/common.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -1257,8 +1258,14 @@ static int map_file(mapped_file_t* mf, const char* path) { fprintf(stderr, "fstat() == -1\n"); goto on_error; } - - mf->base = (uint8_t*) mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (sizeof(st.st_size) != sizeof(size_t)) { + /* On 32 bit systems, check if there is an overflow */ + if (st.st_size > (off_t)UINT32_MAX) { + fprintf(stderr, "mmap() size_t overflow\n"); + goto on_error; + } + } + mf->base = (uint8_t*) mmap(NULL, (size_t)(st.st_size), PROT_READ, MAP_SHARED, fd, 0); if (mf->base == MAP_FAILED) { fprintf(stderr, "mmap() == MAP_FAILED\n"); goto on_error; diff --git a/src/usb.c b/src/usb.c index 9df9d7296..81bd7ae2c 100644 --- a/src/usb.c +++ b/src/usb.c @@ -189,7 +189,7 @@ int _stlink_usb_version(stlink_t *sl) { cmd[i++] = STLINK_APIV3_GET_VERSION_EX; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); - if (size != rep_len) { + if (size != (ssize_t)rep_len) { printf("[!] send_recv STLINK_APIV3_GET_VERSION_EX\n"); return (int) size; } From 46bf0abf77cca47133d3839460cc7679e0f78714 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 3 Apr 2020 16:13:35 +0200 Subject: [PATCH 063/236] add dual bank flash configuration info to chipid database. add a 'has_dual_bank' info to flash param, helping handling a couple of cases - selecting over dual bank specific code path without handling multiple chip id all over the code. - handling dual bank mode dynamic configuration --- include/stlink.h | 2 ++ include/stlink/chipid.h | 1 + src/common.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/include/stlink.h b/include/stlink.h index a69e357b5..ba7ef6196 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -159,6 +159,8 @@ typedef struct flash_loader { int serial_size; enum stlink_flash_type flash_type; // stlink_chipid_params.flash_type, set by stlink_load_device_params(), values: STLINK_FLASH_TYPE_xxx + bool has_dual_bank; + stm32_addr_t flash_base; // STM32_FLASH_BASE, set by stlink_load_device_params() size_t flash_size; // calculated by stlink_load_device_params() size_t flash_pgsz; // stlink_chipid_params.flash_pagesize, set by stlink_load_device_params() diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index 8895cd4f8..d23596c0d 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -73,6 +73,7 @@ struct stlink_chipid_params { uint32_t chip_id; char *description; enum stlink_flash_type flash_type; + bool has_dual_bank; uint32_t flash_size_reg; uint32_t flash_pagesize; uint32_t sram_size; diff --git a/src/common.c b/src/common.c index b6496c00c..5ccfcf0bb 100644 --- a/src/common.c +++ b/src/common.c @@ -885,7 +885,9 @@ int stlink_load_device_params(stlink_t *sl) { } else { sl->flash_size = flash_size * 1024; } + sl->flash_type = params->flash_type; + sl->has_dual_bank = params->has_dual_bank; sl->flash_pgsz = params->flash_pagesize; sl->sram_size = params->sram_size; sl->sys_base = params->bootrom_base; From 804c38ead8aef3e4a1640a82a9b9c01f4f60eed1 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 6 Apr 2020 11:18:09 +0200 Subject: [PATCH 064/236] stm32g4: read flash optr to get flash bank mode on cat3 devices. g4 cat3 devices can be configured in two mode via option bytes: - dual bank, 2x256kib, 2KiB pages. - single bank, 1x512KiB, 4KiB pages. in anycase, these have two banks, and need to be handled with more care. -> read optr after loading flash params to patch page size. -> in single bank mode, mass erase _must_ be triggered by applying MER1 and MER2 bits. erasing half of the flash will lead to a pgserr. --- src/chipid.c | 1 + src/common.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/chipid.c b/src/chipid.c index 426780cf7..b9d3933f0 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -562,6 +562,7 @@ static const struct stlink_chipid_params devices[] = { .chip_id = STLINK_CHIPID_STM32_G4_CAT3, .description = "G4 Category-3", .flash_type = STLINK_FLASH_TYPE_G4, + .has_dual_bank = true, .flash_size_reg = 0x1FFF75E0, // Section 47.2 .flash_pagesize = 0x800, // 2K (sec 3.3.1) // SRAM1 is 80k at 0x20000000 diff --git a/src/common.c b/src/common.c index 5ccfcf0bb..8cfbece35 100644 --- a/src/common.c +++ b/src/common.c @@ -128,9 +128,13 @@ #define STM32Gx_FLASH_CR_OBL_LAUNCH (27) /* Forces the option byte loading */ #define STM32Gx_FLASH_CR_OPTLOCK (30) /* Options Lock */ #define STM32Gx_FLASH_CR_LOCK (31) /* FLASH_CR Lock */ + // G0/G4 FLASH status register #define STM32Gx_FLASH_SR_BSY (16) /* FLASH_SR Busy */ +// G4 FLASH option register +#define STM32G4_FLASH_OPTR_DBANK (22) /* FLASH_OPTR Dual Bank Mode */ + // WB (RM0434) #define STM32WB_FLASH_REGS_ADDR ((uint32_t)0x58004000) #define STM32WB_FLASH_ACR (STM32WB_FLASH_REGS_ADDR + 0x00) @@ -899,6 +903,14 @@ int stlink_load_device_params(stlink_t *sl) { sl->sram_size = 0x1000; } + if (sl->chip_id == STLINK_CHIPID_STM32_G4_CAT3) { + uint32_t flash_optr; + stlink_read_debug32(sl, STM32Gx_FLASH_OPTR, &flash_optr); + if (!(flash_optr & (1 << STM32G4_FLASH_OPTR_DBANK))) { + sl->flash_pgsz <<= 1; + } + } + #if 0 // Old code -- REW ILOG("Device connected is: %s, id %#x\n", params->description, chip_id); From 55ca316cd61a959746d809e1d9b20fa485ec39d8 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 6 Apr 2020 11:09:26 +0200 Subject: [PATCH 065/236] stm32g4: handle mass erase. toggle proper MER bits, taking in account dual bank mode enabled or not. --- src/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index 8cfbece35..b1461c419 100644 --- a/src/common.c +++ b/src/common.c @@ -120,6 +120,7 @@ #define STM32Gx_FLASH_CR_PNB (3) /* Page number */ #define STM32G0_FLASH_CR_PNG_LEN (5) /* STM32G0: 5 page number bits */ #define STM32G4_FLASH_CR_PNG_LEN (7) /* STM32G4: 7 page number bits */ +#define STM32Gx_FLASH_CR_MER2 (15) /* Mass erase (2nd bank)*/ #define STM32Gx_FLASH_CR_STRT (16) /* Start */ #define STM32Gx_FLASH_CR_OPTSTRT (17) /* Start of modification of option bytes */ #define STM32Gx_FLASH_CR_FSTPG (18) /* Fast programming */ @@ -519,7 +520,10 @@ static void set_flash_cr_mer(stlink_t *sl, bool v) { } else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || sl->flash_type == STLINK_FLASH_TYPE_G4) { cr_reg = STM32Gx_FLASH_CR; - cr_mer = (1 << FLASH_CR_MER); + cr_mer = (1 << STM32Gx_FLASH_CR_MER1); + if (sl->has_dual_bank) { + cr_mer |= (1 << STM32Gx_FLASH_CR_MER2); + } cr_pg = (1 << FLASH_CR_PG); } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { cr_reg = STM32WB_FLASH_CR; From 6a2bf1cbe21cf3409926c24f360210ba14d469ff Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 3 Apr 2020 14:50:55 +0200 Subject: [PATCH 066/236] stm32g4: allow mass erase. --- src/common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common.c b/src/common.c index b1461c419..601660360 100644 --- a/src/common.c +++ b/src/common.c @@ -1980,7 +1980,6 @@ int stlink_erase_flash_mass(stlink_t *sl) { /* TODO: User MER bit to mass-erase G0, G4, WB series. */ if (sl->flash_type == STLINK_FLASH_TYPE_L0 || sl->flash_type == STLINK_FLASH_TYPE_G0 || - sl->flash_type == STLINK_FLASH_TYPE_G4 || sl->flash_type == STLINK_FLASH_TYPE_WB) { /* erase each page */ int i = 0, num_pages = (int) sl->flash_size/sl->flash_pgsz; From 98cd484854b8842452759f8752dea5ca2e98c6ea Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 6 Apr 2020 14:00:54 +0200 Subject: [PATCH 067/236] common: add flash error check. use it for mass erase. only implement it for g0/g4 for now, but this is most probably a must for all chips. --- src/common.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/common.c b/src/common.c index 601660360..fd73c1614 100644 --- a/src/common.c +++ b/src/common.c @@ -131,7 +131,9 @@ #define STM32Gx_FLASH_CR_LOCK (31) /* FLASH_CR Lock */ // G0/G4 FLASH status register +#define STM32Gx_FLASH_SR_ERROR_MASK (0x3fa) #define STM32Gx_FLASH_SR_BSY (16) /* FLASH_SR Busy */ +#define STM32Gx_FLASH_SR_EOP (0) /* FLASH_EOP End of Operation */ // G4 FLASH option register #define STM32G4_FLASH_OPTR_DBANK (22) /* FLASH_OPTR Dual Bank Mode */ @@ -688,6 +690,22 @@ static void wait_flash_busy_progress(stlink_t *sl) { fprintf(stdout, "\n"); } +static int check_flash_error(stlink_t *sl) +{ + uint32_t res = 0; + if ((sl->flash_type == STLINK_FLASH_TYPE_G0) || + (sl->flash_type == STLINK_FLASH_TYPE_G4)) { + res = read_flash_sr(sl) & STM32Gx_FLASH_SR_ERROR_MASK; + } + + if (res) { + ELOG("Flash programming error : %#010x\n", res); + return -1; + } + + return 0; +} + static inline unsigned int is_flash_eop(stlink_t *sl) { return read_flash_sr(sl) & (1 << FLASH_SR_EOP); } @@ -2018,6 +2036,8 @@ int stlink_erase_flash_mass(stlink_t *sl) { /* wait for completion */ wait_flash_busy_progress(sl); + check_flash_error(sl); + /* relock the flash */ lock_flash(sl); From 4437314d3383798d4518fe169c7de9db9ac39dc5 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 6 Apr 2020 16:45:26 +0200 Subject: [PATCH 068/236] enable mass erase for g0, worksforme --- src/common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common.c b/src/common.c index fd73c1614..26202fcef 100644 --- a/src/common.c +++ b/src/common.c @@ -1997,7 +1997,6 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) int stlink_erase_flash_mass(stlink_t *sl) { /* TODO: User MER bit to mass-erase G0, G4, WB series. */ if (sl->flash_type == STLINK_FLASH_TYPE_L0 || - sl->flash_type == STLINK_FLASH_TYPE_G0 || sl->flash_type == STLINK_FLASH_TYPE_WB) { /* erase each page */ int i = 0, num_pages = (int) sl->flash_size/sl->flash_pgsz; From be6aafddd1dc6eab29038b0010a582de060cfedd Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 7 Apr 2020 12:12:34 +0200 Subject: [PATCH 069/236] Minor fixes - Updated CentOS repo in README.md - Whitespace fixes --- Makefile | 47 +++++++++++++++++++++--------------------- README.md | 2 +- doc/version_support.md | 3 ++- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 7f81488bb..a94ec598b 100644 --- a/Makefile +++ b/Makefile @@ -1,49 +1,48 @@ ## -# This Makefile is used to drive building of Debug and Release -# targets of CMake +# This Makefile is used to drive building of Debug and Release targets of CMake ## MAKEFLAGS += -s all: release -ci: debug release test +ci: debug release test help: - @echo " release: Run a release build" - @echo " debug: Run a debug build" - @echo " lint: Lint check all source-code" - @echo " test: Build and run tests" - @echo " clean: Clean all build output" - @echo "rebuild_cache: Rebuild all CMake caches" + @echo " release: Run a release build" + @echo " debug: Run a debug build" + @echo " lint: Lint check all source-code" + @echo " test: Build and run tests" + @echo " clean: Clean all build output" + @echo "rebuild_cache: Rebuild all CMake caches" rebuild_cache: build/Debug build/Release - @$(MAKE) -C build/Debug rebuild_cache - @$(MAKE) -C build/Release rebuild_cache + @$(MAKE) -C build/Debug rebuild_cache + @$(MAKE) -C build/Release rebuild_cache debug: build/Debug - @echo "[DEBUG]" - @$(MAKE) -C build/Debug + @echo "[DEBUG]" + @$(MAKE) -C build/Debug release: build/Release - @echo "[RELEASE]" - @$(MAKE) -C build/Release + @echo "[RELEASE]" + @$(MAKE) -C build/Release package: build/Release - @echo "[PACKAGE] Release" - @$(MAKE) -C build/Release package + @echo "[PACKAGE] Release" + @$(MAKE) -C build/Release package test: debug - @$(MAKE) -C build/Debug test + @$(MAKE) -C build/Debug test build/Debug: - @mkdir -p $@ - @cd $@ && cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKEFLAGS) ../../ + @mkdir -p $@ + @cd $@ && cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKEFLAGS) ../../ build/Release: - @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ + @mkdir -p $@ + @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ clean: - @echo "[CLEAN]" - @rm -Rf build + @echo "[CLEAN]" + @rm -Rf build .PHONY: clean diff --git a/README.md b/README.md index b26a147e9..807449594 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ 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) +* 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 install [from source](doc/compiling.md). diff --git a/doc/version_support.md b/doc/version_support.md index 963ca2988..5c8f65841 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -3,7 +3,6 @@ Sources: [pkgs.org - libusb](https://pkgs.org/search/?q=libusb) & [pkgs.org - cm ## Supported Operating Systems - ### Microsoft Windows On Windows users should ensure that cmake 3.17.0 is installed.
@@ -14,6 +13,7 @@ Thus no user interaction regarding libusb is necessary. * Windows 10 * Windows 8.1 + ### Apple macOS On macOS users should ensure that cmake 3.17.0 is installed. @@ -24,6 +24,7 @@ On macOS users should ensure that cmake 3.17.0 is installed. * macOS 10.14 Mojave * macOS 10.13 High Sierra + ### Linux-/Unix-based: | Operating System | libusb
version | cmake
version | Notes | From a8c1f41f1b1c9dd1314f99a1d42de1008f5a4f74 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:10:55 +0200 Subject: [PATCH 070/236] Refactoring for libusb detection --- cmake/modules/FindLibUSB.cmake | 219 ++++++++++++++++----------------- 1 file changed, 106 insertions(+), 113 deletions(-) diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index a8b65cba3..dc90bcc32 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -6,139 +6,132 @@ # LIBUSB_LIBRARY - The libraries needed to use libusb # LIBUSB_DEFINITIONS - Compiler switches required for using libusb +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 (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD - FIND_PATH(LIBUSB_INCLUDE_DIR NAMES libusb.h - HINTS - /usr/include - ) -else () # other OS - 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) -# macOS -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 (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 () -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) -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.23) + # 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}/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} - EXPECTED_MD5 cf3d38d2ff053ef343d10c0b8b0950c2 - ) - 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() + # 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(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 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 + ) - 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 () - endif () 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 () From 23c071edea45f6e8852fef52d884a680973d6d8f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:01:26 +0200 Subject: [PATCH 071/236] Updated documentation - Compiling manual - Updated version support for macOS --- README.md | 21 +++++++++++----- doc/compiling.md | 57 +++++++++++++++++++++--------------------- doc/version_support.md | 11 +++----- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 807449594..343dbd39c 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,20 @@ Currently known working combinations of programmers and targets are listed in [d ## 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**: @@ -56,9 +65,9 @@ We recommend to install `stlink-tools` from the package repository of the used d **Other Operating Systems**: -* 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 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) diff --git a/doc/compiling.md b/doc/compiling.md index bcaf7d567..64f4de466 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -28,7 +28,7 @@ On Windows users should ensure that the following software is installed: ### Building -#### MinGW64 +#### 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` @@ -158,47 +158,46 @@ Choose on of the following options _before_ connecting the device to your comput 2. `modprobe -r usb-storage && modprobe usb-storage` -Author: nightwalker-87 +## 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/). ----- **The following content is outdated and unrevised!** ---- +Then install the following dependencies from the package repository: -## Mac OS X +* `git` +* `cmake` +* `libusb` -When compiling on a mac you need the following: +To do this with only one simple command, type: -* A compiler toolchain (XCode) -* CMake -* Libusb 1.0 +* for homebrew: `sudo brew install git cmake libusb` or +* for MacPorts:`sudo port install git cmake libusb` -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: +Additionally we recommend to install Xcode which delivers the necessary C-compiler toolchain Clang (LLVM). -``` -brew install libusb cmake -``` -Compile as described in the first section of this document. +### 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` -## Build using different directories for udev and modprobe +### Building -To put the udev or the modprobe configuration files into a different directory -during installation you can use the following cmake options: +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_)
+ The debug target is only necessary in order to modify the sources and to run under a debugger. -``` -$ cmake -DSTLINK_UDEV_RULES_DIR="/usr/lib/udev/rules.d" \ - -DSTLINK_MODPROBED_DIR="/usr/lib/modprobe.d" .. -``` +## Build using a different directory for shared libs -## Build using 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" ..`. -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" .. -``` +Author: nightwalker-87 diff --git a/doc/version_support.md b/doc/version_support.md index 5c8f65841..8b1a9b92d 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -16,13 +16,10 @@ Thus no user interaction regarding libusb is necessary. ### Apple macOS -On macOS users should ensure that cmake 3.17.0 is installed. - ---> libusb Installation routine: (TBD) Work in progress... - -* macOS 10.15 Catalina -* macOS 10.14 Mojave -* macOS 10.13 High Sierra +| Package Repository | libusb
version | cmake
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: From af1570ffe971752e25dbe0d6bfcb59ff1bc46391 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:11:45 +0200 Subject: [PATCH 072/236] Minor formatting fixes --- CMakeLists.txt | 2 +- cmake/version.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f46a5f591..1f0b46449 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE cmake/c_flag_overrides.cmake) project(stlink C) 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_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") diff --git a/cmake/version.cmake b/cmake/version.cmake index bdfe95ace..e9e2f7a05 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -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 From 59c5cfd7ec5c7f2a035944ecc5ca01d3d7b31170 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 7 Apr 2020 18:30:26 +0200 Subject: [PATCH 073/236] [doc] macOS ST-Link-v1 detection Added documentation on how to solve a failed detection of the ST-Link-v1 programmer in macOS v10.11 and later. (Closes #574, #587) --- doc/tutorial.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/doc/tutorial.md b/doc/tutorial.md index 1d48eaa38..9c1f7f26d 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -13,6 +13,70 @@ This option accepts decimal (128k), octal 0200k, or hex 0x80k. Obviously leaving the multiplier out is equally valid, for example: `--flash=0x20000`. The size may be followed by an optional "k" or "m" to multiply the given value by 1k (1024) or 1M respectively. + +## Solution to common problems +### ST-Link-v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) +#### Problem: + +st-util fails to detect a ST-Link-v1 device: + +``` +st-util -1 +st-util $VERSION-STRING$ +WARN src/sg.c: Failed to find an stlink v1 by VID:PID +ERROR src/sg.c: Could not open stlink device +``` + +#### Solution (clean setup): + +1) Configure System Integrity Protection (SIP) + +The root of this problem is a system security setting introduced by Apple with OS X El Capitan (10.11) in 2015. +The so called System Integrity Protection (SIP) is active per default +and prevents the operating system amongst other things to load unsigned Kernel Extension Modules (kext). +Thus the ST-Link-v1 driver supplied with the tools, which installs as a kext, remains not functional, +while SIP is fully activated (as is per default). + +Action needs to be taken here by booting into the recovery mode where a terminal console window needs to be opened. + +Here it is **NOT RECOMMEND to disable SIP completely as with the command** `csrutil disable`, +**because this leaves the system more vulnerable to common threats. +Instead there is a more adequate and reasonable option implemented by Apple. +Running** `csrutil enable --without kext`, **allows to load unsigned kernel extensions +while leaving SIP active with all other security features.** +So who ever intends to run the ST-Link-v1 programmer on macOS please take this into account. + +Further details can be found here: https://forums.developer.apple.com/thread/17452 + +2) Install the ST-Link-v1 driver from the subdirectory `/stlinkv1_macosx_driver` + by referring to the instructions in the README file available there. + +3) Move the $OS_VERSION$.kext file to `/System/Library/Extensions`. + +4) Load the Kernel Extension (kext): `$ sudo kextload -v /System/Library/Extensions/stlink_shield10_x.kext` + +``` +Requesting load of /System/Library/Extensions/stlink_shield10_x.kext. +/System/Library/Extensions/stlink_shield10_x.kext loaded successfully (or already loaded). +``` + +5) Enter the command `$ sudo touch /System/Library/Extensions` + + +7) Verify correct detection of the ST-Link-v1 device with the following input: `st-util -1` + +You should then see a similar output like in this example: + +``` +INFO common.c: Loading device parameters.... +INFO common.c: Device connected is: F1 High-density device, id 0x10036414 +INFO common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 2048 bytes +INFO sg.c: Successfully opened a stlink v1 debugger +INFO gdb-server.c: Chip ID is 00000414, Core ID is 1ba01477. +INFO gdb-server.c: Listening at *:4242... +``` + + ------ Using STM32 discovery kits with open source tools From 97484422008df0f75c978627054776f35842a075 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 00:12:36 +0200 Subject: [PATCH 074/236] Deprecated old appveyor-mingw script --- scripts/appveyor-mingw.sh | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 scripts/appveyor-mingw.sh diff --git a/scripts/appveyor-mingw.sh b/scripts/appveyor-mingw.sh deleted file mode 100644 index 4842410ba..000000000 --- a/scripts/appveyor-mingw.sh +++ /dev/null @@ -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 From 17511a6fed8f012e86acebb925ea1977c4798381 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 01:58:59 +0200 Subject: [PATCH 075/236] Update for CHANGELOG.md --- CHANGELOG.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c33bcbb47..1401843a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ Major changes and added features: Updates and fixes: +* Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/texane/stlink/pull/107), [#665](https://github.com/texane/stlink/pull/665), [#763](https://github.com/texane/stlink/pull/763)) +* Fixed an issue with versioning stuck at 1.4.0 for versions cloned with git ([#563](https://github.com/texane/stlink/pull/563), [#762](https://github.com/texane/stlink/pull/762), [#772](https://github.com/texane/stlink/pull/772)) * Updated STM32F3xx chip ID that covers a few different devices ([#685](https://github.com/texane/stlink/pull/685), [#758](https://github.com/texane/stlink/pull/758)) * Made udev rules and modprobe conf installation optional ([#741](https://github.com/texane/stlink/pull/741)) * Fixed case when __FILE__ don't contain "/" nor "\\" ([#745](https://github.com/texane/stlink/pull/745)) @@ -34,7 +36,6 @@ Updates and fixes: * Only do bank calculation on STM32L4 devices with dual banked flash / Added chip-ID 0x464 for STM32L41xxx/L42xxx devices ([#751](https://github.com/texane/stlink/pull/751)) * Added O_BINARY option to open file ([#753](https://github.com/texane/stlink/pull/753)) * Fixed versioning when compiling from the checked out git-repo ([#762](https://github.com/texane/stlink/pull/762), [#772](https://github.com/texane/stlink/pull/772)) -* Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/texane/stlink/pull/107), [#665](https://github.com/texane/stlink/pull/665), [#763](https://github.com/texane/stlink/pull/763)) * win32: move usleep definition to unistd.h ([#765](https://github.com/texane/stlink/pull/765)) * Fixed relative path to the UI files needed by stlink-gui-local (GUI) ([#770](https://github.com/texane/stlink/pull/770), [#771](https://github.com/texane/stlink/pull/771)) * Added howto for sending NRST signal through GDB ([#774](https://github.com/texane/stlink/pull/774), [#776](https://github.com/texane/stlink/pull/776), [#779](https://github.com/texane/stlink/pull/779)) @@ -190,7 +191,7 @@ Chip support added for: * STM32F7xx ([#324](https://github.com/texane/stlink/pull/324), [#326](https://github.com/texane/stlink/pull/326), [#327](https://github.com/texane/stlink/pull/327), [#337](https://github.com/texane/stlink/pull/337)) * STM32F767ZI ([#509](https://github.com/texane/stlink/pull/509)) * STM32L0xx Cat2 devices (chip-ID: 0x425) ([#414](https://github.com/texane/stlink/pull/414)) -* STM32L0xx Cat5 devices (chip-ID: 0x447) ([#406](https://github.com/texane/stlink/pull/406)) +* STM32L0xx Cat5 devices (chip-ID: 0x447) ([#387](https://github.com/texane/stlink/pull/387), [#406](https://github.com/texane/stlink/pull/406)) * STM32L4xx ([#321](https://github.com/texane/stlink/pull/321)) * STM32L432 ([#500](https://github.com/texane/stlink/pull/500), [#501](https://github.com/texane/stlink/pull/501)) @@ -198,7 +199,7 @@ Updates and fixes: * Fixed "unaligned addr or size" when trying to write a program in RAM ([#323](https://github.com/texane/stlink/pull/323)) * Fixed flashing on STM32_F3_SMALL ([#325](https://github.com/texane/stlink/pull/325)) -* Fixed STM32L-problem with flash loader ([#390](https://github.com/texane/stlink/pull/390)) +* Fixed STM32L-problem with flash loader ([#390](https://github.com/texane/stlink/pull/390), [#407](https://github.com/texane/stlink/pull/407),[#408](https://github.com/texane/stlink/pull/408)) * Don't read the target voltage on startup, because it crashes STM32F100 ([#423](https://github.com/texane/stlink/pull/423), [#424](https://github.com/texane/stlink/pull/424)) * Added a useful error message instead of "[!] send_recv" ([#425](https://github.com/texane/stlink/pull/425), [#426](https://github.com/texane/stlink/pull/426)) * Do a JTAG reset prior to reading CPU information when processor is in deep sleep ([#428](https://github.com/texane/stlink/pull/428), [#430](https://github.com/texane/stlink/pull/430), [#451](https://github.com/texane/stlink/pull/451)) @@ -253,6 +254,7 @@ Chip support added for: * Added STM32L4 to CHIPID #defines and devices[], flash driver and loader (Dave Vandervies) * Basic support for STM32F446 (Pavel Kirienko) * STM32F303 High Density +* STM32F469/STM32F479 ([#345](https://github.com/texane/stlink/pull/345), [#555](https://github.com/texane/stlink/pull/555)) (Release v1.2.0) * STM32L1xx Cat.2 devices (Nicolas Schodet) * STM32L1xx (chip-ID 0x427) ([#152](https://github.com/texane/stlink/pull/152), [#163](https://github.com/texane/stlink/pull/163), [#165](https://github.com/texane/stlink/pull/165)) (Release v1.0.0) From 9f2cad2c978a55a4125e6b8c4c656a59e7f9448c Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 12:45:10 +0200 Subject: [PATCH 076/236] Avoid re-define of O_BINARY on Windows (Fixes #788) --- src/common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common.c b/src/common.c index 26202fcef..4e04a33a5 100644 --- a/src/common.c +++ b/src/common.c @@ -16,9 +16,12 @@ #include "stlink/mmap.h" #include "stlink/logging.h" -#ifndef _WIN32 -#define O_BINARY 0 //! @todo get rid of this OH MY (@xor-gate) +#ifdef _WIN32 +#ifndef O_BINARY +#define O_BINARY 0 #endif +#endif + #ifdef _MSC_VER #define __attribute__(x) #endif From ad06dace83d2f6deefcef10b504c250a4a918e89 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 14:10:01 +0200 Subject: [PATCH 077/236] Removed old tested-boards list. --- doc/tested-boards.md | 57 -------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 doc/tested-boards.md diff --git a/doc/tested-boards.md b/doc/tested-boards.md deleted file mode 100644 index a9fa2f1c6..000000000 --- a/doc/tested-boards.md +++ /dev/null @@ -1,57 +0,0 @@ -Stlink tested and compatible boards -=================================== - -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: - -* STM32F0 (STM32F0 Discovery board) -* STM32F030F4P6 (custom board) -* STM32F051R8T6 (STM320518-EVAL board) -* STM32F100xx (Medium Density VL, as on the 32VL Discovery board) -* STM32F103VET6 (HY-STM32 board) ([#149](https://github.com/texane/stlink/pull/149)) -* STM32F105RCT6 (DecaWave EVB1000 board) -* STM32F303xx (STM32F3 Discovery board) -* STM32F407xx (STM32F4 Discovery board) -* STM32F411E-DISCO (STM32F4 Discovery board with gyro, audio) -* STM32F429I-DISCO (STM32F4 Discovery board with LCD) -* STM32F439VIT6 (Discovery board reseated CPU) -* STM32L052K8T6 (custom board) -* STM32L1xx (STM32L Discovery board) -* STM32L151CB (custom board) -* STM32L152RB (STM32L-Discovery board, custom board) -* STM32L496ZG (STM32-Nucleo-L496ZG 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) - - -STLink v2-1 (as found on the Nucleo boards), known working targets: - -* STM32F030R8T6 (STM32 Nucleo-F030R8 board) -* STM32F042K6 (STM32 Nucleo-32 Board) -* STM32F072RBT6 (STM32 Nucleo-F072RB board) -* STM32F103RB (STM32 Nucleo-F103RB board) -* STM32F303RET6 (STM32 Nucleo-F303RE board) -* STM32F334R8 (STM32 Nucleo-F334R8 board) -* STM32F401xx (STM32 Nucleo-F401RE board) -* STM32F411RET6 (STM32 Nucleo-F411RE board) -* STM32F756NGHx (STM32F7 evaluation board) -* STM32F769NI (STM32F7 discovery board) -* STM32L053R8 (STM32 Nucleo-L053R8 board) -* STM32L152RE (STM32-Nucleo-L152RE board -* STM32L452RET6 (STM32 Nucleo-L452RE board) -* STM32L476RG (STM32 Nucleo-L476RG board) - - -Please report any and all known working combinations so I can update this! From 34c0a31204d33fd15a1186709e3f60d186bcda3e Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Wed, 8 Apr 2020 20:33:23 +0800 Subject: [PATCH 078/236] Fix dead loop after an unexpected unplug * Fix by adding error handler in gdb-server * Enhance logs for functions with return values --- src/gdbserver/gdb-server.c | 222 ++++++++++++++++++++++++++++--------- 1 file changed, 167 insertions(+), 55 deletions(-) diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 72f676bb2..3aa769e02 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -1115,8 +1115,13 @@ int serve(stlink_t *sl, st_state_t *st) { * emulate attaching and detaching to target. */ unsigned int attached = 1; - + /* + * If a critical error is detected, break from the loop + */ + int critical_error = 0; + int ret; while(1) { + ret = 0; char* packet; int status = gdb_recv_packet(client, &packet); @@ -1226,32 +1231,75 @@ int serve(stlink_t *sl, st_state_t *st) { if (!strncmp(cmd, "resume", 6)) {// resume DLOG("Rcmd: resume\n"); cache_sync(sl); - stlink_run(sl); + ret = stlink_run(sl); + if (ret) { + DLOG("Rcmd: resume failed\n"); + reply = strdup("E00"); + + } else { + reply = strdup("OK"); + } - reply = strdup("OK"); } else if (!strncmp(cmd, "halt", 4)) { //halt - reply = strdup("OK"); + ret = stlink_force_debug(sl); + if (ret) { + DLOG("Rcmd: halt failed\n"); + reply = strdup("E00"); - stlink_force_debug(sl); + } else { + reply = strdup("OK"); + DLOG("Rcmd: halt\n"); + } - DLOG("Rcmd: halt\n"); } else if (!strncmp(cmd, "jtag_reset", 10)) { //jtag_reset reply = strdup("OK"); - stlink_jtag_reset(sl, 0); - stlink_jtag_reset(sl, 1); - stlink_force_debug(sl); + ret = stlink_jtag_reset(sl, 0); + if (ret) { + DLOG("Rcmd: jtag_reset failed with jtag_reset\n"); + reply = strdup("E00"); + + } + + ret = stlink_jtag_reset(sl, 1); + if (ret) { + DLOG("Rcmd: jtag_reset failed with jtag_reset\n"); + reply = strdup("E00"); + + } - DLOG("Rcmd: jtag_reset\n"); + ret = stlink_force_debug(sl); + if (ret) { + DLOG("Rcmd: jtag_reset failed with force_debug\n"); + reply = strdup("E00"); + + } + if (strcmp(reply, "E00")) { + // no errors have been found + DLOG("Rcmd: jtag_reset\n"); + } } else if (!strncmp(cmd, "reset", 5)) { //reset - reply = strdup("OK"); - stlink_force_debug(sl); - stlink_reset(sl); + ret = stlink_force_debug(sl); + if (ret) { + DLOG("Rcmd: reset failed with force_debug\n"); + reply = strdup("E00"); + } + + ret = stlink_reset(sl); + if (ret) { + DLOG("Rcmd: reset failed with reset\n"); + reply = strdup("E00"); + } + init_code_breakpoints(sl); init_data_watchpoints(sl); - DLOG("Rcmd: reset\n"); + if (reply == NULL) { + reply = strdup("OK"); + DLOG("Rcmd: reset\n"); + } + } else if (!strncmp(cmd, "semihosting ", 12)) { DLOG("Rcmd: got semihosting cmd '%s'", cmd); char *arg = cmd + 12; @@ -1369,7 +1417,10 @@ int serve(stlink_t *sl, st_state_t *st) { case 'c': cache_sync(sl); - stlink_run(sl); + ret = stlink_run(sl); + if (ret) { + DLOG("Semihost: run failed\n"); + } while(1) { status = gdb_check_for_interrupt(client); @@ -1384,10 +1435,12 @@ int serve(stlink_t *sl, st_state_t *st) { break; } - stlink_status(sl); + ret = stlink_status(sl); + if (ret) { + DLOG("Semihost: status failed\n"); + } if(sl->core_stat == STLINK_CORE_HALTED) { struct stlink_reg reg; - int ret; stm32_addr_t pc; stm32_addr_t addr; int offset = 0; @@ -1397,7 +1450,10 @@ int serve(stlink_t *sl, st_state_t *st) { break; } - stlink_read_all_regs (sl, ®); + ret = stlink_read_all_regs (sl, ®); + if (ret) { + DLOG("Semihost: read_all_regs failed\n"); + } /* Read PC */ pc = reg.r[15]; @@ -1421,17 +1477,29 @@ int serve(stlink_t *sl, st_state_t *st) { if (insn == 0xBEAB && !has_breakpoint(addr)) { - do_semihosting (sl, reg.r[0], reg.r[1], ®.r[0]); + ret = do_semihosting (sl, reg.r[0], reg.r[1], ®.r[0]); + if (ret) { + DLOG("Semihost: do_semihosting failed\n"); + } /* Write return value */ - stlink_write_reg(sl, reg.r[0], 0); + ret = stlink_write_reg(sl, reg.r[0], 0); + if (ret) { + DLOG("Semihost: write_reg failed for return value\n"); + } /* Jump over the break instruction */ - stlink_write_reg(sl, reg.r[15] + 2, 15); + ret = stlink_write_reg(sl, reg.r[15] + 2, 15); + if (ret) { + DLOG("Semihost: write_reg failed for jumping over break\n"); + } /* continue execution */ cache_sync(sl); - stlink_run(sl); + ret = stlink_run(sl); + if (ret) { + DLOG("Semihost: continue execution failed with stlink_run\n"); + } } else { break; } @@ -1444,10 +1512,17 @@ int serve(stlink_t *sl, st_state_t *st) { break; case 's': - cache_sync(sl); - stlink_step(sl); + cache_sync(sl); + ret = stlink_step(sl); + if (ret) { + // have problem sending step packet + ELOG("Step: cannot send step request\n"); + reply = strdup("E00"); + critical_error = 1; // absolutely critical + } else { + reply = strdup("S05"); // TRAP + } - reply = strdup("S05"); // TRAP break; case '?': @@ -1460,7 +1535,10 @@ int serve(stlink_t *sl, st_state_t *st) { break; case 'g': - stlink_read_all_regs(sl, ®p); + ret = stlink_read_all_regs(sl, ®p); + if (ret) { + DLOG("g packet: read_all_regs failed\n"); + } reply = calloc(8 * 16 + 1, 1); for(int i = 0; i < 16; i++) @@ -1473,41 +1551,48 @@ int serve(stlink_t *sl, st_state_t *st) { unsigned myreg = 0xDEADDEAD; if(id < 16) { - stlink_read_reg(sl, id, ®p); + ret = stlink_read_reg(sl, id, ®p); myreg = htonl(regp.r[id]); } else if(id == 0x19) { - stlink_read_reg(sl, 16, ®p); + ret = stlink_read_reg(sl, 16, ®p); myreg = htonl(regp.xpsr); } else if(id == 0x1A) { - stlink_read_reg(sl, 17, ®p); + ret = stlink_read_reg(sl, 17, ®p); myreg = htonl(regp.main_sp); } else if(id == 0x1B) { - stlink_read_reg(sl, 18, ®p); + ret = stlink_read_reg(sl, 18, ®p); myreg = htonl(regp.process_sp); } else if(id == 0x1C) { - stlink_read_unsupported_reg(sl, id, ®p); + ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.control); } else if(id == 0x1D) { - stlink_read_unsupported_reg(sl, id, ®p); + ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.faultmask); } else if(id == 0x1E) { - stlink_read_unsupported_reg(sl, id, ®p); + ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.basepri); } else if(id == 0x1F) { - stlink_read_unsupported_reg(sl, id, ®p); + ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.primask); } else if(id >= 0x20 && id < 0x40) { - stlink_read_unsupported_reg(sl, id, ®p); + ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.s[id-0x20]); } else if(id == 0x40) { - stlink_read_unsupported_reg(sl, id, ®p); + ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.fpscr); } else { + ret = 1; reply = strdup("E00"); } + if (ret) { + DLOG("p packet: stlink_read_unsupported_reg failed with id %u\n", id); + } - reply = calloc(8 + 1, 1); - sprintf(reply, "%08x", myreg); + if (reply == NULL) { + // if reply is set to "E00", skip + reply = calloc(8 + 1, 1); + sprintf(reply, "%08x", myreg); + } break; } @@ -1519,31 +1604,36 @@ int serve(stlink_t *sl, st_state_t *st) { unsigned reg = (unsigned int) strtoul(s_reg, NULL, 16); unsigned value = (unsigned int) strtoul(s_value, NULL, 16); + if(reg < 16) { - stlink_write_reg(sl, ntohl(value), reg); + ret = stlink_write_reg(sl, ntohl(value), reg); } else if(reg == 0x19) { - stlink_write_reg(sl, ntohl(value), 16); + ret = stlink_write_reg(sl, ntohl(value), 16); } else if(reg == 0x1A) { - stlink_write_reg(sl, ntohl(value), 17); + ret = stlink_write_reg(sl, ntohl(value), 17); } else if(reg == 0x1B) { - stlink_write_reg(sl, ntohl(value), 18); + ret = stlink_write_reg(sl, ntohl(value), 18); } else if(reg == 0x1C) { - stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); + ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else if(reg == 0x1D) { - stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); + ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else if(reg == 0x1E) { - stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); + ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else if(reg == 0x1F) { - stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); + ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else if(reg >= 0x20 && reg < 0x40) { - stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); + ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else if(reg == 0x40) { - stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); + ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else { + ret = 1; reply = strdup("E00"); } - - if(!reply) { + if (ret) { + DLOG("P packet: stlink_write_unsupported_reg failed with reg %u\n", reg); + } + if(reply == NULL) { + // note that NULL may not be zero reply = strdup("OK"); } @@ -1555,7 +1645,10 @@ int serve(stlink_t *sl, st_state_t *st) { char str[9] = {0}; strncpy(str, &packet[1 + i * 8], 8); uint32_t reg = (uint32_t) strtoul(str, NULL, 16); - stlink_write_reg(sl, ntohl(reg), i); + ret = stlink_write_reg(sl, ntohl(reg), i); + if (ret) { + DLOG("G packet: stlink_write_reg failed"); + } } reply = strdup("OK"); @@ -1729,9 +1822,13 @@ int serve(stlink_t *sl, st_state_t *st) { } case 'R': { + /* Reset the core. */ - stlink_reset(sl); + ret = stlink_reset(sl); + if (ret) { + DLOG("R packet : stlink_reset failed\n"); + } init_code_breakpoints(sl); init_data_watchpoints(sl); @@ -1743,8 +1840,15 @@ int serve(stlink_t *sl, st_state_t *st) { } case 'k': /* Kill request - reset the connection itself */ - stlink_run(sl); - stlink_exit_debug_mode(sl); + ret = stlink_run(sl); + if (ret) { + DLOG("Kill: stlink_run failed\n"); + } + + ret = stlink_exit_debug_mode(sl); + if (ret) { + DLOG("Kill: stlink_exit_debug_mode failed\n"); + } stlink_close(sl); sl = do_connect(st); @@ -1754,7 +1858,10 @@ int serve(stlink_t *sl, st_state_t *st) { if (st->reset) { stlink_reset(sl); } - stlink_force_debug(sl); + ret = stlink_force_debug(sl); + if (ret) { + DLOG("Kill: stlink_force_debug failed\n"); + } init_cache(sl); init_code_breakpoints(sl); init_data_watchpoints(sl); @@ -1782,6 +1889,11 @@ int serve(stlink_t *sl, st_state_t *st) { free(reply); } + if (critical_error) { + close_socket(client); + return 1; + } + free(packet); } From c6753e3bdbcc23b2665373af389abe04cdbd150a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 15:29:01 +0200 Subject: [PATCH 079/236] Fixed compilation errors (Regression) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -> error: ‘O_BINARY’ undeclared -> tabspaces in Makefile --- Makefile | 44 ++++++++++++++++++++++---------------------- src/common.c | 5 +++-- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index a94ec598b..df9099a9e 100644 --- a/Makefile +++ b/Makefile @@ -4,45 +4,45 @@ MAKEFLAGS += -s all: release -ci: debug release test +ci: debug release test help: - @echo " release: Run a release build" - @echo " debug: Run a debug build" - @echo " lint: Lint check all source-code" - @echo " test: Build and run tests" - @echo " clean: Clean all build output" - @echo "rebuild_cache: Rebuild all CMake caches" + @echo " release: Run a release build" + @echo " debug: Run a debug build" + @echo " lint: Lint check all source-code" + @echo " test: Build and run tests" + @echo " clean: Clean all build output" + @echo "rebuild_cache: Rebuild all CMake caches" rebuild_cache: build/Debug build/Release - @$(MAKE) -C build/Debug rebuild_cache - @$(MAKE) -C build/Release rebuild_cache + @$(MAKE) -C build/Debug rebuild_cache + @$(MAKE) -C build/Release rebuild_cache debug: build/Debug - @echo "[DEBUG]" - @$(MAKE) -C build/Debug + @echo "[DEBUG]" + @$(MAKE) -C build/Debug release: build/Release - @echo "[RELEASE]" - @$(MAKE) -C build/Release + @echo "[RELEASE]" + @$(MAKE) -C build/Release package: build/Release - @echo "[PACKAGE] Release" - @$(MAKE) -C build/Release package + @echo "[PACKAGE] Release" + @$(MAKE) -C build/Release package test: debug - @$(MAKE) -C build/Debug test + @$(MAKE) -C build/Debug test build/Debug: - @mkdir -p $@ - @cd $@ && cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKEFLAGS) ../../ + @mkdir -p $@ + @cd $@ && cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKEFLAGS) ../../ build/Release: - @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ + @mkdir -p $@ + @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ clean: - @echo "[CLEAN]" - @rm -Rf build + @echo "[CLEAN]" + @rm -Rf build .PHONY: clean diff --git a/src/common.c b/src/common.c index 913d70e35..27db09fa2 100644 --- a/src/common.c +++ b/src/common.c @@ -15,9 +15,10 @@ #include "stlink/mmap.h" #include "stlink/logging.h" -#ifndef _WIN32 -#define O_BINARY 0 //! @todo get rid of this OH MY (@xor-gate) +#ifndef O_BINARY +#define O_BINARY 0 #endif + #ifdef _MSC_VER #define __attribute__(x) #endif From 6f941b22eb00844eca7d17ebe3168d34276ef6b3 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 15:34:10 +0200 Subject: [PATCH 080/236] Fixed compilation errors (Regression) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -> error: ‘O_BINARY’ undeclared -> tabspaces in Makefile --- Makefile | 45 ++++++++++++++++++++++----------------------- src/common.c | 2 -- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 7f81488bb..0636eb9bd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ ## -# This Makefile is used to drive building of Debug and Release -# targets of CMake +# This Makefile is used to drive building of Debug and Release targets of CMake ## MAKEFLAGS += -s @@ -8,42 +7,42 @@ all: release ci: debug release test help: - @echo " release: Run a release build" - @echo " debug: Run a debug build" - @echo " lint: Lint check all source-code" - @echo " test: Build and run tests" - @echo " clean: Clean all build output" - @echo "rebuild_cache: Rebuild all CMake caches" + @echo " release: Run a release build" + @echo " debug: Run a debug build" + @echo " lint: Lint check all source-code" + @echo " test: Build and run tests" + @echo " clean: Clean all build output" + @echo "rebuild_cache: Rebuild all CMake caches" rebuild_cache: build/Debug build/Release - @$(MAKE) -C build/Debug rebuild_cache - @$(MAKE) -C build/Release rebuild_cache + @$(MAKE) -C build/Debug rebuild_cache + @$(MAKE) -C build/Release rebuild_cache debug: build/Debug - @echo "[DEBUG]" - @$(MAKE) -C build/Debug + @echo "[DEBUG]" + @$(MAKE) -C build/Debug release: build/Release - @echo "[RELEASE]" - @$(MAKE) -C build/Release + @echo "[RELEASE]" + @$(MAKE) -C build/Release package: build/Release - @echo "[PACKAGE] Release" - @$(MAKE) -C build/Release package + @echo "[PACKAGE] Release" + @$(MAKE) -C build/Release package test: debug - @$(MAKE) -C build/Debug test + @$(MAKE) -C build/Debug test build/Debug: - @mkdir -p $@ - @cd $@ && cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKEFLAGS) ../../ + @mkdir -p $@ + @cd $@ && cmake -DCMAKE_BUILD_TYPE=Debug $(CMAKEFLAGS) ../../ build/Release: - @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ + @mkdir -p $@ + @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ clean: - @echo "[CLEAN]" - @rm -Rf build + @echo "[CLEAN]" + @rm -Rf build .PHONY: clean diff --git a/src/common.c b/src/common.c index 4e04a33a5..f432cf5a1 100644 --- a/src/common.c +++ b/src/common.c @@ -16,11 +16,9 @@ #include "stlink/mmap.h" #include "stlink/logging.h" -#ifdef _WIN32 #ifndef O_BINARY #define O_BINARY 0 #endif -#endif #ifdef _MSC_VER #define __attribute__(x) From 38c8b8b499f1d9e87db214e9fb2c144e593c8a08 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 8 Apr 2020 23:44:51 +0200 Subject: [PATCH 081/236] Cleanup - Whitespace fixes - Removed old appveyor-mingw script - travis-lin-mingw.sh -> .gitignore --- .appveyor.yml | 21 ---------------- .gitignore | 2 ++ cmake/version.cmake | 61 ++++++++++++++++++++++----------------------- src/win32/unistd.h | 31 ++++++++++++----------- 4 files changed, 48 insertions(+), 67 deletions(-) delete mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 10c0e935a..000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,21 +0,0 @@ -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 - - libusb-1.0.20.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) diff --git a/.gitignore b/.gitignore index 23e7ddc07..d2dde3a25 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build build-mingw obj-* *.user* + +.travis-lin-mingw.sh diff --git a/cmake/version.cmake b/cmake/version.cmake index e9e2f7a05..fe778c419 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -15,78 +15,77 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") OUTPUT_VARIABLE PROJECT_VERSION RESULT_VARIABLE GIT_DESCRIBE_RESULT ERROR_VARIABLE GIT_DESCRIBE_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE + ) - if(GIT_DESCRIBE_RESULT EQUAL 0) + if (GIT_DESCRIBE_RESULT EQUAL 0) # 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) + COMMAND "${GIT_EXECUTABLE}" diff --quiet + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + RESULT_VARIABLE res + ) if (res EQUAL 1) set (PROJECT_VERSION "${PROJECT_VERSION}-dirty") - endif() + endif () # strip a leading v off of the version as proceeding code expectes just the version numbering. string(REGEX REPLACE "^v" "" PROJECT_VERSION ${PROJECT_VERSION}) 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) + if (len EQUAL 3) list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR) list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) set(__detect_version 1) set(__version_str "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") - if(EXISTS "${PROJECT_SOURCE_DIR}/.version") + if (EXISTS "${PROJECT_SOURCE_DIR}/.version") file(READ "${PROJECT_SOURCE_DIR}/.version" __version_file) - if(NOT __version_str STREQUAL __version_file) + if (NOT __version_str STREQUAL __version_file) message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}") - endif() - else() + endif () + else () file(WRITE "${PROJECT_SOURCE_DIR}/.version" ${__version_str}) - endif() - else() - message(STATUS "Fail to extract version's parts from \"${PROJECT_VERSION}\"") - endif() + endif () + else () + message(STATUS "Fail to extract version parts from \"${PROJECT_VERSION}\"") + endif () else(GIT_DESCRIBE_RESULT EQUAL 0) message(WARNING "git describe failed.") message(WARNING "${GIT_DESCRIBE_ERROR}") endif(GIT_DESCRIBE_RESULT EQUAL 0) -else() +else () message(STATUS "Git or repo not found.") -endif() +endif () -if(NOT __detect_version) +if (NOT __detect_version) message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file.") - if(EXISTS ${PROJECT_SOURCE_DIR}/.version) + if (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 PROJECT_VERSION) + file(STRINGS .version PROJECT_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}) list(LENGTH PROJECT_VERSION_LIST len) - if(len EQUAL 3) + if (len EQUAL 3) list(GET PROJECT_VERSION_LIST 0 PROJECT_VERSION_MAJOR) list(GET PROJECT_VERSION_LIST 1 PROJECT_VERSION_MINOR) list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) set(__detect_version 1) - else() - message(STATUS "Fail to extract version's parts from \"${PROJECT_VERSION}\"") - endif() - else() + else () + message(STATUS "Fail to extract version parts from \"${PROJECT_VERSION}\"") + endif () + else () message(STATUS "File \"${PROJECT_SOURCE_DIR}/.version\" did not exists.") - endif() -endif() - -if(NOT __detect_version) + endif () message(FATAL_ERROR "Unable to determine project version") -endif() +endif () message(STATUS "stlink version: ${PROJECT_VERSION}") message(STATUS "Major ${PROJECT_VERSION_MAJOR} Minor ${PROJECT_VERSION_MINOR} Patch ${PROJECT_VERSION_PATCH}") diff --git a/src/win32/unistd.h b/src/win32/unistd.h index 4c94aed34..5b2798b41 100644 --- a/src/win32/unistd.h +++ b/src/win32/unistd.h @@ -1,9 +1,9 @@ #ifndef _UNISTD_H #define _UNISTD_H 1 -/* This file intended to serve as a drop-in replacement for - * unistd.h on Windows - * Please add functionality as neeeded +/* + * This file intended to serve as a drop-in replacement for unistd.h on Windows + * Please add functionality as neeeded. */ #include @@ -16,19 +16,18 @@ #if defined(_MSC_VER) #pragma warning(pop) #endif -#include /* getopt at: https://gist.github.com/ashelly/7776712 */ -#include /* for getpid() and the exec..() family */ -#include /* for _getcwd() and _chdir() */ +#include // getopt at: https://gist.github.com/ashelly/7776712 +#include // for getpid() and the exec..() family +#include // for _getcwd() and _chdir() #define srandom srand #define random rand -/* Values for the second argument to access. - These may be OR'd together. */ -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -//#define X_OK 1 /* execute permission - unsupported in windows*/ -#define F_OK 0 /* Test for existence. */ +/* Values for the second argument to access. These may be OR'd together. */ +#define R_OK 4 // Test for read permission +#define W_OK 2 // Test for write permission +// #define X_OK 1 // execute permission - unsupported in windows +#define F_OK 0 // Test for existence #define access _access #define dup2 _dup2 @@ -40,7 +39,9 @@ #define chdir _chdir #define isatty _isatty #define lseek _lseek -/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ +/* read, write, and close are NOT being defined here, + * because while there are file handle specific versions for Windows, they probably don't work for sockets. + * You need to look at your app and consider whether to call e.g. closesocket(). */ #define ssize_t int @@ -49,7 +50,7 @@ #define STDERR_FILENO 2 /* should be in some equivalent to */ typedef __int8 int8_t; -typedef __int16 int16_t; +typedef __int16 int16_t; typedef __int32 int32_t; typedef __int64 int64_t; typedef unsigned __int8 uint8_t; @@ -61,4 +62,4 @@ typedef unsigned __int64 uint64_t; int usleep(unsigned int waitTime); #endif -#endif /* unistd.h */ +#endif /* unistd.h */ From 12faa5332ccc02f47c18d2c4ec2c0c0489f7e741 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Fri, 10 Apr 2020 22:07:52 +0800 Subject: [PATCH 082/236] Fix memory overlap --- tests/flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/flash.c b/tests/flash.c index 6c8b8ed9b..b17aa99ae 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -30,9 +30,9 @@ static bool execute_test(const struct Test * test) { // parse (tokenize) the test command line #if defined(_MSC_VER) - char *cmd_line = alloca(strlen(test->cmd_line)); + char *cmd_line = alloca(strlen(test->cmd_line) + 1); #else - char cmd_line[strlen(test->cmd_line)]; + char cmd_line[strlen(test->cmd_line) + 1]; #endif strcpy(cmd_line, test->cmd_line); From 90081dd1f3b31574e76bd068e0814e7015420089 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 14:34:51 +0200 Subject: [PATCH 083/236] usb.h: define some stlink usb pid macros, stop copypasting. ease v1/v2/v2.1/v3 identification and supported devices filtering --- include/stlink/usb.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/stlink/usb.h b/include/stlink/usb.h index 9357c248e..1448481be 100644 --- a/include/stlink/usb.h +++ b/include/stlink/usb.h @@ -29,6 +29,24 @@ extern "C" { #define STLINK_USB_PID_STLINK_V3S_PID 0x374f #define STLINK_USB_PID_STLINK_V3_2VCP_PID 0x3753 +#define STLINK_V1_USB_PID(pid) ((pid) == STLINK_USB_PID_STLINK ) + +#define STLINK_V2_USB_PID(pid) ((pid) == STLINK_USB_PID_STLINK_32L || \ + (pid) == STLINK_USB_PID_STLINK_32L_AUDIO || \ + (pid) == STLINK_USB_PID_STLINK_NUCLEO) + +#define STLINK_V2_1_USB_PID(pid) ( (pid) == STLINK_USB_PID_STLINK_V2_1 ) + +#define STLINK_V3_USB_PID(pid) ((pid) == STLINK_USB_PID_STLINK_V3_USBLOADER || \ + (pid) == STLINK_USB_PID_STLINK_V3E_PID || \ + (pid) == STLINK_USB_PID_STLINK_V3S_PID || \ + (pid) == STLINK_USB_PID_STLINK_V3_2VCP_PID ) + +#define STLINK_SUPPORTED_USB_PID(pid) ( STLINK_V1_USB_PID(pid) || \ + STLINK_V2_USB_PID(pid) || \ + STLINK_V2_1_USB_PID(pid) || \ + STLINK_V3_USB_PID(pid)) + #define STLINK_SG_SIZE 31 #define STLINK_CMD_SIZE 16 From 8fba7ab9fe9647957763be5f00443cb2192f8a28 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 11:51:27 +0200 Subject: [PATCH 084/236] usb.c: align probe code. actually open all counted devices - the two vid check need to be aligned. also now display if some st device has been skipped. --- src/usb.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/usb.c b/src/usb.c index f9d141745..7ebd58b1a 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1114,15 +1114,13 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { break; } - if (desc.idProduct != STLINK_USB_PID_STLINK_32L && - desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO && - desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO && - desc.idProduct != STLINK_USB_PID_STLINK_V2_1 && - desc.idProduct != STLINK_USB_PID_STLINK_V3_USBLOADER && - desc.idProduct != STLINK_USB_PID_STLINK_V3E_PID && - desc.idProduct != STLINK_USB_PID_STLINK_V3S_PID && - desc.idProduct != STLINK_USB_PID_STLINK_V3_2VCP_PID) - continue; + if (desc.idVendor != STLINK_USB_VID_ST) + continue; + + if (!STLINK_SUPPORTED_USB_PID(desc.idProduct)) { + WLOG("skipping ST device : %#04x:%#04x)\n", desc.idVendor, desc.idProduct); + continue; + } slcnt++; } @@ -1144,10 +1142,9 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { break; } - if (desc.idProduct != STLINK_USB_PID_STLINK_32L && - desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO && - desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO) + if (!STLINK_SUPPORTED_USB_PID(desc.idProduct)) { continue; + } struct libusb_device_handle* handle; char serial[STLINK_SERIAL_MAX_SIZE]; From 6b03c7f9ed4c65139aa05900e288bd5228d62024 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 11:55:03 +0200 Subject: [PATCH 085/236] usb.c: rework probe loop to _not_ free all stuff without closing if _one_ probe failed. we return count and list of successfully probed devices, no need to free everything if some libusb call of the last probe attempt failed. --- src/usb.c | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/src/usb.c b/src/usb.c index 7ebd58b1a..e3b2a453c 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1101,14 +1101,13 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { stlink_t **_sldevs; libusb_device *dev; int i = 0; - int ret = 0; size_t slcnt = 0; size_t slcur = 0; /* Count stlink */ while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; - ret = libusb_get_device_descriptor(dev, &desc); + int ret = libusb_get_device_descriptor(dev, &desc); if (ret < 0) { WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret); break; @@ -1136,7 +1135,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { i = 0; while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; - ret = libusb_get_device_descriptor(dev, &desc); + int ret = libusb_get_device_descriptor(dev, &desc); if (ret < 0) { WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret); break; @@ -1146,40 +1145,32 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { continue; } - struct libusb_device_handle* handle; - char serial[STLINK_SERIAL_MAX_SIZE]; - memset(serial, 0, sizeof(serial)); + struct libusb_device_handle* handle; + char serial[STLINK_SERIAL_MAX_SIZE] = {0,}; - ret = libusb_open(dev, &handle); - if (ret < 0) { - if (ret == LIBUSB_ERROR_ACCESS) { + ret = libusb_open(dev, &handle); + if (ret < 0) { + if (ret == LIBUSB_ERROR_ACCESS) { WLOG("failed to open USB device (LIBUSB_ERROR_ACCESS), try running as root?\n"); } else { WLOG("failed to open USB device (libusb error: %d)\n", ret); - } - break; - } + } + break; + } + + ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)&serial, sizeof(serial)); - ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)&serial, sizeof(serial)); - if (ret < 0) - *serial = 0; + libusb_close(handle); - libusb_close(handle); + if (ret < 0) { + continue; + } - stlink_t *sl = NULL; - sl = stlink_open_usb(0, 1, serial); + stlink_t *sl = stlink_open_usb(0, 1, serial); if (!sl) continue; - _sldevs[slcur] = sl; - slcur++; - } - - /* Something went wrong */ - if (ret < 0) { - free(_sldevs); - *sldevs = NULL; - return 0; + _sldevs[slcur++] = sl; } *sldevs = _sldevs; From aff1df29adfb945983e8938807fd58aa2222b5bf Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 11:58:28 +0200 Subject: [PATCH 086/236] stlink_probe_usb_devs: return number of successfully opened devices, not number of probed devices. --- src/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usb.c b/src/usb.c index e3b2a453c..6000e1b4b 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1174,7 +1174,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { } *sldevs = _sldevs; - return slcnt; + return slcur; } size_t stlink_probe_usb(stlink_t **stdevs[]) { From 512999da56107e783e1982a459d3197b4959bb9d Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 15:04:51 +0200 Subject: [PATCH 087/236] stlink_open_usb: use macros for stlink pid filtering --- src/usb.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/usb.c b/src/usb.c index 6000e1b4b..d1c7e6484 100644 --- a/src/usb.c +++ b/src/usb.c @@ -937,14 +937,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } } - if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) || - (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) || - (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) || - (desc.idProduct == STLINK_USB_PID_STLINK_V2_1) || - (desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER) || - (desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID) || - (desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID) || - (desc.idProduct == STLINK_USB_PID_STLINK_V3_2VCP_PID)) { + if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct) || STLINK_V3_USB_PID(desc.idProduct)) { struct libusb_device_handle *handle; ret = libusb_open(list[cnt], &handle); @@ -955,15 +948,9 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST (unsigned char *)sl->serial, sizeof(sl->serial)); libusb_close(handle); - if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) - || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) - || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) - || (desc.idProduct == STLINK_USB_PID_STLINK_V2_1)) { - sl->version.stlink_v = 2; - } else if ((desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER) - || (desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID) - || (desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID) - || (desc.idProduct == STLINK_USB_PID_STLINK_V3_2VCP_PID)) { + if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct)) { + sl->version.stlink_v = 2; + } else if (STLINK_V3_USB_PID(desc.idProduct)) { sl->version.stlink_v = 3; } @@ -977,9 +964,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST break; continue; - } - - if (desc.idProduct == STLINK_USB_PID_STLINK) { + } else if (STLINK_V1_USB_PID(desc.idProduct)) { slu->protocoll = 1; sl->version.stlink_v = 1; break; From 395eee53dfa65302466cd46296b3f2681f3a3f0a Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 17:25:20 +0200 Subject: [PATCH 088/236] stlink_open_usb: fix serial lookup mecanism when a v1 device is connected. serial match was not done for v1 device, resulting in attempting to open it systematically, leading to some libusb device claim call failure. Lookup device serial for all chips, compare it if needed, and continue. --- src/usb.c | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/usb.c b/src/usb.c index d1c7e6484..850ae18a1 100644 --- a/src/usb.c +++ b/src/usb.c @@ -926,6 +926,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } while (cnt--) { + struct libusb_device_handle *handle; + libusb_get_device_descriptor( list[cnt], &desc ); if (desc.idVendor != STLINK_USB_VID_ST) continue; @@ -937,48 +939,44 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } } - if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct) || STLINK_V3_USB_PID(desc.idProduct)) { - struct libusb_device_handle *handle; - - ret = libusb_open(list[cnt], &handle); - if (ret) - continue; + ret = libusb_open(list[cnt], &handle); - sl->serial_size = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, - (unsigned char *)sl->serial, sizeof(sl->serial)); - libusb_close(handle); + /* could not open device, continue */ + if (ret) + continue; - if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct)) { - sl->version.stlink_v = 2; - } else if (STLINK_V3_USB_PID(desc.idProduct)) { - sl->version.stlink_v = 3; - } + sl->serial_size = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, + (unsigned char *)sl->serial, sizeof(sl->serial)); - if ((serial == NULL) || (*serial == 0)) - break; + libusb_close(handle); - if (sl->serial_size < 0) - continue; + /* could not read serial, continue */ + if (sl->serial_size < 0) + continue; - if (memcmp(serial, &sl->serial, sl->serial_size) == 0) - break; + /* if no serial provided, or if serial match device, fixup version and protocol */ + if (((serial == NULL) || (*serial == 0)) || (memcmp(serial, &sl->serial, sl->serial_size) == 0)) { + if (STLINK_V1_USB_PID(desc.idProduct)) { + slu->protocoll = 1; + sl->version.stlink_v = 1; + } else if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct)) { + sl->version.stlink_v = 2; + } else if (STLINK_V3_USB_PID(desc.idProduct)) { + sl->version.stlink_v = 3; + } - continue; - } else if (STLINK_V1_USB_PID(desc.idProduct)) { - slu->protocoll = 1; - sl->version.stlink_v = 1; - break; - } + break; + } } if (cnt < 0) { - WLOG ("Couldn't find %s ST-Link/V2 devices\n",(devBus && devAddr)?"matched":"any"); + WLOG ("Couldn't find %s ST-Link devices\n", (devBus && devAddr) ? "matched":"any"); goto on_error; } else { ret = libusb_open(list[cnt], &slu->usb_handle); if (ret != 0) { - WLOG("Error %d (%s) opening ST-Link/V2 device %03d:%03d\n", - ret, strerror (errno), libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt])); + WLOG("Error %d (%s) opening ST-Link v%d device %03d:%03d\n", + ret, strerror (errno), sl->version.stlink_v, libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt])); libusb_free_device_list(list, 1); goto on_error; } From cec61aaea33fbe7a07887867dda9149ea74c16a0 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 10 Apr 2020 17:26:15 +0200 Subject: [PATCH 089/236] stlink_open_usb: remove wrong comment, we do handle protocoll (?) v1 for stlinkv1 --- src/usb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/usb.c b/src/usb.c index 850ae18a1..970d3ee81 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1027,8 +1027,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } slu->sg_transfer_idx = 0; - // TODO - never used at the moment, always CMD_SIZE - slu->cmd_len = (slu->protocoll == 1)? STLINK_SG_SIZE: STLINK_CMD_SIZE; + slu->cmd_len = (slu->protocoll == 1) ? STLINK_SG_SIZE: STLINK_CMD_SIZE; // Initialize stlink version (sl->version) stlink_version(sl); From 99a8aaab253a1cda634291b6a975d1560bb89c0a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 10 Apr 2020 23:38:17 +0200 Subject: [PATCH 090/236] General Project Update - Updated CHANGELOG.md - README.md: Edited note on licensing. - Formatting in tutorial.md Temporarily removed travis-lin-mingw script for clean travis builds. --- .gitignore | 2 - .travis-lin-mingw.sh | 14 ------ CHANGELOG.md | 6 ++- README.md | 16 +++--- doc/tutorial.md | 115 ++++++++++++++++++++++--------------------- 5 files changed, 71 insertions(+), 82 deletions(-) delete mode 100755 .travis-lin-mingw.sh diff --git a/.gitignore b/.gitignore index d2dde3a25..23e7ddc07 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ build build-mingw obj-* *.user* - -.travis-lin-mingw.sh diff --git a/.travis-lin-mingw.sh b/.travis-lin-mingw.sh deleted file mode 100755 index 0422a06f6..000000000 --- a/.travis-lin-mingw.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -DIR=$PWD - -if [ "$TRAVIS_OS_NAME" == "linux" ]; then - echo "WORK DIR:$DIR" - mkdir -p $DIR/build/linux-mingw32-release - cd $DIR/build/linux-mingw32-release - echo "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR - echo "make" - make -fi - diff --git a/CHANGELOG.md b/CHANGELOG.md index 1401843a9..9e31aaf47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Major changes and added features: * Build for Windows under Debian/Ubuntu ([#802](https://github.com/texane/stlink/pull/802)) * Allow for 64 bytes serials ([#809](https://github.com/texane/stlink/pull/809)) * Added full support for STLINK CHIP ID L4RX ([#814](https://github.com/texane/stlink/pull/814), [#839](https://github.com/texane/stlink/pull/839)) +* Added support for the STLink-v2.1 when flashed with no mass storage (PID 0x3752) ([#819](https://github.com/texane/stlink/pull/819), [#861](https://github.com/texane/stlink/pull/861)) * Added support for writing option bytes on STM32L0xx ([#830](https://github.com/texane/stlink/pull/830)) * Added support to read and write option bytes for STM32F2 series ([#836](https://github.com/texane/stlink/pull/836), [#837](https://github.com/texane/stlink/pull/837)) * Added support to read and write option bytes for STM32F446 ([#843](https://github.com/texane/stlink/pull/843)) @@ -65,7 +66,7 @@ Major changes and added features: * Added creation of icons for .desktop file ([#684](https://github.com/texane/stlink/pull/684), [#708](https://github.com/texane/stlink/pull/708)) * Added desktop file for linux ([#688](https://github.com/texane/stlink/pull/688)) * Added button to export STM32 flash memory to a file ([#691](https://github.com/texane/stlink/pull/691)) -* Updated libusb to 1.0.22 ([#695](https://github.com/texane/stlink/pull/695)) +* Updated libusb to 1.0.22 ([#695](https://github.com/texane/stlink/pull/695)) - (related Bugs: [#438](https://github.com/texane/stlink/pull/438), [#632](https://github.com/texane/stlink/pull/632)) * Added icons for STLink GUI ([#697](https://github.com/texane/stlink/pull/697)) * Added support for STM32L4R9 target ([#694](https://github.com/texane/stlink/pull/694), [#699](https://github.com/texane/stlink/pull/699)) * Added memory map for STM32F411RE target ([#709](https://github.com/texane/stlink/pull/709)) @@ -132,7 +133,7 @@ Updates and fixes: * Added --flash=n[k][m] command line option to override device model ([#305](https://github.com/texane/stlink/pull/305), [#516](https://github.com/texane/stlink/pull/516), [#576](https://github.com/texane/stlink/pull/576)) * Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) * Fixed low-voltage flashing on STM32F7 devices ([#566](https://github.com/texane/stlink/pull/566), [#567](https://github.com/texane/stlink/pull/567)) -* Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#573](https://github.com/texane/stlink/pull/573), [#578](https://github.com/texane/stlink/pull/578), [#584](https://github.com/texane/stlink/pull/584), [#610](https://github.com/texane/stlink/pull/610)) +* Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#573](https://github.com/texane/stlink/pull/573), [#578](https://github.com/texane/stlink/pull/578), [#582](https://github.com/texane/stlink/pull/582), [#584](https://github.com/texane/stlink/pull/584), [#610](https://github.com/texane/stlink/pull/610), [#846](https://github.com/texane/stlink/pull/846)) * Fixed possible memory leak ([#570](https://github.com/texane/stlink/pull/570), [#571](https://github.com/texane/stlink/pull/571)) * Fixed installation path for shared objects ([#581](https://github.com/texane/stlink/pull/581)) * Fixed a few -Wformat warnings ([#582](https://github.com/texane/stlink/pull/582)) @@ -246,6 +247,7 @@ Updates and fixes: * Stm32l0x flash loader (Robin Kreis) * Send F4 memory-map and features for STM32F429 ([#188](https://github.com/texane/stlink/pull/188), [#196](https://github.com/texane/stlink/pull/196), [#250](https://github.com/texane/stlink/pull/250), [#251](https://github.com/texane/stlink/pull/251)) (Release v1.1.0) * Added AHB3 Peripherals definition for STM32F4 ([#218](https://github.com/texane/stlink/pull/218), [#288](https://github.com/texane/stlink/pull/288)) (Release v1.1.0) +* Corrected flash size register address for STM32F2 devices ([#278](https://github.com/texane/stlink/pull/278)) (Release v1.0.0) Chip support added for: diff --git a/README.md b/README.md index 4b1195166..e6de34dab 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Open source version of the STMicroelectronics Stlink Tools +Open source version of the STMicroelectronics STlink Tools ========================================================== [![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) @@ -11,6 +11,13 @@ Open source version of the STMicroelectronics Stlink Tools Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) of this software project. +#### License + +The stlink library and tools are licensed under the **[BSD-3 License](LICENSE.md)**.
+The source files **stm32l0x.s** and **stm32lx.s** found in the subdirectory `/flashloaders/` +are licensed under the **General Public License (GPL v2+)**. + + ## Introduction This stlink toolset supports several so called stlink programmer boards (and clones thereof) which use a microcontroller chip to translate commands from USB to JTAG. @@ -89,13 +96,6 @@ When there is no executable available for your platform or you need the latest ( * Please start new forks from the develop branch if possible as pull requests will go into this branch as well. -## License - -The stlink library and tools are licensed under the [BSD-3 license](LICENSE.md). - -The flashloaders/stm32l0x.s and flashloaders/stm32lx.s source files are licensed under the GPLv2+. - - # Current state of the project ## Known missing features diff --git a/doc/tutorial.md b/doc/tutorial.md index 9c1f7f26d..66bed0382 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2,6 +2,7 @@ stlink Tools Tutorial ===================== ## Useful tool options + ### st-flash #### --flash=n[k][m] @@ -14,8 +15,8 @@ Obviously leaving the multiplier out is equally valid, for example: `--flash=0x2 The size may be followed by an optional "k" or "m" to multiply the given value by 1k (1024) or 1M respectively. -## Solution to common problems -### ST-Link-v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) +## Solutions to common problems +### a) ST-Link-v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) #### Problem: st-util fails to detect a ST-Link-v1 device: @@ -39,11 +40,13 @@ while SIP is fully activated (as is per default). Action needs to be taken here by booting into the recovery mode where a terminal console window needs to be opened. -Here it is **NOT RECOMMEND to disable SIP completely as with the command** `csrutil disable`, -**because this leaves the system more vulnerable to common threats. +For macOS 10.11 - 10.13 it is not recommended to disable SIP completely as with the command `csrutil disable`, +because this leaves the system more vulnerable to common threats. Instead there is a more adequate and reasonable option implemented by Apple. -Running** `csrutil enable --without kext`, **allows to load unsigned kernel extensions -while leaving SIP active with all other security features.** +Running `csrutil enable --without kext`, allows to load unsigned kernel extensions +while leaving SIP active with all other security features. +Unfortunately this option has been removed in macOS 10.14, which leaves the only option to disable SIP completely. + So who ever intends to run the ST-Link-v1 programmer on macOS please take this into account. Further details can be found here: https://forums.developer.apple.com/thread/17452 @@ -76,8 +79,56 @@ INFO gdb-server.c: Chip ID is 00000414, Core ID is 1ba01477. INFO gdb-server.c: Listening at *:4242... ``` +### b) Verify if udev rules are set correctly (by Dave Hylands) + +To investigate, start by plugging your STLINK device into the usb port. Then run lsusb. You should see an entry something like the following: + +``` +Bus 005 Device 017: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB) +``` + +Note the bus number (005) and the Device (017). You should then do: +`ls -l /dev/bus/usb/005/017` (replacing 005 and 017 appropriately). + +On my system I see the following: + +``` +crw-rw-rw- 1 root root 189, 528 Jan 24 17:52 /dev/bus/usb/005/017 +``` + +which is world writable (this is from the MODE:="0666" below). I have several files in my `/etc/udev/rules.d` directory. In this particular case, the `49-stlinkv2-1.rules` file contains the following: + +``` +# stm32 nucleo boards, with onboard st/linkv2-1 +# ie, STM32F0, STM32F4. +# STM32VL has st/linkv1, which is quite different + +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ + MODE:="0666", \ + SYMLINK+="stlinkv2-1_%n" + +# If you share your linux system with other users, or just don't like the +# idea of write permission for everybody, you can replace MODE:="0666" with +# OWNER:="yourusername" to create the device owned by you, or with +# GROUP:="somegroupname" and mange access using standard unix groups. +``` + +and the idVendor of 0483 and idProduct of 374b matches the vendor id from the lsusb output. + +Make sure that you have all 3 files from here: https://github.com/texane/stlink/tree/master/etc/udev/rules.d in your `/etc/udev/rules.d` directory. After copying new files or editing excisting files in `/etc/udev/ruled.d` you should run the following: + +``` +sudo udevadm control --reload-rules +sudo udevadm trigger +``` + +to ensure that the rules actually take effect. Using the trigger command means that you shouldn't need to unplug and replug the device, but you might want to try that for good measure as well. + +If the VID:PID of your device doesn't match those in any of the 3 files, then you may need to create a custom rule file to match your VID:PID. + ------ +( Content below is currently unrevised and may be outdated as of Apr 2020. ) Using STM32 discovery kits with open source tools ======== @@ -249,56 +300,8 @@ $> [sudo] ./st-flash write fancy_blink.bin 0x08000000 Upon reset, the board LEDs should be blinking. -HOWTO -===== - -## Verify if udev rules are set correctly (by Dave Hylands) - -To investigate, start by plugging your STLINK device into the usb port. Then run lsusb. You should see an entry something like the following: - -``` -Bus 005 Device 017: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB) -``` - -Note the bus number (005) and the Device (017). You should then do: -`ls -l /dev/bus/usb/005/017` (replacing 005 and 017 appropriately). - -On my system I see the following: - -``` -crw-rw-rw- 1 root root 189, 528 Jan 24 17:52 /dev/bus/usb/005/017 -``` - -which is world writable (this is from the MODE:="0666" below). I have several files in my `/etc/udev/rules.d` directory. In this particular case, the `49-stlinkv2-1.rules` file contains the following: - -``` -# stm32 nucleo boards, with onboard st/linkv2-1 -# ie, STM32F0, STM32F4. -# STM32VL has st/linkv1, which is quite different - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ - MODE:="0666", \ - SYMLINK+="stlinkv2-1_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. -``` - -and the idVendor of 0483 and idProduct of 374b matches the vendor id from the lsusb output. - -Make sure that you have all 3 files from here: https://github.com/texane/stlink/tree/master/etc/udev/rules.d in your `/etc/udev/rules.d` directory. After copying new files or editing excisting files in `/etc/udev/ruled.d` you should run the following: - -``` -sudo udevadm control --reload-rules -sudo udevadm trigger -``` - -to ensure that the rules actually take effect. Using the trigger command means that you shouldn't need to unplug and replug the device, but you might want to try that for good measure as well. - -If the VID:PID of your device doesn't match those in any of the 3 files, then you may need to create a custom rule file to match your VID:PID. - +HOWTO (old) +=========== ## Using the gdb server From 7e4540aa7ddf478fca44aad140c3af04bfbaee5a Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 12:11:08 +0800 Subject: [PATCH 091/236] Fix code style alignment --- src/tools/flash_opts.c | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index ef41601a5..a6633d973 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -93,30 +93,30 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { else return -1; } - else if ( starts_with(av[0], "--flash=") ) { - const char *arg = av[0] + strlen("--flash="); - char *ep = 0; - - o->flash_size = (uint32_t)strtoul(arg,&ep,0); - while ( *ep ) { - switch ( *ep++ ) { - case 0: - break; - case 'k': - case 'K': - o->flash_size *= 1024u; - break; - case 'm': - case 'M': - o->flash_size *= 1024u * 1024u; - break; - default: - fprintf(stderr,"Invalid --flash=%s\n",arg); - return -1; - } - } - } - else { + else if ( starts_with(av[0], "--flash=") ) { + const char *arg = av[0] + strlen("--flash="); + char *ep = 0; + + o->flash_size = (uint32_t)strtoul(arg,&ep,0); + while ( *ep ) { + switch ( *ep++ ) { + case 0: + break; + case 'k': + case 'K': + o->flash_size *= 1024u; + break; + case 'm': + case 'M': + o->flash_size *= 1024u * 1024u; + break; + default: + fprintf(stderr,"Invalid --flash=%s\n",arg); + return -1; + } + } + } + else { break; // non-option found } From cc27e61e9d5bd45e3d9d78f972649bec01f26707 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 13:46:59 +0800 Subject: [PATCH 092/236] Fix 0xFF optimization bug --- include/stlink.h | 1 + include/stlink/tools/flash.h | 4 ++- src/common.c | 56 ++++++++++++++++++++++++------------ src/tools/flash.c | 5 ++-- src/tools/flash_opts.c | 3 ++ 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index 94e980435..508b50f7d 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -151,6 +151,7 @@ typedef struct flash_loader { // transport layer verboseness: 0 for no debug info, 10 for lots int verbose; + int opt; uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram int core_stat; // set by stlink_status(), values STLINK_CORE_xxxxx diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index a73d7aee4..659c17f28 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -6,6 +6,7 @@ #define DEBUG_LOG_LEVEL 100 #define STND_LOG_LEVEL 50 +#define ENABLE_OPT 1 enum flash_cmd {FLASH_CMD_NONE = 0, FLASH_CMD_WRITE = 1, FLASH_CMD_READ = 2, FLASH_CMD_ERASE = 3, CMD_RESET = 4}; enum flash_format {FLASH_FORMAT_BINARY = 0, FLASH_FORMAT_IHEX = 1}; @@ -24,9 +25,10 @@ struct flash_opts enum flash_area area; uint32_t val; size_t flash_size; /* --flash=n[k][m] */ + int opt; }; -#define FLASH_OPTS_INITIALIZER {0, NULL, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0 } +#define FLASH_OPTS_INITIALIZER {0, NULL, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} int flash_get_opts(struct flash_opts* o, int ac, char** av); diff --git a/src/common.c b/src/common.c index f432cf5a1..c5506c061 100644 --- a/src/common.c +++ b/src/common.c @@ -2621,17 +2621,30 @@ int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr unsigned int num_empty, idx; uint8_t erased_pattern = stlink_get_erased_pattern(sl); - idx = (unsigned int)length; - for(num_empty = 0; num_empty != length; ++num_empty) { - if (data[--idx] != erased_pattern) { - break; + /* + * This optimization may cause unexpected garbage data remaining + * Turned off by default + */ + if (sl->opt) { + idx = (unsigned int)length; + for(num_empty = 0; num_empty != length; ++num_empty) { + if (data[--idx] != erased_pattern) { + break; + } } + /* Round down to words */ + num_empty -= (num_empty & 3); + if(num_empty != 0) { + ILOG("Ignoring %d bytes of 0x%02x at end of file\n", num_empty, erased_pattern); + } + } else { + num_empty = 0; } - /* Round down to words */ - num_empty -= (num_empty & 3); - if(num_empty != 0) { - ILOG("Ignoring %d bytes of 0x%02x at end of file\n", num_empty, erased_pattern); - } + /* + * a kind of weird behaviour here: + * if the file is identified to be all-empty and four-bytes aligned, + * still flash the whole file even if ignoring message is printed + */ err = stlink_write_flash(sl, addr, data, (num_empty == length) ? (uint32_t) length : (uint32_t) length - num_empty, num_empty == length); stlink_fwrite_finalize(sl, addr); return err; @@ -2655,18 +2668,23 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { ELOG("map_file() == -1\n"); return -1; } - - idx = (unsigned int) mf.len; - for(num_empty = 0; num_empty != mf.len; ++num_empty) { - if (mf.base[--idx] != erased_pattern) { - break; + + if (sl->opt) { + idx = (unsigned int) mf.len; + for(num_empty = 0; num_empty != mf.len; ++num_empty) { + if (mf.base[--idx] != erased_pattern) { + break; + } } + /* Round down to words */ + num_empty -= (num_empty & 3); + if(num_empty != 0) { + ILOG("Ignoring %d bytes of 0x%02x at end of file\n", num_empty, erased_pattern); + } + } else { + num_empty = 0; } - /* Round down to words */ - num_empty -= (num_empty & 3); - if(num_empty != 0) { - ILOG("Ignoring %d bytes of 0x%02x at end of file\n", num_empty, erased_pattern); - } + err = stlink_write_flash(sl, addr, mf.base, (num_empty == mf.len) ? (uint32_t) mf.len : (uint32_t) mf.len - num_empty, num_empty == mf.len); stlink_fwrite_finalize(sl, addr); unmap_file(&mf); diff --git a/src/tools/flash.c b/src/tools/flash.c index e1e9f41f6..67e03c62b 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -29,9 +29,9 @@ static void cleanup(int signum) { static void usage(void) { - puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--format ] [--flash=] {read|write} /dev/sgX "); + puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--opt] [--format ] [--flash=] {read|write} /dev/sgX "); puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--serial ] [--format ] [--flash=] {read|write} "); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] {read|write} "); puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] erase"); puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] reset"); puts(" , and : Use hex format."); @@ -73,6 +73,7 @@ int main(int ac, char** av) } sl->verbose = o.log_level; + sl->opt = o.opt; connected_stlink = sl; signal(SIGINT, &cleanup); diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index a6633d973..d409603f9 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -27,6 +27,9 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { else if (strcmp(av[0], "--debug") == 0) { o->log_level = DEBUG_LOG_LEVEL; } + else if (strcmp(av[0], "--opt") == 0) { + o->opt = ENABLE_OPT; + } else if (strcmp(av[0], "--reset") == 0) { o->reset = 1; } From e97eaa329a43dde694851cf27b55aa3891f9e85e Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 14:06:38 +0800 Subject: [PATCH 093/236] Add man documentation about --opt --- doc/man/st-flash.1 | 39 +++++++++++++++++++++------------------ doc/man/st-flash.md | 3 +++ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/doc/man/st-flash.1 b/doc/man/st-flash.1 index 36df7daa8..c2654f280 100644 --- a/doc/man/st-flash.1 +++ b/doc/man/st-flash.1 @@ -1,52 +1,55 @@ -.\" Automatically generated by Pandoc 2.4 +.\" Automatically generated by Pandoc 2.9 .\" -.TH "st\-flash" "1" "Feb 2018" "Open Source STMicroelectronics Stlink Tools" "stlink" +.TH "st-flash" "1" "Feb 2018" "Open Source STMicroelectronics Stlink Tools" "stlink" .hy .SH NAME .PP -st\-flash \- Flash binary files to STM32 device +st-flash - Flash binary files to STM32 device .SH SYNOPSIS .PP -\f[I]st\-flash\f[R] [\f[I]OPTIONS\f[R]] {read|write|erase} +\f[I]st-flash\f[R] [\f[I]OPTIONS\f[R]] {read|write|erase} [\f[I]FILE\f[R]] .SH DESCRIPTION .PP Flash binary files to arbitrary sections of memory, or read arbitrary addresses of memory out to a binary file. .PP -You can use this instead of st\-util(1) if you prefer, but remember to +You can use this instead of st-util(1) if you prefer, but remember to use the \f[B].bin\f[R] image, rather than the \f[B].elf\f[R] file. .PP Use hexadecimal format for the \f[I]ADDR\f[R] and \f[I]SIZE\f[R]. .SH COMMANDS .TP -.B write \f[I]FILE\f[R] \f[I]ADDR\f[R] +write \f[I]FILE\f[R] \f[I]ADDR\f[R] Write firmware \f[I]FILE\f[R] to device starting from \f[I]ADDR\f[R] .TP -.B read \f[I]FILE\f[R] \f[I]ADDR\f[R] \f[I]SIZE\f[R] +read \f[I]FILE\f[R] \f[I]ADDR\f[R] \f[I]SIZE\f[R] Read firmware from device starting from \f[I]ADDR\f[R] up to \f[I]SIZE\f[R] bytes to \f[I]FILE\f[R] .TP -.B erase +erase Perform a mass erasing of the device firmware .TP -.B reset +reset Reset the target .SH OPTIONS .TP -.B \-\-version +--version Print version information .TP -.B \-\-debug +--debug TODO .TP -.B \-\-reset +--reset TODO .TP -.B \-\-serial \f[I]iSerial\f[R] +--opt +Enable ignore ending empty bytes optimization +.TP +--serial \f[I]iSerial\f[R] TODO .TP -.B \-\-flash=fsize +--flash=fsize Where fsize is the size in decimal, octal, or hex followed by an optional multiplier `k' for KB, or `m' for MB. Use a leading \[lq]0x\[rq] to specify hexadecimal, or a leading zero for @@ -57,7 +60,7 @@ Flash \f[C]firmware.bin\f[R] to device .IP .nf \f[C] -$ st\-flash write firmware.bin 0x8000000 +$ st-flash write firmware.bin 0x8000000 \f[R] .fi .PP @@ -65,7 +68,7 @@ Read firmware from device (4096 bytes) .IP .nf \f[C] -$ st\-flash read firmware.bin 0x8000000 0x1000 +$ st-flash read firmware.bin 0x8000000 0x1000 \f[R] .fi .PP @@ -73,12 +76,12 @@ Erase firmware from device .IP .nf \f[C] -$ st\-flash erase +$ st-flash erase \f[R] .fi .SH SEE ALSO .PP -st\-util(1), st\-info(1) +st-util(1), st-info(1) .SH COPYRIGHT .PP This work is copyrighted. diff --git a/doc/man/st-flash.md b/doc/man/st-flash.md index 1860a8c72..b787e8dd7 100644 --- a/doc/man/st-flash.md +++ b/doc/man/st-flash.md @@ -45,6 +45,9 @@ reset \--reset : TODO +\--opt +: Enable ignore ending empty bytes optimization + \--serial *iSerial* : TODO From 12637a47f52a6595417b672963bf47cbe026b272 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 16:44:25 +0800 Subject: [PATCH 094/236] Indent with four spaces --- .travis-lin-mingw.sh | 14 ------------ src/tools/flash_opts.c | 48 +++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 38 deletions(-) delete mode 100755 .travis-lin-mingw.sh diff --git a/.travis-lin-mingw.sh b/.travis-lin-mingw.sh deleted file mode 100755 index 0422a06f6..000000000 --- a/.travis-lin-mingw.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -DIR=$PWD - -if [ "$TRAVIS_OS_NAME" == "linux" ]; then - echo "WORK DIR:$DIR" - mkdir -p $DIR/build/linux-mingw32-release - cd $DIR/build/linux-mingw32-release - echo "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR - echo "make" - make -fi - diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index d409603f9..a24bde1be 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -96,30 +96,30 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { else return -1; } - else if ( starts_with(av[0], "--flash=") ) { - const char *arg = av[0] + strlen("--flash="); - char *ep = 0; - - o->flash_size = (uint32_t)strtoul(arg,&ep,0); - while ( *ep ) { - switch ( *ep++ ) { - case 0: - break; - case 'k': - case 'K': - o->flash_size *= 1024u; - break; - case 'm': - case 'M': - o->flash_size *= 1024u * 1024u; - break; - default: - fprintf(stderr,"Invalid --flash=%s\n",arg); - return -1; - } - } - } - else { + else if ( starts_with(av[0], "--flash=") ) { + const char *arg = av[0] + strlen("--flash="); + char *ep = 0; + + o->flash_size = (uint32_t)strtoul(arg,&ep,0); + while ( *ep ) { + switch ( *ep++ ) { + case 0: + break; + case 'k': + case 'K': + o->flash_size *= 1024u; + break; + case 'm': + case 'M': + o->flash_size *= 1024u * 1024u; + break; + default: + fprintf(stderr,"Invalid --flash=%s\n",arg); + return -1; + } + } + } + else { break; // non-option found } From 11156bc66b7b3473654def392cccca9f0c3222d7 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 20:02:03 +0800 Subject: [PATCH 095/236] Add TODO tag in source code --- src/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index c5506c061..af9a87a8a 100644 --- a/src/common.c +++ b/src/common.c @@ -2641,6 +2641,7 @@ int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr num_empty = 0; } /* + * TODO: investigate: * a kind of weird behaviour here: * if the file is identified to be all-empty and four-bytes aligned, * still flash the whole file even if ignoring message is printed @@ -2684,7 +2685,12 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { } else { num_empty = 0; } - + /* + * TODO: investigate: + * a kind of weird behaviour here: + * if the file is identified to be all-empty and four-bytes aligned, + * still flash the whole file even if ignoring message is printed + */ err = stlink_write_flash(sl, addr, mf.base, (num_empty == mf.len) ? (uint32_t) mf.len : (uint32_t) mf.len - num_empty, num_empty == mf.len); stlink_fwrite_finalize(sl, addr); unmap_file(&mf); From 734bfdaa4754d6a6dd9ac974670ec7c0b9096347 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 20:24:08 +0800 Subject: [PATCH 096/236] Remove .travis-lin-mingw.sh in travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b1832d57f..d88bf1036 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,4 +26,3 @@ script: - printenv - cmake --version - ./.travis.sh - - ./.travis-lin-mingw.sh From 2979df40480be52678f41e20c3ed1893888ea0dc Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 11 Apr 2020 22:24:33 +0800 Subject: [PATCH 097/236] Fix 32 bit build on develop branch --- src/common.c | 22 +++++++++++----------- src/gdbserver/gdb-server.c | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/common.c b/src/common.c index af9a87a8a..b44c1e692 100644 --- a/src/common.c +++ b/src/common.c @@ -190,10 +190,10 @@ #define STM32L4_FLASH_CR_OBL_LAUNCH 27 /* Option bytes reload */ // Bits requesting flash operations (useful when we want to clear them) #define STM32L4_FLASH_CR_OPBITS \ - ((1lu<chip_id == STLINK_CHIPID_STM32_L496X || sl->chip_id == STLINK_CHIPID_STM32_L4RX) { // This chip use dual banked flash - if (flashopt & (1lu << STM32L4_FLASH_OPTR_DUALBANK)) { + if (flashopt & (uint32_t)(1lu << STM32L4_FLASH_OPTR_DUALBANK)) { uint32_t banksize = (uint32_t) sl->flash_size / 2; if (flashaddr >= banksize) { flashaddr -= banksize; @@ -1731,7 +1731,7 @@ uint32_t calculate_L4_page(stlink_t *sl, uint32_t flashaddr) { // For 1MB chips without the dual-bank option set, the page address will // overflow into the BKER bit, which gives us the correct bank:page value. - return bker | flashaddr/sl->flash_pgsz; + return bker | flashaddr/(uint32_t)sl->flash_pgsz; } uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr){ @@ -1907,7 +1907,7 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) // Set the page to erase. if (sl->flash_type == STLINK_FLASH_TYPE_WB) { - uint32_t flash_page = ((flashaddr - STM32_FLASH_BASE) / sl->flash_pgsz); + uint32_t flash_page = ((flashaddr - STM32_FLASH_BASE) / (uint32_t)(sl->flash_pgsz)); stlink_read_debug32(sl, STM32WB_FLASH_CR, &val); // sec 3.10.5 - PNB[7:0] is offset by 3. @@ -1916,14 +1916,14 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) stlink_write_debug32(sl, STM32WB_FLASH_CR, val); } else if (sl->flash_type == STLINK_FLASH_TYPE_G0) { - uint32_t flash_page = ((flashaddr - STM32_FLASH_BASE) / sl->flash_pgsz); + uint32_t flash_page = ((flashaddr - STM32_FLASH_BASE) / (uint32_t)(sl->flash_pgsz)); stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); // sec 3.7.5 - PNB[5:0] is offset by 3. PER is 0x2. val &= ~(0x3F << 3); val |= ((flash_page & 0x3F) << 3) | ( 1 << FLASH_CR_PER ); stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); } else if (sl->flash_type == STLINK_FLASH_TYPE_G4) { - uint32_t flash_page = ((flashaddr - STM32_FLASH_BASE) / sl->flash_pgsz); + uint32_t flash_page = ((flashaddr - STM32_FLASH_BASE) / (uint32_t)(sl->flash_pgsz)); stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); // sec 3.7.5 - PNB[6:0] is offset by 3. PER is 0x2. val &= ~(0x7F << 3); @@ -2000,7 +2000,7 @@ int stlink_erase_flash_mass(stlink_t *sl) { if (sl->flash_type == STLINK_FLASH_TYPE_L0 || sl->flash_type == STLINK_FLASH_TYPE_WB) { /* erase each page */ - int i = 0, num_pages = (int) sl->flash_size/sl->flash_pgsz; + int i = 0, num_pages = (int)(sl->flash_size/sl->flash_pgsz); for (i = 0; i < num_pages; i++) { /* addr must be an addr inside the page */ stm32_addr_t addr = (stm32_addr_t) sl->flash_base + i * (stm32_addr_t) sl->flash_pgsz; diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 3aa769e02..9cff5f917 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -862,7 +862,7 @@ static int flash_go(stlink_t *sl) { for(struct flash_block* fb = flash_root; fb; fb = fb->next) { DLOG("flash_do: block %08x -> %04x\n", fb->addr, fb->length); - for(stm32_addr_t page = fb->addr; page < fb->addr + fb->length; page += FLASH_PAGE) { + for(stm32_addr_t page = fb->addr; page < fb->addr + fb->length; page += (uint32_t)FLASH_PAGE) { unsigned length = fb->length - (page - fb->addr); //Update FLASH_PAGE From 067639ff8cb6fb23a00c9122822e542560f9a4ee Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sun, 12 Apr 2020 21:02:42 +0800 Subject: [PATCH 098/236] Enhance error log with file path for map_file() --- src/common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.c b/src/common.c index b44c1e692..813151f67 100644 --- a/src/common.c +++ b/src/common.c @@ -1302,19 +1302,19 @@ static int map_file(mapped_file_t* mf, const char* path) { } if (fstat(fd, &st) == -1) { - fprintf(stderr, "fstat() == -1\n"); + fprintf(stderr, "fstat(%s) == -1\n", path); goto on_error; } if (sizeof(st.st_size) != sizeof(size_t)) { /* On 32 bit systems, check if there is an overflow */ if (st.st_size > (off_t)UINT32_MAX) { - fprintf(stderr, "mmap() size_t overflow\n"); + fprintf(stderr, "mmap() size_t overflow for file %s\n", path); goto on_error; } } mf->base = (uint8_t*) mmap(NULL, (size_t)(st.st_size), PROT_READ, MAP_SHARED, fd, 0); if (mf->base == MAP_FAILED) { - fprintf(stderr, "mmap() == MAP_FAILED\n"); + fprintf(stderr, "mmap() == MAP_FAILED for file %s\n", path); goto on_error; } From cadfa941621cef85205622d6af0f87648d2a31c7 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 12 Apr 2020 18:26:46 +0200 Subject: [PATCH 099/236] General Project Update - Updated travis CI build configuration - Updated project references - Minor formatting fixes --- .travis.yml | 109 ++++++++++++++++++++++++++++++++------- CMakeLists.txt | 18 ++++--- README.md | 10 ++-- cmake/cpack_config.cmake | 3 +- 4 files changed, 106 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index d88bf1036..079888765 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,96 @@ - -compiler: - - gcc - - clang - language: c -os: - - linux - - osx +matrix: + include: + ### 64-bit builds ### + - os: linux + arch: x64 + compiler: gcc-5 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-5', 'libusb-1.0.0-dev'] + - os: linux + arch: x64 + compiler: gcc-7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-7', 'libusb-1.0.0-dev'] + - os: linux + arch: x64 + compiler: gcc-9 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-9', 'libusb-1.0.0-dev'] + - os: linux + arch: x64 + compiler: clang-3.7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] + packages: ['clang-3.7', 'libusb-1.0.0-dev'] + - os: linux + arch: x64 + compiler: clang-6.0 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] + packages: ['clang-6.0', 'libusb-1.0.0-dev'] + + ### 32-bit builds ### + - os: linux + arch: x86 + compiler: gcc-5 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-5', 'libusb-1.0.0-dev'] + - os: linux + arch: x86 + compiler: gcc-6 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-6', 'libusb-1.0.0-dev'] + - os: linux + arch: x86 + compiler: gcc-7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-7', 'libusb-1.0.0-dev'] + - os: linux + arch: x86 + compiler: clang-3.7 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] + packages: ['clang-3.7', 'libusb-1.0.0-dev'] + - os: linux + arch: x86 + compiler: clang-6.0 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] + packages: ['clang-6.0', 'libusb-1.0.0-dev'] -addons: - apt: - sources: - - sourceline: 'ppa:ubuntu-toolchain-r/test' - packages: - - clang - - g++-6 - - gcc-6 - - libusb-1.0.0-dev - - p7zip - - mingw-w64 + ### macOS ### + - os: osx + compiler: gcc + addons: + homebrew: + packages: + - libusb + - gcc + - os: osx + compiler: clang + addons: + homebrew: + packages: + - libusb + - clang script: - git fetch --tags diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f0b46449..8a282f550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,12 @@ if (IS_DIRECTORY ${LIB_INSTALL_DIR}) set(STLINK_LIBRARY_PATH "${LIB_INSTALL_DIR}") else () set(LIB_INSTALL_DIR "lib" CACHE PATH "Main library directory") - set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" ) + set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}") endif () 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}" ) + set(STLINK_INCLUDE_PATH "${INCLUDE_INSTALL_DIR}") else () set(INCLUDE_INSTALL_DIR "include" CACHE PATH "Main include directory") set(STLINK_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}") @@ -148,7 +148,7 @@ set_target_properties( VERSION ${STLINK_SHARED_VERSION} ) -# Link shared library with apple OS libraries +# Link shared library with Apple macOS libraries if (APPLE) find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) @@ -178,9 +178,9 @@ 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 +# Link shared library with Apple macOS libraries if (APPLE) find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) @@ -257,7 +257,9 @@ if (NOT TARGET uninstall) "${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) + ) + add_custom_target( + uninstall COMMAND ${CMAKE_COMMAND} + -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + ) endif () diff --git a/README.md b/README.md index e6de34dab..29d1ef766 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Open source version of the STMicroelectronics STlink Tools ========================================================== [![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) -[![GitHub release](https://img.shields.io/github/release/texane/stlink.svg)](https://github.com/texane/stlink/releases/latest) -[![GitHub commits](https://img.shields.io/github/commits-since/texane/stlink/v1.6.0.svg)](https://github.com/texane/stlink/releases/master) -[![Downloads](https://img.shields.io/github/downloads/texane/stlink/total.svg)](https://github.com/texane/stlink/releases) -[![Linux Status](https://img.shields.io/travis/texane/stlink/master.svg?label=linux)](https://travis-ci.org/texane/stlink) -[![macOS Status](https://img.shields.io/travis/texane/stlink/master.svg?label=osx)](https://travis-ci.org/texane/stlink) +[![GitHub release](https://img.shields.io/github/release/texane/stlink.svg)](https://github.com/stlink-org/stlink/releases/latest) +[![GitHub commits](https://img.shields.io/github/commits-since/texane/stlink/v1.6.0.svg)](https://github.com/stlink-org/stlink/releases/master) +[![Downloads](https://img.shields.io/github/downloads/texane/stlink/total.svg)](https://github.com/stlink-org/stlink/releases) +[![Linux Status](https://img.shields.io/travis/texane/stlink/master.svg?label=linux)](https://travis-ci.org/stlink-org/stlink) +[![macOS Status](https://img.shields.io/travis/texane/stlink/master.svg?label=osx)](https://travis-ci.org/stlink-org/stlink) Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) of this software project. diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake index 72a98a821..b8d4be186 100644 --- a/cmake/cpack_config.cmake +++ b/cmake/cpack_config.cmake @@ -16,12 +16,11 @@ elseif (WIN32) 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_HOMEPAGE "https://github.com/stlink-org/stlink") set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luca Boccassi") set(CPACK_PACKAGE_CONTACT "bluca@debian.org") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "STM32 STlink programmer tools") From 79676cdf793eedcfa210147098e621926d1cb222 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 13 Apr 2020 17:12:58 +0800 Subject: [PATCH 100/236] Add md5 checksum for binary file --- CMakeLists.txt | 1 + src/common.c | 23 +++- src/md5.c | 339 +++++++++++++++++++++++++++++++++++++++++++++++++ src/md5.h | 100 +++++++++++++++ 4 files changed, 462 insertions(+), 1 deletion(-) create mode 100755 src/md5.c create mode 100755 src/md5.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f0b46449..7dd8c4d0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ set(STLINK_SOURCE src/sg.c src/logging.c src/flash_loader.c + src/md5.c ) if (WIN32 OR MSYS OR MINGW) diff --git a/src/common.c b/src/common.c index 813151f67..43cec756d 100644 --- a/src/common.c +++ b/src/common.c @@ -15,6 +15,7 @@ #include "stlink.h" #include "stlink/mmap.h" #include "stlink/logging.h" +#include "md5.h" #ifndef O_BINARY #define O_BINARY 0 @@ -1365,6 +1366,20 @@ static int check_file(stlink_t* sl, mapped_file_t* mf, stm32_addr_t addr) { return 0; } +static void md5_calculate(mapped_file_t *mf, const char *path) { + /* calculate md5 checksum of given binary file */ + Md5Context md5Context; + MD5_HASH md5Hash; + Md5Initialise(&md5Context); + Md5Update(&md5Context, mf->base, (uint32_t)mf->len); + Md5Finalise(&md5Context, &md5Hash); + printf("file %s md5 checksum: ",path); + for(int i = 0; i < (int) sizeof(md5Hash); i++) { + printf("%x", md5Hash.bytes[i]); + } + printf("\n"); +} + static void stlink_fwrite_finalize(stlink_t *sl, stm32_addr_t addr) { unsigned int val; /* set stack*/ @@ -1446,6 +1461,8 @@ int stlink_fwrite_sram(stlink_t * sl, const char* path, stm32_addr_t addr) { return -1; } + md5_calculate(&mf, path); + /* check addr range is inside the sram */ if (addr < sl->sram_base) { fprintf(stderr, "addr too low\n"); @@ -2669,7 +2686,9 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { ELOG("map_file() == -1\n"); return -1; } - + + md5_calculate(&mf, path); + if (sl->opt) { idx = (unsigned int) mf.len; for(num_empty = 0; num_empty != mf.len; ++num_empty) { @@ -3234,6 +3253,8 @@ int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr return -1; } + md5_calculate(&mf, path); + err = stlink_write_option_bytes(sl, addr, mf.base, (uint32_t) mf.len); stlink_fwrite_finalize(sl, addr); unmap_file(&mf); diff --git a/src/md5.c b/src/md5.c new file mode 100755 index 000000000..ff7d2d76e --- /dev/null +++ b/src/md5.c @@ -0,0 +1,339 @@ +/* + * Retrieved from https://github.com/WaterJuice/WjCryptLib + */ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// WjCryptLib_Md5 +// +// Implementation of MD5 hash function. Originally written by Alexander Peslyak. Modified by WaterJuice retaining +// Public Domain license. +// +// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// IMPORTS +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "md5.h" +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// INTERNAL FUNCTIONS +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// F, G, H, I +// +// The basic MD5 functions. F and G are optimised compared to their RFC 1321 definitions for architectures that lack +// an AND-NOT instruction, just like in Colin Plumb's implementation. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define F( x, y, z ) ( (z) ^ ((x) & ((y) ^ (z))) ) +#define G( x, y, z ) ( (y) ^ ((z) & ((x) ^ (y))) ) +#define H( x, y, z ) ( (x) ^ (y) ^ (z) ) +#define I( x, y, z ) ( (y) ^ ((x) | ~(z)) ) + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// STEP +// +// The MD5 transformation for all four rounds. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#define STEP( f, a, b, c, d, x, t, s ) \ + (a) += f((b), (c), (d)) + (x) + (t); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ + (a) += (b); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TransformFunction +// +// This processes one or more 64-byte data blocks, but does NOT update the bit counters. There are no alignment +// requirements. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +static +void* + TransformFunction + ( + Md5Context* ctx, + void const* data, + uintmax_t size + ) +{ + uint8_t* ptr; + uint32_t a; + uint32_t b; + uint32_t c; + uint32_t d; + uint32_t saved_a; + uint32_t saved_b; + uint32_t saved_c; + uint32_t saved_d; + + #define GET(n) (ctx->block[(n)]) + #define SET(n) (ctx->block[(n)] = \ + ((uint32_t)ptr[(n)*4 + 0] << 0 ) \ + | ((uint32_t)ptr[(n)*4 + 1] << 8 ) \ + | ((uint32_t)ptr[(n)*4 + 2] << 16) \ + | ((uint32_t)ptr[(n)*4 + 3] << 24) ) + + ptr = (uint8_t*)data; + + a = ctx->a; + b = ctx->b; + c = ctx->c; + d = ctx->d; + + do + { + saved_a = a; + saved_b = b; + saved_c = c; + saved_d = d; + + // Round 1 + STEP( F, a, b, c, d, SET(0), 0xd76aa478, 7 ) + STEP( F, d, a, b, c, SET(1), 0xe8c7b756, 12 ) + STEP( F, c, d, a, b, SET(2), 0x242070db, 17 ) + STEP( F, b, c, d, a, SET(3), 0xc1bdceee, 22 ) + STEP( F, a, b, c, d, SET(4), 0xf57c0faf, 7 ) + STEP( F, d, a, b, c, SET(5), 0x4787c62a, 12 ) + STEP( F, c, d, a, b, SET(6), 0xa8304613, 17 ) + STEP( F, b, c, d, a, SET(7), 0xfd469501, 22 ) + STEP( F, a, b, c, d, SET(8 ), 0x698098d8, 7 ) + STEP( F, d, a, b, c, SET(9 ), 0x8b44f7af, 12 ) + STEP( F, c, d, a, b, SET(10 ), 0xffff5bb1, 17 ) + STEP( F, b, c, d, a, SET(11 ), 0x895cd7be, 22 ) + STEP( F, a, b, c, d, SET(12 ), 0x6b901122, 7 ) + STEP( F, d, a, b, c, SET(13 ), 0xfd987193, 12 ) + STEP( F, c, d, a, b, SET(14 ), 0xa679438e, 17 ) + STEP( F, b, c, d, a, SET(15 ), 0x49b40821, 22 ) + + // Round 2 + STEP( G, a, b, c, d, GET(1), 0xf61e2562, 5 ) + STEP( G, d, a, b, c, GET(6), 0xc040b340, 9 ) + STEP( G, c, d, a, b, GET(11), 0x265e5a51, 14 ) + STEP( G, b, c, d, a, GET(0), 0xe9b6c7aa, 20 ) + STEP( G, a, b, c, d, GET(5), 0xd62f105d, 5 ) + STEP( G, d, a, b, c, GET(10), 0x02441453, 9 ) + STEP( G, c, d, a, b, GET(15), 0xd8a1e681, 14 ) + STEP( G, b, c, d, a, GET(4), 0xe7d3fbc8, 20 ) + STEP( G, a, b, c, d, GET(9), 0x21e1cde6, 5 ) + STEP( G, d, a, b, c, GET(14), 0xc33707d6, 9 ) + STEP( G, c, d, a, b, GET(3), 0xf4d50d87, 14 ) + STEP( G, b, c, d, a, GET(8), 0x455a14ed, 20 ) + STEP( G, a, b, c, d, GET(13), 0xa9e3e905, 5 ) + STEP( G, d, a, b, c, GET(2), 0xfcefa3f8, 9 ) + STEP( G, c, d, a, b, GET(7), 0x676f02d9, 14 ) + STEP( G, b, c, d, a, GET(12), 0x8d2a4c8a, 20 ) + + // Round 3 + STEP( H, a, b, c, d, GET(5), 0xfffa3942, 4 ) + STEP( H, d, a, b, c, GET(8), 0x8771f681, 11 ) + STEP( H, c, d, a, b, GET(11), 0x6d9d6122, 16 ) + STEP( H, b, c, d, a, GET(14), 0xfde5380c, 23 ) + STEP( H, a, b, c, d, GET(1), 0xa4beea44, 4 ) + STEP( H, d, a, b, c, GET(4), 0x4bdecfa9, 11 ) + STEP( H, c, d, a, b, GET(7), 0xf6bb4b60, 16 ) + STEP( H, b, c, d, a, GET(10), 0xbebfbc70, 23 ) + STEP( H, a, b, c, d, GET(13), 0x289b7ec6, 4 ) + STEP( H, d, a, b, c, GET(0), 0xeaa127fa, 11 ) + STEP( H, c, d, a, b, GET(3), 0xd4ef3085, 16 ) + STEP( H, b, c, d, a, GET(6), 0x04881d05, 23 ) + STEP( H, a, b, c, d, GET(9), 0xd9d4d039, 4 ) + STEP( H, d, a, b, c, GET(12), 0xe6db99e5, 11 ) + STEP( H, c, d, a, b, GET(15), 0x1fa27cf8, 16 ) + STEP( H, b, c, d, a, GET(2), 0xc4ac5665, 23 ) + + // Round 4 + STEP( I, a, b, c, d, GET(0), 0xf4292244, 6 ) + STEP( I, d, a, b, c, GET(7), 0x432aff97, 10 ) + STEP( I, c, d, a, b, GET(14), 0xab9423a7, 15 ) + STEP( I, b, c, d, a, GET(5), 0xfc93a039, 21 ) + STEP( I, a, b, c, d, GET(12), 0x655b59c3, 6 ) + STEP( I, d, a, b, c, GET(3), 0x8f0ccc92, 10 ) + STEP( I, c, d, a, b, GET(10), 0xffeff47d, 15 ) + STEP( I, b, c, d, a, GET(1), 0x85845dd1, 21 ) + STEP( I, a, b, c, d, GET(8), 0x6fa87e4f, 6 ) + STEP( I, d, a, b, c, GET(15), 0xfe2ce6e0, 10 ) + STEP( I, c, d, a, b, GET(6), 0xa3014314, 15 ) + STEP( I, b, c, d, a, GET(13), 0x4e0811a1, 21 ) + STEP( I, a, b, c, d, GET(4), 0xf7537e82, 6 ) + STEP( I, d, a, b, c, GET(11), 0xbd3af235, 10 ) + STEP( I, c, d, a, b, GET(2), 0x2ad7d2bb, 15 ) + STEP( I, b, c, d, a, GET(9), 0xeb86d391, 21 ) + + a += saved_a; + b += saved_b; + c += saved_c; + d += saved_d; + + ptr += 64; + } while( size -= 64 ); + + ctx->a = a; + ctx->b = b; + ctx->c = c; + ctx->d = d; + + #undef GET + #undef SET + + return ptr; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// EXPORTED FUNCTIONS +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Initialise +// +// Initialises an MD5 Context. Use this to initialise/reset a context. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Initialise + ( + Md5Context* Context // [out] + ) +{ + Context->a = 0x67452301; + Context->b = 0xefcdab89; + Context->c = 0x98badcfe; + Context->d = 0x10325476; + + Context->lo = 0; + Context->hi = 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Update +// +// Adds data to the MD5 context. This will process the data and update the internal state of the context. Keep on +// calling this function until all the data has been added. Then call Md5Finalise to calculate the hash. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Update + ( + Md5Context* Context, // [in out] + void const* Buffer, // [in] + uint32_t BufferSize // [in] + ) +{ + uint32_t saved_lo; + uint32_t used; + uint32_t free; + + saved_lo = Context->lo; + if( (Context->lo = (saved_lo + BufferSize) & 0x1fffffff) < saved_lo ) + { + Context->hi++; + } + Context->hi += (uint32_t)( BufferSize >> 29 ); + + used = saved_lo & 0x3f; + + if( used ) + { + free = 64 - used; + + if( BufferSize < free ) + { + memcpy( &Context->buffer[used], Buffer, BufferSize ); + return; + } + + memcpy( &Context->buffer[used], Buffer, free ); + Buffer = (uint8_t*)Buffer + free; + BufferSize -= free; + TransformFunction(Context, Context->buffer, 64); + } + + if( BufferSize >= 64 ) + { + Buffer = TransformFunction( Context, Buffer, BufferSize & ~(unsigned long)0x3f ); + BufferSize &= 0x3f; + } + + memcpy( Context->buffer, Buffer, BufferSize ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Finalise +// +// Performs the final calculation of the hash and returns the digest (16 byte buffer containing 128bit hash). After +// calling this, Md5Initialised must be used to reuse the context. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Finalise + ( + Md5Context* Context, // [in out] + MD5_HASH* Digest // [in] + ) +{ + uint32_t used; + uint32_t free; + + used = Context->lo & 0x3f; + + Context->buffer[used++] = 0x80; + + free = 64 - used; + + if(free < 8) + { + memset( &Context->buffer[used], 0, free ); + TransformFunction( Context, Context->buffer, 64 ); + used = 0; + free = 64; + } + + memset( &Context->buffer[used], 0, free - 8 ); + + Context->lo <<= 3; + Context->buffer[56] = (uint8_t)( Context->lo ); + Context->buffer[57] = (uint8_t)( Context->lo >> 8 ); + Context->buffer[58] = (uint8_t)( Context->lo >> 16 ); + Context->buffer[59] = (uint8_t)( Context->lo >> 24 ); + Context->buffer[60] = (uint8_t)( Context->hi ); + Context->buffer[61] = (uint8_t)( Context->hi >> 8 ); + Context->buffer[62] = (uint8_t)( Context->hi >> 16 ); + Context->buffer[63] = (uint8_t)( Context->hi >> 24 ); + + TransformFunction( Context, Context->buffer, 64 ); + + Digest->bytes[0] = (uint8_t)( Context->a ); + Digest->bytes[1] = (uint8_t)( Context->a >> 8 ); + Digest->bytes[2] = (uint8_t)( Context->a >> 16 ); + Digest->bytes[3] = (uint8_t)( Context->a >> 24 ); + Digest->bytes[4] = (uint8_t)( Context->b ); + Digest->bytes[5] = (uint8_t)( Context->b >> 8 ); + Digest->bytes[6] = (uint8_t)( Context->b >> 16 ); + Digest->bytes[7] = (uint8_t)( Context->b >> 24 ); + Digest->bytes[8] = (uint8_t)( Context->c ); + Digest->bytes[9] = (uint8_t)( Context->c >> 8 ); + Digest->bytes[10] = (uint8_t)( Context->c >> 16 ); + Digest->bytes[11] = (uint8_t)( Context->c >> 24 ); + Digest->bytes[12] = (uint8_t)( Context->d ); + Digest->bytes[13] = (uint8_t)( Context->d >> 8 ); + Digest->bytes[14] = (uint8_t)( Context->d >> 16 ); + Digest->bytes[15] = (uint8_t)( Context->d >> 24 ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Calculate +// +// Combines Md5Initialise, Md5Update, and Md5Finalise into one function. Calculates the MD5 hash of the buffer. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Calculate + ( + void const* Buffer, // [in] + uint32_t BufferSize, // [in] + MD5_HASH* Digest // [in] + ) +{ + Md5Context context; + + Md5Initialise( &context ); + Md5Update( &context, Buffer, BufferSize ); + Md5Finalise( &context, Digest ); +} diff --git a/src/md5.h b/src/md5.h new file mode 100755 index 000000000..5ef252221 --- /dev/null +++ b/src/md5.h @@ -0,0 +1,100 @@ +/* + * Retrieved from https://github.com/WaterJuice/WjCryptLib + */ + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// WjCryptLib_Md5 +// +// Implementation of MD5 hash function. Originally written by Alexander Peslyak. Modified by WaterJuice retaining +// Public Domain license. +// +// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#pragma once + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// IMPORTS +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// TYPES +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// Md5Context - This must be initialised using Md5Initialised. Do not modify the contents of this structure directly. +typedef struct +{ + uint32_t lo; + uint32_t hi; + uint32_t a; + uint32_t b; + uint32_t c; + uint32_t d; + uint8_t buffer[64]; + uint32_t block[16]; +} Md5Context; + +#define MD5_HASH_SIZE ( 128 / 8 ) + +typedef struct +{ + uint8_t bytes [MD5_HASH_SIZE]; +} MD5_HASH; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// PUBLIC FUNCTIONS +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Initialise +// +// Initialises an MD5 Context. Use this to initialise/reset a context. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Initialise + ( + Md5Context* Context // [out] + ); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Update +// +// Adds data to the MD5 context. This will process the data and update the internal state of the context. Keep on +// calling this function until all the data has been added. Then call Md5Finalise to calculate the hash. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Update + ( + Md5Context* Context, // [in out] + void const* Buffer, // [in] + uint32_t BufferSize // [in] + ); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Finalise +// +// Performs the final calculation of the hash and returns the digest (16 byte buffer containing 128bit hash). After +// calling this, Md5Initialised must be used to reuse the context. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Finalise + ( + Md5Context* Context, // [in out] + MD5_HASH* Digest // [in] + ); + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Md5Calculate +// +// Combines Md5Initialise, Md5Update, and Md5Finalise into one function. Calculates the MD5 hash of the buffer. +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void + Md5Calculate + ( + void const* Buffer, // [in] + uint32_t BufferSize, // [in] + MD5_HASH* Digest // [in] + ); From 42c5fd7e69ae7205befb37fac8868b1fd5965ad7 Mon Sep 17 00:00:00 2001 From: Simon Derr Date: Mon, 13 Apr 2020 10:46:56 +0200 Subject: [PATCH 101/236] st-flash: minor usage fix, and make cmdline parsing more user friendly Somewhat fix the help message that showed some parameters as mandatory, when in reality they depend on the operation type and file format. Try to show explicit error messages for the most common mistakes. --- src/tools/flash.c | 2 +- src/tools/flash_opts.c | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/tools/flash.c b/src/tools/flash.c index 67e03c62b..b9cc86d45 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -31,7 +31,7 @@ static void usage(void) { puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--opt] [--format ] [--flash=] {read|write} /dev/sgX "); puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] {read|write} "); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] {read|write} [addr] [size]"); puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] erase"); puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] reset"); puts(" , and : Use hex format."); diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index a24bde1be..261d8b524 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -11,6 +11,18 @@ static bool starts_with(const char * str, const char * prefix) { return (0 == strncmp(str, prefix, n)); } +static int invalid_args(const char *expected) +{ + fprintf(stderr, "*** Error: Expected args for this command: %s\n", expected); + return -1; +} + +static int bad_arg(const char *arg) +{ + fprintf(stderr, "*** Error: Invalid value for %s\n", arg); + return -1; +} + int flash_get_opts(struct flash_opts* o, int ac, char** av) { bool serial_specified = false; @@ -94,7 +106,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { else if (strcmp(format, "ihex") == 0) o->format = FLASH_FORMAT_IHEX; else - return -1; + return bad_arg("format"); } else if ( starts_with(av[0], "--flash=") ) { const char *arg = av[0] + strlen("--flash="); @@ -168,12 +180,13 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { case FLASH_CMD_READ: // expect filename, addr and size if((o->area == FLASH_OPTION_BYTES) &&(ac == 0)) break; + if (ac != 3) return invalid_args("read "); if (ac != 3) return -1; o->filename = av[0]; o->addr = (uint32_t) strtoul(av[1], &tail, 16); - if(tail[0] != '\0') return -1; + if(tail[0] != '\0') return bad_arg("addr"); o->size = strtoul(av[2], &tail, 16); - if(tail[0] != '\0') return -1; + if(tail[0] != '\0') return bad_arg("size"); break; case FLASH_CMD_WRITE: @@ -182,17 +195,17 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { o->val = (uint32_t)strtoul(av[0], &tail, 16); } else if(o->format == FLASH_FORMAT_BINARY) { // expect filename and addr - if (ac != 2) return -1; + if (ac != 2) return invalid_args("write "); o->filename = av[0]; o->addr = (uint32_t) strtoul(av[1], &tail, 16); - if(tail[0] != '\0') return -1; + if(tail[0] != '\0') return bad_arg("addr"); } else if(o->format == FLASH_FORMAT_IHEX) { // expect filename - if (ac != 1) return -1; + if (ac != 1) return invalid_args("write "); o->filename = av[0]; } else { - return -1; + return -1; // should have been caught during format parsing } break; From eb243044338b9a1f312a92b7dbc5c2b61fc0360a Mon Sep 17 00:00:00 2001 From: Simon Derr Date: Mon, 13 Apr 2020 11:55:39 +0200 Subject: [PATCH 102/236] src/tools/flash_opts.c: fix style issues --- src/tools/flash_opts.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 261d8b524..5f6417bac 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -11,16 +11,14 @@ static bool starts_with(const char * str, const char * prefix) { return (0 == strncmp(str, prefix, n)); } -static int invalid_args(const char *expected) -{ - fprintf(stderr, "*** Error: Expected args for this command: %s\n", expected); - return -1; +static int invalid_args(const char *expected) { + fprintf(stderr, "*** Error: Expected args for this command: %s\n", expected); + return -1; } -static int bad_arg(const char *arg) -{ - fprintf(stderr, "*** Error: Invalid value for %s\n", arg); - return -1; +static int bad_arg(const char *arg) { + fprintf(stderr, "*** Error: Invalid value for %s\n", arg); + return -1; } int flash_get_opts(struct flash_opts* o, int ac, char** av) { From 35cbe57f4f6c2e2052b32c4c2431a578c6344a10 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 13 Apr 2020 18:30:44 +0800 Subject: [PATCH 103/236] Add st official checksum for binary file --- src/common.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/common.c b/src/common.c index 43cec756d..d3944eec5 100644 --- a/src/common.c +++ b/src/common.c @@ -1380,6 +1380,16 @@ static void md5_calculate(mapped_file_t *mf, const char *path) { printf("\n"); } +static void stlink_checksum(mapped_file_t *mp, const char* path) { + /* checksum that backward compatible with official ST tools */ + uint32_t sum = 0; + uint8_t *mp_byte = (uint8_t *)mp->base; + for (size_t i = 0; i < mp->len; ++i) { + sum += mp_byte[i]; + } + printf("file %s stlink checksum: 0x%08x\n", path, sum); +} + static void stlink_fwrite_finalize(stlink_t *sl, stm32_addr_t addr) { unsigned int val; /* set stack*/ @@ -1462,6 +1472,7 @@ int stlink_fwrite_sram(stlink_t * sl, const char* path, stm32_addr_t addr) { } md5_calculate(&mf, path); + stlink_checksum(&mf, path); /* check addr range is inside the sram */ if (addr < sl->sram_base) { @@ -2688,6 +2699,7 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { } md5_calculate(&mf, path); + stlink_checksum(&mf, path); if (sl->opt) { idx = (unsigned int) mf.len; @@ -3254,6 +3266,7 @@ int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr } md5_calculate(&mf, path); + stlink_checksum(&mf, path); err = stlink_write_option_bytes(sl, addr, mf.base, (uint32_t) mf.len); stlink_fwrite_finalize(sl, addr); From 6eb9103a235dcf24c86e39553f807a987b533aa0 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 13 Apr 2020 15:02:43 +0200 Subject: [PATCH 104/236] Updated build-settings - Added new build configs for Travis - Refactoring for cmake modules - Updated Travis build script - Makefile: binary build for Windows --- .travis.sh | 38 ++++++-- .travis.yml | 8 ++ Makefile | 14 ++- cmake/modules/FindLibUSB.cmake | 155 ++++++++++++++++++--------------- cmake/version.cmake | 61 +++++++------ 5 files changed, 176 insertions(+), 100 deletions(-) diff --git a/.travis.sh b/.travis.sh index 05568d37d..3d6da055f 100755 --- a/.travis.sh +++ b/.travis.sh @@ -5,15 +5,43 @@ ls -1 /usr/bin/clang* ls -1 /usr/bin/scan-build* echo "----" +echo "WORK DIR:$DIR" +DIR=$PWD + if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update -qq || true sudo apt-get install -qq -y --no-install-recommends libgtk-3-dev + + echo "--> Building Debug..." + mkdir -p build/Debug && cd build/Debug + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - + + echo "--> Building Release..." + mkdir -p build/Release && cd build/Release + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - + + echo "--> Building Binary..." + mkdir -p build/Binary && cd build/Binary + cho "-DCMAKE_BUILD_TYPE=Binary -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Binary -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - + else #("$TRAVIS_OS_NAME" == "osx") brew install libusb -fi -echo "=== Building Debug" -mkdir -p build/Debug && cd build/Debug && cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ && make && make package && cd - + echo "--> Building Debug..." + mkdir -p build/Debug && cd build/Debug + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - -echo "=== Building Release" -mkdir -p build/Release && cd build/Release && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ && make && make package && cd - + echo "--> Building Release..." + mkdir -p build/Release && cd build/Release + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - +fi diff --git a/.travis.yml b/.travis.yml index 079888765..221e8ece7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,14 @@ matrix: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] packages: ['clang-6.0', 'libusb-1.0.0-dev'] + - os: linux + arch: x64 + compiler: clang-6.0 + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] + packages: ['clang-6.0', 'libusb-1.0.0-dev'] + env: CFLAGS=-m32 LDFLAGS=-m32 ### 32-bit builds ### - os: linux diff --git a/Makefile b/Makefile index 0636eb9bd..6b44bd70c 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,12 @@ MAKEFLAGS += -s all: release -ci: debug release test +ci: debug release binary test help: - @echo " release: Run a release build" @echo " debug: Run a debug build" + @echo " release: Run a release build" + @echo " binary: Build Windows-Binary" @echo " lint: Lint check all source-code" @echo " test: Build and run tests" @echo " clean: Clean all build output" @@ -17,6 +18,7 @@ help: rebuild_cache: build/Debug build/Release @$(MAKE) -C build/Debug rebuild_cache @$(MAKE) -C build/Release rebuild_cache + @$(MAKE) -C build/Binary rebuild_cache debug: build/Debug @echo "[DEBUG]" @@ -26,6 +28,10 @@ release: build/Release @echo "[RELEASE]" @$(MAKE) -C build/Release +binary: build/Binary + @echo "[BINARY]" + @$(MAKE) -C build/Binary + package: build/Release @echo "[PACKAGE] Release" @$(MAKE) -C build/Release package @@ -41,6 +47,10 @@ build/Release: @mkdir -p $@ @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ +build/Binary: + @mkdir -p $@ + @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Binary $(CMAKEFLAGS) ../../ + clean: @echo "[CLEAN]" @rm -Rf build diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index dc90bcc32..b583b8491 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -1,102 +1,90 @@ # FindLibUSB.cmake # Once done this will define # -# LIBUSB_FOUND - System has libusb -# LIBUSB_INCLUDE_DIR - The libusb include directory -# LIBUSB_LIBRARY - The libraries needed to use libusb -# LIBUSB_DEFINITIONS - Compiler switches required for using libusb +# LIBUSB_FOUND libusb present on system +# LIBUSB_INCLUDE_DIR the libusb include directory +# LIBUSB_LIBRARY the libraries needed to use libusb +# LIBUSB_DEFINITIONS compiler switches required for using libusb -if (NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")) # all OS apart from FreeBSD +include(FindPackageHandleStandardArgs) + +if (APPLE) # macOS 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 - ) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) + if (NOT LIBUSB_FOUND) + message(FATAL_ERROR "No libusb library found on your system! Install libusb-1.0 from Homebrew or MacPorts") 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 +elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system 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 ) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) + if (NOT LIBUSB_FOUND) + message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.") + endif () -else () # all other OS - set(LIBUSB_NAME usb-1.0) - find_library( - LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} - HINTS /usr /usr/local /opt - ) -endif() +elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES "Binary")) + # Windows & Windows-Binary-Build on Debian/Ubuntu -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) -mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) + # for MinGW/MSYS/MSVC: 64-bit or 32-bit? + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ARCH 64) + else () + set(ARCH 32) + endif () -if (NOT LIBUSB_FOUND) - if (WIN32 OR MINGW OR MSYS OR MSVC) # Windows + if (NOT EXISTS "/etc/debian_version") + FIND_PATH( + LIBUSB_INCLUDE_DIR NAMES libusb.h + HINTS /usr /usr/local /opt + PATH_SUFFIXES libusb-1.0 + ) + if (MINGW OR MSYS) + set(LIBUSB_NAME usb-1.0) + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static + ) + else (MSVC) + set(LIBUSB_NAME libusb-1.0.lib) + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS${ARCH}/dll + ) + endif () + endif () + + if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # 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_VERSION 1.0.23) # set libusb version 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}/3rdparty/libusb-${LIBUSB_WIN_VERSION}) # Get libusb package - if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there (for whatever reason) + if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there (for whatever reason) message(STATUS "libusb archive already in build folder") - else () # ... download the package (1.0.23 as of Apr 2020) + else () # ... download the package message(STATUS "downloading libusb ${LIBUSB_WIN_VERSION}") file(DOWNLOAD https://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-${LIBUSB_WIN_VERSION}/libusb-${LIBUSB_WIN_VERSION}.7z/download @@ -127,11 +115,42 @@ if (NOT LIBUSB_FOUND) NO_CMAKE_FIND_ROOT_PATH ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) - message(STATUS "installed libusb library") - else () # all other OS - message(FATAL_ERROR "libusb library not found on your system! Compilation terminated.") + if (MINGW OR MSYS) + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + + else (MSVC) + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS${ARCH}/dll + NO_DEFAULT_PATH + NO_CMAKE_FIND_ROOT_PATH + ) + endif () + message(STATUS "Missing libusb library has been installed") + endif () + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) + +else () # all other OS (unix-based) + FIND_PATH( + LIBUSB_INCLUDE_DIR NAMES libusb.h + HINTS /usr /usr/local /opt + PATH_SUFFIXES libusb-1.0 + ) + set(LIBUSB_NAME usb-1.0) + find_library( + LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} + HINTS /usr /usr/local /opt + ) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) + + if (NOT LIBUSB_FOUND) + message(FATAL_ERROR "libusb library not found on your system! Install libusb 1.0.x from your package repository.") endif () -else (NOT LIBUSB_FOUND) - message(STATUS "found libusb library") endif () diff --git a/cmake/version.cmake b/cmake/version.cmake index fe778c419..38254409f 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -5,9 +5,11 @@ set(__detect_version 0) find_package(Git) +set(ERROR_FLAG "0") if (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 --tag @@ -17,22 +19,22 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") ERROR_VARIABLE GIT_DESCRIBE_ERROR OUTPUT_STRIP_TRAILING_WHITESPACE ) - if (GIT_DESCRIBE_RESULT EQUAL 0) + # 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 (PROJECT_VERSION "${PROJECT_VERSION}-dirty") + set(PROJECT_VERSION "${PROJECT_VERSION}-dirty") endif () - # strip a leading v off of the version as proceeding code expectes just the version numbering. + # Strip a leading v off of the version as proceeding code expects just the version numbering. string(REGEX REPLACE "^v" "" PROJECT_VERSION ${PROJECT_VERSION}) + # Read version string 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}) list(LENGTH PROJECT_VERSION_LIST len) @@ -42,34 +44,46 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") list(GET PROJECT_VERSION_LIST 2 PROJECT_VERSION_PATCH) set(__detect_version 1) set(__version_str "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + + # Compare git-Version with version read from .version file in source folder if (EXISTS "${PROJECT_SOURCE_DIR}/.version") + + # Local .version file found, read version string... file(READ "${PROJECT_SOURCE_DIR}/.version" __version_file) + + # ...the version does not match with git-version string if (NOT __version_str STREQUAL __version_file) - message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}") + message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}.") endif () - else () + + else (EXISTS "${PROJECT_SOURCE_DIR}/.version") + + # No local .version file found: Create a new one... file(WRITE "${PROJECT_SOURCE_DIR}/.version" ${__version_str}) + endif () - else () - message(STATUS "Fail to extract version parts from \"${PROJECT_VERSION}\"") - endif () - else(GIT_DESCRIBE_RESULT EQUAL 0) - message(WARNING "git describe failed.") - message(WARNING "${GIT_DESCRIBE_ERROR}") + message(STATUS "stlink version: ${PROJECT_VERSION}") + message(STATUS "Major ${PROJECT_VERSION_MAJOR} Minor ${PROJECT_VERSION_MINOR} Patch ${PROJECT_VERSION_PATCH}") + + else (len EQUAL 3) + message(STATUS "Failed to extract version parts from \"${PROJECT_VERSION}\"") + set(ERROR_FLAG "1") + endif (len EQUAL 3) + + else (GIT_DESCRIBE_RESULT EQUAL 0) + message(WARNING "git describe failed: ${GIT_DESCRIBE_ERROR}") + set(ERROR_FLAG "1") endif(GIT_DESCRIBE_RESULT EQUAL 0) -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 (ERROR_FLAG EQUAL 1) + message(STATUS "Git and/or repository not found.") # e.g. when building from source package + message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file instead...") if (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 PROJECT_VERSION) - # TODO create function to extract semver from file or string and check if it is correct instead of copy-pasting + # Read version string 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}) list(LENGTH PROJECT_VERSION_LIST len) @@ -81,11 +95,8 @@ if (NOT __detect_version) else () message(STATUS "Fail to extract version parts from \"${PROJECT_VERSION}\"") endif () - else () - message(STATUS "File \"${PROJECT_SOURCE_DIR}/.version\" did not exists.") + else (EXISTS ${PROJECT_SOURCE_DIR}/.version) + message(STATUS "File \"${PROJECT_SOURCE_DIR}/.version\" does not exist.") + message(FATAL_ERROR "Unable to determine project version") endif () - 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}") From 6515e57b9ea4db69de3f66ba8db709163ab22456 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 13 Apr 2020 21:20:20 +0800 Subject: [PATCH 105/236] Adjust output format for better formating --- src/common.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common.c b/src/common.c index d3944eec5..e719c6031 100644 --- a/src/common.c +++ b/src/common.c @@ -1373,11 +1373,11 @@ static void md5_calculate(mapped_file_t *mf, const char *path) { Md5Initialise(&md5Context); Md5Update(&md5Context, mf->base, (uint32_t)mf->len); Md5Finalise(&md5Context, &md5Hash); - printf("file %s md5 checksum: ",path); + printf("md5 checksum: "); for(int i = 0; i < (int) sizeof(md5Hash); i++) { printf("%x", md5Hash.bytes[i]); } - printf("\n"); + printf(", "); } static void stlink_checksum(mapped_file_t *mp, const char* path) { @@ -1387,7 +1387,7 @@ static void stlink_checksum(mapped_file_t *mp, const char* path) { for (size_t i = 0; i < mp->len; ++i) { sum += mp_byte[i]; } - printf("file %s stlink checksum: 0x%08x\n", path, sum); + printf("stlink checksum: 0x%08x\n", sum); } static void stlink_fwrite_finalize(stlink_t *sl, stm32_addr_t addr) { @@ -1470,7 +1470,7 @@ int stlink_fwrite_sram(stlink_t * sl, const char* path, stm32_addr_t addr) { fprintf(stderr, "map_file() == -1\n"); return -1; } - + printf("file %s "); md5_calculate(&mf, path); stlink_checksum(&mf, path); @@ -2698,6 +2698,7 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { return -1; } + printf("file %s "); md5_calculate(&mf, path); stlink_checksum(&mf, path); @@ -3265,6 +3266,7 @@ int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr return -1; } + printf("file %s "); md5_calculate(&mf, path); stlink_checksum(&mf, path); From 1047fdd44063d26e25974704ef23ef9ee8595e3e Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 13 Apr 2020 21:26:16 +0800 Subject: [PATCH 106/236] Add documentation about the checksum --- doc/tutorial.md | 5 +++++ src/common.c | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 66bed0382..f19a6ecd9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -539,6 +539,11 @@ want to disassemble the code at 0x20000000, use:\ (gdb) disassemble 0x20000001 ``` +Checksum of binary file +----------------------- + +When flashing a file, the checksum of which is calculated, both in md5 and the sum algorithm used by ST's official tool. The detail of sum algorithm can be found in [https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf](https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf). + References ========== diff --git a/src/common.c b/src/common.c index e719c6031..d04644071 100644 --- a/src/common.c +++ b/src/common.c @@ -1366,7 +1366,7 @@ static int check_file(stlink_t* sl, mapped_file_t* mf, stm32_addr_t addr) { return 0; } -static void md5_calculate(mapped_file_t *mf, const char *path) { +static void md5_calculate(mapped_file_t *mf) { /* calculate md5 checksum of given binary file */ Md5Context md5Context; MD5_HASH md5Hash; @@ -1380,7 +1380,7 @@ static void md5_calculate(mapped_file_t *mf, const char *path) { printf(", "); } -static void stlink_checksum(mapped_file_t *mp, const char* path) { +static void stlink_checksum(mapped_file_t *mp) { /* checksum that backward compatible with official ST tools */ uint32_t sum = 0; uint8_t *mp_byte = (uint8_t *)mp->base; @@ -1470,9 +1470,9 @@ int stlink_fwrite_sram(stlink_t * sl, const char* path, stm32_addr_t addr) { fprintf(stderr, "map_file() == -1\n"); return -1; } - printf("file %s "); - md5_calculate(&mf, path); - stlink_checksum(&mf, path); + printf("file %s ", path); + md5_calculate(&mf); + stlink_checksum(&mf); /* check addr range is inside the sram */ if (addr < sl->sram_base) { @@ -2698,9 +2698,9 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { return -1; } - printf("file %s "); - md5_calculate(&mf, path); - stlink_checksum(&mf, path); + printf("file %s ", path); + md5_calculate(&mf); + stlink_checksum(&mf); if (sl->opt) { idx = (unsigned int) mf.len; @@ -3266,9 +3266,9 @@ int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr return -1; } - printf("file %s "); - md5_calculate(&mf, path); - stlink_checksum(&mf, path); + printf("file %s ", path); + md5_calculate(&mf); + stlink_checksum(&mf); err = stlink_write_option_bytes(sl, addr, mf.base, (uint32_t) mf.len); stlink_fwrite_finalize(sl, addr); From fc507fd4842cd9b4719378d0ee79a6a123eecae3 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Sun, 12 Apr 2020 15:58:17 +0200 Subject: [PATCH 107/236] flash.c: stlink_open_usb is actually able to open v1 and v2 (and v3 ..) devices. no need to check that _not used_ o.devname .. no need to specify devname in commandline get rid of the devname cmdline stuff, and update comments --- src/tools/flash.c | 13 ++++--------- src/tools/flash_opts.c | 11 +---------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/tools/flash.c b/src/tools/flash.c index b9cc86d45..f703bc813 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -29,11 +29,9 @@ static void cleanup(int signum) { static void usage(void) { - puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--opt] [--format ] [--flash=] {read|write} /dev/sgX "); - puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] {read|write} [addr] [size]"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] erase"); - puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] reset"); + puts("command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] {read|write} [addr] [size]"); + puts("command line: ./st-flash [--debug] [--serial ] erase"); + puts("command line: ./st-flash [--debug] [--serial ] reset"); puts(" , and : Use hex format."); puts(" : Use decimal, octal or hex (prefix 0xXXX) format, optionally followed by k=KB, or m=MB (eg. --flash=128k)"); puts(" : Can be 'binary' (default) or 'ihex', although must be specified for binary format only."); @@ -59,10 +57,7 @@ int main(int ac, char** av) printf("st-flash %s\n", STLINK_VERSION); - if (o.devname != NULL) /* stlinkv1 */ - sl = stlink_v1_open(o.log_level, 1); - else /* stlinkv2 */ - sl = stlink_open_usb(o.log_level, 1, (char *)o.serial); + sl = stlink_open_usb(o.log_level, 1, (char *)o.serial); if (sl == NULL) return -1; diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 5f6417bac..c139977ce 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -22,7 +22,6 @@ static int bad_arg(const char *arg) { } int flash_get_opts(struct flash_opts* o, int ac, char** av) { - bool serial_specified = false; // defaults memset(o, 0, sizeof(*o)); @@ -63,7 +62,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { memcpy(buffer, serial + j, 2); o->serial[length - k] = (uint8_t)strtol(buffer, NULL, 16); } - serial_specified = true; } else if (strcmp(av[0], "--area") == 0 || starts_with(av[0], "--area=")) { const char * area; @@ -138,7 +136,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { } // command and (optional) device name - while(ac >= 1) { // looks like for stlinkv1 the device name and command may be swaped - check both positions in all cases + while(ac >= 1) { if (strcmp(av[0], "erase") == 0) { if (o->cmd != FLASH_CMD_NONE) return -1; o->cmd = FLASH_CMD_ERASE; @@ -155,10 +153,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { if (o->cmd != FLASH_CMD_NONE) return -1; o->cmd = CMD_RESET; } - else if(starts_with(av[0], "/dev/")) { - if (o->devname) return -1; - o->devname = av[0]; - } else { break; } @@ -210,8 +204,5 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { default: break ; } - // some constistence checks - if(serial_specified && o->devname != NULL) return -1; // serial not supported for v1 - return 0; } From 308fccb04875c51dcfcf0730872ca0de37929bc8 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 14 Apr 2020 21:01:52 +0200 Subject: [PATCH 108/236] General Project Update - Updated CHANGELOG.md - Updated links to project repository - Improved project description - Minor revision for tutorial.md - Formatting fixes --- CHANGELOG.md | 6 +-- README.md | 37 ++++++++----- doc/compiling.md | 6 +-- doc/tutorial.md | 133 +++++++++++++---------------------------------- 4 files changed, 67 insertions(+), 115 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e31aaf47..99d307f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -173,7 +173,7 @@ Release date: 2017-01-28 Major changes and added features: * Deprecation of autotools (autoconf, automake) and fixed build with MinGW ([#83](https://github.com/texane/stlink/pull/83), [#431](https://github.com/texane/stlink/pull/431), [#434](https://github.com/texane/stlink/pull/434), [#465](https://github.com/texane/stlink/pull/465)) -* Added intel hex file reading for `st-flash` ([#110](https://github.com/texane/stlink/pull/110), [#157](https://github.com/texane/stlink/pull/157), [#200](https://github.com/texane/stlink/pull/200), [#239](https://github.com/texane/stlink/pull/239), [#457](https://github.com/texane/stlink/pull/547), [#459](https://github.com/texane/stlink/pull/549)) +* Added intel hex file reading for `st-flash` ([#110](https://github.com/texane/stlink/pull/110), [#157](https://github.com/texane/stlink/pull/157), [#457](https://github.com/texane/stlink/pull/547), [#459](https://github.com/texane/stlink/pull/549)) * Added support for ARM semihosting to `st-util` ([#147](https://github.com/texane/stlink/pull/147), [#227](https://github.com/texane/stlink/pull/227), [#454](https://github.com/texane/stlink/pull/454), [#455](https://github.com/texane/stlink/pull/455)) * Added manpages (generated with pandoc from Markdown) ([#208](https://github.com/texane/stlink/pull/208), [#464](https://github.com/texane/stlink/pull/464), [#466](https://github.com/texane/stlink/pull/466), [#467](https://github.com/texane/stlink/pull/467)) * Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/texane/stlink/pull/228), ([#507](https://github.com/texane/stlink/pull/507), commit [#3fd0f09](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) @@ -190,7 +190,7 @@ Chip support added for: * STM32F410RBTx ([#418](https://github.com/texane/stlink/pull/418)) * STM32F412 ([#537](https://github.com/texane/stlink/pull/537), [#538](https://github.com/texane/stlink/pull/538)) * STM32F7xx ([#324](https://github.com/texane/stlink/pull/324), [#326](https://github.com/texane/stlink/pull/326), [#327](https://github.com/texane/stlink/pull/327), [#337](https://github.com/texane/stlink/pull/337)) -* STM32F767ZI ([#509](https://github.com/texane/stlink/pull/509)) +* STM32F7x7x ([#433](https://github.com/texane/stlink/pull/433), [#435](https://github.com/texane/stlink/pull/435), [#436](https://github.com/texane/stlink/pull/436), [#509](https://github.com/texane/stlink/pull/509)) * STM32L0xx Cat2 devices (chip-ID: 0x425) ([#414](https://github.com/texane/stlink/pull/414)) * STM32L0xx Cat5 devices (chip-ID: 0x447) ([#387](https://github.com/texane/stlink/pull/387), [#406](https://github.com/texane/stlink/pull/406)) * STM32L4xx ([#321](https://github.com/texane/stlink/pull/321)) @@ -207,7 +207,7 @@ Updates and fixes: * Fixed STM32F030 erase error ([#442](https://github.com/texane/stlink/pull/442)) * Fixed memory map for STM32F7xx ([#453](https://github.com/texane/stlink/pull/453), [#456](https://github.com/texane/stlink/pull/456)) * Redesign of `st-flash` commandline options parsing ([#459](https://github.com/texane/stlink/pull/459)) -* Set SWDCLK and fixed jtag_reset bug ([#475](https://github.com/texane/stlink/pull/475), [#534](https://github.com/texane/stlink/pull/534)) +* Set SWDCLK and fixed jtag_reset bug ([#462](https://github.com/texane/stlink/pull/462), [#475](https://github.com/texane/stlink/pull/475), [#534](https://github.com/texane/stlink/pull/534)) * doc/compiling.md: Add note about installation and ldconfig ([#478](https://github.com/texane/stlink/pull/478), commit [#be66bbf](https://github.com/texane/stlink/commit/be66bbf200c718904514b044ba84d64a36456218)) * Fixed Release target to generate the man-pages with pandoc ([#479](https://github.com/texane/stlink/pull/479)) * Fixed Cygwin build ([#487](https://github.com/texane/stlink/pull/487), ([#506](https://github.com/texane/stlink/pull/506)) diff --git a/README.md b/README.md index 29d1ef766..b2ff03d54 100644 --- a/README.md +++ b/README.md @@ -20,21 +20,32 @@ are licensed under the **General Public License (GPL v2+)**. ## Introduction -This stlink toolset supports several so called stlink programmer boards (and clones thereof) which use a microcontroller chip to translate commands from USB to JTAG. +STLink is an open source toolset to program and debug STM32 devices and boards manufactured by STMicroelectronics. +It supports several so called STLINK programmer boards (and clones thereof) which use a microcontroller chip +to translate commands from USB to JTAG/SWD. There are four generations available on the market: -These programmer boards are available in four versions: - -* **STLINKv1:** +* **STLINK/v1** _(obsolete as of 21-11-2019)_ - transport layer: SCSI passthru commands over USB - - present on STM32VL discovery kits -* **STLINKv2:** - * transport layer: raw USB commands - * present on STM32L discovery and nucleo and later kits -* **STLINKv2-1:** - * transport layer: raw USB commands - * present on some STM32 nucleo boards -* **STLINKv3:** - * _not yet supported by this toolset (but planned)_ + - stand-alone programmer and present on STM32VL Discovery boards +* **STLINK/v2** + - transport layer: raw USB commands + - stand-alone programmer and present on STM32L Discovery and Nucleo boards +* **STLINK/v2-1** + - transport layer: raw USB commands + - present on some STM32 Nucleo boards +* **STLINK/v3** + - transport layer: raw USB commands + - stand-alone programmer + +On the user level there is no difference in handling or operation between these different revisions. + +The STlink toolset includes: + +* a communication library (libstlink.a), +* a programmer and chip information tool (st-info), +* a flash manipulation tool (st-flash), +* a GDB server (st-util) and +* a GUI-Interface (stlink-gui) _[optional]_ ## Supported hardware combinations diff --git a/doc/compiling.md b/doc/compiling.md index 64f4de466..59685ef17 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -23,7 +23,7 @@ On Windows users should ensure that the following software is installed: 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)
+7. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git`from the command-line (cmd.exe)
or download the stlink zip-sourcefolder from the Release page on GitHub @@ -76,7 +76,7 @@ or execute (Debian-based systems only): `apt-get install gcc build-essential cma 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` +4. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git` ### Building @@ -183,7 +183,7 @@ Additionally we recommend to install Xcode which delivers the necessary C-compil 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` +4. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git` ### Building diff --git a/doc/tutorial.md b/doc/tutorial.md index f19a6ecd9..75e03f1bc 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -14,12 +14,17 @@ This option accepts decimal (128k), octal 0200k, or hex 0x80k. Obviously leaving the multiplier out is equally valid, for example: `--flash=0x20000`. The size may be followed by an optional "k" or "m" to multiply the given value by 1k (1024) or 1M respectively. +#### Checksum for binary files + +When flashing a file, a checksum is calculated for the binary file, both in md5 and the sum algorithm. +The latter is also used by the official ST-Link utility tool from STMicroelectronics as described in the document: [`UM0892 - User manual - STM32 ST-LINK utility software description`](https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf). + ## Solutions to common problems -### a) ST-Link-v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) +### a) STLINK/v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) #### Problem: -st-util fails to detect a ST-Link-v1 device: +st-util fails to detect a STLINK/v1 device: ``` st-util -1 @@ -35,7 +40,7 @@ ERROR src/sg.c: Could not open stlink device The root of this problem is a system security setting introduced by Apple with OS X El Capitan (10.11) in 2015. The so called System Integrity Protection (SIP) is active per default and prevents the operating system amongst other things to load unsigned Kernel Extension Modules (kext). -Thus the ST-Link-v1 driver supplied with the tools, which installs as a kext, remains not functional, +Thus the STLINK/v1 driver supplied with the tools, which installs as a kext, remains not functional, while SIP is fully activated (as is per default). Action needs to be taken here by booting into the recovery mode where a terminal console window needs to be opened. @@ -47,7 +52,7 @@ Running `csrutil enable --without kext`, allows to load unsigned kernel extensio while leaving SIP active with all other security features. Unfortunately this option has been removed in macOS 10.14, which leaves the only option to disable SIP completely. -So who ever intends to run the ST-Link-v1 programmer on macOS please take this into account. +So who ever intends to run the STLINK/v1 programmer on macOS please take this into account. Further details can be found here: https://forums.developer.apple.com/thread/17452 @@ -66,7 +71,7 @@ Requesting load of /System/Library/Extensions/stlink_shield10_x.kext. 5) Enter the command `$ sudo touch /System/Library/Extensions` -7) Verify correct detection of the ST-Link-v1 device with the following input: `st-util -1` +7) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` You should then see a similar output like in this example: @@ -81,7 +86,7 @@ INFO gdb-server.c: Listening at *:4242... ### b) Verify if udev rules are set correctly (by Dave Hylands) -To investigate, start by plugging your STLINK device into the usb port. Then run lsusb. You should see an entry something like the following: +To investigate, start by plugging your STLINK device into the usb port. Then run `lsusb`. You should see an entry something like the following: ``` Bus 005 Device 017: ID 0483:374b STMicroelectronics ST-LINK/V2.1 (Nucleo-F103RB) @@ -96,7 +101,7 @@ On my system I see the following: crw-rw-rw- 1 root root 189, 528 Jan 24 17:52 /dev/bus/usb/005/017 ``` -which is world writable (this is from the MODE:="0666" below). I have several files in my `/etc/udev/rules.d` directory. In this particular case, the `49-stlinkv2-1.rules` file contains the following: +which is world writable (this is from the `MODE:="0666"` below). I have several files in my `/etc/udev/rules.d` directory. In this particular case, the `49-stlinkv2-1.rules` file contains the following: ``` # stm32 nucleo boards, with onboard st/linkv2-1 @@ -113,9 +118,9 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ # GROUP:="somegroupname" and mange access using standard unix groups. ``` -and the idVendor of 0483 and idProduct of 374b matches the vendor id from the lsusb output. +and the `idVendor` of `0483` and `idProduct` of `374b` matches the vendor id from the `lsusb` output. -Make sure that you have all 3 files from here: https://github.com/texane/stlink/tree/master/etc/udev/rules.d in your `/etc/udev/rules.d` directory. After copying new files or editing excisting files in `/etc/udev/ruled.d` you should run the following: +Make sure that you have all 3 files from here: https://github.com/stlink-org/stlink/tree/master/etc/udev/rules.d in your `/etc/udev/rules.d` directory. After copying new files or editing excisting files in `/etc/udev/ruled.d` you should run the following: ``` sudo udevadm control --reload-rules @@ -135,8 +140,7 @@ Using STM32 discovery kits with open source tools This guide details the use of STMicroelectronics STM32 discovery kits in an open source environment. -Installing a GNU toolchain -========================== +## Installing a GNU toolchain Any toolchain supporting the cortex m3 should do. You can find the necessary to install such a toolchain here: @@ -149,51 +153,7 @@ Details for the installation are provided in the topmost `README` file. This documentation assumes the toolchains is installed in a `$TOOLCHAIN_PATH`. -Installing STLINK -================= - -STLINK is open source software to program and debug ST’s STM32 Discovery -kits. Those kits have an onboard chip that translates USB commands sent -by the host PC into JTAG/SWD commands. This chip is called STLINK, (yes, -isn’t that confusing? suggest a better name!) and comes in 2 versions -(STLINK v1 and v2). From a software point of view, those versions differ -only in the transport layer used to communicate (v1 uses SCSI passthru -commands, while v2 uses raw USB). From a user point of view, they are -identical. - - -Before continuing, the following dependencies must be met: - -- libusb-1.0 -- cmake - -Also make sure `gtk+` version 3.0 is installed. (`sudo apt-get install gtk+-3.0` or similiar) - -STLINK should run on any system meeting the above constraints. - -The STLINK software source code is retrieved using: - -``` -$> git clone https://github.com/texane/stlink.git -``` - -Everything can be built from the top directory: - -``` -$> cd stlink -$> make -$> cd build/Release && make install DESTDIR=_install -``` - -It includes: - -- a communication library (libstlink.a), -- a GDB server (st-util), -- a flash manipulation tool (st-flash). -- a programmer and chip information tool (st-info) - -Using the GDB server -==================== +## Using the GDB server This assumes you have got the libopencm3 project downloaded in `ocm3`. The libopencm3 project has some good, reliable examples for each of the @@ -259,8 +219,7 @@ examples from libopencm3, the LEDs on the board should be blinking for you. -Building and flashing a program -=============================== +## Building and flashing a program If you want to simply flash binary files to arbitrary sections of memory, or read arbitary addresses of memory out to a binary file, use @@ -300,9 +259,6 @@ $> [sudo] ./st-flash write fancy_blink.bin 0x08000000 Upon reset, the board LEDs should be blinking. -HOWTO (old) -=========== - ## Using the gdb server To run the gdb server: @@ -376,6 +332,16 @@ If you need to send a hard reset signal through `NRST` pin, you can use the foll ``` +## Disassembling THUMB code in GDB + +By default, the disassemble command in GDB operates in ARM mode. The programs running on CORTEX-M3 are compiled in THUMB mode. +To correctly disassemble them under GDB, uses an odd address. For instance, if you want to disassemble the code at 0x20000000, use: + +``` +(gdb) disassemble 0x20000001 +``` + + ## Running programs from SRAM You can run your firmware directly from SRAM if you want to. Just link @@ -469,19 +435,15 @@ A: Installed on Mac OS X 10.9.4 with ports method, [https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q) -`sudo port install libusb automake autoconf pkgconfig` - -`aclocal --force -I /opt/local/share/aclocal` - -`git clone https://github.com/texane/stlink.git stlink-utility` - -`cd stlink-utility` - -`./autogen.sh` - -`./configure` - -`make` +``` +sudo port install libusb automake autoconf pkgconfig +aclocal --force -I /opt/local/share/aclocal +git clone https://github.com/stlink-org/stlink.git stlink-utility +cd stlink-utility +./autogen.sh +./configure +make +``` Then trying to flash the image with STLINK v2 : @@ -524,26 +486,6 @@ http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103- > 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good! -Notes -===== - -Disassembling THUMB code in GDB -------------------------------- - -By default, the disassemble command in GDB operates in ARM mode. The -programs running on CORTEX-M3 are compiled in THUMB mode. To correctly -disassemble them under GDB, uses an odd address. For instance, if you -want to disassemble the code at 0x20000000, use:\ - -``` -(gdb) disassemble 0x20000001 -``` - -Checksum of binary file ------------------------ - -When flashing a file, the checksum of which is calculated, both in md5 and the sum algorithm used by ST's official tool. The detail of sum algorithm can be found in [https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf](https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf). - References ========== @@ -554,5 +496,4 @@ References documentation related to the STM32L discovery kit - - libopencm3, a project providing a firmware library, with solid - examples for Cortex M3, M4 and M0 processors from any vendor. + libopencm3, a project providing a firmware library, with solid examples for Cortex M3, M4 and M0 processors from any vendor. From 6f934a396ef320ee5ade3de95135818e1683aefd Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 15 Apr 2020 16:20:17 +0200 Subject: [PATCH 109/236] Whitespace cleanup --- CMakeLists.txt | 4 +- cmake/c_flag_overrides.cmake | 4 +- cmake/c_flags.cmake | 6 +- cmake/cpack_config.cmake | 14 +- cmake/modules/FindLibUSB.cmake | 2 +- cmake/modules/pandocology.cmake | 40 +++--- cmake/version.cmake | 4 +- cmake_uninstall.cmake.in | 4 +- doc/man/CMakeLists.txt | 2 +- src/common.c | 166 +++++++++++----------- src/flash_loader.c | 2 +- src/gdbserver/gdb-remote.c | 36 ++--- src/gdbserver/gdb-server.c | 234 ++++++++++++++++---------------- src/gdbserver/semihosting.c | 22 +-- src/md5.c | 14 +- src/mingw/mingw.c | 30 ++-- src/sg.c | 4 +- src/tools/flash.c | 16 +-- src/tools/flash_opts.c | 32 ++--- src/tools/gui/stlink-gui.c | 14 +- src/usb.c | 6 +- tests/flash.c | 14 +- 22 files changed, 335 insertions(+), 335 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45e332b10..3572c2a15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,8 +101,8 @@ set(STLINK_SOURCE ) 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}) diff --git a/cmake/c_flag_overrides.cmake b/cmake/c_flag_overrides.cmake index c15815e17..1a1d163fb 100644 --- a/cmake/c_flag_overrides.cmake +++ b/cmake/c_flag_overrides.cmake @@ -1,7 +1,7 @@ -if(MSVC) +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_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") -endif() +endif () diff --git a/cmake/c_flags.cmake b/cmake/c_flags.cmake index fbadd6d9e..c7954bf54 100644 --- a/cmake/c_flags.cmake +++ b/cmake/c_flags.cmake @@ -11,7 +11,7 @@ function(add_cflag_if_supported flag) if (C_SUPPORTS${flagclean}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE) - endif() + endif () endfunction() add_cflag_if_supported("-std=gnu11") @@ -41,10 +41,10 @@ if (NOT WIN32) add_cflag_if_supported("-fPIC") endif () -if(${CMAKE_BUILD_TYPE} MATCHES "Debug") +if (${CMAKE_BUILD_TYPE} MATCHES "Debug") add_cflag_if_supported("-ggdb") add_cflag_if_supported("-O0") else() add_cflag_if_supported("-O2") add_cflag_if_supported("-Werror") -endif() +endif () diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake index b8d4be186..c70cf3a63 100644 --- a/cmake/cpack_config.cmake +++ b/cmake/cpack_config.cmake @@ -1,27 +1,27 @@ -set (CPACK_PACKAGE_NAME ${PROJECT_NAME}) -set (CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) -set (CPACK_SET_DESTDIR "ON") +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_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_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() + endif () set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/stlink-org/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() +endif () diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/FindLibUSB.cmake index dc90bcc32..1fd465e4b 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/FindLibUSB.cmake @@ -77,7 +77,7 @@ else () # all other OS LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) -endif() +endif () include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) diff --git a/cmake/modules/pandocology.cmake b/cmake/modules/pandocology.cmake index 763eae558..ff9053197 100644 --- a/cmake/modules/pandocology.cmake +++ b/cmake/modules/pandocology.cmake @@ -42,10 +42,10 @@ include(CMakeParseArguments) -if(NOT EXISTS ${PANDOC_EXECUTABLE}) +if (NOT EXISTS ${PANDOC_EXECUTABLE}) find_program(PANDOC_EXECUTABLE pandoc) mark_as_advanced(PANDOC_EXECUTABLE) -endif() +endif () ############################################################################### # Based on code from UseLATEX @@ -133,7 +133,7 @@ This process created the file `CMakeCache.txt' and the directory `CMakeFiles'. Please delete them: $ rm -r CMakeFiles/ CmakeCache.txt ") - ENDIF() + ENDif () endfunction() # This builds a document @@ -171,7 +171,7 @@ function(add_document target_name) if (NOT PANDOC_EXECUTABLE) message(WARNING "Pandoc not found. Install Pandoc (http://johnmacfarlane.net/pandoc/) or set cache variable PANDOC_EXECUTABLE.") return() - endif() + endif () set(options EXPORT_ARCHIVE NO_EXPORT_PRODUCT EXPORT_PDF DIRECT_TEX_TO_PDF VERBOSE) set(oneValueArgs PRODUCT_DIRECTORY) @@ -188,29 +188,29 @@ function(add_document target_name) if (NOT "${target_extension}" STREQUAL ".tex" AND NOT "${target_extension}" STREQUAL ".latex") # if (NOT "${target_extension}" STREQUAL ".tex") MESSAGE(FATAL_ERROR "Target '${target_name}': Cannot use 'EXPORT_PDF' for target of type '${target_extension}': target type must be '.tex' or '.latex'") - endif() - endif() + endif () + endif () if (${ADD_DOCUMENT_DIRECT_TEX_TO_PDF}) list(LENGTH ${ADD_DOCUMENT_SOURCES} SOURCE_LEN) if (SOURCE_LEN GREATER 1) MESSAGE(FATAL_ERROR "Target '${target_name}': Only one source can be specified when using the 'DIRECT_TEX_TO_PDF' option") - endif() + endif () # set(ADD_DOCUMENT_SOURCES, list(GET ${ADD_DOCUMENT_SOURCES} 1)) pandocology_get_file_stemname(source_stemname ${ADD_DOCUMENT_SOURCES}) pandocology_get_file_extension(source_extension ${ADD_DOCUMENT_SOURCES}) if (NOT "${source_extension}" STREQUAL ".tex" AND NOT "${source_extension}" STREQUAL ".latex") MESSAGE(FATAL_ERROR "Target '${target_name}': Cannot use 'DIRECT_TEX_TO_PDF' for source of type '${source_extension}': source type must be '.tex' or '.latex'") - endif() + endif () SET(check_target ${source_stemname}.pdf) IF (NOT ${check_target} STREQUAL ${target_name}) MESSAGE(FATAL_ERROR "Target '${target_name}': Must use target name of '${check_target}' if using 'DIRECT_TEX_TO_PDF'") - endif() - endif() + endif () + endif () ## set up output directory if ("${ADD_DOCUMENT_PRODUCT_DIRECTORY}" STREQUAL "") set(ADD_DOCUMENT_PRODUCT_DIRECTORY "product") - endif() + endif () get_filename_component(product_directory ${CMAKE_BINARY_DIR}/${ADD_DOCUMENT_PRODUCT_DIRECTORY} ABSOLUTE) # get_filename_component(absolute_product_path ${product_directory}/${target_name} ABSOLUTE) @@ -232,7 +232,7 @@ function(add_document target_name) pandocology_add_input_dir(${CMAKE_CURRENT_SOURCE_DIR}/${resource_dir} ${CMAKE_CURRENT_BINARY_DIR} build_resources) if (${ADD_DOCUMENT_EXPORT_ARCHIVE}) pandocology_add_input_dir(${CMAKE_CURRENT_SOURCE_DIR}/${resource_dir} ${product_directory} exported_resources) - endif() + endif () endforeach() ## primary command @@ -255,7 +255,7 @@ function(add_document target_name) # we produce the target in the source directory, in case other build targets require it as a source COMMAND latexmk -gg -halt-on-error -interaction=nonstopmode -file-line-error -pdf ${build_sources} 2>/dev/null >/dev/null || (grep --no-messages -A8 ".*:[0-9]*:.*" ${target_stemname}.log && false) ) - endif() + endif () add_to_make_clean(${CMAKE_CURRENT_BINARY_DIR}/${target_name}) else() add_custom_command( @@ -267,7 +267,7 @@ function(add_document target_name) COMMAND ${PANDOC_EXECUTABLE} ${build_sources} ${ADD_DOCUMENT_PANDOC_DIRECTIVES} -o ${target_name} ) add_to_make_clean(${CMAKE_CURRENT_BINARY_DIR}/${target_name}) - endif() + endif () ## figure out what all is going to be produced by this build set, and set ## those as dependencies of the primary target @@ -275,14 +275,14 @@ function(add_document target_name) set(primary_target_dependencies ${primary_target_dependencies} ${CMAKE_CURRENT_BINARY_DIR}/${target_name}) if (NOT ${ADD_DOCUMENT_NO_EXPORT_PRODUCT}) set(primary_target_dependencies ${primary_target_dependencies} ${product_directory}/${target_name}) - endif() + endif () if (${ADD_DOCUMENT_EXPORT_PDF}) set(primary_target_dependencies ${primary_target_dependencies} ${CMAKE_CURRENT_BINARY_DIR}/${target_stemname}.pdf) set(primary_target_dependencies ${primary_target_dependencies} ${product_directory}/${target_stemname}.pdf) - endif() + endif () if (${ADD_DOCUMENT_EXPORT_ARCHIVE}) set(primary_target_dependencies ${primary_target_dependencies} ${product_directory}/${target_stemname}.tbz) - endif() + endif () ## primary target # # target cannot have same (absolute name) as dependencies: @@ -326,7 +326,7 @@ function(add_document target_name) ) add_to_make_clean(${CMAKE_CURRENT_BINARY_DIR}/${target_stemname}.pdf) add_to_make_clean(${product_directory}/${target_stemname}.pdf) - endif() + endif () ## copy products if (NOT ${ADD_DOCUMENT_NO_EXPORT_PRODUCT}) @@ -336,7 +336,7 @@ function(add_document target_name) COMMAND ${CMAKE_COMMAND} -E copy ${target_name} ${product_directory} ) add_to_make_clean(${product_directory}/${target_name}) - endif() + endif () ## copy resources if (${ADD_DOCUMENT_EXPORT_ARCHIVE}) @@ -359,7 +359,7 @@ function(add_document target_name) # ALL # DEPENDS ${product_directory}/${target_stemname}.tbz # ) - endif() + endif () endfunction(add_document) diff --git a/cmake/version.cmake b/cmake/version.cmake index fe778c419..d27b43515 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -27,7 +27,7 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") ) if (res EQUAL 1) - set (PROJECT_VERSION "${PROJECT_VERSION}-dirty") + set(PROJECT_VERSION "${PROJECT_VERSION}-dirty") endif () # strip a leading v off of the version as proceeding code expectes just the version numbering. @@ -57,7 +57,7 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") else(GIT_DESCRIBE_RESULT EQUAL 0) message(WARNING "git describe failed.") message(WARNING "${GIT_DESCRIBE_ERROR}") - endif(GIT_DESCRIBE_RESULT EQUAL 0) + endif (GIT_DESCRIBE_RESULT EQUAL 0) else () message(STATUS "Git or repo not found.") endif () diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in index ed17c45cd..0c9f6a437 100644 --- a/cmake_uninstall.cmake.in +++ b/cmake_uninstall.cmake.in @@ -1,6 +1,6 @@ -if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") +if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") -endif() +endif () file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 5b435c022..090a2237e 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -23,7 +23,7 @@ foreach (manpage ${MANPAGES}) set(f "${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.1") else() message(AUTHOR_WARNING "Manpage ${manpage} not generated") - endif() + endif () if (f AND NOT WIN32) install(FILES ${f} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1) diff --git a/src/common.c b/src/common.c index d04644071..e94240351 100644 --- a/src/common.c +++ b/src/common.c @@ -546,7 +546,7 @@ static void set_flash_cr_mer(stlink_t *sl, bool v) { stlink_write_debug32(sl, cr_reg, val); } - if(v) + if (v) val |= cr_mer; else val &= ~cr_mer; @@ -905,7 +905,7 @@ int stlink_load_device_params(stlink_t *sl) { sl->flash_size = (flash_size & 0xff) * 1024; } else if ((sl->chip_id & 0xFFF) == STLINK_CHIPID_STM32_L1_HIGH) { // 0 is 384k and 1 is 256k - if ( flash_size == 0 ) { + if ( flash_size == 0){ sl->flash_size = 384 * 1024; } else { sl->flash_size = 256 * 1024; @@ -923,7 +923,7 @@ int stlink_load_device_params(stlink_t *sl) { //medium and low devices have the same chipid. ram size depends on flash size. //STM32F100xx datasheet Doc ID 16455 Table 2 - if(sl->chip_id == STLINK_CHIPID_STM32_F1_VL_MEDIUM_LOW && sl->flash_size < 64 * 1024){ + if (sl->chip_id == STLINK_CHIPID_STM32_F1_VL_MEDIUM_LOW && sl->flash_size < 64 * 1024){ sl->sram_size = 0x1000; } @@ -1091,7 +1091,7 @@ int stlink_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { int stlink_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len) { DLOG("*** stlink_write_mem8 ***\n"); - if (len > 0x40 ) { // !!! never ever: Writing more then 0x40 bytes gives unexpected behaviour + if (len > 0x40){ // !!! never ever: Writing more then 0x40 bytes gives unexpected behaviour fprintf(stderr, "Error: Data length > 64: +%d byte.\n", len); abort(); @@ -1374,7 +1374,7 @@ static void md5_calculate(mapped_file_t *mf) { Md5Update(&md5Context, mf->base, (uint32_t)mf->len); Md5Finalise(&md5Context, &md5Hash); printf("md5 checksum: "); - for(int i = 0; i < (int) sizeof(md5Hash); i++) { + for (int i = 0; i < (int) sizeof(md5Hash); i++) { printf("%x", md5Hash.bytes[i]); } printf(", "); @@ -1426,7 +1426,7 @@ int stlink_mwrite_sram(stlink_t * sl, uint8_t* data, uint32_t length, stm32_addr len = length; - if(len & 3) { + if (len & 3) { len -= len & 3; } @@ -1445,7 +1445,7 @@ int stlink_mwrite_sram(stlink_t * sl, uint8_t* data, uint32_t length, stm32_addr stlink_write_mem32(sl, addr + (uint32_t) off, size); } - if(length > len) { + if (length > len) { memcpy(sl->q_buf, data + len, length - len); stlink_write_mem8(sl, addr + (uint32_t) len, length - len); } @@ -1492,7 +1492,7 @@ int stlink_fwrite_sram(stlink_t * sl, const char* path, stm32_addr_t addr) { len = mf.len; - if(len & 3) { + if (len & 3) { len -= len & 3; } @@ -1511,7 +1511,7 @@ int stlink_fwrite_sram(stlink_t * sl, const char* path, stm32_addr_t addr) { stlink_write_mem32(sl, addr + (uint32_t) off, size); } - if(mf.len > len) { + if (mf.len > len) { memcpy(sl->q_buf, mf.base + len, mf.len - len); stlink_write_mem8(sl, addr + (uint32_t) len, mf.len - len); } @@ -1595,7 +1595,7 @@ struct stlink_fread_ihex_worker_arg { static bool stlink_fread_ihex_newsegment(struct stlink_fread_ihex_worker_arg* the_arg) { uint32_t addr = the_arg->addr; uint8_t sum = 2 + 4 + (uint8_t)((addr & 0xFF000000) >> 24) + (uint8_t)((addr & 0x00FF0000) >> 16); - if(17 != fprintf(the_arg->file, ":02000004%04X%02X\r\n", (addr & 0xFFFF0000) >> 16, (uint8_t)(0x100 - sum))) + if (17 != fprintf(the_arg->file, ":02000004%04X%02X\r\n", (addr & 0xFFFF0000) >> 16, (uint8_t)(0x100 - sum))) return false; the_arg->lba = (addr & 0xFFFF0000); @@ -1605,26 +1605,26 @@ static bool stlink_fread_ihex_newsegment(struct stlink_fread_ihex_worker_arg* th static bool stlink_fread_ihex_writeline(struct stlink_fread_ihex_worker_arg* the_arg) { uint8_t count = the_arg->buf_pos; - if(count == 0) return true; + if (count == 0) return true; uint32_t addr = the_arg->addr; - if(the_arg->lba != (addr & 0xFFFF0000)) { // segment changed - if(!stlink_fread_ihex_newsegment(the_arg)) return false; + if (the_arg->lba != (addr & 0xFFFF0000)) { // segment changed + if (!stlink_fread_ihex_newsegment(the_arg)) return false; } uint8_t sum = count + (uint8_t)((addr & 0x0000FF00) >> 8) + (uint8_t)(addr & 0x000000FF); - if(9 != fprintf(the_arg->file, ":%02X%04X00", count, (addr & 0x0000FFFF))) + if (9 != fprintf(the_arg->file, ":%02X%04X00", count, (addr & 0x0000FFFF))) return false; - for(uint8_t i = 0; i < count; ++i) { + for (uint8_t i = 0; i < count; ++i) { uint8_t b = the_arg->buf[i]; sum += b; - if(2 != fprintf(the_arg->file, "%02X", b)) + if (2 != fprintf(the_arg->file, "%02X", b)) return false; } - if(4 != fprintf(the_arg->file, "%02X\r\n", (uint8_t)(0x100 - sum))) + if (4 != fprintf(the_arg->file, "%02X\r\n", (uint8_t)(0x100 - sum))) return false; the_arg->addr += count; @@ -1645,9 +1645,9 @@ static bool stlink_fread_ihex_init(struct stlink_fread_ihex_worker_arg* the_arg, static bool stlink_fread_ihex_worker(void* arg, uint8_t* block, ssize_t len) { struct stlink_fread_ihex_worker_arg* the_arg = (struct stlink_fread_ihex_worker_arg*)arg; - for(ssize_t i = 0; i < len; ++i) { - if(the_arg->buf_pos == sizeof(the_arg->buf)) { // line is full - if(!stlink_fread_ihex_writeline(the_arg)) return false; + for (ssize_t i = 0; i < len; ++i) { + if (the_arg->buf_pos == sizeof(the_arg->buf)) { // line is full + if (!stlink_fread_ihex_writeline(the_arg)) return false; } the_arg->buf[the_arg->buf_pos++] = block[i]; @@ -1657,11 +1657,11 @@ static bool stlink_fread_ihex_worker(void* arg, uint8_t* block, ssize_t len) { } static bool stlink_fread_ihex_finalize(struct stlink_fread_ihex_worker_arg* the_arg) { - if(!stlink_fread_ihex_writeline(the_arg)) return false; + if (!stlink_fread_ihex_writeline(the_arg)) return false; // FIXME do we need the Start Linear Address? - if(13 != fprintf(the_arg->file, ":00000001FF\r\n")) // EoF + if (13 != fprintf(the_arg->file, ":00000001FF\r\n")) // EoF return false; return (0 == fclose(the_arg->file)); @@ -1678,11 +1678,11 @@ int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr return -1; } - if(is_ihex) { + if (is_ihex) { struct stlink_fread_ihex_worker_arg arg; - if(stlink_fread_ihex_init(&arg, fd, addr)) { + if (stlink_fread_ihex_init(&arg, fd, addr)) { error = stlink_read(sl, addr, size, &stlink_fread_ihex_worker, &arg); - if(!stlink_fread_ihex_finalize(&arg)) + if (!stlink_fread_ihex_finalize(&arg)) error = -1; } else { @@ -1722,18 +1722,18 @@ uint32_t calculate_F4_sectornum(uint32_t flashaddr){ flashaddr -= 0x100000; } if (flashaddr<0x4000) return (offset + 0); - else if(flashaddr<0x8000) return(offset + 1); - else if(flashaddr<0xc000) return(offset + 2); - else if(flashaddr<0x10000) return(offset + 3); - else if(flashaddr<0x20000) return(offset + 4); + else if (flashaddr<0x8000) return(offset + 1); + else if (flashaddr<0xc000) return(offset + 2); + else if (flashaddr<0x10000) return(offset + 3); + else if (flashaddr<0x20000) return(offset + 4); else return offset + (flashaddr/0x20000) +4; } uint32_t calculate_F7_sectornum(uint32_t flashaddr){ flashaddr &= ~STM32_FLASH_BASE; //Page now holding the actual flash address - if(flashaddr<0x20000) return(flashaddr/0x8000); - else if(flashaddr<0x40000) return(4); + if (flashaddr<0x20000) return(flashaddr/0x8000); + else if (flashaddr<0x40000) return(4); else return(flashaddr/0x40000) +4; } @@ -1778,14 +1778,14 @@ uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr){ sector -= 12; } if (sector<4) sl->flash_pgsz=0x4000; - else if(sector<5) sl->flash_pgsz=0x10000; + else if (sector<5) sl->flash_pgsz=0x10000; else sl->flash_pgsz=0x20000; } else if (sl->chip_id == STLINK_CHIPID_STM32_F7 || sl->chip_id == STLINK_CHIPID_STM32_F7XXXX) { uint32_t sector=calculate_F7_sectornum(flashaddr); if (sector<4) sl->flash_pgsz=0x8000; - else if(sector<5) sl->flash_pgsz=0x20000; + else if (sector<5) sl->flash_pgsz=0x20000; else sl->flash_pgsz=0x40000; } return (uint32_t) sl->flash_pgsz; @@ -1866,7 +1866,7 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) /* check if the locks are set */ stlink_read_debug32(sl, flash_regs_base + FLASH_PECR_OFF, &val); - if((val & (1<<0))||(val & (1<<1))) { + if ((val & (1<<0))||(val & (1<<1))) { /* disable pecr protection */ stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, 0x89abcdef); stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, 0x02030405); @@ -1903,7 +1903,7 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) */ do { stlink_read_debug32(sl, STM32L_FLASH_SR, &val) - } while((val & (1 << 0)) != 0); + } while ((val & (1 << 0)) != 0); #endif /* fix_to_be_confirmed */ @@ -2265,7 +2265,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t (sl->chip_id != STLINK_CHIPID_STM32_L496X) && (sl->chip_id != STLINK_CHIPID_STM32_L4RX)) { - if( sl->version.stlink_v == 1 ) { + if ( sl->version.stlink_v == 1){ printf("STLINK V1 cannot read voltage, defaulting to 32-bit writes on F4 devices\n"); write_flash_cr_psiz(sl, 2); } @@ -2299,7 +2299,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t set_flash_cr_pg(sl); size_t buf_size = (sl->sram_size > 0x8000) ? 0x8000 : 0x4000; - for(off = 0; off < len;) { + for (off = 0; off < len;) { size_t size = len - off > buf_size ? buf_size : len - off; printf("size: %u\n", (unsigned int)size); @@ -2483,11 +2483,11 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t // note: length not checked static uint8_t stlink_parse_hex(const char* hex) { uint8_t d[2]; - for(int i = 0; i < 2; ++i) { + for (int i = 0; i < 2; ++i) { char c = *(hex + i); - if(c >= '0' && c <= '9') d[i] = c - '0'; - else if(c >= 'A' && c <= 'F') d[i] = c - 'A' + 10; - else if(c >= 'a' && c <= 'f') d[i] = c - 'a' + 10; + if (c >= '0' && c <= '9') d[i] = c - '0'; + else if (c >= 'A' && c <= 'F') d[i] = c - 'A' + 10; + else if (c >= 'a' && c <= 'f') d[i] = c - 'a' + 10; else return 0; // error } return (d[0] << 4) | (d[1]); @@ -2500,15 +2500,15 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, uint32_t end = 0; bool eof_found = false; - for(int scan = 0; (res == 0) && (scan < 2); ++scan) { // parse file two times - first to find memory range, second - to fill it - if(scan == 1) { - if(!eof_found) { + for (int scan = 0; (res == 0) && (scan < 2); ++scan) { // parse file two times - first to find memory range, second - to fill it + if (scan == 1) { + if (!eof_found) { ELOG("No EoF recond\n"); res = -1; break; } - if(*begin >= end) { + if (*begin >= end) { ELOG("No data found in file\n"); res = -1; break; @@ -2516,7 +2516,7 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, *size = (end - *begin) + 1; data = calloc(*size, 1); // use calloc to get NULL if out of memory - if(!data) { + if (!data) { ELOG("Cannot allocate %d bytes\n", *size); res = -1; break; @@ -2526,7 +2526,7 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, } FILE* file = fopen(path, "r"); - if(!file) { + if (!file) { ELOG("Cannot open file\n"); res = -1; break; @@ -2535,17 +2535,17 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, uint32_t lba = 0; char line[1 + 5*2 + 255*2 + 2]; - while(fgets(line, sizeof(line), file)) { - if(line[0] == '\n' || line[0] == '\r') continue; // skip empty lines - if(line[0] != ':') { // no marker - wrong file format + while (fgets(line, sizeof(line), file)) { + if (line[0] == '\n' || line[0] == '\r') continue; // skip empty lines + if (line[0] != ':') { // no marker - wrong file format ELOG("Wrong file format - no marker\n"); res = -1; break; } size_t l = strlen(line); - while(l > 0 && (line[l-1] == '\n' || line[l-1] == '\r')) --l; // trim EoL - if((l < 11) || (l == (sizeof(line)-1))) { // line too short or long - wrong file format + while (l > 0 && (line[l-1] == '\n' || line[l-1] == '\r')) --l; // trim EoL + if ((l < 11) || (l == (sizeof(line)-1))) { // line too short or long - wrong file format ELOG("Wrong file format - wrong line length\n"); res = -1; break; @@ -2553,17 +2553,17 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, // check sum uint8_t chksum = 0; - for(size_t i = 1; i < l; i += 2) { + for (size_t i = 1; i < l; i += 2) { chksum += stlink_parse_hex(line + i); } - if(chksum != 0) { + if (chksum != 0) { ELOG("Wrong file format - checksum mismatch\n"); res = -1; break; } uint8_t reclen = stlink_parse_hex(line + 1); - if(((uint32_t)reclen + 5)*2 + 1 != l) { + if (((uint32_t)reclen + 5)*2 + 1 != l) { ELOG("Wrong file format - record length mismatch\n"); res = -1; break; @@ -2574,17 +2574,17 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, switch(rectype) { case 0: // data - if(scan == 0) { + if (scan == 0) { uint32_t b = lba + offset; uint32_t e = b + reclen - 1; - if(b < *begin) *begin = b; - if(e > end) end = e; + if (b < *begin) *begin = b; + if (e > end) end = e; } else { - for(uint8_t i = 0; i < reclen; ++i) { + for (uint8_t i = 0; i < reclen; ++i) { uint8_t b = stlink_parse_hex(line + 9 + i*2); uint32_t addr = lba + offset + i; - if(addr >= *begin && addr <= end) { + if (addr >= *begin && addr <= end) { data[addr - *begin] = b; } } @@ -2604,7 +2604,7 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, break; case 4: // Extended Linear Address - if(reclen == 2) { + if (reclen == 2) { lba = ((uint32_t)stlink_parse_hex(line + 9) << 24) | ((uint32_t)stlink_parse_hex(line + 11) << 16); } else { @@ -2620,13 +2620,13 @@ int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, ELOG("Wrong file format - unexpected record type %d\n", rectype); res = -1; } - if(res != 0) break; + if (res != 0) break; } fclose(file); } - if(res == 0) { + if (res == 0) { *mem = data; } else { @@ -2655,14 +2655,14 @@ int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr */ if (sl->opt) { idx = (unsigned int)length; - for(num_empty = 0; num_empty != length; ++num_empty) { + for (num_empty = 0; num_empty != length; ++num_empty) { if (data[--idx] != erased_pattern) { break; } } /* Round down to words */ num_empty -= (num_empty & 3); - if(num_empty != 0) { + if (num_empty != 0) { ILOG("Ignoring %d bytes of 0x%02x at end of file\n", num_empty, erased_pattern); } } else { @@ -2704,14 +2704,14 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { if (sl->opt) { idx = (unsigned int) mf.len; - for(num_empty = 0; num_empty != mf.len; ++num_empty) { + for (num_empty = 0; num_empty != mf.len; ++num_empty) { if (mf.base[--idx] != erased_pattern) { break; } } /* Round down to words */ num_empty -= (num_empty & 3); - if(num_empty != 0) { + if (num_empty != 0) { ILOG("Ignoring %d bytes of 0x%02x at end of file\n", num_empty, erased_pattern); } } else { @@ -2740,7 +2740,7 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l uint32_t val; - if(len != 4) { + if (len != 4) { ELOG("Wrong length for writing option bytes, must be 4 is %d\n", len); return -1; } @@ -2749,7 +2749,7 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l stlink_core_id(sl); /* Check if chip is supported and for correct address */ - if(sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1 && + if (sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1 && sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2) { ELOG("Option bytes writing is currently only supported for the STM32G0\n"); return -1; @@ -2833,7 +2833,7 @@ static int stlink_write_option_bytes_l0_cat2(stlink_t *sl, uint8_t* base, uint32 uint32_t val; - if(len != 4) { + if (len != 4) { ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); return -1; } @@ -2891,7 +2891,7 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ uint32_t val; uint32_t data; - if(len != 4 && len != 8) { + if (len != 4 && len != 8) { ELOG("Wrong length for writting option bytes, must be 4 or 8 is %d\n", len); return -1; } @@ -2932,7 +2932,7 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ /* Write options bytes */ write_uint32((unsigned char*) &data, *(uint32_t*) (base)); - if( data != val ) { + if ( data != val ) { WLOG("Writing option bytes 0x%04x\n", data); stlink_write_debug32(sl, addr, data); stlink_read_debug32(sl, addr, &val); @@ -2940,7 +2940,7 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ } - if(len==8) { + if (len==8) { /* Clear errors */ stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_SR_OFF, 0x00003F00); @@ -2949,7 +2949,7 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ /* Write options bytes */ write_uint32((unsigned char*) &data, *(uint32_t*) (base+4)); - if( data != val ) { + if ( data != val ) { WLOG("Writing 2nd option bytes 0x%04x\n", data); stlink_write_debug32(sl, addr+4, data); stlink_read_debug32(sl, addr+4, &val); @@ -2976,7 +2976,7 @@ static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, uint32_t uint32_t val; - if(len != 4) { + if (len != 4) { ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); return -1; } @@ -3082,7 +3082,7 @@ static int stlink_write_option_bytes_f2(stlink_t *sl, uint32_t option_byte) { stlink_read_debug32(sl, FLASH_F2_SR, &val); WLOG("wait BSY flag to be 0\n"); - while(val & 0x00010000){ + while (val & 0x00010000){ stlink_read_debug32(sl, FLASH_F2_SR, &val); } WLOG("BSY flag is 0\n"); @@ -3132,7 +3132,7 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint32_t option_byte) { stlink_read_debug32(sl, FLASH_F4_SR, &val); WLOG("wait BSY flag to be 0\n"); - while(val & 0x00010000){ + while (val & 0x00010000){ stlink_read_debug32(sl, FLASH_F4_SR, &val); } WLOG("BSY flag is 0\n"); @@ -3228,17 +3228,17 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui WLOG("Option bytes write chip_id 0x%08x addr 0x%08x\n",sl->chip_id,addr); /* Check if chip is supported and for correct address */ - if(((sl->chip_id == STLINK_CHIPID_STM32_G0_CAT1) || + if (((sl->chip_id == STLINK_CHIPID_STM32_G0_CAT1) || (sl->chip_id == STLINK_CHIPID_STM32_G0_CAT2)) && (addr == STM32_G0_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_g0x(sl, base, len); } - else if((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { + else if ((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_l0_cat2(sl, base, len); } - else if((sl->chip_id == STLINK_CHIPID_STM32_L496X) && (addr == STM32_L496X_OPTION_BYTES_BASE)) { + else if ((sl->chip_id == STLINK_CHIPID_STM32_L496X) && (addr == STM32_L496X_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_l496x(sl, base, len); } - else if(((sl->chip_id == STLINK_CHIPID_STM32_L152_RE) || (sl->chip_id == STLINK_CHIPID_STM32_L1_HIGH) ) && + else if (((sl->chip_id == STLINK_CHIPID_STM32_L152_RE) || (sl->chip_id == STLINK_CHIPID_STM32_L1_HIGH) ) && ((addr == STM32_L1_OPTION_BYTES_BASE) || (addr == STM32_L1_OPTION_BYTES_BASE+4))) { return stlink_write_option_bytes_l1(sl, base, addr, len); } @@ -3284,9 +3284,9 @@ int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr */ int stlink_fwrite_option_bytes_32bit(stlink_t *sl, uint32_t val) { - if(sl->chip_id == STLINK_CHIPID_STM32_F2){ + if (sl->chip_id == STLINK_CHIPID_STM32_F2){ return stlink_write_option_bytes_f2(sl, val); - }else if(sl->chip_id == STLINK_CHIPID_STM32_F446){ + } else if (sl->chip_id == STLINK_CHIPID_STM32_F446){ return stlink_write_option_bytes_f4(sl, val); } else diff --git a/src/flash_loader.c b/src/flash_loader.c index 9c24ff9e8..a1c9c3757 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -226,7 +226,7 @@ static int loader_v_dependent_assignment(stlink_t *sl, { int retval = 0; - if( sl->version.stlink_v == 1 ) { + if ( sl->version.stlink_v == 1){ printf("STLINK V1 cannot read voltage, defaulting to 32-bit writes\n"); *loader_code = high_v_loader; *loader_size = high_v_loader_size; diff --git a/src/gdbserver/gdb-remote.c b/src/gdbserver/gdb-remote.c index e4aad312d..3b1794f3e 100644 --- a/src/gdbserver/gdb-remote.c +++ b/src/gdbserver/gdb-remote.c @@ -27,7 +27,7 @@ int gdb_send_packet(int fd, char* data) { packet[0] = '$'; uint8_t cksum = 0; - for(unsigned int i = 0; i < data_length; i++) { + for (unsigned int i = 0; i < data_length; i++) { packet[i + 1] = data[i]; cksum += data[i]; } @@ -36,19 +36,19 @@ int gdb_send_packet(int fd, char* data) { packet[length - 2] = hex[cksum >> 4]; packet[length - 1] = hex[cksum & 0xf]; - while(1) { - if(write(fd, packet, length) != length) { + while (1) { + if (write(fd, packet, length) != length) { free(packet); return -2; } char ack; - if(read(fd, &ack, 1) != 1) { + if (read(fd, &ack, 1) != 1) { free(packet); return -2; } - if(ack == '+') { + if (ack == '+') { free(packet); return 0; } @@ -64,7 +64,7 @@ int gdb_recv_packet(int fd, char** buffer) { char* packet_buffer = malloc(packet_size); unsigned state; - if(packet_buffer == NULL) + if (packet_buffer == NULL) return -2; start: @@ -79,15 +79,15 @@ int gdb_recv_packet(int fd, char** buffer) { */ char c; - while(state != 4) { - if(read(fd, &c, 1) != 1) { + while (state != 4) { + if (read(fd, &c, 1) != 1) { free(packet_buffer); return -2; } switch(state) { case 0: - if(c != '$') { + if (c != '$') { // ignore } else { state = 1; @@ -95,16 +95,16 @@ int gdb_recv_packet(int fd, char** buffer) { break; case 1: - if(c == '#') { + if (c == '#') { state = 2; } else { packet_buffer[packet_idx++] = c; cksum += c; - if(packet_idx == packet_size) { + if (packet_idx == packet_size) { packet_size += ALLOC_STEP; void* p = realloc(packet_buffer, packet_size); - if(p != NULL) + if (p != NULL) packet_buffer = p; else { free(packet_buffer); @@ -127,9 +127,9 @@ int gdb_recv_packet(int fd, char** buffer) { } uint8_t recv_cksum_int = strtoul(recv_cksum, NULL, 16); - if(recv_cksum_int != cksum) { + if (recv_cksum_int != cksum) { char nack = '-'; - if(write(fd, &nack, 1) != 1) { + if (write(fd, &nack, 1) != 1) { free(packet_buffer); return -2; } @@ -137,7 +137,7 @@ int gdb_recv_packet(int fd, char** buffer) { goto start; } else { char ack = '+'; - if(write(fd, &ack, 1) != 1) { + if (write(fd, &ack, 1) != 1) { free(packet_buffer); return -2; } @@ -157,13 +157,13 @@ int gdb_check_for_interrupt(int fd) { pfd.fd = fd; pfd.events = POLLIN; - if(poll(&pfd, 1, 0) != 0) { + if (poll(&pfd, 1, 0) != 0) { char c; - if(read(fd, &c, 1) != 1) + if (read(fd, &c, 1) != 1) return -2; - if(c == '\x03') // ^C + if (c == '\x03') // ^C return 1; } diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 9cff5f917..1c45c2538 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -89,10 +89,10 @@ static stlink_t* do_connect(st_state_t *st) { stlink_t *ret = NULL; switch (st->stlink_version) { case 2: - if(serial_specified){ + if (serial_specified){ ret = stlink_open_usb(st->logging_level, st->reset, serialnumber); } - else{ + else { ret = stlink_open_usb(st->logging_level, st->reset, NULL); } break; @@ -199,8 +199,8 @@ int parse_options(int argc, char** argv, st_state_t *st) { /** @todo This is not really portable, as strlen really returns size_t we need to obey and not cast it to a signed type. */ int j = (int)strlen(optarg); int length = j / 2; //the length of the destination-array - if(j % 2 != 0) return -1; - for(size_t k = 0; j >= 0 && k < sizeof(serialnumber); ++k, j -= 2) { + if (j % 2 != 0) return -1; + for (size_t k = 0; j >= 0 && k < sizeof(serialnumber); ++k, j -= 2) { char buffer[3] = {0}; memcpy(buffer, optarg + j, 2); serialnumber[length - k] = (uint8_t)strtol(buffer, NULL, 16); @@ -234,7 +234,7 @@ int main(int argc, char** argv) { printf("st-util %s\n", STLINK_VERSION); sl = do_connect(&state); - if(sl == NULL) return 1; + if (sl == NULL) return 1; connected_stlink = sl; signal(SIGINT, &cleanup); @@ -255,7 +255,7 @@ int main(int argc, char** argv) { #if defined(__MINGW32__) || defined(_MSC_VER) WSADATA wsadata; - if (WSAStartup(MAKEWORD(2,2),&wsadata) !=0 ) { + if (WSAStartup(MAKEWORD(2,2),&wsadata) !=0){ goto winsock_error; } #endif @@ -532,27 +532,27 @@ char* make_memory_map(stlink_t *sl) { char* map = malloc(sz); map[0] = '\0'; - if(sl->chip_id==STLINK_CHIPID_STM32_F4 || sl->chip_id==STLINK_CHIPID_STM32_F446 || sl->chip_id==STLINK_CHIPID_STM32_F411RE) { + if (sl->chip_id==STLINK_CHIPID_STM32_F4 || sl->chip_id==STLINK_CHIPID_STM32_F446 || sl->chip_id==STLINK_CHIPID_STM32_F411RE) { strcpy(map, memory_map_template_F4); - } else if(sl->chip_id==STLINK_CHIPID_STM32_F4_DE) { + } else if (sl->chip_id==STLINK_CHIPID_STM32_F4_DE) { strcpy(map, memory_map_template_F4_DE); - } else if(sl->core_id==STM32F7_CORE_ID) { + } else if (sl->core_id==STM32F7_CORE_ID) { snprintf(map, sz, memory_map_template_F7, (unsigned int)sl->sram_size); - } else if(sl->chip_id==STLINK_CHIPID_STM32_F4_HD) { + } else if (sl->chip_id==STLINK_CHIPID_STM32_F4_HD) { strcpy(map, memory_map_template_F4_HD); - } else if(sl->chip_id==STLINK_CHIPID_STM32_F2) { + } else if (sl->chip_id==STLINK_CHIPID_STM32_F2) { snprintf(map, sz, memory_map_template_F2, (unsigned int)sl->flash_size, (unsigned int)sl->sram_size, (unsigned int)sl->flash_size - 0x20000, (unsigned int)sl->sys_base, (unsigned int)sl->sys_size); - } else if((sl->chip_id==STLINK_CHIPID_STM32_L4) || + } else if ((sl->chip_id==STLINK_CHIPID_STM32_L4) || (sl->chip_id==STLINK_CHIPID_STM32_L43X) || (sl->chip_id==STLINK_CHIPID_STM32_L46X)) { snprintf(map, sz, memory_map_template_L4, (unsigned int)sl->flash_size, (unsigned int)sl->flash_size); - } else if(sl->chip_id==STLINK_CHIPID_STM32_L496X) { + } else if (sl->chip_id==STLINK_CHIPID_STM32_L496X) { snprintf(map, sz, memory_map_template_L496, (unsigned int)sl->flash_size, (unsigned int)sl->flash_size); } else { @@ -603,7 +603,7 @@ static void init_data_watchpoints(stlink_t *sl) { stlink_write_debug32(sl, 0xE000EDFC, data); // make sure all watchpoints are cleared - for(int i = 0; i < DATA_WATCH_NUM; i++) { + for (int i = 0; i < DATA_WATCH_NUM; i++) { data_watches[i].fun = WATCHDISABLED; stlink_write_debug32(sl, 0xe0001028 + i * 16, 0); } @@ -620,15 +620,15 @@ static int add_data_watchpoint(stlink_t *sl, enum watchfun wf, mask = -1; i = len; - while(i) { + while (i) { i >>= 1; mask++; } - if((mask != (uint32_t)-1) && (mask < 16)) { - for(i = 0; i < DATA_WATCH_NUM; i++) { + if ((mask != (uint32_t)-1) && (mask < 16)) { + for (i = 0; i < DATA_WATCH_NUM; i++) { // is this an empty slot ? - if(data_watches[i].fun == WATCHDISABLED) { + if (data_watches[i].fun == WATCHDISABLED) { DLOG("insert watchpoint %d addr %x wf %u mask %u len %d\n", i, addr, wf, mask, len); data_watches[i].fun = wf; @@ -659,8 +659,8 @@ static int delete_data_watchpoint(stlink_t *sl, stm32_addr_t addr) { int i; - for(i = 0 ; i < DATA_WATCH_NUM; i++) { - if((data_watches[i].addr == addr) && (data_watches[i].fun != WATCHDISABLED)) { + for (i = 0 ; i < DATA_WATCH_NUM; i++) { + if ((data_watches[i].addr == addr) && (data_watches[i].fun != WATCHDISABLED)) { DLOG("delete watchpoint %d addr %x\n", i, addr); data_watches[i].fun = WATCHDISABLED; @@ -698,7 +698,7 @@ static void init_code_breakpoints(stlink_t *sl) { ILOG("Found %i hw breakpoint registers\n", code_break_num); - for(int i = 0; i < code_break_num; i++) { + for (int i = 0; i < code_break_num; i++) { code_breaks[i].type = 0; stlink_write_debug32(sl, STLINK_REG_CM3_FP_COMP0 + i * 4, 0); } @@ -706,7 +706,7 @@ static void init_code_breakpoints(stlink_t *sl) { static int has_breakpoint(stm32_addr_t addr) { - for(int i = 0; i < code_break_num; i++) { + for (int i = 0; i < code_break_num; i++) { if (code_breaks[i].addr == addr) { return 1; } @@ -719,7 +719,7 @@ static int update_code_breakpoint(stlink_t *sl, stm32_addr_t addr, int set) { uint32_t mask; int type = (addr & 0x2) ? CODE_BREAK_HIGH : CODE_BREAK_LOW; - if(addr & 1) { + if (addr & 1) { ELOG("update_code_breakpoint: unaligned address %08x\n", addr); return -1; } @@ -731,16 +731,16 @@ static int update_code_breakpoint(stlink_t *sl, stm32_addr_t addr, int set) { } int id = -1; - for(int i = 0; i < code_break_num; i++) { - if(fpb_addr == code_breaks[i].addr || + for (int i = 0; i < code_break_num; i++) { + if (fpb_addr == code_breaks[i].addr || (set && code_breaks[i].type == 0)) { id = i; break; } } - if(id == -1) { - if(set) return -1; // Free slot not found + if (id == -1) { + if (set) return -1; // Free slot not found else return 0; // Breakpoint is already removed } @@ -749,18 +749,18 @@ static int update_code_breakpoint(stlink_t *sl, stm32_addr_t addr, int set) { bp->addr = fpb_addr; if (sl->core_id==STM32F7_CORE_ID) { - if(set) bp->type = type; + if (set) bp->type = type; else bp->type = 0; mask = (bp->addr) | 1; } else { - if(set) bp->type |= type; + if (set) bp->type |= type; else bp->type &= ~type; mask = (bp->addr) | 1 | (bp->type << 30); } - if(bp->type == 0) { + if (bp->type == 0) { DLOG("clearing hw break %d\n", id); stlink_write_debug32(sl, 0xe0002008 + id * 4, 0); @@ -789,13 +789,13 @@ static struct flash_block* flash_root; static int flash_add_block(stm32_addr_t addr, unsigned length, stlink_t *sl) { - if(addr < FLASH_BASE || addr + length > FLASH_BASE + sl->flash_size) { + if (addr < FLASH_BASE || addr + length > FLASH_BASE + sl->flash_size) { ELOG("flash_add_block: incorrect bounds\n"); return -1; } stlink_calculate_pagesize(sl, addr); - if(addr % FLASH_PAGE != 0 || length % FLASH_PAGE != 0) { + if (addr % FLASH_PAGE != 0 || length % FLASH_PAGE != 0) { ELOG("flash_add_block: unaligned block\n"); return -1; } @@ -815,7 +815,7 @@ static int flash_add_block(stm32_addr_t addr, unsigned length, stlink_t *sl) { static int flash_populate(stm32_addr_t addr, uint8_t* data, unsigned length) { unsigned int fit_blocks = 0, fit_length = 0; - for(struct flash_block* fb = flash_root; fb; fb = fb->next) { + for (struct flash_block* fb = flash_root; fb; fb = fb->next) { /* Block: ------X------Y-------- * Data: a-----b * a--b @@ -826,7 +826,7 @@ static int flash_populate(stm32_addr_t addr, uint8_t* data, unsigned length) { unsigned X = fb->addr, Y = fb->addr + fb->length; unsigned a = addr, b = addr + length; - if(a < Y && b > X) { + if (a < Y && b > X) { // from start of the block unsigned start = (a > X ? a : X) - X; unsigned end = (b > Y ? Y : b) - X; @@ -838,12 +838,12 @@ static int flash_populate(stm32_addr_t addr, uint8_t* data, unsigned length) { } } - if(fit_blocks == 0) { + if (fit_blocks == 0) { ELOG("Unfit data block %08x -> %04x\n", addr, length); return -1; } - if(fit_length != length) { + if (fit_length != length) { WLOG("data block %08x -> %04x truncated to %04x\n", addr, length, fit_length); WLOG("(this is not an error, just a GDB glitch)\n"); @@ -859,10 +859,10 @@ static int flash_go(stlink_t *sl) { stlink_reset(sl); stlink_force_debug(sl); - for(struct flash_block* fb = flash_root; fb; fb = fb->next) { + for (struct flash_block* fb = flash_root; fb; fb = fb->next) { DLOG("flash_do: block %08x -> %04x\n", fb->addr, fb->length); - for(stm32_addr_t page = fb->addr; page < fb->addr + fb->length; page += (uint32_t)FLASH_PAGE) { + for (stm32_addr_t page = fb->addr; page < fb->addr + fb->length; page += (uint32_t)FLASH_PAGE) { unsigned length = fb->length - (page - fb->addr); //Update FLASH_PAGE @@ -881,7 +881,7 @@ static int flash_go(stlink_t *sl) { error = 0; error: - for(struct flash_block* fb = flash_root, *next; fb; fb = next) { + for (struct flash_block* fb = flash_root, *next; fb; fb = next) { next = fb->next; free(fb->data); free(fb); @@ -956,7 +956,7 @@ static void init_cache (stlink_t *sl) { int i; /* Assume only F7 has a cache. */ - if(sl->core_id!=STM32F7_CORE_ID) + if (sl->core_id!=STM32F7_CORE_ID) return; stlink_read_debug32(sl, CLIDR, &clidr); @@ -972,14 +972,14 @@ static void init_cache (stlink_t *sl) { (clidr >> 27) & 7, (clidr >> 24) & 7, (clidr >> 21) & 7); ILOG(" cache: ctr: %08x, DminLine: %u bytes, IminLine: %u bytes\n", ctr, cache_desc.dminline, cache_desc.iminline); - for(i = 0; i < 7; i++) + for (i = 0; i < 7; i++) { unsigned int ct = (clidr >> (3 * i)) & 0x07; cache_desc.dcache[i].width = 0; cache_desc.icache[i].width = 0; - if(ct == 2 || ct == 3 || ct == 4) + if (ct == 2 || ct == 3 || ct == 4) { /* Data. */ stlink_write_debug32(sl, CSSELR, i << 1); @@ -987,7 +987,7 @@ static void init_cache (stlink_t *sl) { read_cache_level_desc(sl, &cache_desc.dcache[i]); } - if(ct == 1 || ct == 3) + if (ct == 1 || ct == 3) { /* Instruction. */ stlink_write_debug32(sl, CSSELR, (i << 1) | 1); @@ -1035,7 +1035,7 @@ static void cache_sync(stlink_t *sl) { unsigned ccr; - if(sl->core_id!=STM32F7_CORE_ID) + if (sl->core_id!=STM32F7_CORE_ID) return; if (!cache_modified) return; @@ -1063,7 +1063,7 @@ static size_t unhexify(const char *in, char *out, size_t out_count) int serve(stlink_t *sl, st_state_t *st) { SOCKET sock = socket(AF_INET, SOCK_STREAM, 0); - if(!IS_SOCK_VALID(sock)) { + if (!IS_SOCK_VALID(sock)) { perror("socket"); return 1; } @@ -1077,13 +1077,13 @@ int serve(stlink_t *sl, st_state_t *st) { serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(st->listen_port); - if(bind(sock, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { + if (bind(sock, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { perror("bind"); close_socket(sock); return 1; } - if(listen(sock, 5) < 0) { + if (listen(sock, 5) < 0) { perror("listen"); close_socket(sock); return 1; @@ -1093,7 +1093,7 @@ int serve(stlink_t *sl, st_state_t *st) { SOCKET client = accept(sock, NULL, NULL); //signal (SIGINT, SIG_DFL); - if(!IS_SOCK_VALID(client)) { + if (!IS_SOCK_VALID(client)) { perror("accept"); close_socket(sock); return 1; @@ -1120,12 +1120,12 @@ int serve(stlink_t *sl, st_state_t *st) { */ int critical_error = 0; int ret; - while(1) { + while (1) { ret = 0; char* packet; int status = gdb_recv_packet(client, &packet); - if(status < 0) { + if (status < 0) { ELOG("cannot recv: %d\n", status); close_socket(client); return 1; @@ -1138,13 +1138,13 @@ int serve(stlink_t *sl, st_state_t *st) { switch(packet[0]) { case 'q': { - if(packet[1] == 'P' || packet[1] == 'C' || packet[1] == 'L') { + if (packet[1] == 'P' || packet[1] == 'C' || packet[1] == 'L') { reply = strdup(""); break; } char *separator = strstr(packet, ":"), *params = ""; - if(separator == NULL) { + if (separator == NULL) { separator = packet + strlen(packet); } else { params = separator + 1; @@ -1156,8 +1156,8 @@ int serve(stlink_t *sl, st_state_t *st) { DLOG("query: %s;%s\n", queryName, params); - if(!strcmp(queryName, "Supported")) { - if(sl->chip_id==STLINK_CHIPID_STM32_F4 + if (!strcmp(queryName, "Supported")) { + if (sl->chip_id==STLINK_CHIPID_STM32_F4 || sl->chip_id==STLINK_CHIPID_STM32_F4_HD || sl->core_id==STM32F7_CORE_ID) { reply = strdup("PacketSize=3fff;qXfer:memory-map:read+;qXfer:features:read+"); @@ -1165,7 +1165,7 @@ int serve(stlink_t *sl, st_state_t *st) { else { reply = strdup("PacketSize=3fff;qXfer:memory-map:read+"); } - } else if(!strcmp(queryName, "Xfer")) { + } else if (!strcmp(queryName, "Xfer")) { char *type, *op, *__s_addr, *s_length; char *tok = params; char *annex __attribute__((unused)); @@ -1184,18 +1184,18 @@ int serve(stlink_t *sl, st_state_t *st) { const char* data = NULL; - if(!strcmp(type, "memory-map") && !strcmp(op, "read")) + if (!strcmp(type, "memory-map") && !strcmp(op, "read")) data = current_memory_map; - if(!strcmp(type, "features") && !strcmp(op, "read")) + if (!strcmp(type, "features") && !strcmp(op, "read")) data = target_description_F4; - if(data) { + if (data) { unsigned data_length = (unsigned int) strlen(data); - if(addr + length > data_length) + if (addr + length > data_length) length = data_length - addr; - if(length == 0) { + if (length == 0) { reply = strdup("l"); } else { reply = calloc(length + 2, 1); @@ -1203,11 +1203,11 @@ int serve(stlink_t *sl, st_state_t *st) { strncpy(&reply[1], data, length); } } - } else if(!strncmp(queryName, "Rcmd,",4)) { + } else if (!strncmp(queryName, "Rcmd,",4)) { // Rcmd uses the wrong separator separator = strstr(packet, ","); params = ""; - if(separator == NULL) { + if (separator == NULL) { separator = packet + strlen(packet); } else { params = separator + 1; @@ -1328,7 +1328,7 @@ int serve(stlink_t *sl, st_state_t *st) { free(cmd); } - if(reply == NULL) + if (reply == NULL) reply = strdup(""); free(queryName); @@ -1342,7 +1342,7 @@ int serve(stlink_t *sl, st_state_t *st) { cmdName++; // vCommand -> Command - if(!strcmp(cmdName, "FlashErase")) { + if (!strcmp(cmdName, "FlashErase")) { char *__s_addr, *s_length; char *tok = params; @@ -1355,12 +1355,12 @@ int serve(stlink_t *sl, st_state_t *st) { DLOG("FlashErase: addr:%08x,len:%04x\n", addr, length); - if(flash_add_block(addr, length, sl) < 0) { + if (flash_add_block(addr, length, sl) < 0) { reply = strdup("E00"); } else { reply = strdup("OK"); } - } else if(!strcmp(cmdName, "FlashWrite")) { + } else if (!strcmp(cmdName, "FlashWrite")) { char *__s_addr, *data; char *tok = params; @@ -1375,8 +1375,8 @@ int serve(stlink_t *sl, st_state_t *st) { // Additional byte is reserved for alignment fix. uint8_t *decoded = calloc(data_length + 1, 1); unsigned dec_index = 0; - for(unsigned int i = 0; i < data_length; i++) { - if(data[i] == 0x7d) { + for (unsigned int i = 0; i < data_length; i++) { + if (data[i] == 0x7d) { i++; decoded[dec_index++] = data[i] ^ 0x20; } else { @@ -1385,31 +1385,31 @@ int serve(stlink_t *sl, st_state_t *st) { } // Fix alignment - if(dec_index % 2 != 0) + if (dec_index % 2 != 0) dec_index++; DLOG("binary packet %d -> %d\n", data_length, dec_index); - if(flash_populate(addr, decoded, dec_index) < 0) { + if (flash_populate(addr, decoded, dec_index) < 0) { reply = strdup("E00"); } else { reply = strdup("OK"); } free(decoded); - } else if(!strcmp(cmdName, "FlashDone")) { - if(flash_go(sl) < 0) { + } else if (!strcmp(cmdName, "FlashDone")) { + if (flash_go(sl) < 0) { reply = strdup("E00"); } else { reply = strdup("OK"); } - } else if(!strcmp(cmdName, "Kill")) { + } else if (!strcmp(cmdName, "Kill")) { attached = 0; reply = strdup("OK"); } - if(reply == NULL) + if (reply == NULL) reply = strdup(""); break; @@ -1422,15 +1422,15 @@ int serve(stlink_t *sl, st_state_t *st) { DLOG("Semihost: run failed\n"); } - while(1) { + while (1) { status = gdb_check_for_interrupt(client); - if(status < 0) { + if (status < 0) { ELOG("cannot check for int: %d\n", status); close_socket(client); return 1; } - if(status == 1) { + if (status == 1) { stlink_force_debug(sl); break; } @@ -1439,7 +1439,7 @@ int serve(stlink_t *sl, st_state_t *st) { if (ret) { DLOG("Semihost: status failed\n"); } - if(sl->core_stat == STLINK_CORE_HALTED) { + if (sl->core_stat == STLINK_CORE_HALTED) { struct stlink_reg reg; stm32_addr_t pc; stm32_addr_t addr; @@ -1526,7 +1526,7 @@ int serve(stlink_t *sl, st_state_t *st) { break; case '?': - if(attached) { + if (attached) { reply = strdup("S05"); // TRAP } else { /* Stub shall reply OK if not attached. */ @@ -1541,7 +1541,7 @@ int serve(stlink_t *sl, st_state_t *st) { } reply = calloc(8 * 16 + 1, 1); - for(int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) sprintf(&reply[i * 8], "%08x", (uint32_t)htonl(regp.r[i])); break; @@ -1550,34 +1550,34 @@ int serve(stlink_t *sl, st_state_t *st) { unsigned id = (unsigned int) strtoul(&packet[1], NULL, 16); unsigned myreg = 0xDEADDEAD; - if(id < 16) { + if (id < 16) { ret = stlink_read_reg(sl, id, ®p); myreg = htonl(regp.r[id]); - } else if(id == 0x19) { + } else if (id == 0x19) { ret = stlink_read_reg(sl, 16, ®p); myreg = htonl(regp.xpsr); - } else if(id == 0x1A) { + } else if (id == 0x1A) { ret = stlink_read_reg(sl, 17, ®p); myreg = htonl(regp.main_sp); - } else if(id == 0x1B) { + } else if (id == 0x1B) { ret = stlink_read_reg(sl, 18, ®p); myreg = htonl(regp.process_sp); - } else if(id == 0x1C) { + } else if (id == 0x1C) { ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.control); - } else if(id == 0x1D) { + } else if (id == 0x1D) { ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.faultmask); - } else if(id == 0x1E) { + } else if (id == 0x1E) { ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.basepri); - } else if(id == 0x1F) { + } else if (id == 0x1F) { ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.primask); - } else if(id >= 0x20 && id < 0x40) { + } else if (id >= 0x20 && id < 0x40) { ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.s[id-0x20]); - } else if(id == 0x40) { + } else if (id == 0x40) { ret = stlink_read_unsupported_reg(sl, id, ®p); myreg = htonl(regp.fpscr); } else { @@ -1605,25 +1605,25 @@ int serve(stlink_t *sl, st_state_t *st) { unsigned value = (unsigned int) strtoul(s_value, NULL, 16); - if(reg < 16) { + if (reg < 16) { ret = stlink_write_reg(sl, ntohl(value), reg); - } else if(reg == 0x19) { + } else if (reg == 0x19) { ret = stlink_write_reg(sl, ntohl(value), 16); - } else if(reg == 0x1A) { + } else if (reg == 0x1A) { ret = stlink_write_reg(sl, ntohl(value), 17); - } else if(reg == 0x1B) { + } else if (reg == 0x1B) { ret = stlink_write_reg(sl, ntohl(value), 18); - } else if(reg == 0x1C) { + } else if (reg == 0x1C) { ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); - } else if(reg == 0x1D) { + } else if (reg == 0x1D) { ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); - } else if(reg == 0x1E) { + } else if (reg == 0x1E) { ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); - } else if(reg == 0x1F) { + } else if (reg == 0x1F) { ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); - } else if(reg >= 0x20 && reg < 0x40) { + } else if (reg >= 0x20 && reg < 0x40) { ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); - } else if(reg == 0x40) { + } else if (reg == 0x40) { ret = stlink_write_unsupported_reg(sl, ntohl(value), reg, ®p); } else { ret = 1; @@ -1632,7 +1632,7 @@ int serve(stlink_t *sl, st_state_t *st) { if (ret) { DLOG("P packet: stlink_write_unsupported_reg failed with reg %u\n", reg); } - if(reply == NULL) { + if (reply == NULL) { // note that NULL may not be zero reply = strdup("OK"); } @@ -1641,7 +1641,7 @@ int serve(stlink_t *sl, st_state_t *st) { } case 'G': - for(int i = 0; i < 16; i++) { + for (int i = 0; i < 16; i++) { char str[9] = {0}; strncpy(str, &packet[1 + i * 8], 8); uint32_t reg = (uint32_t) strtoul(str, NULL, 16); @@ -1676,7 +1676,7 @@ int serve(stlink_t *sl, st_state_t *st) { } reply = calloc(count * 2 + 1, 1); - for(unsigned int i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { reply[i * 2 + 0] = hex[sl->q_buf[i + adj_start] >> 4]; reply[i * 2 + 1] = hex[sl->q_buf[i + adj_start] & 0xf]; } @@ -1693,10 +1693,10 @@ int serve(stlink_t *sl, st_state_t *st) { unsigned count = (unsigned int) strtoul(s_count, NULL, 16); int err = 0; - if(start % 4) { + if (start % 4) { unsigned align_count = 4 - start % 4; if (align_count > count) align_count = count; - for(unsigned int i = 0; i < align_count; i ++) { + for (unsigned int i = 0; i < align_count; i ++) { char hextmp[3] = { hexdata[i*2], hexdata[i*2+1], 0 }; uint8_t byte = strtoul(hextmp, NULL, 16); sl->q_buf[i] = byte; @@ -1708,10 +1708,10 @@ int serve(stlink_t *sl, st_state_t *st) { hexdata += 2*align_count; } - if(count - count % 4) { + if (count - count % 4) { unsigned aligned_count = count - count % 4; - for(unsigned int i = 0; i < aligned_count; i ++) { + for (unsigned int i = 0; i < aligned_count; i ++) { char hextmp[3] = { hexdata[i*2], hexdata[i*2+1], 0 }; uint8_t byte = strtoul(hextmp, NULL, 16); sl->q_buf[i] = byte; @@ -1723,8 +1723,8 @@ int serve(stlink_t *sl, st_state_t *st) { hexdata += 2*aligned_count; } - if(count) { - for(unsigned int i = 0; i < count; i ++) { + if (count) { + for (unsigned int i = 0; i < count; i ++) { char hextmp[3] = { hexdata[i*2], hexdata[i*2+1], 0 }; uint8_t byte = strtoul(hextmp, NULL, 16); sl->q_buf[i] = byte; @@ -1743,7 +1743,7 @@ int serve(stlink_t *sl, st_state_t *st) { switch (packet[1]) { case '1': - if(update_code_breakpoint(sl, addr, 1) < 0) { + if (update_code_breakpoint(sl, addr, 1) < 0) { reply = strdup("E00"); } else { reply = strdup("OK"); @@ -1754,15 +1754,15 @@ int serve(stlink_t *sl, st_state_t *st) { case '3': // insert read watchpoint case '4': { // insert access watchpoint enum watchfun wf; - if(packet[1] == '2') { + if (packet[1] == '2') { wf = WATCHWRITE; - } else if(packet[1] == '3') { + } else if (packet[1] == '3') { wf = WATCHREAD; } else { wf = WATCHACCESS; } - if(add_data_watchpoint(sl, wf, addr, len) < 0) { + if (add_data_watchpoint(sl, wf, addr, len) < 0) { reply = strdup("E00"); } else { reply = strdup("OK"); @@ -1790,7 +1790,7 @@ int serve(stlink_t *sl, st_state_t *st) { case '2' : // remove write watchpoint case '3' : // remove read watchpoint case '4' : // remove access watchpoint - if(delete_data_watchpoint(sl, addr) < 0) { + if (delete_data_watchpoint(sl, addr) < 0) { reply = strdup("E00"); break; } else { @@ -1852,7 +1852,7 @@ int serve(stlink_t *sl, st_state_t *st) { stlink_close(sl); sl = do_connect(st); - if(sl == NULL) cleanup(0); + if (sl == NULL) cleanup(0); connected_stlink = sl; if (st->reset) { @@ -1874,11 +1874,11 @@ int serve(stlink_t *sl, st_state_t *st) { reply = strdup(""); } - if(reply) { + if (reply) { DLOG("send: %s\n", reply); int result = gdb_send_packet(client, reply); - if(result != 0) { + if (result != 0) { ELOG("cannot send: %d\n", result); free(reply); free(packet); diff --git a/src/gdbserver/semihosting.c b/src/gdbserver/semihosting.c index 9e92cf3bd..40758b61d 100644 --- a/src/gdbserver/semihosting.c +++ b/src/gdbserver/semihosting.c @@ -178,7 +178,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { uint32_t name_len; char *name; - if (mem_read(sl, r1, args, sizeof (args)) != 0 ) { + if (mem_read(sl, r1, args, sizeof (args)) != 0){ DLOG("Semihosting SYS_OPEN error: " "cannot read args from target memory\n"); *ret = -1; @@ -215,7 +215,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { return -1; } - if (mem_read(sl, name_address, name, name_len) != 0 ) { + if (mem_read(sl, name_address, name, name_len) != 0){ free(name); *ret = -1; DLOG("Semihosting SYS_OPEN error: " @@ -238,7 +238,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { uint32_t args[1]; int fd; - if (mem_read(sl, r1, args, sizeof (args)) != 0 ) { + if (mem_read(sl, r1, args, sizeof (args)) != 0){ DLOG("Semihosting SYS_CLOSE error: " "cannot read args from target memory\n"); *ret = -1; @@ -263,7 +263,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { uint32_t buffer_len; void *buffer; - if (mem_read(sl, r1, args, sizeof (args)) != 0 ) { + if (mem_read(sl, r1, args, sizeof (args)) != 0){ DLOG("Semihosting SYS_WRITE error: " "cannot read args from target memory\n"); *ret = -1; @@ -289,7 +289,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { return -1; } - if (mem_read(sl, buffer_address, buffer, buffer_len) != 0 ) { + if (mem_read(sl, buffer_address, buffer, buffer_len) != 0){ DLOG("Semihosting SYS_WRITE error: " "cannot read buffer from target memory\n"); free(buffer); @@ -322,7 +322,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { void *buffer; ssize_t read_result; - if (mem_read(sl, r1, args, sizeof (args)) != 0 ) { + if (mem_read(sl, r1, args, sizeof (args)) != 0){ DLOG("Semihosting SYS_READ error: " "cannot read args from target memory\n"); *ret = -1; @@ -357,7 +357,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { if (read_result == -1) { *ret = buffer_len; } else { - if (mem_write(sl, buffer_address, buffer, read_result) != 0 ) { + if (mem_write(sl, buffer_address, buffer, read_result) != 0){ DLOG("Semihosting SYS_READ error: " "cannot write buffer to target memory\n"); free(buffer); @@ -385,7 +385,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { uint32_t name_len; char *name; - if (mem_read(sl, r1, args, sizeof (args)) != 0 ) { + if (mem_read(sl, r1, args, sizeof (args)) != 0){ DLOG("Semihosting SYS_REMOVE error: " "cannot read args from target memory\n"); *ret = -1; @@ -414,7 +414,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { return -1; } - if (mem_read(sl, name_address, name, name_len) != 0 ) { + if (mem_read(sl, name_address, name, name_len) != 0){ free(name); *ret = -1; DLOG("Semihosting SYS_REMOVE error: " @@ -438,7 +438,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { int fd; off_t offset; - if (mem_read(sl, r1, args, sizeof (args)) != 0 ) { + if (mem_read(sl, r1, args, sizeof (args)) != 0){ DLOG("Semihosting SYS_SEEK error: " "cannot read args from target memory\n"); *ret = -1; @@ -482,7 +482,7 @@ int do_semihosting (stlink_t *sl, uint32_t r0, uint32_t r1, uint32_t *ret) { uint8_t buf[WRITE0_BUFFER_SIZE]; while (true) { - if (mem_read(sl, r1, buf, WRITE0_BUFFER_SIZE) != 0 ) { + if (mem_read(sl, r1, buf, WRITE0_BUFFER_SIZE) != 0){ DLOG("Semihosting WRITE0: " "cannot read target memory at 0x%08x\n", r1); return -1; diff --git a/src/md5.c b/src/md5.c index ff7d2d76e..e2b526c7d 100755 --- a/src/md5.c +++ b/src/md5.c @@ -70,7 +70,7 @@ void* #define GET(n) (ctx->block[(n)]) #define SET(n) (ctx->block[(n)] = \ - ((uint32_t)ptr[(n)*4 + 0] << 0 ) \ + ((uint32_t)ptr[(n)*4 + 0] << 0) \ | ((uint32_t)ptr[(n)*4 + 1] << 8 ) \ | ((uint32_t)ptr[(n)*4 + 2] << 16) \ | ((uint32_t)ptr[(n)*4 + 3] << 24) ) @@ -167,7 +167,7 @@ void* d += saved_d; ptr += 64; - } while( size -= 64 ); + } while ( size -= 64 ); ctx->a = a; ctx->b = b; @@ -223,7 +223,7 @@ void uint32_t free; saved_lo = Context->lo; - if( (Context->lo = (saved_lo + BufferSize) & 0x1fffffff) < saved_lo ) + if ( (Context->lo = (saved_lo + BufferSize) & 0x1fffffff) < saved_lo ) { Context->hi++; } @@ -231,11 +231,11 @@ void used = saved_lo & 0x3f; - if( used ) + if ( used ) { free = 64 - used; - if( BufferSize < free ) + if ( BufferSize < free ) { memcpy( &Context->buffer[used], Buffer, BufferSize ); return; @@ -247,7 +247,7 @@ void TransformFunction(Context, Context->buffer, 64); } - if( BufferSize >= 64 ) + if ( BufferSize >= 64 ) { Buffer = TransformFunction( Context, Buffer, BufferSize & ~(unsigned long)0x3f ); BufferSize &= 0x3f; @@ -278,7 +278,7 @@ void free = 64 - used; - if(free < 8) + if (free < 8) { memset( &Context->buffer[used], 0, free ); TransformFunction( Context, Context->buffer, 64 ); diff --git a/src/mingw/mingw.c b/src/mingw/mingw.c index 4cb917ac4..646fca238 100644 --- a/src/mingw/mingw.c +++ b/src/mingw/mingw.c @@ -27,11 +27,11 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo) FD_ZERO(&efds); for (i = 0, op = ip = 0; i < nfds; ++i) { fds[i].revents = 0; - if(fds[i].events & (POLLIN|POLLPRI)) { + if (fds[i].events & (POLLIN|POLLPRI)) { ip = &ifds; FD_SET(fds[i].fd, ip); } - if(fds[i].events & POLLOUT) { + if (fds[i].events & POLLOUT) { op = &ofds; FD_SET(fds[i].fd, op); } @@ -42,7 +42,7 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo) #endif /* Set up the timeval structure for the timeout parameter */ - if(timo < 0) { + if (timo < 0) { toptr = 0; } else { toptr = &timeout; @@ -59,17 +59,17 @@ int win32_poll(struct pollfd *fds, unsigned int nfds, int timo) printf("Exiting select rc=%d\n", rc); #endif - if(rc <= 0) + if (rc <= 0) return rc; - if(rc > 0) { + if (rc > 0) { for ( i = 0; i < nfds; ++i) { int fd = fds[i].fd; - if(fds[i].events & (POLLIN|POLLPRI) && FD_ISSET(fd, &ifds)) + if (fds[i].events & (POLLIN|POLLPRI) && FD_ISSET(fd, &ifds)) fds[i].revents |= POLLIN; - if(fds[i].events & POLLOUT && FD_ISSET(fd, &ofds)) + if (fds[i].events & POLLOUT && FD_ISSET(fd, &ofds)) fds[i].revents |= POLLOUT; - if(FD_ISSET(fd, &efds)) + if (FD_ISSET(fd, &efds)) /* Some error was detected ... should be some way to know. */ fds[i].revents |= POLLHUP; #ifdef DEBUG_POLL @@ -118,7 +118,7 @@ SOCKET win32_socket(int domain, int type, int protocol) { SOCKET fd = socket(domain, type, protocol); - if(fd == INVALID_SOCKET) { + if (fd == INVALID_SOCKET) { set_socket_errno(WSAGetLastError()); } return fd; @@ -133,7 +133,7 @@ win32_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len) { int rc = connect(fd, addr, addr_len); assert(rc == 0 || rc == SOCKET_ERROR); - if(rc == SOCKET_ERROR) { + if (rc == SOCKET_ERROR) { set_connect_errno(WSAGetLastError()); } return rc; @@ -148,7 +148,7 @@ SOCKET win32_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len) { SOCKET newfd = accept(fd, addr, addr_len); - if(newfd == INVALID_SOCKET) { + if (newfd == INVALID_SOCKET) { set_socket_errno(WSAGetLastError()); newfd = (SOCKET)-1; } @@ -165,7 +165,7 @@ win32_shutdown(SOCKET fd, int mode) { int rc = shutdown(fd, mode); assert(rc == 0 || rc == SOCKET_ERROR); - if(rc == SOCKET_ERROR) { + if (rc == SOCKET_ERROR) { set_socket_errno(WSAGetLastError()); } return rc; @@ -174,7 +174,7 @@ win32_shutdown(SOCKET fd, int mode) int win32_close_socket(SOCKET fd) { int rc = closesocket(fd); - if(rc == SOCKET_ERROR) { + if (rc == SOCKET_ERROR) { set_socket_errno(WSAGetLastError()); } return rc; @@ -183,7 +183,7 @@ int win32_close_socket(SOCKET fd) ssize_t win32_write_socket(SOCKET fd, void *buf, int n) { int rc = send(fd, buf, n, 0); - if(rc == SOCKET_ERROR) { + if (rc == SOCKET_ERROR) { set_socket_errno(WSAGetLastError()); } return rc; @@ -192,7 +192,7 @@ ssize_t win32_write_socket(SOCKET fd, void *buf, int n) ssize_t win32_read_socket(SOCKET fd, void *buf, int n) { int rc = recv(fd, buf, n, 0); - if(rc == SOCKET_ERROR) { + if (rc == SOCKET_ERROR) { set_socket_errno(WSAGetLastError()); } return rc; diff --git a/src/sg.c b/src/sg.c index d1ee5aea1..031cc64e5 100644 --- a/src/sg.c +++ b/src/sg.c @@ -921,9 +921,9 @@ static stlink_t* stlink_open(const int verbose) { struct stlink_libsg *slsg = malloc(sizeof (struct stlink_libsg)); if (sl == NULL || slsg == NULL) { WLOG("Couldn't malloc stlink and stlink_sg structures out of memory!\n"); - if(sl != NULL) + if (sl != NULL) free(sl); - if(slsg != NULL) + if (slsg != NULL) free(slsg); return NULL; } diff --git a/src/tools/flash.c b/src/tools/flash.c index f703bc813..f39b6c6e4 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -129,7 +129,7 @@ int main(int ac, char** av) if (o.cmd == FLASH_CMD_WRITE) /* write */ { size_t size = 0; - if(o.format == FLASH_FORMAT_IHEX) { + if (o.format == FLASH_FORMAT_IHEX) { err = stlink_parse_ihex(o.filename, stlink_get_erased_pattern(sl), &mem, &size, &o.addr); if (err == -1) { printf("Cannot parse %s as Intel-HEX file\n", o.filename); @@ -138,7 +138,7 @@ int main(int ac, char** av) } if ((o.addr >= sl->flash_base) && (o.addr < sl->flash_base + sl->flash_size)) { - if(o.format == FLASH_FORMAT_IHEX) + if (o.format == FLASH_FORMAT_IHEX) err = stlink_mwrite_flash(sl, mem, (uint32_t)size, o.addr); else err = stlink_fwrite_flash(sl, o.filename, o.addr); @@ -150,7 +150,7 @@ int main(int ac, char** av) } else if ((o.addr >= sl->sram_base) && (o.addr < sl->sram_base + sl->sram_size)) { - if(o.format == FLASH_FORMAT_IHEX) + if (o.format == FLASH_FORMAT_IHEX) err = stlink_mwrite_sram(sl, mem, (uint32_t)size, o.addr); else err = stlink_fwrite_sram(sl, o.filename, o.addr); @@ -207,19 +207,19 @@ int main(int ac, char** av) } else /* read */ { - if(o.area == FLASH_OPTION_BYTES){ - if(sl->chip_id == STLINK_CHIPID_STM32_F2){ + if (o.area == FLASH_OPTION_BYTES){ + if (sl->chip_id == STLINK_CHIPID_STM32_F2){ uint32_t option_byte = 0; err = stlink_read_option_bytes_f2(sl,&option_byte); printf("%x\n",option_byte); - }else if(sl->chip_id == STLINK_CHIPID_STM32_F446){ + } else if (sl->chip_id == STLINK_CHIPID_STM32_F446){ uint32_t option_byte = 0; err = stlink_read_option_bytes_f4(sl,&option_byte); printf("%x\n",option_byte); - }else{ + } else { printf("This format is available for STM32F2 and STM32F4 only\n"); } - }else{ + } else { if ((o.addr >= sl->flash_base) && (o.size == 0) && (o.addr < sl->flash_base + sl->flash_size)){ o.size = sl->flash_size; diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index c139977ce..085d278db 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -28,7 +28,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { o->log_level = STND_LOG_LEVEL; // options - while(ac >= 1) { + while (ac >= 1) { if (strcmp(av[0], "--version") == 0) { printf("v%s\n", STLINK_VERSION); exit(EXIT_SUCCESS); @@ -44,7 +44,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { } else if (strcmp(av[0], "--serial") == 0 || starts_with(av[0], "--serial=")) { const char * serial; - if(strcmp(av[0], "--serial") == 0) { + if (strcmp(av[0], "--serial") == 0) { ac--; av++; if (ac < 1) return -1; @@ -56,8 +56,8 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { /** @todo This is not really portable, as strlen really returns size_t we need to obey and not cast it to a signed type. */ int j = (int)strlen(serial); int length = j / 2; // the length of the destination-array - if(j % 2 != 0) return -1; - for(size_t k = 0; j >= 0 && k < sizeof(o->serial); ++k, j -= 2) { + if (j % 2 != 0) return -1; + for (size_t k = 0; j >= 0 && k < sizeof(o->serial); ++k, j -= 2) { char buffer[3] = {0}; memcpy(buffer, serial + j, 2); o->serial[length - k] = (uint8_t)strtol(buffer, NULL, 16); @@ -65,7 +65,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { } else if (strcmp(av[0], "--area") == 0 || starts_with(av[0], "--area=")) { const char * area; - if(strcmp(av[0], "--area") == 0) { + if (strcmp(av[0], "--area") == 0) { ac--; av++; if (ac < 1) return -1; @@ -88,7 +88,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { } else if (strcmp(av[0], "--format") == 0 || starts_with(av[0], "--format=")) { const char * format; - if(strcmp(av[0], "--format") == 0) { + if (strcmp(av[0], "--format") == 0) { ac--; av++; if (ac < 1) return -1; @@ -136,7 +136,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { } // command and (optional) device name - while(ac >= 1) { + while (ac >= 1) { if (strcmp(av[0], "erase") == 0) { if (o->cmd != FLASH_CMD_NONE) return -1; o->cmd = FLASH_CMD_ERASE; @@ -167,32 +167,32 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { return -1; case FLASH_CMD_ERASE: // no more arguments expected - if(ac != 0) return -1; + if (ac != 0) return -1; break; case FLASH_CMD_READ: // expect filename, addr and size - if((o->area == FLASH_OPTION_BYTES) &&(ac == 0)) break; + if ((o->area == FLASH_OPTION_BYTES) &&(ac == 0)) break; if (ac != 3) return invalid_args("read "); if (ac != 3) return -1; o->filename = av[0]; o->addr = (uint32_t) strtoul(av[1], &tail, 16); - if(tail[0] != '\0') return bad_arg("addr"); + if (tail[0] != '\0') return bad_arg("addr"); o->size = strtoul(av[2], &tail, 16); - if(tail[0] != '\0') return bad_arg("size"); + if (tail[0] != '\0') return bad_arg("size"); break; case FLASH_CMD_WRITE: - if(o->area == FLASH_OPTION_BYTES){ - if(ac != 1) return -1; + if (o->area == FLASH_OPTION_BYTES){ + if (ac != 1) return -1; o->val = (uint32_t)strtoul(av[0], &tail, 16); } - else if(o->format == FLASH_FORMAT_BINARY) { // expect filename and addr + else if (o->format == FLASH_FORMAT_BINARY) { // expect filename and addr if (ac != 2) return invalid_args("write "); o->filename = av[0]; o->addr = (uint32_t) strtoul(av[1], &tail, 16); - if(tail[0] != '\0') return bad_arg("addr"); + if (tail[0] != '\0') return bad_arg("addr"); } - else if(o->format == FLASH_FORMAT_IHEX) { // expect filename + else if (o->format == FLASH_FORMAT_IHEX) { // expect filename if (ac != 1) return invalid_args("write "); o->filename = av[0]; } diff --git a/src/tools/gui/stlink-gui.c b/src/tools/gui/stlink-gui.c index c1cf26b76..0dc8bd723 100644 --- a/src/tools/gui/stlink-gui.c +++ b/src/tools/gui/stlink-gui.c @@ -142,7 +142,7 @@ mem_view_add_as_hex (GtkListStore *store, gchar *hex_str; hex_str = g_strdup_printf ("0x%08X", value); - gtk_list_store_set (store, iter, column, hex_str, -1); + gtk_list_store_set(store, iter, column, hex_str, -1); g_free (hex_str); } @@ -439,7 +439,7 @@ static void mem_jmp (GtkTreeView *view, } } } - g_value_unset (&value); + g_value_unset(&value); } while (gtk_tree_model_iter_next (model, &iter)); } } @@ -751,10 +751,10 @@ int export_to_file(const char*filename, const struct mem_t flash_mem) { printf("%s\n", filename); FILE * f=fopen(filename, "w"); - if(f==NULL) + if (f==NULL) return -1; - for(gsize i=0;iflash_mem)!=0) + if (export_to_file (filename, gui->flash_mem)!=0) stlink_gui_set_info_error_message(gui, "Failed to export flash"); else stlink_gui_set_info_error_message(gui, "Export successful"); @@ -886,7 +886,7 @@ stlink_gui_init_dnd (STlinkGUI *gui) { "text/uri-list", 0, TARGET_FILENAME }, }; - gtk_drag_dest_set (GTK_WIDGET (gui->window), + gtk_drag_dest_set(GTK_WIDGET (gui->window), GTK_DEST_DEFAULT_ALL, target_list, G_N_ELEMENTS (target_list), diff --git a/src/usb.c b/src/usb.c index 970d3ee81..206600f14 100644 --- a/src/usb.c +++ b/src/usb.c @@ -144,7 +144,7 @@ static int fill_command unsigned char* const cmd = sl->c_buf; int i = 0; memset(cmd, 0, sizeof (sl->c_buf)); - if(slu->protocoll == 1) { + if (slu->protocoll == 1) { cmd[i++] = 'U'; cmd[i++] = 'S'; cmd[i++] = 'B'; @@ -651,7 +651,7 @@ int _stlink_usb_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { } sl->q_len = (int) size; stlink_print_data(sl); - for(i=0; i<16; i++) + for (i=0; i<16; i++) regp->r[i]= read_uint32(sl->q_buf, i*4); regp->xpsr = read_uint32(sl->q_buf, 64); regp->main_sp = read_uint32(sl->q_buf, 68); @@ -1049,7 +1049,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } if (reset) { - if( sl->version.stlink_v > 1 ) stlink_jtag_reset(sl, 2); + if ( sl->version.stlink_v > 1)stlink_jtag_reset(sl, 2); stlink_reset(sl); usleep(10000); } diff --git a/tests/flash.c b/tests/flash.c index b17aa99ae..d193666ff 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -15,12 +15,12 @@ struct Test { }; static bool cmp_strings(const char * s1, const char * s2) { - if(s1 == NULL || s2 == NULL) return (s1 == s2); + if (s1 == NULL || s2 == NULL) return (s1 == s2); else return (0 == strcmp(s1, s2)); } static bool cmp_mem(const uint8_t * s1, const uint8_t * s2, size_t size) { - if(s1 == NULL || s2 == NULL) return (s1 == s2); + if (s1 == NULL || s2 == NULL) return (s1 == s2); else return (0 == memcmp(s1, s2, size)); } @@ -36,8 +36,8 @@ static bool execute_test(const struct Test * test) { #endif strcpy(cmd_line, test->cmd_line); - for(char * tok = strtok(cmd_line, " "); tok; tok = strtok(NULL, " ")) { - if((size_t)ac >= sizeof(av)/sizeof(av[0])) return false; + for (char * tok = strtok(cmd_line, " "); tok; tok = strtok(NULL, " ")) { + if ((size_t)ac >= sizeof(av)/sizeof(av[0])) return false; av[ac] = tok; ++ac; @@ -50,7 +50,7 @@ static bool execute_test(const struct Test * test) { // compare results bool ret = (res == test->res); - if(ret && (res == 0)) { + if (ret && (res == 0)) { ret &= (opts.cmd == test->opts.cmd); ret &= cmp_strings(opts.devname, test->opts.devname); ret &= cmp_mem(opts.serial, test->opts.serial, sizeof(opts.serial)); @@ -104,8 +104,8 @@ static struct Test tests[] = { int main() { bool allOk = true; - for(size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { - if(!execute_test(&tests[i])) allOk = false; + for (size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { + if (!execute_test(&tests[i])) allOk = false; } return (allOk ? 0 : 1); From ee4a52288a68126f3c74fee7d3413fa5ee9900bd Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 6 Apr 2020 14:32:34 +0200 Subject: [PATCH 110/236] st-flash: print proper error in case of option byte read error. User could get a wrong "stlink_fread()" error in case of bad stlink_read_option_foo.. --- src/tools/flash.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tools/flash.c b/src/tools/flash.c index f39b6c6e4..6e7b37103 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -218,6 +218,10 @@ int main(int ac, char** av) printf("%x\n",option_byte); } else { printf("This format is available for STM32F2 and STM32F4 only\n"); + if (err == -1) + { + printf("could not read option bytes\n"); + goto on_error; } } else { if ((o.addr >= sl->flash_base) && (o.size == 0) && @@ -229,11 +233,12 @@ int main(int ac, char** av) o.size = sl->sram_size; } err = stlink_fread(sl, o.filename, o.format == FLASH_FORMAT_IHEX, o.addr, o.size); - } - if (err == -1) - { - printf("stlink_fread() == -1\n"); - goto on_error; + + if (err == -1) + { + printf("stlink_fread() == -1\n"); + goto on_error; + } } } From 8430a6e6fa7d507fa5a19ef2552f3ae5422aa24e Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 6 Apr 2020 14:01:35 +0200 Subject: [PATCH 111/236] add read, write option byte for g4 and g0 use g0 code, same logic with different base address. also cleanup some duplicate lock/unlock code. --- include/stlink.h | 1 + include/stm32.h | 1 + src/common.c | 57 +++++++++++++++++++++++++++-------------------- src/tools/flash.c | 9 +++++--- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index 508b50f7d..a21874454 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -236,6 +236,7 @@ typedef struct flash_loader { int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size); int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); int stlink_load_device_params(stlink_t *sl); + int stlink_read_option_bytes_Gx(stlink_t *sl, uint32_t* option_byte); int stlink_read_option_bytes_f2(stlink_t *sl, uint32_t* option_byte); int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte); diff --git a/include/stm32.h b/include/stm32.h index 9a01baaf4..890d11254 100644 --- a/include/stm32.h +++ b/include/stm32.h @@ -15,6 +15,7 @@ #define STM32_FLASH_BASE ((uint32_t)0x08000000) #define STM32_SRAM_BASE ((uint32_t)0x20000000) #define STM32_G0_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) +#define STM32_G4_OPTION_BYTES_BASE ((uint32_t)0x1FFFF800) #define STM32_L0_CAT2_OPTION_BYTES_BASE ((uint32_t)0x1FF80000) #define STM32_F2_OPTION_BYTES_BASE ((uint32_t)0x1FFFC000) #define STM32_L496X_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) diff --git a/src/common.c b/src/common.c index e94240351..332b9125d 100644 --- a/src/common.c +++ b/src/common.c @@ -2736,7 +2736,7 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { * @param base option bytes to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t len) { +static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, uint32_t len) { uint32_t val; @@ -2750,25 +2750,16 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l /* Check if chip is supported and for correct address */ if (sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1 && - sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2) { - ELOG("Option bytes writing is currently only supported for the STM32G0\n"); + sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2 && + sl->chip_id != STLINK_CHIPID_STM32_G4_CAT2 && + sl->chip_id != STLINK_CHIPID_STM32_G4_CAT3) { + ELOG("Option bytes writing is currently only supported for the STM32G0/G4\n"); return -1; } - /* Unlock flash if necessary (ref manuel page 52) */ - stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); - if ((val & (1u << STM32Gx_FLASH_CR_LOCK))) { - - /* disable flash write protection. */ - stlink_write_debug32(sl, STM32Gx_FLASH_KEYR, 0x45670123); - stlink_write_debug32(sl, STM32Gx_FLASH_KEYR, 0xCDEF89AB); - - // check that the lock is no longer set. - stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); - if ((val & (1u << STM32Gx_FLASH_CR_LOCK))) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_if(sl)) { + ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); + return -1; } /* Unlock option bytes if necessary (ref manuel page 61) */ @@ -2802,7 +2793,9 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l /* Wait for 'busy' bit in FLASH_SR to clear. */ do { stlink_read_debug32(sl, STM32Gx_FLASH_SR, &val); - } while ((val & (1 << 16)) != 0); + } while ((val & (1 << STM32Gx_FLASH_SR_BSY)) != 0); + + check_flash_error(sl); /* apply options bytes immediate */ stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); @@ -2813,10 +2806,9 @@ static int stlink_write_option_bytes_g0x(stlink_t *sl, uint8_t* base, uint32_t l stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); val |= (1u << STM32Gx_FLASH_CR_OPTLOCK); stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); + /* Re-lock flash. */ - stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); - val |= (1u << STM32Gx_FLASH_CR_LOCK); - stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); + lock_flash(sl); return 0; } @@ -3147,6 +3139,19 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint32_t option_byte) { return 0; } +/** + * Read option bytes + * @param sl + * @param option_byte value to write + * @return 0 on success, -ve on failure. + */ +int stlink_read_option_bytes_Gx(stlink_t *sl, uint32_t* option_byte) +{ + uint32_t ret = stlink_read_debug32(sl, STM32Gx_FLASH_OPTR, option_byte); + WLOG("option bytes CR = %#010x\n", *option_byte); + return ret; +} + /** * Read option bytes * @param sl @@ -3183,7 +3188,7 @@ int stlink_read_option_bytes_f2(stlink_t *sl, uint32_t* option_byte) { /** * Read option bytes * @param sl - * @param option_byte value to write + * @param option_byte value to read * @return 0 on success, -ve on failure. */ int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte) { @@ -3230,9 +3235,13 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui /* Check if chip is supported and for correct address */ if (((sl->chip_id == STLINK_CHIPID_STM32_G0_CAT1) || (sl->chip_id == STLINK_CHIPID_STM32_G0_CAT2)) && (addr == STM32_G0_OPTION_BYTES_BASE)) { - return stlink_write_option_bytes_g0x(sl, base, len); + return stlink_write_option_bytes_gx(sl, base, len); + } + else if (((sl->chip_id == STLINK_CHIPID_STM32_G4_CAT2) || + (sl->chip_id == STLINK_CHIPID_STM32_G4_CAT3)) && (addr == STM32_G4_OPTION_BYTES_BASE)) { + return stlink_write_option_bytes_gx(sl, base, len); } - else if ((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { + else if((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { return stlink_write_option_bytes_l0_cat2(sl, base, len); } else if ((sl->chip_id == STLINK_CHIPID_STM32_L496X) && (addr == STM32_L496X_OPTION_BYTES_BASE)) { diff --git a/src/tools/flash.c b/src/tools/flash.c index 6e7b37103..e211a2e81 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -208,16 +208,19 @@ int main(int ac, char** av) else /* read */ { if (o.area == FLASH_OPTION_BYTES){ + uint32_t option_byte = 0; if (sl->chip_id == STLINK_CHIPID_STM32_F2){ - uint32_t option_byte = 0; err = stlink_read_option_bytes_f2(sl,&option_byte); printf("%x\n",option_byte); } else if (sl->chip_id == STLINK_CHIPID_STM32_F446){ - uint32_t option_byte = 0; err = stlink_read_option_bytes_f4(sl,&option_byte); printf("%x\n",option_byte); + }else if(sl->flash_type == STLINK_FLASH_TYPE_G0 || sl->flash_type == STLINK_FLASH_TYPE_G4) { + err = stlink_read_option_bytes_Gx(sl,&option_byte); + printf("%x\n",option_byte); } else { - printf("This format is available for STM32F2 and STM32F4 only\n"); + printf("This format is only available for STM32F2, STM32F4, STM32G0 and STM32G4\n"); + } if (err == -1) { printf("could not read option bytes\n"); From 1801fb1f005a93756ea566cb0cdb658611982f99 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 14 Apr 2020 15:03:19 +0200 Subject: [PATCH 112/236] flash.c: move device specific read option stuff to common.c --- include/stlink.h | 9 ++++----- src/common.c | 20 ++++++++++++++++++++ src/tools/flash.c | 26 ++++++++------------------ 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index a21874454..078251cf8 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -213,8 +213,6 @@ typedef struct flash_loader { uint8_t stlink_get_erased_pattern(stlink_t *sl); int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_fwrite_option_bytes_32bit(stlink_t *sl,uint32_t val); int stlink_mwrite_sram(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); int stlink_fwrite_sram(stlink_t *sl, const char* path, stm32_addr_t addr); int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, uint32_t length); @@ -236,9 +234,10 @@ typedef struct flash_loader { int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size); int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); int stlink_load_device_params(stlink_t *sl); - int stlink_read_option_bytes_Gx(stlink_t *sl, uint32_t* option_byte); - int stlink_read_option_bytes_f2(stlink_t *sl, uint32_t* option_byte); - int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte); + + int stlink_read_option_bytes(stlink_t *sl, uint32_t* option_byte); + int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); + int stlink_fwrite_option_bytes_32bit(stlink_t *sl,uint32_t val); #include "stlink/sg.h" #include "stlink/usb.h" diff --git a/src/common.c b/src/common.c index 332b9125d..00d982593 100644 --- a/src/common.c +++ b/src/common.c @@ -3218,6 +3218,26 @@ int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte) { return 0; } +/** + * Read option bytes + * @param sl + * @param option_byte value to read + * @return 0 on success, -ve on failure. + */ +int stlink_read_option_bytes(stlink_t *sl, uint32_t* option_byte) { + int err = -1; + if (sl->chip_id == STLINK_CHIPID_STM32_F2){ + err = stlink_read_option_bytes_f2(sl, option_byte); + }else if(sl->chip_id == STLINK_CHIPID_STM32_F446){ + err = stlink_read_option_bytes_f4(sl, option_byte); + }else if(sl->flash_type == STLINK_FLASH_TYPE_G0 || sl->flash_type == STLINK_FLASH_TYPE_G4) { + err = stlink_read_option_bytes_Gx(sl, option_byte); + }else{ + ELOG("This format is only available for STM32F2, STM32F4, STM32G0 and STM32G4\n"); + } + return err; +} + /** * Write option bytes * @param sl diff --git a/src/tools/flash.c b/src/tools/flash.c index e211a2e81..06256823c 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -207,26 +207,16 @@ int main(int ac, char** av) } else /* read */ { - if (o.area == FLASH_OPTION_BYTES){ - uint32_t option_byte = 0; - if (sl->chip_id == STLINK_CHIPID_STM32_F2){ - err = stlink_read_option_bytes_f2(sl,&option_byte); + if(o.area == FLASH_OPTION_BYTES){ + uint32_t option_byte; + err = stlink_read_option_bytes(sl, &option_byte); + if (err == -1) { + printf("could not read option bytes (%d)\n", err); + goto on_error; + } else { printf("%x\n",option_byte); - } else if (sl->chip_id == STLINK_CHIPID_STM32_F446){ - err = stlink_read_option_bytes_f4(sl,&option_byte); - printf("%x\n",option_byte); - }else if(sl->flash_type == STLINK_FLASH_TYPE_G0 || sl->flash_type == STLINK_FLASH_TYPE_G4) { - err = stlink_read_option_bytes_Gx(sl,&option_byte); - printf("%x\n",option_byte); - } else { - printf("This format is only available for STM32F2, STM32F4, STM32G0 and STM32G4\n"); - } - if (err == -1) - { - printf("could not read option bytes\n"); - goto on_error; } - } else { + }else{ if ((o.addr >= sl->flash_base) && (o.size == 0) && (o.addr < sl->flash_base + sl->flash_size)){ o.size = sl->flash_size; From 2aeae8d85f74b00aeb64cfcf5c4d644f8fbecf08 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 14 Apr 2020 16:30:58 +0200 Subject: [PATCH 113/236] chipid: add option bytes info to chip db --- include/stlink.h | 4 ++++ include/stlink/chipid.h | 2 ++ src/common.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/include/stlink.h b/include/stlink.h index 078251cf8..f22abbb42 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -170,6 +170,10 @@ typedef struct flash_loader { stm32_addr_t sram_base; // STM32_SRAM_BASE, set by stlink_load_device_params() size_t sram_size; // stlink_chipid_params.sram_size, set by stlink_load_device_params() + /* option settings */ + stm32_addr_t option_base; + size_t option_size; + // 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) diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index d23596c0d..64227962b 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -79,6 +79,8 @@ struct stlink_chipid_params { uint32_t sram_size; uint32_t bootrom_base; uint32_t bootrom_size; + uint32_t option_base; + uint32_t option_size; }; const struct stlink_chipid_params *stlink_chipid_get_params(uint32_t chipid); diff --git a/src/common.c b/src/common.c index 00d982593..4525d0222 100644 --- a/src/common.c +++ b/src/common.c @@ -920,6 +920,8 @@ int stlink_load_device_params(stlink_t *sl) { sl->sram_size = params->sram_size; sl->sys_base = params->bootrom_base; sl->sys_size = params->bootrom_size; + sl->option_base = params->option_base; + sl->option_size = params->option_size; //medium and low devices have the same chipid. ram size depends on flash size. //STM32F100xx datasheet Doc ID 16455 Table 2 From 92ceb7f35a667637b574924be9d43f70e6073eb3 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 14 Apr 2020 16:33:15 +0200 Subject: [PATCH 114/236] chipid: insert data for supported chips, from common.c --- src/chipid.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/chipid.c b/src/chipid.c index b9d3933f0..5d43c3ab0 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -175,7 +175,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x100, .sram_size = 0xC000, /*Not completely clear if there are some with 32K*/ .bootrom_base = 0x1ff00000, - .bootrom_size = 0x1000 + .bootrom_size = 0x1000, + .option_base = STM32_L1_OPTION_BYTES_BASE, + .option_size = 8, }, { .chip_id = STLINK_CHIPID_STM32_L152_RE, @@ -400,7 +402,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x80, .sram_size = 0x2000, .bootrom_base = 0x1ff0000, - .bootrom_size = 0x1000 + .bootrom_size = 0x1000, + .option_base = STM32_L0_CAT2_OPTION_BYTES_BASE, + .option_size = 4, }, { // STM32F334, STM32F303x6/8, and STM32F328 @@ -494,7 +498,9 @@ static const struct stlink_chipid_params devices[] = { // SRAM2 is 64k at 0x20040000 (sec 2.2.1, fig 2, page 74) .sram_size = 0x40000, // Embedded SRAM (sec 2.4, page 84) .bootrom_base = 0x1fff0000, // System Memory (Bank 1) (sec 3.3.1) - .bootrom_size = 0x7000 // 28k (per bank), same source as base + .bootrom_size = 0x7000, // 28k (per bank), same source as base + .option_base = STM32_L496X_OPTION_BYTES_BASE, + .option_size = 4, }, { // STLINK_CHIPID_STM32_L46X @@ -530,7 +536,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x800, // 2K (sec 3.2) .sram_size = 0x2000, // 8K (sec 2.3) .bootrom_base = 0x1fff0000, - .bootrom_size = 0x2000 // 8K (sec 2.2.2 table 3) + .bootrom_size = 0x2000, // 8K (sec 2.2.2 table 3) + .option_base = STM32_G4_OPTION_BYTES_BASE, + .option_size = 4, }, { // STM32G071/081 (from RM0444) @@ -541,7 +549,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x800, // 2K (sec 3.2) .sram_size = 0x9000, // 36K (sec 2.3) .bootrom_base = 0x1fff0000, - .bootrom_size = 0x7000 // 28K (sec 2.2.2 table 2) + .bootrom_size = 0x7000, // 28K (sec 2.2.2 table 2) + .option_base = STM32_G0_OPTION_BYTES_BASE, + .option_size = 4, }, { // STM32G431/441 (from RM0440) @@ -555,7 +565,10 @@ static const struct stlink_chipid_params devices[] = { // SRAM3/CCM is 10k at 0x10000000, aliased at 0x20018000 .sram_size = 0x8000, // 32K (sec 2.4) .bootrom_base = 0x1fff0000, - .bootrom_size = 0x7000 // 28K (table 2) + .bootrom_size = 0x7000, // 28K (table 2) + .option_base = STM32_G4_OPTION_BYTES_BASE, + .option_size = 4*4, + }, { // STM32G471/473/474/483/484 (from RM0440) @@ -570,7 +583,9 @@ static const struct stlink_chipid_params devices[] = { // SRAM3/CCM is 32k at 0x10000000, aliased at 0x20018000 .sram_size = 0x18000, // 128K (sec 2.4) .bootrom_base = 0x1fff0000, - .bootrom_size = 0x7000 // 28K (table 2) + .bootrom_size = 0x7000, // 28K (table 2) + .option_base = STM32_G4_OPTION_BYTES_BASE, + .option_size = 4*4, }, { // STM32WB55 (from RM0434) From 6f0795d931500d556420e27e2d62683a336c1fd2 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 14 Apr 2020 17:35:15 +0200 Subject: [PATCH 115/236] chipid: add some l0 and l4 option info to allow option byte read --- include/stlink/chipid.h | 2 +- include/stm32.h | 4 ++-- src/chipid.c | 26 +++++++++++++++++--------- src/common.c | 2 +- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/stlink/chipid.h b/include/stlink/chipid.h index 64227962b..98164a8fc 100644 --- a/include/stlink/chipid.h +++ b/include/stlink/chipid.h @@ -57,7 +57,7 @@ enum stlink_stm32_chipids { STLINK_CHIPID_STM32_F72XXX = 0x452, /* This ID is found on the NucleoF722ZE board */ STLINK_CHIPID_STM32_L011 = 0x457, STLINK_CHIPID_STM32_F410 = 0x458, - STLINK_CHIPID_STM32_G0_CAT2 = 0x460, /* G070/G071/081 */ + STLINK_CHIPID_STM32_G0_CAT2 = 0x460, /* G070/G071/081 */ STLINK_CHIPID_STM32_F413 = 0x463, STLINK_CHIPID_STM32_G0_CAT1 = 0x466, /* G030/G031/041 */ STLINK_CHIPID_STM32_G4_CAT2 = 0x468, /* See: RM 0440 s46.6.1 "MCU device ID code" */ diff --git a/include/stm32.h b/include/stm32.h index 890d11254..c71718653 100644 --- a/include/stm32.h +++ b/include/stm32.h @@ -16,9 +16,9 @@ #define STM32_SRAM_BASE ((uint32_t)0x20000000) #define STM32_G0_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) #define STM32_G4_OPTION_BYTES_BASE ((uint32_t)0x1FFFF800) -#define STM32_L0_CAT2_OPTION_BYTES_BASE ((uint32_t)0x1FF80000) +#define STM32_L0_CATx_OPTION_BYTES_BASE ((uint32_t)0x1FF80000) #define STM32_F2_OPTION_BYTES_BASE ((uint32_t)0x1FFFC000) -#define STM32_L496X_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) +#define STM32_L4_OPTION_BYTES_BASE ((uint32_t)0x1FFF7800) #define STM32_L1_OPTION_BYTES_BASE ((uint32_t)0x1FF80000) #endif /* STM32_H */ diff --git a/src/chipid.c b/src/chipid.c index 5d43c3ab0..bc3d37567 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -378,7 +378,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x80, .sram_size = 0x2000, .bootrom_base = 0x1ff0000, - .bootrom_size = 0x1000 + .bootrom_size = 0x1000, + .option_base = STM32_L0_CATx_OPTION_BYTES_BASE, + .option_size = 4, }, { // STM32L0x Category 5 @@ -390,7 +392,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x80, .sram_size = 0x5000, .bootrom_base = 0x1ff0000, - .bootrom_size = 0x2000 + .bootrom_size = 0x2000, + .option_base = STM32_L0_CATx_OPTION_BYTES_BASE, + .option_size = 4, }, { // STM32L0x Category 2 @@ -403,7 +407,7 @@ static const struct stlink_chipid_params devices[] = { .sram_size = 0x2000, .bootrom_base = 0x1ff0000, .bootrom_size = 0x1000, - .option_base = STM32_L0_CAT2_OPTION_BYTES_BASE, + .option_base = STM32_L0_CATx_OPTION_BYTES_BASE, .option_size = 4, }, { @@ -443,7 +447,9 @@ static const struct stlink_chipid_params devices[] = { // sizes; table 2, page 74 for SRAM2 location) .sram_size = 0x18000, .bootrom_base = 0x1fff0000, // Tables 4-6, pages 80-81 (Bank 1 system memory) - .bootrom_size = 0x7000 // 28k (per bank), same source as base + .bootrom_size = 0x7000, // 28k (per bank), same source as base + .option_base = STM32_L4_OPTION_BYTES_BASE, + .option_size = 4, }, { // STM32L4RX @@ -484,7 +490,9 @@ static const struct stlink_chipid_params devices[] = { // sizes; table 2, page 74 for SRAM2 location) .sram_size = 0xc000, .bootrom_base = 0x1fff0000, // Tables 4-6, pages 80-81 (Bank 1 system memory) - .bootrom_size = 0x7000 // 28k (per bank), same source as base + .bootrom_size = 0x7000, // 28k (per bank), same source as base + .option_base = STM32_L4_OPTION_BYTES_BASE, + .option_size = 4, }, { // STLINK_CHIPID_STM32_L496X @@ -499,7 +507,7 @@ static const struct stlink_chipid_params devices[] = { .sram_size = 0x40000, // Embedded SRAM (sec 2.4, page 84) .bootrom_base = 0x1fff0000, // System Memory (Bank 1) (sec 3.3.1) .bootrom_size = 0x7000, // 28k (per bank), same source as base - .option_base = STM32_L496X_OPTION_BYTES_BASE, + .option_base = STM32_L4_OPTION_BYTES_BASE, .option_size = 4, }, { @@ -537,8 +545,8 @@ static const struct stlink_chipid_params devices[] = { .sram_size = 0x2000, // 8K (sec 2.3) .bootrom_base = 0x1fff0000, .bootrom_size = 0x2000, // 8K (sec 2.2.2 table 3) - .option_base = STM32_G4_OPTION_BYTES_BASE, - .option_size = 4, + .option_base = STM32_G0_OPTION_BYTES_BASE, + .option_size = 8*4, }, { // STM32G071/081 (from RM0444) @@ -551,7 +559,7 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000, // 28K (sec 2.2.2 table 2) .option_base = STM32_G0_OPTION_BYTES_BASE, - .option_size = 4, + .option_size = 8*4, }, { // STM32G431/441 (from RM0440) diff --git a/src/common.c b/src/common.c index 4525d0222..351c74497 100644 --- a/src/common.c +++ b/src/common.c @@ -2863,7 +2863,7 @@ static int stlink_write_option_bytes_l0_cat2(stlink_t *sl, uint8_t* base, uint32 uint32_t data; write_uint32((unsigned char*) &data, *(uint32_t*) (base)); WLOG("Writing option bytes 0x%04x\n", data); - stlink_write_debug32(sl, STM32_L0_CAT2_OPTION_BYTES_BASE, data); + stlink_write_debug32(sl, STM32_L0_CATx_OPTION_BYTES_BASE, data); /* Reload options */ stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); From 72cfd5ee20658cbd9a4cefd01e0099b461018822 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 14 Apr 2020 15:32:47 +0200 Subject: [PATCH 116/236] option: refactor option flash code. unify option bytes read/write, interface, use chipid db to store size and base to provide some write sanity check and generic option read code. --- include/stlink.h | 6 +- src/chipid.c | 8 +- src/common.c | 195 +++++++++++++++++++++++++--------------------- src/tools/flash.c | 12 +-- 4 files changed, 119 insertions(+), 102 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index f22abbb42..db737acb0 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -239,9 +239,11 @@ typedef struct flash_loader { int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); int stlink_load_device_params(stlink_t *sl); - int stlink_read_option_bytes(stlink_t *sl, uint32_t* option_byte); + int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte); + int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte); + + int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len); int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_fwrite_option_bytes_32bit(stlink_t *sl,uint32_t val); #include "stlink/sg.h" #include "stlink/usb.h" diff --git a/src/chipid.c b/src/chipid.c index bc3d37567..60d0787e9 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -546,7 +546,7 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x2000, // 8K (sec 2.2.2 table 3) .option_base = STM32_G0_OPTION_BYTES_BASE, - .option_size = 8*4, + .option_size = 4, }, { // STM32G071/081 (from RM0444) @@ -559,7 +559,7 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000, // 28K (sec 2.2.2 table 2) .option_base = STM32_G0_OPTION_BYTES_BASE, - .option_size = 8*4, + .option_size = 4, }, { // STM32G431/441 (from RM0440) @@ -575,7 +575,7 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000, // 28K (table 2) .option_base = STM32_G4_OPTION_BYTES_BASE, - .option_size = 4*4, + .option_size = 4, }, { @@ -593,7 +593,7 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x1fff0000, .bootrom_size = 0x7000, // 28K (table 2) .option_base = STM32_G4_OPTION_BYTES_BASE, - .option_size = 4*4, + .option_size = 4, }, { // STM32WB55 (from RM0434) diff --git a/src/common.c b/src/common.c index 351c74497..66d21b2b4 100644 --- a/src/common.c +++ b/src/common.c @@ -2738,26 +2738,12 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { * @param base option bytes to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, uint32_t len) { +static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; - if (len != 4) { - ELOG("Wrong length for writing option bytes, must be 4 is %d\n", len); - return -1; - } - - // Make sure we've loaded the context with the chip details - stlink_core_id(sl); - - /* Check if chip is supported and for correct address */ - if (sl->chip_id != STLINK_CHIPID_STM32_G0_CAT1 && - sl->chip_id != STLINK_CHIPID_STM32_G0_CAT2 && - sl->chip_id != STLINK_CHIPID_STM32_G4_CAT2 && - sl->chip_id != STLINK_CHIPID_STM32_G4_CAT3) { - ELOG("Option bytes writing is currently only supported for the STM32G0/G4\n"); - return -1; - } + (void) addr; + (void) len; if (unlock_flash_if(sl)) { ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); @@ -2783,7 +2769,7 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, uint32_t le /* Write options bytes */ uint32_t data; write_uint32((unsigned char*) &data, *(uint32_t*) (base)); - WLOG("Writing option bytes 0x%04x\n", data); + WLOG("Writing option bytes %#10x to %#10x\n", data, addr); //stlink_write_debug32(sl, addr, data); stlink_write_debug32(sl, STM32Gx_FLASH_OPTR, data); @@ -2823,14 +2809,12 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, uint32_t le * @param base option bytes to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_l0_cat2(stlink_t *sl, uint8_t* base, uint32_t len) { +static int stlink_write_option_bytes_l0_cat2(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; + (void) addr; + (void) len; - if (len != 4) { - ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); - return -1; - } stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); if (val & STM32L0_FLASH_PELOCK_BIT) { WLOG("Unlocking flash\n"); @@ -2885,10 +2869,6 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ uint32_t val; uint32_t data; - if (len != 4 && len != 8) { - ELOG("Wrong length for writting option bytes, must be 4 or 8 is %d\n", len); - return -1; - } stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); if (val & STM32L1_FLASH_PELOCK_BIT) { WLOG("Unlocking flash\n"); @@ -2966,14 +2946,12 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ * @param base option bytes to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, uint32_t len) { +static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; - if (len != 4) { - ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); - return -1; - } + (void) addr; + (void) len; /* Unlock flash if necessary */ stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); @@ -3047,8 +3025,18 @@ static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, uint32_t * @param option_byte value to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_f2(stlink_t *sl, uint32_t option_byte) { +static int stlink_write_option_bytes_f2(stlink_t *sl, uint8_t *base, stm32_addr_t addr, size_t len) { uint32_t val; + uint32_t option_byte; + + (void) addr; /* todo: add sanitary check */ + + if(len != 4) { + ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); + return -1; + } + + option_byte = *(uint32_t*) (base); stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); if (val & FLASH_F2_OPT_LOCK_BIT) { @@ -3097,8 +3085,18 @@ static int stlink_write_option_bytes_f2(stlink_t *sl, uint32_t option_byte) { * @param option_byte value to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_f4(stlink_t *sl, uint32_t option_byte) { +static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; + uint32_t option_byte; + + (void) addr; /* todo: add sanitary check */ + + if(len != 4) { + ELOG("Wrong length for writing option bytes, must be 4 is %d\n", len); + return -1; + } + + option_byte = *(uint32_t*) (base); stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); if (val & FLASH_F4_OPT_LOCK_BIT) { @@ -3219,25 +3217,54 @@ int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte) { return 0; } +/** +* Read first option bytes +* @param sl +* @param option_byte option value +* @return 0 on success, -ve on failure. +*/ +int stlink_read_option_bytes_generic(stlink_t *sl, uint32_t* option_byte) +{ + return stlink_read_debug32(sl, sl->option_base, option_byte); +} /** * Read option bytes * @param sl - * @param option_byte value to read + * @param option_byte option value * @return 0 on success, -ve on failure. */ -int stlink_read_option_bytes(stlink_t *sl, uint32_t* option_byte) { - int err = -1; - if (sl->chip_id == STLINK_CHIPID_STM32_F2){ - err = stlink_read_option_bytes_f2(sl, option_byte); - }else if(sl->chip_id == STLINK_CHIPID_STM32_F446){ - err = stlink_read_option_bytes_f4(sl, option_byte); - }else if(sl->flash_type == STLINK_FLASH_TYPE_G0 || sl->flash_type == STLINK_FLASH_TYPE_G4) { - err = stlink_read_option_bytes_Gx(sl, option_byte); - }else{ - ELOG("This format is only available for STM32F2, STM32F4, STM32G0 and STM32G4\n"); +int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte) +{ + if (sl->option_base == 0) { + ELOG("Option bytes read is currently not supported for connected chip\n"); + return -1; + } + switch (sl->chip_id) { + case STLINK_CHIPID_STM32_F2: + return stlink_read_option_bytes_f2(sl, option_byte); + case STLINK_CHIPID_STM32_F446: + return stlink_read_option_bytes_f4(sl, option_byte); + case STLINK_CHIPID_STM32_G0_CAT1: + case STLINK_CHIPID_STM32_G0_CAT2: + case STLINK_CHIPID_STM32_G4_CAT2: + case STLINK_CHIPID_STM32_G4_CAT3: + return stlink_read_option_bytes_Gx(sl, option_byte); + default: + return stlink_read_option_bytes_generic(sl, option_byte); } - return err; +} + +/** + * Write option bytes + * @param sl + * @param option_byte value to write + * @return 0 on success, -ve on failure. + */ +int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte) +{ + WLOG("About to write option byte %#10x to target.\n", option_byte); + return stlink_write_option_bytes(sl, sl->option_base, (uint8_t *) &option_byte, 4); } /** @@ -3247,34 +3274,42 @@ int stlink_read_option_bytes(stlink_t *sl, uint32_t* option_byte) { * @param base option bytes to write * @return 0 on success, -ve on failure. */ -int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len) { +int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len) +{ + if (sl->option_base == 0) { + ELOG("Option bytes writing is currently not supported for connected chip\n"); + return -1; + } - // Make sure we've loaded the context with the chip details - stlink_core_id(sl); + if ((addr < sl->option_base) || addr > sl->option_base + sl->option_size) { + ELOG("Option bytes start address out of Option bytes range\n"); + return -1; + } - WLOG("Option bytes write chip_id 0x%08x addr 0x%08x\n",sl->chip_id,addr); + if (addr + len > sl->option_base + sl->option_size) { + ELOG("Option bytes data too long\n"); + return -1; + } - /* Check if chip is supported and for correct address */ - if (((sl->chip_id == STLINK_CHIPID_STM32_G0_CAT1) || - (sl->chip_id == STLINK_CHIPID_STM32_G0_CAT2)) && (addr == STM32_G0_OPTION_BYTES_BASE)) { - return stlink_write_option_bytes_gx(sl, base, len); - } - else if (((sl->chip_id == STLINK_CHIPID_STM32_G4_CAT2) || - (sl->chip_id == STLINK_CHIPID_STM32_G4_CAT3)) && (addr == STM32_G4_OPTION_BYTES_BASE)) { - return stlink_write_option_bytes_gx(sl, base, len); - } - else if((sl->chip_id == STLINK_CHIPID_STM32_L0_CAT2) && (addr == STM32_L0_CAT2_OPTION_BYTES_BASE)) { - return stlink_write_option_bytes_l0_cat2(sl, base, len); - } - else if ((sl->chip_id == STLINK_CHIPID_STM32_L496X) && (addr == STM32_L496X_OPTION_BYTES_BASE)) { - return stlink_write_option_bytes_l496x(sl, base, len); - } - else if (((sl->chip_id == STLINK_CHIPID_STM32_L152_RE) || (sl->chip_id == STLINK_CHIPID_STM32_L1_HIGH) ) && - ((addr == STM32_L1_OPTION_BYTES_BASE) || (addr == STM32_L1_OPTION_BYTES_BASE+4))) { + switch (sl->chip_id) { + case STLINK_CHIPID_STM32_F2: + return stlink_write_option_bytes_f2(sl, base, addr, len); + case STLINK_CHIPID_STM32_F446: + return stlink_write_option_bytes_f4(sl, base, addr, len); + case STLINK_CHIPID_STM32_L0_CAT2: + return stlink_write_option_bytes_l0_cat2(sl, base, addr, len); + case STLINK_CHIPID_STM32_L496X: + return stlink_write_option_bytes_l496x(sl, base, addr, len); + case STLINK_CHIPID_STM32_L152_RE: + case STLINK_CHIPID_STM32_L1_HIGH: return stlink_write_option_bytes_l1(sl, base, addr, len); - } - else { - ELOG("Option bytes writing is currently only supported for the STM32F2, STM32G0, STM32L496x/L4A6x, STM32L1 and STM32L0\n"); + case STLINK_CHIPID_STM32_G0_CAT1: + case STLINK_CHIPID_STM32_G0_CAT2: + case STLINK_CHIPID_STM32_G4_CAT2: + case STLINK_CHIPID_STM32_G4_CAT3: + return stlink_write_option_bytes_gx(sl, base, addr, len); + default: + ELOG("Option bytes writing is currently not implemented for connected chip\n"); return -1; } @@ -3306,23 +3341,3 @@ int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr unmap_file(&mf); return err; } - -/** - * Write the given 32-bit value with option byte - * @param sl - * @param option_byte value to write - * @return 0 on success, -ve on failure. - */ -int stlink_fwrite_option_bytes_32bit(stlink_t *sl, uint32_t val) { - - if (sl->chip_id == STLINK_CHIPID_STM32_F2){ - return stlink_write_option_bytes_f2(sl, val); - } else if (sl->chip_id == STLINK_CHIPID_STM32_F446){ - return stlink_write_option_bytes_f4(sl, val); - } - else - { - ELOG("Option bytes writing is currently only supported for the STM32F2, STM32F4, STM32G0 and STM32L0\n"); - return -1; - } -} diff --git a/src/tools/flash.c b/src/tools/flash.c index 06256823c..20fbacd9a 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -160,9 +160,8 @@ int main(int ac, char** av) goto on_error; } } - else if (o.addr == STM32_G0_OPTION_BYTES_BASE || - o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE || - o.addr == STM32_L0_CAT2_OPTION_BYTES_BASE + 4){ + else if ((o.addr >= sl->option_base) && + (o.addr < sl->option_base + sl->option_size)) { err = stlink_fwrite_option_bytes(sl, o.filename, o.addr); if (err == -1) { @@ -171,10 +170,11 @@ int main(int ac, char** av) } } else if (o.area == FLASH_OPTION_BYTES){ - err = stlink_fwrite_option_bytes_32bit(sl, o.val); + // XXX some sanity check should be done here to check o.val parsing. + err = stlink_write_option_bytes32(sl, o.val); if (err == -1) { - printf("stlink_fwrite_option_bytes() == -1\n"); + printf("stlink_write_option_bytes32() == -1\n"); goto on_error; } } @@ -209,7 +209,7 @@ int main(int ac, char** av) { if(o.area == FLASH_OPTION_BYTES){ uint32_t option_byte; - err = stlink_read_option_bytes(sl, &option_byte); + err = stlink_read_option_bytes32(sl, &option_byte); if (err == -1) { printf("could not read option bytes (%d)\n", err); goto on_error; From e146a28a67cdfea1d4e9b5bf76471e05fe692494 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 14 Apr 2020 19:01:05 +0200 Subject: [PATCH 117/236] st-flash: add sanity check to option flash. current opt parse code can make bad cmdline parameter attempt to flash bad flash option. ie: calling st-flash write --area=option a_file.bin will make parser attempt to translate "a_file.bon" to an uint32 and will return 0.., --- src/tools/flash.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/flash.c b/src/tools/flash.c index 20fbacd9a..e91001659 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -170,7 +170,11 @@ int main(int ac, char** av) } } else if (o.area == FLASH_OPTION_BYTES){ - // XXX some sanity check should be done here to check o.val parsing. + if (o.val == 0) { + printf("attempting to set option byte to 0, abort.\n"); + goto on_error; + } + err = stlink_write_option_bytes32(sl, o.val); if (err == -1) { From 3aaec273da217faf54601c02480ce990baa09894 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Thu, 16 Apr 2020 15:12:40 +0200 Subject: [PATCH 118/236] common.c: fix define - use Gx Base for Gx defines avoid some potential issues later. --- src/common.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common.c b/src/common.c index 66d21b2b4..0ccdeccdb 100644 --- a/src/common.c +++ b/src/common.c @@ -79,13 +79,13 @@ // Flash registers common to STM32G0 and STM32G4 series. #define STM32Gx_FLASH_REGS_ADDR ((uint32_t)0x40022000) -#define STM32Gx_FLASH_ACR (STM32G0_FLASH_REGS_ADDR + 0x00) -#define STM32Gx_FLASH_KEYR (STM32G0_FLASH_REGS_ADDR + 0x08) -#define STM32Gx_FLASH_OPTKEYR (STM32G0_FLASH_REGS_ADDR + 0x0c) -#define STM32Gx_FLASH_SR (STM32G0_FLASH_REGS_ADDR + 0x10) -#define STM32Gx_FLASH_CR (STM32G0_FLASH_REGS_ADDR + 0x14) -#define STM32Gx_FLASH_ECCR (STM32G0_FLASH_REGS_ADDR + 0x18) -#define STM32Gx_FLASH_OPTR (STM32G0_FLASH_REGS_ADDR + 0x20) +#define STM32Gx_FLASH_ACR (STM32Gx_FLASH_REGS_ADDR + 0x00) +#define STM32Gx_FLASH_KEYR (STM32Gx_FLASH_REGS_ADDR + 0x08) +#define STM32Gx_FLASH_OPTKEYR (STM32Gx_FLASH_REGS_ADDR + 0x0c) +#define STM32Gx_FLASH_SR (STM32Gx_FLASH_REGS_ADDR + 0x10) +#define STM32Gx_FLASH_CR (STM32Gx_FLASH_REGS_ADDR + 0x14) +#define STM32Gx_FLASH_ECCR (STM32Gx_FLASH_REGS_ADDR + 0x18) +#define STM32Gx_FLASH_OPTR (STM32Gx_FLASH_REGS_ADDR + 0x20) // G0 (RM0444 Table 1, sec 3.7) // Mostly the same as G4 chips, but the notation From 977576215e64b9b138fff890f8fbf52d17572e4d Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 16 Apr 2020 21:00:30 +0200 Subject: [PATCH 119/236] Partial project restructuring - Updated travis CI build config - Refactoring of cmake build config - Alligned coding style for GUI - Whitespace cleanup for GUI - Moved source code for GUI --- .travis.sh | 13 +- .travis.yml | 24 +- CMakeLists.txt | 48 +- cmake/c_flag_overrides.cmake | 7 - {usr/lib => debian}/pkgconfig/CMakeLists.txt | 0 .../pkgconfig/pkg-config.pc.cmake | 0 src/{tools/gui => stlink-gui}/CMakeLists.txt | 21 +- .../gui/stlink-gui.c => stlink-gui/gui.c} | 625 +++++++----------- .../gui/stlink-gui.h => stlink-gui/gui.h} | 6 +- .../gui/stlink-gui.ui => stlink-gui/gui.ui} | 0 src/stlink-gui/icons/export-icons.sh | 40 ++ .../hicolor/128x128/apps/stlink-gui.png | Bin .../icons}/hicolor/16x16/apps/stlink-gui.png | Bin .../icons}/hicolor/22x22/apps/stlink-gui.png | Bin .../icons}/hicolor/24x24/apps/stlink-gui.png | Bin .../hicolor/256x256/apps/stlink-gui.png | Bin .../icons}/hicolor/32x32/apps/stlink-gui.png | Bin .../icons}/hicolor/48x48/apps/stlink-gui.png | Bin .../icons}/hicolor/64x64/apps/stlink-gui.png | Bin .../art => stlink-gui/icons}/stlink-gui.png | Bin .../art => stlink-gui/icons}/stlink-gui.svg | 0 .../art => stlink-gui/icons}/stlink-gui.xpm | 0 .../icons}/stlink-gui_48.png | Bin .../gui => stlink-gui}/stlink-gui.desktop | 0 src/tools/gui/art/export-icons.sh | 38 -- 25 files changed, 324 insertions(+), 498 deletions(-) delete mode 100644 cmake/c_flag_overrides.cmake rename {usr/lib => debian}/pkgconfig/CMakeLists.txt (100%) rename {usr/lib => debian}/pkgconfig/pkg-config.pc.cmake (100%) rename src/{tools/gui => stlink-gui}/CMakeLists.txt (55%) rename src/{tools/gui/stlink-gui.c => stlink-gui/gui.c} (62%) rename src/{tools/gui/stlink-gui.h => stlink-gui/gui.h} (98%) rename src/{tools/gui/stlink-gui.ui => stlink-gui/gui.ui} (100%) create mode 100644 src/stlink-gui/icons/export-icons.sh rename src/{tools/gui/art => stlink-gui/icons}/hicolor/128x128/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/16x16/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/22x22/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/24x24/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/256x256/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/32x32/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/48x48/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/hicolor/64x64/apps/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/stlink-gui.png (100%) rename src/{tools/gui/art => stlink-gui/icons}/stlink-gui.svg (100%) rename src/{tools/gui/art => stlink-gui/icons}/stlink-gui.xpm (100%) rename src/{tools/gui/art => stlink-gui/icons}/stlink-gui_48.png (100%) rename src/{tools/gui => stlink-gui}/stlink-gui.desktop (100%) delete mode 100755 src/tools/gui/art/export-icons.sh diff --git a/.travis.sh b/.travis.sh index 3d6da055f..5291ec95b 100755 --- a/.travis.sh +++ b/.travis.sh @@ -24,13 +24,12 @@ if [ "$TRAVIS_OS_NAME" == "linux" ]; then cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ make && make package && cd - - echo "--> Building Binary..." - mkdir -p build/Binary && cd build/Binary - cho "-DCMAKE_BUILD_TYPE=Binary -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Binary -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ - make && make package && cd - - -else #("$TRAVIS_OS_NAME" == "osx") +# echo "--> Building Binary..." +# mkdir -p build/Binary && cd build/Binary +# cho "-DCMAKE_BUILD_TYPE=Binary -DCMAKE_INSTALL_PREFIX=$PWD/_install" +# cmake -DCMAKE_BUILD_TYPE=Binary -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ +# make && make package && cd - +else [ "$TRAVIS_OS_NAME" == "osx" ]; brew install libusb echo "--> Building Debug..." diff --git a/.travis.yml b/.travis.yml index 221e8ece7..542a25d98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,14 +38,14 @@ matrix: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] packages: ['clang-6.0', 'libusb-1.0.0-dev'] - - os: linux - arch: x64 - compiler: clang-6.0 - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] - packages: ['clang-6.0', 'libusb-1.0.0-dev'] - env: CFLAGS=-m32 LDFLAGS=-m32 +# - os: linux +# arch: x64 +# compiler: clang-6.0 +# addons: +# apt: +# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] +# packages: ['clang-6.0', 'libusb-1.0.0-dev'] +# env: CFLAGS=-m32 LDFLAGS=-m32 ### 32-bit builds ### - os: linux @@ -57,18 +57,18 @@ matrix: packages: ['gcc-5', 'libusb-1.0.0-dev'] - os: linux arch: x86 - compiler: gcc-6 + compiler: gcc-7 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-6', 'libusb-1.0.0-dev'] + packages: ['gcc-7', 'libusb-1.0.0-dev'] - os: linux arch: x86 - compiler: gcc-7 + compiler: gcc-9 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev'] + packages: ['gcc-9', 'libusb-1.0.0-dev'] - os: linux arch: x86 compiler: clang-3.7 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3572c2a15..87bd47aac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,24 @@ cmake_minimum_required(VERSION 3.4.2) -set(CMAKE_USER_MAKE_RULES_OVERRIDE cmake/c_flag_overrides.cmake) +cmake_policy(SET CMP0042 NEW) +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") +include(GNUInstallDirs) project(stlink C) 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") -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) +option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) +option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) +option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) + +# ==== + +#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") @@ -28,17 +36,16 @@ else () set(STLINK_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}") 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) - -# 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/c_flags.cmake) +else () + 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_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") endif () @@ -207,16 +214,13 @@ endif () ### 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 () - target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB}) -endif () - add_executable(st-info src/tools/info.c) + if (WIN32 OR APPLE) + target_link_libraries(st-flash ${STLINK_LIB_STATIC} ${SSP_LIB}) target_link_libraries(st-info ${STLINK_LIB_STATIC} ${SSP_LIB}) else () + target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB}) target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB}) endif () @@ -233,14 +237,14 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") endif () add_subdirectory(src/gdbserver) -add_subdirectory(src/tools/gui) +add_subdirectory(src/stlink-gui) ### # Others ### -add_subdirectory(usr/lib/pkgconfig) +add_subdirectory(debian/pkgconfig) add_subdirectory(include) add_subdirectory(doc/man) add_subdirectory(tests) @@ -248,6 +252,8 @@ add_subdirectory(tests) include(cmake/cpack_config.cmake) include(CPack) +# ==== + ### # Uninstall target diff --git a/cmake/c_flag_overrides.cmake b/cmake/c_flag_overrides.cmake deleted file mode 100644 index 1a1d163fb..000000000 --- a/cmake/c_flag_overrides.cmake +++ /dev/null @@ -1,7 +0,0 @@ -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_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") -endif () diff --git a/usr/lib/pkgconfig/CMakeLists.txt b/debian/pkgconfig/CMakeLists.txt similarity index 100% rename from usr/lib/pkgconfig/CMakeLists.txt rename to debian/pkgconfig/CMakeLists.txt diff --git a/usr/lib/pkgconfig/pkg-config.pc.cmake b/debian/pkgconfig/pkg-config.pc.cmake similarity index 100% rename from usr/lib/pkgconfig/pkg-config.pc.cmake rename to debian/pkgconfig/pkg-config.pc.cmake diff --git a/src/tools/gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt similarity index 55% rename from src/tools/gui/CMakeLists.txt rename to src/stlink-gui/CMakeLists.txt index d7add834b..bb6465481 100644 --- a/src/tools/gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -3,32 +3,31 @@ if (NOT gtk_FOUND) return() endif () -set(GUI_SOURCES stlink-gui.c stlink-gui.h) -set(INSTALLED_UI_DIR share/stlink) +set(GUI_SOURCES gui.c gui.h) +set(INSTALLED_UI_DIR share/stlink) ### TODO: Check Path include_directories(SYSTEM ${gtk_INCLUDE_DIRS}) +# stlink-gui-local add_executable(stlink-gui-local ${GUI_SOURCES}) set_target_properties( stlink-gui-local PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}" ### TODO: Check Path ) target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${gtk_LDFLAGS} ${SSP_LIB}) - +# stlink-gui add_executable(stlink-gui ${GUI_SOURCES}) set_target_properties( stlink-gui PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}" + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}" ### TODO: Check Path ) 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) ### TODO: Check Path +install(FILES gui.ui DESTINATION ${INSTALLED_UI_DIR}) ### TODO: Check Path if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - # Install desktop entry - install(FILES stlink-gui.desktop DESTINATION share/applications) - # Install icon - install(FILES art/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps) + install(FILES stlink-gui.desktop DESTINATION share/applications) # Install desktop entry + install(FILES icons/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps) # Install icon endif () diff --git a/src/tools/gui/stlink-gui.c b/src/stlink-gui/gui.c similarity index 62% rename from src/tools/gui/stlink-gui.c rename to src/stlink-gui/gui.c index 0dc8bd723..f90196c06 100644 --- a/src/tools/gui/stlink-gui.c +++ b/src/stlink-gui/gui.c @@ -1,11 +1,11 @@ -#include -#include #include +#include +#include #include #include #include -#include "stlink-gui.h" +#include "gui.h" #define MEM_READ_SIZE 1024 @@ -15,30 +15,21 @@ G_DEFINE_TYPE (STlinkGUI, stlink_gui, G_TYPE_OBJECT); -static void -stlink_gui_dispose (GObject *gobject) -{ +static void stlink_gui_dispose (GObject *gobject) { G_OBJECT_CLASS (stlink_gui_parent_class)->dispose (gobject); } -static void -stlink_gui_finalize (GObject *gobject) -{ +static void stlink_gui_finalize (GObject *gobject) { G_OBJECT_CLASS (stlink_gui_parent_class)->finalize (gobject); } -static void -stlink_gui_class_init (STlinkGUIClass *klass) -{ +static void stlink_gui_class_init (STlinkGUIClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->dispose = stlink_gui_dispose; gobject_class->finalize = stlink_gui_finalize; } -static void -stlink_gui_init (STlinkGUI *self) -{ +static void stlink_gui_init (STlinkGUI *self) { self->sl = NULL; self->filename = NULL; @@ -54,9 +45,7 @@ stlink_gui_init (STlinkGUI *self) self->file_mem.base = 0; } -static gboolean -set_info_error_message_idle (STlinkGUI *gui) -{ +static gboolean set_info_error_message_idle (STlinkGUI *gui) { if (gui->error_message != NULL) { gchar *markup; @@ -72,40 +61,31 @@ set_info_error_message_idle (STlinkGUI *gui) return FALSE; } -static void -stlink_gui_set_info_error_message (STlinkGUI *gui, const gchar *message) -{ +static void stlink_gui_set_info_error_message (STlinkGUI *gui, const gchar *message) { gui->error_message = g_strdup (message); g_idle_add ((GSourceFunc) set_info_error_message_idle, gui); } -static void -stlink_gui_set_sensitivity (STlinkGUI *gui, gboolean sensitivity) -{ +static void stlink_gui_set_sensitivity (STlinkGUI *gui, gboolean sensitivity) { gtk_widget_set_sensitive (GTK_WIDGET (gui->open_button), sensitivity); - if (sensitivity && gui->sl) gtk_widget_set_sensitive (GTK_WIDGET (gui->disconnect_button), sensitivity); - if (sensitivity && !gui->sl) gtk_widget_set_sensitive (GTK_WIDGET (gui->connect_button), sensitivity); - if (sensitivity && gui->sl && gui->filename) gtk_widget_set_sensitive (GTK_WIDGET (gui->flash_button), sensitivity); - gtk_widget_set_sensitive (GTK_WIDGET (gui->export_button), sensitivity && (gui->sl != NULL)); } -static void -mem_view_init_headers (GtkTreeView *view) -{ +static void mem_view_init_headers (GtkTreeView *view) { GtkCellRenderer *renderer; gint i; g_return_if_fail (view != NULL); renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (view, + gtk_tree_view_insert_column_with_attributes ( + view, -1, "Address", renderer, @@ -133,12 +113,11 @@ mem_view_init_headers (GtkTreeView *view) } } -static void -mem_view_add_as_hex (GtkListStore *store, - GtkTreeIter *iter, - gint column, - guint32 value) -{ +static void mem_view_add_as_hex ( + GtkListStore *store, + GtkTreeIter *iter, + gint column, + guint32 value) { gchar *hex_str; hex_str = g_strdup_printf ("0x%08X", value); @@ -146,13 +125,12 @@ mem_view_add_as_hex (GtkListStore *store, g_free (hex_str); } -static void -mem_view_add_buffer (GtkListStore *store, - GtkTreeIter *iter, - guint32 address, - guchar *buffer, - gint len) -{ +static void mem_view_add_buffer ( + GtkListStore *store, + GtkTreeIter *iter, + guint32 address, + guchar *buffer, + gint len) { guint32 *word; gint i, step; gint column = 0; @@ -174,61 +152,41 @@ mem_view_add_buffer (GtkListStore *store, } } -static guint32 -hexstr_to_guint32 (const gchar *str, GError **err) -{ +static guint32 hexstr_to_guint32 (const gchar *str, GError **err) { guint32 val; gchar *end_ptr; val = (guint32) strtoul (str, &end_ptr, 16); if ((errno == ERANGE && val == UINT_MAX) || (errno != 0 && val == 0)) { - g_set_error (err, - g_quark_from_string ("hextou32"), - 1, - "Invalid hexstring"); + g_set_error (err, g_quark_from_string ("hextou32"), 1, "Invalid hexstring"); return UINT32_MAX; } if (end_ptr == str) { - g_set_error (err, - g_quark_from_string ("hextou32"), - 2, - "Invalid hexstring"); + g_set_error (err, g_quark_from_string ("hextou32"), 2, "Invalid hexstring"); return UINT32_MAX; } return val; } - -static void -stlink_gui_update_mem_view (STlinkGUI *gui, struct mem_t *mem, GtkTreeView *view) { +static void stlink_gui_update_mem_view (STlinkGUI *gui, struct mem_t *mem, GtkTreeView *view) { GtkListStore *store; GtkTreeIter iter; store = GTK_LIST_STORE (gtk_tree_view_get_model (view)); - mem_view_add_buffer (store, - &iter, - mem->base, - mem->memory, - (gint) mem->size); + mem_view_add_buffer (store, &iter, mem->base, mem->memory, (gint) mem->size); gtk_widget_hide (GTK_WIDGET (gui->progress.bar)); gtk_progress_bar_set_fraction (gui->progress.bar, 0); stlink_gui_set_sensitivity (gui, TRUE); } -static gboolean -stlink_gui_update_devmem_view (STlinkGUI *gui) -{ +static gboolean stlink_gui_update_devmem_view (STlinkGUI *gui) { stlink_gui_update_mem_view (gui, &gui->flash_mem, gui->devmem_treeview); return FALSE; } - - -static gpointer -stlink_gui_populate_devmem_view (gpointer data) -{ +static gpointer stlink_gui_populate_devmem_view (gpointer data) { guint off; stm32_addr_t addr; @@ -240,23 +198,21 @@ stlink_gui_populate_devmem_view (gpointer data) addr = gui->sl->flash_base; - if (gui->flash_mem.memory) { + if (gui->flash_mem.memory) g_free (gui->flash_mem.memory); - } gui->flash_mem.memory = g_malloc (gui->sl->flash_size); gui->flash_mem.size = gui->sl->flash_size; gui->flash_mem.base = gui->sl->flash_base; for (off = 0; off < gui->sl->flash_size; off += MEM_READ_SIZE) { - guint n_read = MEM_READ_SIZE; + guint n_read = MEM_READ_SIZE; if (off + MEM_READ_SIZE > gui->sl->flash_size) { n_read = (guint) gui->sl->flash_size - off; /* align if needed */ - if (n_read & 3) { + if (n_read & 3) n_read = (n_read + 4) & ~(3); - } } /* reads to sl->q_buf */ stlink_read_mem32(gui->sl, addr + off, n_read); @@ -270,29 +226,22 @@ stlink_gui_populate_devmem_view (gpointer data) gui->progress.fraction = (gdouble) (off + n_read) / gui->sl->flash_size; } g_idle_add ((GSourceFunc) stlink_gui_update_devmem_view, gui); - return NULL; } -static gboolean -stlink_gui_update_filemem_view (STlinkGUI *gui) -{ +static gboolean stlink_gui_update_filemem_view (STlinkGUI *gui) { gchar *basename; basename = g_path_get_basename (gui->filename); gtk_notebook_set_tab_label_text (gui->notebook, - GTK_WIDGET (gtk_notebook_get_nth_page (gui->notebook, 1)), - basename); + GTK_WIDGET (gtk_notebook_get_nth_page (gui->notebook, 1)), basename); g_free (basename); stlink_gui_update_mem_view (gui, &gui->file_mem, gui->filemem_treeview); - return FALSE; } -static gpointer -stlink_gui_populate_filemem_view (gpointer data) -{ +static gpointer stlink_gui_populate_filemem_view (gpointer data) { guchar buffer[MEM_READ_SIZE]; GFile *file; GFileInfo *file_info; @@ -306,81 +255,73 @@ stlink_gui_populate_filemem_view (gpointer data) g_return_val_if_fail (gui != NULL, NULL); g_return_val_if_fail (gui->filename != NULL, NULL); - if (g_str_has_suffix (gui->filename, ".hex")) { - // If the file has prefix .hex - try to interpret it as Intel-HEX. - // It's difficult to merge the world of standard functions and GLib, - // so do it simple - load whole file into buffer and copy the data - // to the destination afterwards. - // We loose meanwhile the displaying of the progress and need - // double memory. - - uint8_t* mem = NULL; - size_t size = 0; - uint32_t begin = 0; - int res = stlink_parse_ihex (gui->filename, 0, &mem, &size, &begin); - - if (res == 0) { - if (gui->file_mem.memory) { - g_free (gui->file_mem.memory); - } - gui->file_mem.size = size; - gui->file_mem.memory = g_malloc (size); - gui->file_mem.base = begin; - - memcpy (gui->file_mem.memory, mem, size); - } - else { - stlink_gui_set_info_error_message (gui, "Cannot interpret the file as Intel-HEX"); - } - - free(mem); - } - else { - file = g_file_new_for_path (gui->filename); - input_stream = G_INPUT_STREAM (g_file_read (file, NULL, &err)); - if (err) { - stlink_gui_set_info_error_message (gui, err->message); - g_error_free (err); - goto out; - } - - file_info = g_file_input_stream_query_info (G_FILE_INPUT_STREAM (input_stream), - G_FILE_ATTRIBUTE_STANDARD_SIZE, NULL, &err); - if (err) { - stlink_gui_set_info_error_message (gui, err->message); - g_error_free (err); - goto out_input; - } - if (gui->file_mem.memory) { - g_free (gui->file_mem.memory); - } - gui->file_mem.size = g_file_info_get_size (file_info); - gui->file_mem.memory = g_malloc (gui->file_mem.size); - - for (off = 0; off < (gint) gui->file_mem.size; off += MEM_READ_SIZE) { - guint n_read = MEM_READ_SIZE; - - if (off + MEM_READ_SIZE > (gint) gui->file_mem.size) { - n_read = (guint) gui->file_mem.size - off; - } - - if (g_input_stream_read (G_INPUT_STREAM (input_stream), - &buffer, n_read, NULL, &err) == -1) { - stlink_gui_set_info_error_message (gui, err->message); - g_error_free (err); - goto out_input; - } - memcpy (gui->file_mem.memory + off, buffer, n_read); - gui->progress.fraction = (gdouble) (off + n_read) / gui->file_mem.size; - } - -out_input: - g_object_unref (input_stream); -out: - g_object_unref (file); - } - - g_idle_add ((GSourceFunc) stlink_gui_update_filemem_view, gui); + if (g_str_has_suffix (gui->filename, ".hex")) { + // If the file has prefix .hex - try to interpret it as Intel-HEX. + // It's difficult to merge the world of standard functions and GLib, + // so do it simple - load whole file into buffer and copy the data to the + // destination afterwards. + // We loose meanwhile the displaying of the progress and need double memory. + + uint8_t* mem = NULL; + size_t size = 0; + uint32_t begin = 0; + int res = stlink_parse_ihex (gui->filename, 0, &mem, &size, &begin); + + if (res == 0) { + if (gui->file_mem.memory) + g_free (gui->file_mem.memory); + gui->file_mem.size = size; + gui->file_mem.memory = g_malloc (size); + gui->file_mem.base = begin; + + memcpy (gui->file_mem.memory, mem, size); + } else { + stlink_gui_set_info_error_message (gui, "Cannot interpret the file as Intel-HEX"); + } + + free(mem); + } else { + file = g_file_new_for_path (gui->filename); + input_stream = G_INPUT_STREAM (g_file_read (file, NULL, &err)); + if (err) { + stlink_gui_set_info_error_message (gui, err->message); + g_error_free (err); + goto out; + } + + file_info = g_file_input_stream_query_info (G_FILE_INPUT_STREAM (input_stream), + G_FILE_ATTRIBUTE_STANDARD_SIZE, NULL, &err); + if (err) { + stlink_gui_set_info_error_message (gui, err->message); + g_error_free (err); + goto out_input; + } + if (gui->file_mem.memory) + g_free (gui->file_mem.memory); + gui->file_mem.size = g_file_info_get_size (file_info); + gui->file_mem.memory = g_malloc (gui->file_mem.size); + + for (off = 0; off < (gint) gui->file_mem.size; off += MEM_READ_SIZE) { + guint n_read = MEM_READ_SIZE; + + if (off + MEM_READ_SIZE > (gint) gui->file_mem.size) + n_read = (guint) gui->file_mem.size - off; + + if (g_input_stream_read (G_INPUT_STREAM (input_stream), + &buffer, n_read, NULL, &err) == -1) { + stlink_gui_set_info_error_message (gui, err->message); + g_error_free (err); + goto out_input; + } + memcpy (gui->file_mem.memory + off, buffer, n_read); + gui->progress.fraction = (gdouble) (off + n_read) / gui->file_mem.size; + } + + out_input: g_object_unref (input_stream); + out: g_object_unref (file); + } + + g_idle_add ((GSourceFunc) stlink_gui_update_filemem_view, gui); return NULL; } @@ -388,29 +329,23 @@ static void mem_jmp (GtkTreeView *view, GtkEntry *entry, guint32 base_addr, gsize size, - GError **err) -{ + GError **err) { GtkTreeModel *model; guint32 jmp_addr; GtkTreeIter iter; jmp_addr = hexstr_to_guint32 (gtk_entry_get_text (entry), err); - if (err && *err) { + if (err && *err) return; - } if (jmp_addr < base_addr || jmp_addr > base_addr + size) { - g_set_error (err, - g_quark_from_string ("mem_jmp"), - 1, - "Invalid address"); + g_set_error (err, g_quark_from_string ("mem_jmp"), 1, "Invalid address"); return; } model = gtk_tree_view_get_model (view); - if (!model) { + if (!model) return; - } if (gtk_tree_model_get_iter_first (model, &iter)) { do { @@ -429,12 +364,7 @@ static void mem_jmp (GtkTreeView *view, path = gtk_tree_model_get_path (model, &iter); gtk_tree_selection_select_iter (selection, &iter); - gtk_tree_view_scroll_to_cell (view, - path, - NULL, - TRUE, - 0.0, - 0.0); + gtk_tree_view_scroll_to_cell (view, path, NULL, TRUE, 0.0, 0.0); gtk_tree_path_free (path); } } @@ -444,9 +374,7 @@ static void mem_jmp (GtkTreeView *view, } } -static void -devmem_jmp_cb (GtkWidget *widget, gpointer data) -{ +static void devmem_jmp_cb (GtkWidget *widget, gpointer data) { STlinkGUI *gui; GError *err = NULL; (void) widget; @@ -465,9 +393,7 @@ devmem_jmp_cb (GtkWidget *widget, gpointer data) } } -static void -filemem_jmp_cb (GtkWidget *widget, gpointer data) -{ +static void filemem_jmp_cb (GtkWidget *widget, gpointer data) { STlinkGUI *gui; GError *err = NULL; (void) widget; @@ -488,9 +414,7 @@ filemem_jmp_cb (GtkWidget *widget, gpointer data) } } -static gchar * -dev_format_chip_id (guint32 chip_id) -{ +static gchar *dev_format_chip_id (guint32 chip_id) { const struct stlink_chipid_params *params; params = stlink_chipid_get_params(chip_id); @@ -500,31 +424,25 @@ dev_format_chip_id (guint32 chip_id) return g_strdup (params->description); } -static gchar * -dev_format_mem_size (gsize flash_size) -{ +static gchar *dev_format_mem_size (gsize flash_size) { return g_strdup_printf ("%u kB", (unsigned int)(flash_size / 1024)); } -static void -stlink_gui_set_connected (STlinkGUI *gui) -{ +static void stlink_gui_set_connected (STlinkGUI *gui) { gchar *tmp_str; GtkListStore *store; GtkTreeIter iter; gtk_statusbar_push (gui->statusbar, - gtk_statusbar_get_context_id (gui->statusbar, "conn"), - "Connected"); + gtk_statusbar_get_context_id (gui->statusbar, "conn"), "Connected"); gtk_widget_set_sensitive (GTK_WIDGET (gui->device_frame), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (gui->devmem_box), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (gui->connect_button), FALSE); - if (gui->filename) { + if (gui->filename) gtk_widget_set_sensitive (GTK_WIDGET (gui->flash_button), TRUE); - } tmp_str = dev_format_chip_id (gui->sl->chip_id); gtk_label_set_text (gui->chip_id_label, tmp_str); @@ -548,9 +466,8 @@ stlink_gui_set_connected (STlinkGUI *gui) g_free (tmp_str); store = GTK_LIST_STORE (gtk_tree_view_get_model (gui->devmem_treeview)); - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) gtk_list_store_clear (store); - } stlink_gui_set_sensitivity (gui, FALSE); gtk_notebook_set_current_page (gui->notebook, PAGE_DEVMEM); @@ -560,9 +477,7 @@ stlink_gui_set_connected (STlinkGUI *gui) g_thread_new ("devmem", (GThreadFunc) stlink_gui_populate_devmem_view, gui); } -static void -connect_button_cb (GtkWidget *widget, gpointer data) -{ +static void connect_button_cb (GtkWidget *widget, gpointer data) { STlinkGUI *gui; gint i; (void) widget; @@ -574,11 +489,11 @@ connect_button_cb (GtkWidget *widget, gpointer data) /* try version 1 then version 2 */ gui->sl = stlink_v1_open(0, 1); + if (gui->sl == NULL) + gui->sl = stlink_open_usb(0, 1, NULL); if (gui->sl == NULL) { - gui->sl = stlink_open_usb(0, 1, NULL); - } - if (gui->sl == NULL) { - stlink_gui_set_info_error_message (gui, "Failed to connect to STLink."); return; + stlink_gui_set_info_error_message (gui, "Failed to connect to STLink."); + return; } /* code below taken from flash/main.c, refactoring might be in order */ @@ -601,8 +516,7 @@ connect_button_cb (GtkWidget *widget, gpointer data) stlink_gui_set_connected (gui); } -static void stlink_gui_set_disconnected (STlinkGUI *gui) -{ +static void stlink_gui_set_disconnected (STlinkGUI *gui) { gtk_statusbar_push (gui->statusbar, gtk_statusbar_get_context_id (gui->statusbar, "conn"), "Disconnected"); @@ -614,9 +528,7 @@ static void stlink_gui_set_disconnected (STlinkGUI *gui) gtk_widget_set_sensitive (GTK_WIDGET (gui->connect_button), TRUE); } -static void -disconnect_button_cb (GtkWidget *widget, gpointer data) -{ +static void disconnect_button_cb (GtkWidget *widget, gpointer data) { STlinkGUI *gui; (void) widget; @@ -631,9 +543,7 @@ disconnect_button_cb (GtkWidget *widget, gpointer data) } -static void -stlink_gui_open_file (STlinkGUI *gui) -{ +static void stlink_gui_open_file (STlinkGUI *gui) { GtkWidget *dialog; GtkListStore *store; GtkTreeIter iter; @@ -646,13 +556,11 @@ stlink_gui_open_file (STlinkGUI *gui) NULL); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - gui->filename = - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + gui->filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); store = GTK_LIST_STORE (gtk_tree_view_get_model (gui->filemem_treeview)); - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) gtk_list_store_clear (store); - } stlink_gui_set_sensitivity (gui, FALSE); gtk_notebook_set_current_page (gui->notebook, PAGE_FILEMEM); @@ -663,37 +571,30 @@ stlink_gui_open_file (STlinkGUI *gui) gtk_widget_destroy (dialog); } -static void -open_button_cb (GtkWidget *widget, gpointer data) -{ +static void open_button_cb (GtkWidget *widget, gpointer data) { STlinkGUI *gui; (void) widget; gui = STLINK_GUI (data); - stlink_gui_open_file (gui); } -static gboolean -stlink_gui_write_flash_update (STlinkGUI *gui) -{ +static gboolean stlink_gui_write_flash_update (STlinkGUI *gui) { stlink_gui_set_sensitivity (gui, TRUE); gui->progress.activity_mode = FALSE; gtk_widget_hide (GTK_WIDGET (gui->progress.bar)); - return FALSE; } -static gpointer -stlink_gui_write_flash (gpointer data) -{ +static gpointer stlink_gui_write_flash (gpointer data) { g_return_val_if_fail (STLINK_IS_GUI (data), NULL); STlinkGUI *gui = (STlinkGUI *)data; g_return_val_if_fail ((gui->sl != NULL), NULL); g_return_val_if_fail ((gui->filename != NULL), NULL); - if (stlink_mwrite_flash(gui->sl, gui->file_mem.memory, (uint32_t)gui->file_mem.size, gui->sl->flash_base) < 0) { + if (stlink_mwrite_flash(gui->sl, gui->file_mem.memory, + (uint32_t)gui->file_mem.size, gui->sl->flash_base) < 0) { stlink_gui_set_info_error_message (gui, "Failed to write to flash"); } @@ -701,9 +602,7 @@ stlink_gui_write_flash (gpointer data) return NULL; } -static void -flash_button_cb (GtkWidget *widget, gpointer data) -{ +static void flash_button_cb (GtkWidget *widget, gpointer data) { STlinkGUI *gui; gchar *tmp_str; guint32 address; @@ -722,47 +621,38 @@ flash_button_cb (GtkWidget *widget, gpointer data) result = gtk_dialog_run (gui->flash_dialog); if (result == GTK_RESPONSE_OK) { - address = hexstr_to_guint32 (gtk_entry_get_text (gui->flash_dialog_entry), - &err); + address = hexstr_to_guint32 (gtk_entry_get_text (gui->flash_dialog_entry), &err); if (err) { stlink_gui_set_info_error_message (gui, err->message); } else { - if (address > gui->sl->flash_base + gui->sl->flash_size || - address < gui->sl->flash_base) { + if (address > gui->sl->flash_base + gui->sl->flash_size || address < gui->sl->flash_base) { stlink_gui_set_info_error_message (gui, "Invalid address"); - } - else if (address + gui->file_mem.size > - gui->sl->flash_base + gui->sl->flash_size) { + } else if (address + gui->file_mem.size > gui->sl->flash_base + gui->sl->flash_size) { stlink_gui_set_info_error_message (gui, "Binary overwrites flash"); } else { stlink_gui_set_sensitivity (gui, FALSE); - gtk_progress_bar_set_text (gui->progress.bar, - "Writing to flash"); + gtk_progress_bar_set_text (gui->progress.bar, "Writing to flash"); gui->progress.activity_mode = TRUE; gtk_widget_show (GTK_WIDGET (gui->progress.bar)); - g_thread_new ("flash", - (GThreadFunc) stlink_gui_write_flash, gui); + g_thread_new ("flash", (GThreadFunc) stlink_gui_write_flash, gui); } } } } -int export_to_file(const char*filename, const struct mem_t flash_mem) -{ +int export_to_file(const char*filename, const struct mem_t flash_mem) { printf("%s\n", filename); FILE * f=fopen(filename, "w"); - if (f==NULL) + if (f == NULL) return -1; for (gsize i=0;iflash_mem)!=0) + if (export_to_file (filename, gui->flash_mem) != 0) { stlink_gui_set_info_error_message(gui, "Failed to export flash"); - else + } else { stlink_gui_set_info_error_message(gui, "Export successful"); + } g_free (filename); } gtk_widget_destroy (dialog); } -static gboolean -progress_pulse_timeout (STlinkGUI *gui) { +static gboolean progress_pulse_timeout (STlinkGUI *gui) { if (gui->progress.activity_mode) { gtk_progress_bar_pulse (gui->progress.bar); } else { @@ -802,12 +691,11 @@ progress_pulse_timeout (STlinkGUI *gui) { return TRUE; } -static void -notebook_switch_page_cb (GtkNotebook *notebook, - GtkWidget *widget, - guint page_num, - gpointer data) -{ +static void notebook_switch_page_cb ( + GtkNotebook *notebook, + GtkWidget *widget, + guint page_num, + gpointer data) { STlinkGUI *gui; (void) notebook; (void) widget; @@ -815,22 +703,20 @@ notebook_switch_page_cb (GtkNotebook *notebook, gui = STLINK_GUI (data); if (page_num == 1) { - if (gui->filename == NULL) { + if (gui->filename == NULL) stlink_gui_open_file (gui); - } } } -static void -dnd_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint target_type, - guint timestamp, - gpointer data) -{ +static void dnd_received_cb ( + GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint target_type, + guint timestamp, + gpointer data) { GFile *file_uri; gchar **file_list; const guchar *file_data; @@ -841,14 +727,12 @@ dnd_received_cb (GtkWidget *widget, (void) x; (void) y; - if (selection_data != NULL && - gtk_selection_data_get_length (selection_data) > 0) { + if (selection_data != NULL && gtk_selection_data_get_length (selection_data) > 0) { switch (target_type) { case TARGET_FILENAME: - if (gui->filename) { + if (gui->filename) g_free (gui->filename); - } file_data = gtk_selection_data_get_data (selection_data); file_list = g_strsplit ((gchar *)file_data, "\r\n", 0); @@ -859,11 +743,9 @@ dnd_received_cb (GtkWidget *widget, g_strfreev (file_list); g_object_unref (file_uri); - store = GTK_LIST_STORE (gtk_tree_view_get_model (gui->devmem_treeview)); - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) { + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) gtk_list_store_clear (store); - } stlink_gui_set_sensitivity (gui, FALSE); gtk_notebook_set_current_page (gui->notebook, PAGE_FILEMEM); @@ -873,39 +755,34 @@ dnd_received_cb (GtkWidget *widget, break; } } - gtk_drag_finish (context, - TRUE, - gdk_drag_context_get_suggested_action (context) == GDK_ACTION_MOVE, - timestamp); + gtk_drag_finish ( + context, + TRUE, + gdk_drag_context_get_suggested_action (context) == GDK_ACTION_MOVE, + timestamp); } -void -stlink_gui_init_dnd (STlinkGUI *gui) -{ - GtkTargetEntry target_list[] = { - { "text/uri-list", 0, TARGET_FILENAME }, - }; - - gtk_drag_dest_set(GTK_WIDGET (gui->window), - GTK_DEST_DEFAULT_ALL, - target_list, - G_N_ELEMENTS (target_list), - GDK_ACTION_COPY); - - g_signal_connect (gui->window, "drag-data-received", - G_CALLBACK (dnd_received_cb), gui); +void stlink_gui_init_dnd (STlinkGUI *gui) { + GtkTargetEntry target_list[] = { { "text/uri-list", 0, TARGET_FILENAME }, }; + + gtk_drag_dest_set( + GTK_WIDGET (gui->window), + GTK_DEST_DEFAULT_ALL, + target_list, + G_N_ELEMENTS (target_list), + GDK_ACTION_COPY); + + g_signal_connect (gui->window, "drag-data-received", G_CALLBACK (dnd_received_cb), gui); } -static void -stlink_gui_build_ui (STlinkGUI *gui) { +static void stlink_gui_build_ui (STlinkGUI *gui) { GtkBuilder *builder; GtkListStore *devmem_store; GtkListStore *filemem_store; - gchar *ui_file = STLINK_UI_DIR "/stlink-gui.ui"; + gchar *ui_file = STLINK_UI_DIR "/gui.ui"; - if (!g_file_test (ui_file, G_FILE_TEST_EXISTS)) { - ui_file = "stlink-gui.ui"; - } + if (!g_file_test (ui_file, G_FILE_TEST_EXISTS)) + ui_file = "gui.ui"; builder = gtk_builder_new (); if (!gtk_builder_add_from_file (builder, ui_file, NULL)) { g_printerr ("Failed to load UI file: %s\n", ui_file); @@ -913,37 +790,25 @@ stlink_gui_build_ui (STlinkGUI *gui) { } gui->window = GTK_WINDOW (gtk_builder_get_object (builder, "window")); - g_signal_connect (G_OBJECT (gui->window), "destroy", - G_CALLBACK (gtk_main_quit), NULL); + g_signal_connect (G_OBJECT (gui->window), "destroy", G_CALLBACK (gtk_main_quit), NULL); /* set up toolutton clicked callbacks */ - gui->open_button = - GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "open_button")); - g_signal_connect (G_OBJECT (gui->open_button), "clicked", - G_CALLBACK (open_button_cb), gui); - - gui->connect_button = - GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "connect_button")); - g_signal_connect (G_OBJECT (gui->connect_button), "clicked", - G_CALLBACK (connect_button_cb), gui); - - gui->disconnect_button = - GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "disconnect_button")); - g_signal_connect (G_OBJECT (gui->disconnect_button), "clicked", - G_CALLBACK (disconnect_button_cb), gui); - - gui->flash_button = - GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "flash_button")); - g_signal_connect (G_OBJECT (gui->flash_button), "clicked", - G_CALLBACK (flash_button_cb), gui); - - gui->export_button = - GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "export_button")); - g_signal_connect (G_OBJECT (gui->export_button), "clicked", - G_CALLBACK (export_button_cb), gui); - - gui->devmem_treeview = - GTK_TREE_VIEW (gtk_builder_get_object (builder, "devmem_treeview")); + gui->open_button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "open_button")); + g_signal_connect (G_OBJECT (gui->open_button), "clicked", G_CALLBACK (open_button_cb), gui); + + gui->connect_button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "connect_button")); + g_signal_connect (G_OBJECT (gui->connect_button), "clicked", G_CALLBACK (connect_button_cb), gui); + + gui->disconnect_button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "disconnect_button")); + g_signal_connect (G_OBJECT (gui->disconnect_button), "clicked", G_CALLBACK (disconnect_button_cb), gui); + + gui->flash_button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "flash_button")); + g_signal_connect (G_OBJECT (gui->flash_button), "clicked", G_CALLBACK (flash_button_cb), gui); + + gui->export_button = GTK_TOOL_BUTTON (gtk_builder_get_object (builder, "export_button")); + g_signal_connect (G_OBJECT (gui->export_button), "clicked", G_CALLBACK (export_button_cb), gui); + + gui->devmem_treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "devmem_treeview")); mem_view_init_headers (gui->devmem_treeview); devmem_store = gtk_list_store_new (5, G_TYPE_STRING, @@ -954,8 +819,7 @@ stlink_gui_build_ui (STlinkGUI *gui) { gtk_tree_view_set_model (gui->devmem_treeview, GTK_TREE_MODEL (devmem_store)); g_object_unref (devmem_store); - gui->filemem_treeview = - GTK_TREE_VIEW (gtk_builder_get_object (builder, "filemem_treeview")); + gui->filemem_treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "filemem_treeview")); mem_view_init_headers (gui->filemem_treeview); filemem_store = gtk_list_store_new (5, G_TYPE_STRING, @@ -966,75 +830,43 @@ stlink_gui_build_ui (STlinkGUI *gui) { gtk_tree_view_set_model (gui->filemem_treeview, GTK_TREE_MODEL (filemem_store)); g_object_unref (filemem_store); - gui->core_id_label = - GTK_LABEL (gtk_builder_get_object (builder, "core_id_value")); - - gui->chip_id_label = - GTK_LABEL (gtk_builder_get_object (builder, "chip_id_value")); + gui->core_id_label = GTK_LABEL (gtk_builder_get_object (builder, "core_id_value")); + gui->chip_id_label = GTK_LABEL (gtk_builder_get_object (builder, "chip_id_value")); + gui->flash_size_label = GTK_LABEL (gtk_builder_get_object (builder, "flash_size_value")); + gui->ram_size_label = GTK_LABEL (gtk_builder_get_object (builder, "ram_size_value")); + gui->device_frame = GTK_FRAME (gtk_builder_get_object (builder, "device_frame")); - gui->flash_size_label = - GTK_LABEL (gtk_builder_get_object (builder, "flash_size_value")); + gui->notebook = GTK_NOTEBOOK (gtk_builder_get_object (builder, "mem_notebook")); + g_signal_connect (gui->notebook, "switch-page", G_CALLBACK (notebook_switch_page_cb), gui); - gui->ram_size_label = - GTK_LABEL (gtk_builder_get_object (builder, "ram_size_value")); + gui->devmem_box = GTK_BOX (gtk_builder_get_object (builder, "devmem_box")); + gui->filemem_box = GTK_BOX (gtk_builder_get_object (builder, "filemem_box")); - gui->device_frame = - GTK_FRAME (gtk_builder_get_object (builder, "device_frame")); + gui->devmem_jmp_entry = GTK_ENTRY (gtk_builder_get_object (builder, "devmem_jmp_entry")); + g_signal_connect (gui->devmem_jmp_entry, "activate", G_CALLBACK (devmem_jmp_cb), gui); - gui->notebook = - GTK_NOTEBOOK (gtk_builder_get_object (builder, "mem_notebook")); - g_signal_connect (gui->notebook, "switch-page", - G_CALLBACK (notebook_switch_page_cb), gui); - - gui->devmem_box = - GTK_BOX (gtk_builder_get_object (builder, "devmem_box")); - - gui->filemem_box = - GTK_BOX (gtk_builder_get_object (builder, "filemem_box")); - - gui->devmem_jmp_entry = - GTK_ENTRY (gtk_builder_get_object (builder, "devmem_jmp_entry")); - g_signal_connect (gui->devmem_jmp_entry, "activate", - G_CALLBACK (devmem_jmp_cb), gui); - - gui->filemem_jmp_entry = - GTK_ENTRY (gtk_builder_get_object (builder, "filemem_jmp_entry")); - g_signal_connect (gui->filemem_jmp_entry, "activate", - G_CALLBACK (filemem_jmp_cb), gui); + gui->filemem_jmp_entry = GTK_ENTRY (gtk_builder_get_object (builder, "filemem_jmp_entry")); + g_signal_connect (gui->filemem_jmp_entry, "activate", G_CALLBACK (filemem_jmp_cb), gui); gtk_editable_set_editable (GTK_EDITABLE (gui->filemem_jmp_entry), TRUE); - gui->progress.bar = - GTK_PROGRESS_BAR (gtk_builder_get_object (builder, "progressbar")); + gui->progress.bar = GTK_PROGRESS_BAR (gtk_builder_get_object (builder, "progressbar")); gtk_progress_bar_set_show_text (gui->progress.bar, TRUE); - gui->progress.timer = g_timeout_add (100, - (GSourceFunc) progress_pulse_timeout, - gui); + gui->progress.timer = g_timeout_add (100, (GSourceFunc) progress_pulse_timeout, gui); - gui->statusbar = - GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")); + gui->statusbar = GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")); - gui->infobar = - GTK_INFO_BAR (gtk_builder_get_object (builder, "infobar")); + gui->infobar = GTK_INFO_BAR (gtk_builder_get_object (builder, "infobar")); gtk_info_bar_add_button (gui->infobar, "_OK", GTK_RESPONSE_OK); gui->infolabel = GTK_LABEL (gtk_label_new ("")); - gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (gui->infobar)), - GTK_WIDGET (gui->infolabel)); + gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (gui->infobar)), GTK_WIDGET (gui->infolabel)); g_signal_connect (gui->infobar, "response", G_CALLBACK (gtk_widget_hide), NULL); /* flash dialog */ - gui->flash_dialog = - GTK_DIALOG (gtk_builder_get_object (builder, "flash_dialog")); - g_signal_connect_swapped (gui->flash_dialog, "response", - G_CALLBACK (gtk_widget_hide), gui->flash_dialog); - - gui->flash_dialog_ok = - GTK_BUTTON (gtk_builder_get_object (builder, "flash_dialog_ok_button")); - - gui->flash_dialog_cancel = - GTK_BUTTON (gtk_builder_get_object (builder, "flash_dialog_cancel_button")); - - gui->flash_dialog_entry = - GTK_ENTRY (gtk_builder_get_object (builder, "flash_dialog_entry")); + gui->flash_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "flash_dialog")); + g_signal_connect_swapped (gui->flash_dialog, "response", G_CALLBACK (gtk_widget_hide), gui->flash_dialog); + gui->flash_dialog_ok = GTK_BUTTON (gtk_builder_get_object (builder, "flash_dialog_ok_button")); + gui->flash_dialog_cancel = GTK_BUTTON (gtk_builder_get_object (builder, "flash_dialog_cancel_button")); + gui->flash_dialog_entry = GTK_ENTRY (gtk_builder_get_object (builder, "flash_dialog_entry")); /* make it so */ gtk_widget_show_all (GTK_WIDGET (gui->window)); @@ -1044,9 +876,7 @@ stlink_gui_build_ui (STlinkGUI *gui) { stlink_gui_set_disconnected (gui); } -int -main (int argc, char **argv) -{ +int main (int argc, char **argv) { STlinkGUI *gui; gtk_init (&argc, &argv); @@ -1056,6 +886,5 @@ main (int argc, char **argv) stlink_gui_init_dnd (gui); gtk_main (); - return 0; } diff --git a/src/tools/gui/stlink-gui.h b/src/stlink-gui/gui.h similarity index 98% rename from src/tools/gui/stlink-gui.h rename to src/stlink-gui/gui.h index 30c503fd3..c83e638f6 100644 --- a/src/tools/gui/stlink-gui.h +++ b/src/stlink-gui/gui.h @@ -39,8 +39,7 @@ struct mem_t { guint32 base; }; -struct _STlinkGUI -{ +struct _STlinkGUI { GObject parent_instance; /*< private >*/ @@ -82,8 +81,7 @@ struct _STlinkGUI stlink_t *sl; }; -struct _STlinkGUIClass -{ +struct _STlinkGUIClass { GObjectClass parent_class; /* class members */ diff --git a/src/tools/gui/stlink-gui.ui b/src/stlink-gui/gui.ui similarity index 100% rename from src/tools/gui/stlink-gui.ui rename to src/stlink-gui/gui.ui diff --git a/src/stlink-gui/icons/export-icons.sh b/src/stlink-gui/icons/export-icons.sh new file mode 100644 index 000000000..f36cb5598 --- /dev/null +++ b/src/stlink-gui/icons/export-icons.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# create the XPM icon and all resolutions below hicolor as PNG + +APPNAME="stlink-gui" +ORIGIN="stlink-gui_icon.svg" +OUTDIR="hicolor" + +# possible size options are --export-dpi / --export-width / --export-height +OPTS="-z --export-id-only" +ID="scalable-icon" +RESOLUTIONS="16 22 24 32 48 64 128 256" + +if ! [ -d $OUTDIR ]; then + echo "output directory missing. Create it..." + mkdir $OUTDIR + for RES in $RESOLUTIONS; do + mkdir -p $OUTDIR/${RES}x${RES}/apps + done +fi + +# create single app icon +inkscape $OPTS --export-width=32 --export-id=$ID --export-png=$APPNAME.png $ORIGIN +if [ $? != 0 ]; then + exit 1; +fi +convert $APPNAME.png $APPNAME.xpm + +# create all the resolutions +ALL="" +for RES in $RESOLUTIONS; do + inkscape $OPTS --export-width=$RES --export-id=$ID --export-png=$OUTDIR/${RES}x${RES}/apps/$APPNAME.png $ORIGIN + ALL="$ALL $OUTDIR/${RES}x${RES}/apps/$APPNAME.png" +done + +# this is for windows... +#echo "build Windows icon from $ALL" +#convert $ALL $APPNAME.ico + +exit 0 diff --git a/src/tools/gui/art/hicolor/128x128/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/128x128/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/128x128/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/128x128/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/16x16/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/16x16/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/16x16/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/16x16/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/22x22/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/22x22/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/22x22/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/22x22/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/24x24/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/24x24/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/24x24/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/24x24/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/256x256/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/256x256/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/256x256/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/256x256/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/32x32/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/32x32/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/32x32/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/32x32/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/48x48/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/48x48/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/48x48/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/48x48/apps/stlink-gui.png diff --git a/src/tools/gui/art/hicolor/64x64/apps/stlink-gui.png b/src/stlink-gui/icons/hicolor/64x64/apps/stlink-gui.png similarity index 100% rename from src/tools/gui/art/hicolor/64x64/apps/stlink-gui.png rename to src/stlink-gui/icons/hicolor/64x64/apps/stlink-gui.png diff --git a/src/tools/gui/art/stlink-gui.png b/src/stlink-gui/icons/stlink-gui.png similarity index 100% rename from src/tools/gui/art/stlink-gui.png rename to src/stlink-gui/icons/stlink-gui.png diff --git a/src/tools/gui/art/stlink-gui.svg b/src/stlink-gui/icons/stlink-gui.svg similarity index 100% rename from src/tools/gui/art/stlink-gui.svg rename to src/stlink-gui/icons/stlink-gui.svg diff --git a/src/tools/gui/art/stlink-gui.xpm b/src/stlink-gui/icons/stlink-gui.xpm similarity index 100% rename from src/tools/gui/art/stlink-gui.xpm rename to src/stlink-gui/icons/stlink-gui.xpm diff --git a/src/tools/gui/art/stlink-gui_48.png b/src/stlink-gui/icons/stlink-gui_48.png similarity index 100% rename from src/tools/gui/art/stlink-gui_48.png rename to src/stlink-gui/icons/stlink-gui_48.png diff --git a/src/tools/gui/stlink-gui.desktop b/src/stlink-gui/stlink-gui.desktop similarity index 100% rename from src/tools/gui/stlink-gui.desktop rename to src/stlink-gui/stlink-gui.desktop diff --git a/src/tools/gui/art/export-icons.sh b/src/tools/gui/art/export-icons.sh deleted file mode 100755 index 9d61719b9..000000000 --- a/src/tools/gui/art/export-icons.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# create the XPM icon and all resolutions below hicolor as PNG - -APPNAME="stlink-gui" -ORIGIN="stlink-gui_icon.svg" -OUTDIR="hicolor" - -## possible size options are --export-dpi / --export-width / --export-height -OPTS="-z --export-id-only" -ID="scalable-icon" -RESOLUTIONS="16 22 24 32 48 64 128 256" - - if ! [ -d $OUTDIR ]; then - echo "output directory missing. Create it..." - mkdir $OUTDIR - for RES in $RESOLUTIONS; do - mkdir -p $OUTDIR/${RES}x${RES}/apps - done - fi - - # create single app icon - inkscape $OPTS --export-width=32 --export-id=$ID --export-png=$APPNAME.png $ORIGIN - if [ $? != 0 ]; then exit 1; fi - convert $APPNAME.png $APPNAME.xpm - - # create all the resolutions - ALL="" - for RES in $RESOLUTIONS; do - inkscape $OPTS --export-width=$RES --export-id=$ID --export-png=$OUTDIR/${RES}x${RES}/apps/$APPNAME.png $ORIGIN - ALL="$ALL $OUTDIR/${RES}x${RES}/apps/$APPNAME.png" - done - - # this is for windows... - #echo "build Windows icon from $ALL" - #convert $ALL $APPNAME.ico - -exit 0 From c2c480846a493ae5493a5aecda41ad53f0b83bb2 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 00:37:03 +0200 Subject: [PATCH 120/236] Project cleanup - Updated old project references - Alligned code style in /tests - Added note on OS support to README.md --- CHANGELOG.md | 272 +++++++++++++++++++++++------------------------ LICENSE.md | 2 +- README.md | 30 +++--- debian/control | 8 +- debian/copyright | 4 +- debian/watch | 2 +- tests/flash.c | 154 ++++++++++++++++++++------- tests/sg.c | 67 ++++++------ tests/usb.c | 19 ++-- 9 files changed, 319 insertions(+), 239 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99d307f9a..8cf102910 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,44 +8,44 @@ Release date: 2020-02-20 Major changes and added features: -* Initial support for STM32L41X ([#754](https://github.com/texane/stlink/pull/754), [#799](https://github.com/texane/stlink/pull/799)) -* Working support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 ([#756](https://github.com/texane/stlink/pull/756), [#757](https://github.com/texane/stlink/pull/757), [#805](https://github.com/texane/stlink/pull/805), [#834](https://github.com/texane/stlink/pull/834), Regression-Fixes: [#761](https://github.com/texane/stlink/pull/761), [#766](https://github.com/texane/stlink/pull/766)) -* Added preliminary support for some STM32G0 chips ([#759](https://github.com/texane/stlink/pull/759), [#760](https://github.com/texane/stlink/pull/760), [#797](https://github.com/texane/stlink/pull/797)) -* Added support for mass erasing second bank on STM32F10x_XL ([#767](https://github.com/texane/stlink/pull/767), [#768](https://github.com/texane/stlink/pull/768)) -* Added call to clear PG bit after writing to flash ([#773](https://github.com/texane/stlink/pull/773)) -* Added support to write option bytes for the STM32G0 ([#778](https://github.com/texane/stlink/pull/778)) -* Added support for STM32WB55 chips ([#786](https://github.com/texane/stlink/pull/786), [#810](https://github.com/texane/stlink/pull/810), [#816](https://github.com/texane/stlink/pull/816)) -* Added STLink V3SET VID:PIDs to the udev rules ([#789](https://github.com/texane/stlink/pull/789)) -* Support for "STM32+Audio" v2-1 firmware ([#790](https://github.com/texane/stlink/pull/790)) -* Build for Windows under Debian/Ubuntu ([#802](https://github.com/texane/stlink/pull/802)) -* Allow for 64 bytes serials ([#809](https://github.com/texane/stlink/pull/809)) -* Added full support for STLINK CHIP ID L4RX ([#814](https://github.com/texane/stlink/pull/814), [#839](https://github.com/texane/stlink/pull/839)) -* Added support for the STLink-v2.1 when flashed with no mass storage (PID 0x3752) ([#819](https://github.com/texane/stlink/pull/819), [#861](https://github.com/texane/stlink/pull/861)) -* Added support for writing option bytes on STM32L0xx ([#830](https://github.com/texane/stlink/pull/830)) -* Added support to read and write option bytes for STM32F2 series ([#836](https://github.com/texane/stlink/pull/836), [#837](https://github.com/texane/stlink/pull/837)) -* Added support to read and write option bytes for STM32F446 ([#843](https://github.com/texane/stlink/pull/843)) +* Initial support for STM32L41X ([#754](https://github.com/stlink-org/stlink/pull/754), [#799](https://github.com/stlink-org/stlink/pull/799)) +* Working support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 ([#756](https://github.com/stlink-org/stlink/pull/756), [#757](https://github.com/stlink-org/stlink/pull/757), [#805](https://github.com/stlink-org/stlink/pull/805), [#834](https://github.com/stlink-org/stlink/pull/834), Regression-Fixes: [#761](https://github.com/stlink-org/stlink/pull/761), [#766](https://github.com/stlink-org/stlink/pull/766)) +* Added preliminary support for some STM32G0 chips ([#759](https://github.com/stlink-org/stlink/pull/759), [#760](https://github.com/stlink-org/stlink/pull/760), [#797](https://github.com/stlink-org/stlink/pull/797)) +* Added support for mass erasing second bank on STM32F10x_XL ([#767](https://github.com/stlink-org/stlink/pull/767), [#768](https://github.com/stlink-org/stlink/pull/768)) +* Added call to clear PG bit after writing to flash ([#773](https://github.com/stlink-org/stlink/pull/773)) +* Added support to write option bytes for the STM32G0 ([#778](https://github.com/stlink-org/stlink/pull/778)) +* Added support for STM32WB55 chips ([#786](https://github.com/stlink-org/stlink/pull/786), [#810](https://github.com/stlink-org/stlink/pull/810), [#816](https://github.com/stlink-org/stlink/pull/816)) +* Added STLink V3SET VID:PIDs to the udev rules ([#789](https://github.com/stlink-org/stlink/pull/789)) +* Support for "STM32+Audio" v2-1 firmware ([#790](https://github.com/stlink-org/stlink/pull/790)) +* Build for Windows under Debian/Ubuntu ([#802](https://github.com/stlink-org/stlink/pull/802)) +* Allow for 64 bytes serials ([#809](https://github.com/stlink-org/stlink/pull/809)) +* Added full support for STLINK CHIP ID L4RX ([#814](https://github.com/stlink-org/stlink/pull/814), [#839](https://github.com/stlink-org/stlink/pull/839)) +* Added support for the STLink-v2.1 when flashed with no mass storage (PID 0x3752) ([#819](https://github.com/stlink-org/stlink/pull/819), [#861](https://github.com/stlink-org/stlink/pull/861)) +* Added support for writing option bytes on STM32L0xx ([#830](https://github.com/stlink-org/stlink/pull/830)) +* Added support to read and write option bytes for STM32F2 series ([#836](https://github.com/stlink-org/stlink/pull/836), [#837](https://github.com/stlink-org/stlink/pull/837)) +* Added support to read and write option bytes for STM32F446 ([#843](https://github.com/stlink-org/stlink/pull/843)) Updates and fixes: -* Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/texane/stlink/pull/107), [#665](https://github.com/texane/stlink/pull/665), [#763](https://github.com/texane/stlink/pull/763)) -* Fixed an issue with versioning stuck at 1.4.0 for versions cloned with git ([#563](https://github.com/texane/stlink/pull/563), [#762](https://github.com/texane/stlink/pull/762), [#772](https://github.com/texane/stlink/pull/772)) -* Updated STM32F3xx chip ID that covers a few different devices ([#685](https://github.com/texane/stlink/pull/685), [#758](https://github.com/texane/stlink/pull/758)) -* Made udev rules and modprobe conf installation optional ([#741](https://github.com/texane/stlink/pull/741)) -* Fixed case when __FILE__ don't contain "/" nor "\\" ([#745](https://github.com/texane/stlink/pull/745)) -* Fixed double dash issue in doc/man ([#746](https://github.com/texane/stlink/pull/746), [#747](https://github.com/texane/stlink/pull/747)) -* Compiling documentation: package is called libusb-1.0-0-dev on Debian ([#748](https://github.com/texane/stlink/pull/748)) -* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip-ID 0x464 for STM32L41xxx/L42xxx devices ([#751](https://github.com/texane/stlink/pull/751)) -* Added O_BINARY option to open file ([#753](https://github.com/texane/stlink/pull/753)) -* Fixed versioning when compiling from the checked out git-repo ([#762](https://github.com/texane/stlink/pull/762), [#772](https://github.com/texane/stlink/pull/772)) -* win32: move usleep definition to unistd.h ([#765](https://github.com/texane/stlink/pull/765)) -* Fixed relative path to the UI files needed by stlink-gui-local (GUI) ([#770](https://github.com/texane/stlink/pull/770), [#771](https://github.com/texane/stlink/pull/771)) -* Added howto for sending NRST signal through GDB ([#774](https://github.com/texane/stlink/pull/774), [#776](https://github.com/texane/stlink/pull/776), [#779](https://github.com/texane/stlink/pull/779)) -* Fixed package name "devscripts" in doc/compiling.md ([#775](https://github.com/texane/stlink/pull/775)) -* Fixed few potential memory/resource leaks ([#803](https://github.com/texane/stlink/pull/803)) -* Updated Linux source repositories in README.md: Debian and Ubuntu ([#821](https://github.com/texane/stlink/pull/821), [#835](https://github.com/texane/stlink/pull/835), [#859](https://github.com/texane/stlink/pull/859)) -* Do not issue JTAG reset on stlink-v1 ([#828](https://github.com/texane/stlink/pull/828)) -* Fixed flash size of STM32 Discovery vl ([#829](https://github.com/texane/stlink/pull/829)) -* Updated documentation on software structure ([#851](https://github.com/texane/stlink/pull/851)) +* Fixed "unkown chip id", piped output and st-util -v ([#107](https://github.com/stlink-org/stlink/pull/107), [#665](https://github.com/stlink-org/stlink/pull/665), [#763](https://github.com/stlink-org/stlink/pull/763)) +* Fixed an issue with versioning stuck at 1.4.0 for versions cloned with git ([#563](https://github.com/stlink-org/stlink/pull/563), [#762](https://github.com/stlink-org/stlink/pull/762), [#772](https://github.com/stlink-org/stlink/pull/772)) +* Updated STM32F3xx chip ID that covers a few different devices ([#685](https://github.com/stlink-org/stlink/pull/685), [#758](https://github.com/stlink-org/stlink/pull/758)) +* Made udev rules and modprobe conf installation optional ([#741](https://github.com/stlink-org/stlink/pull/741)) +* Fixed case when __FILE__ don't contain "/" nor "\\" ([#745](https://github.com/stlink-org/stlink/pull/745)) +* Fixed double dash issue in doc/man ([#746](https://github.com/stlink-org/stlink/pull/746), [#747](https://github.com/stlink-org/stlink/pull/747)) +* Compiling documentation: package is called libusb-1.0-0-dev on Debian ([#748](https://github.com/stlink-org/stlink/pull/748)) +* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip-ID 0x464 for STM32L41xxx/L42xxx devices ([#751](https://github.com/stlink-org/stlink/pull/751)) +* Added O_BINARY option to open file ([#753](https://github.com/stlink-org/stlink/pull/753)) +* Fixed versioning when compiling from the checked out git-repo ([#762](https://github.com/stlink-org/stlink/pull/762), [#772](https://github.com/stlink-org/stlink/pull/772)) +* win32: move usleep definition to unistd.h ([#765](https://github.com/stlink-org/stlink/pull/765)) +* Fixed relative path to the UI files needed by stlink-gui-local (GUI) ([#770](https://github.com/stlink-org/stlink/pull/770), [#771](https://github.com/stlink-org/stlink/pull/771)) +* Added howto for sending NRST signal through GDB ([#774](https://github.com/stlink-org/stlink/pull/774), [#776](https://github.com/stlink-org/stlink/pull/776), [#779](https://github.com/stlink-org/stlink/pull/779)) +* Fixed package name "devscripts" in doc/compiling.md ([#775](https://github.com/stlink-org/stlink/pull/775)) +* Fixed few potential memory/resource leaks ([#803](https://github.com/stlink-org/stlink/pull/803)) +* Updated Linux source repositories in README.md: Debian and Ubuntu ([#821](https://github.com/stlink-org/stlink/pull/821), [#835](https://github.com/stlink-org/stlink/pull/835), [#859](https://github.com/stlink-org/stlink/pull/859)) +* Do not issue JTAG reset on stlink-v1 ([#828](https://github.com/stlink-org/stlink/pull/828)) +* Fixed flash size of STM32 Discovery vl ([#829](https://github.com/stlink-org/stlink/pull/829)) +* Updated documentation on software structure ([#851](https://github.com/stlink-org/stlink/pull/851)) General project updates: @@ -62,32 +62,32 @@ Release date: 2018-09-13 Major changes and added features: -* Added reset through AIRCR ([#540](https://github.com/texane/stlink/pull/540), [#712](https://github.com/texane/stlink/pull/712)) -* Added creation of icons for .desktop file ([#684](https://github.com/texane/stlink/pull/684), [#708](https://github.com/texane/stlink/pull/708)) -* Added desktop file for linux ([#688](https://github.com/texane/stlink/pull/688)) -* Added button to export STM32 flash memory to a file ([#691](https://github.com/texane/stlink/pull/691)) -* Updated libusb to 1.0.22 ([#695](https://github.com/texane/stlink/pull/695)) - (related Bugs: [#438](https://github.com/texane/stlink/pull/438), [#632](https://github.com/texane/stlink/pull/632)) -* Added icons for STLink GUI ([#697](https://github.com/texane/stlink/pull/697)) -* Added support for STM32L4R9 target ([#694](https://github.com/texane/stlink/pull/694), [#699](https://github.com/texane/stlink/pull/699)) -* Added memory map for STM32F411RE target ([#709](https://github.com/texane/stlink/pull/709)) -* Implemented intel hex support for GTK GUI ([#713](https://github.com/texane/stlink/pull/713), [#718](https://github.com/texane/stlink/pull/718)) +* Added reset through AIRCR ([#540](https://github.com/stlink-org/stlink/pull/540), [#712](https://github.com/stlink-org/stlink/pull/712)) +* Added creation of icons for .desktop file ([#684](https://github.com/stlink-org/stlink/pull/684), [#708](https://github.com/stlink-org/stlink/pull/708)) +* Added desktop file for linux ([#688](https://github.com/stlink-org/stlink/pull/688)) +* Added button to export STM32 flash memory to a file ([#691](https://github.com/stlink-org/stlink/pull/691)) +* Updated libusb to 1.0.22 ([#695](https://github.com/stlink-org/stlink/pull/695)) - (related Bugs: [#438](https://github.com/stlink-org/stlink/pull/438), [#632](https://github.com/stlink-org/stlink/pull/632)) +* Added icons for STLink GUI ([#697](https://github.com/stlink-org/stlink/pull/697)) +* Added support for STM32L4R9 target ([#694](https://github.com/stlink-org/stlink/pull/694), [#699](https://github.com/stlink-org/stlink/pull/699)) +* Added memory map for STM32F411RE target ([#709](https://github.com/stlink-org/stlink/pull/709)) +* Implemented intel hex support for GTK GUI ([#713](https://github.com/stlink-org/stlink/pull/713), [#718](https://github.com/stlink-org/stlink/pull/718)) Updates and fixes: -* Fixed missing flash_loader for STM32L0x ([#269](https://github.com/texane/stlink/pull/269), [#274](https://github.com/texane/stlink/pull/274), [#654](https://github.com/texane/stlink/pull/654), [#675](https://github.com/texane/stlink/pull/675)) -* Fix for stlink library calls exit() or _exit() ([#634](https://github.com/texane/stlink/pull/634), [#696](https://github.com/texane/stlink/pull/696)) -* Added semihosting parameter documentation in doc/man ([#674](https://github.com/texane/stlink/pull/674)) -* Fixed reference to non-exisiting st-term tool in doc/man ([#676](https://github.com/texane/stlink/pull/676)) -* Fixed serial number size mismatch with stlink_open_usb() ([#680](https://github.com/texane/stlink/pull/680)) -* Debian packaging, CMake and README.md fixes ([#682](https://github.com/texane/stlink/pull/682), [#683](https://github.com/texane/stlink/pull/683)) -* Disabled static library installation by default ([#702](https://github.com/texane/stlink/pull/702)) -* Fix for libusb deprecation ([#703](https://github.com/texane/stlink/pull/703), [#704](https://github.com/texane/stlink/pull/704)) -* Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX ([#706](https://github.com/texane/stlink/pull/706)) -* Regression: stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/texane/stlink/pull/700), [#701](https://github.com/texane/stlink/pull/701), [#707](https://github.com/texane/stlink/pull/707)) -* Fixed flash memory map for STM32F72xxx target ([#711](https://github.com/texane/stlink/pull/711)) -* Proper flash page size calculation for STM32F412xx target ([#721](https://github.com/texane/stlink/pull/721)) -* Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/texane/stlink/pull/726), [#727](https://github.com/texane/stlink/pull/727), [#728](https://github.com/texane/stlink/pull/728), [#729](https://github.com/texane/stlink/pull/729), [#730](https://github.com/texane/stlink/pull/730), [#731](https://github.com/texane/stlink/pull/731), [#732](https://github.com/texane/stlink/pull/732)) -* FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733)) +* Fixed missing flash_loader for STM32L0x ([#269](https://github.com/stlink-org/stlink/pull/269), [#274](https://github.com/stlink-org/stlink/pull/274), [#654](https://github.com/stlink-org/stlink/pull/654), [#675](https://github.com/stlink-org/stlink/pull/675)) +* Fix for stlink library calls exit() or _exit() ([#634](https://github.com/stlink-org/stlink/pull/634), [#696](https://github.com/stlink-org/stlink/pull/696)) +* Added semihosting parameter documentation in doc/man ([#674](https://github.com/stlink-org/stlink/pull/674)) +* Fixed reference to non-exisiting st-term tool in doc/man ([#676](https://github.com/stlink-org/stlink/pull/676)) +* Fixed serial number size mismatch with stlink_open_usb() ([#680](https://github.com/stlink-org/stlink/pull/680)) +* Debian packaging, CMake and README.md fixes ([#682](https://github.com/stlink-org/stlink/pull/682), [#683](https://github.com/stlink-org/stlink/pull/683)) +* Disabled static library installation by default ([#702](https://github.com/stlink-org/stlink/pull/702)) +* Fix for libusb deprecation ([#703](https://github.com/stlink-org/stlink/pull/703), [#704](https://github.com/stlink-org/stlink/pull/704)) +* Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX ([#706](https://github.com/stlink-org/stlink/pull/706)) +* Regression: stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/stlink-org/stlink/pull/700), [#701](https://github.com/stlink-org/stlink/pull/701), [#707](https://github.com/stlink-org/stlink/pull/707)) +* Fixed flash memory map for STM32F72xxx target ([#711](https://github.com/stlink-org/stlink/pull/711)) +* Proper flash page size calculation for STM32F412xx target ([#721](https://github.com/stlink-org/stlink/pull/721)) +* Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/stlink-org/stlink/pull/726), [#727](https://github.com/stlink-org/stlink/pull/727), [#728](https://github.com/stlink-org/stlink/pull/728), [#729](https://github.com/stlink-org/stlink/pull/729), [#730](https://github.com/stlink-org/stlink/pull/730), [#731](https://github.com/stlink-org/stlink/pull/731), [#732](https://github.com/stlink-org/stlink/pull/732)) +* FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/stlink-org/stlink/pull/733)) v1.5.0 @@ -97,21 +97,21 @@ Release date: 2018-02-16 Major changes and added features: -* Added support of STM32L496xx/4A6xx devices ([#615](https://github.com/texane/stlink/pull/615), [#657](https://github.com/texane/stlink/pull/657)) -* Added unknown chip dummy to obtain the serial of the ST-link by a call to st-info --probe ([#641](https://github.com/texane/stlink/pull/641)) -* Added support for STM32F72xx (chip-ID: 0x452) devices (commit [#1969148](https://github.com/texane/stlink/commit/19691485359afef1a256964afcbb8dcf4b733209)) +* Added support of STM32L496xx/4A6xx devices ([#615](https://github.com/stlink-org/stlink/pull/615), [#657](https://github.com/stlink-org/stlink/pull/657)) +* Added unknown chip dummy to obtain the serial of the ST-link by a call to st-info --probe ([#641](https://github.com/stlink-org/stlink/pull/641)) +* Added support for STM32F72xx (chip-ID: 0x452) devices (commit [#1969148](https://github.com/stlink-org/stlink/commit/19691485359afef1a256964afcbb8dcf4b733209)) Updates and fixes: -* Fixed verification of flash error for STM32L496x device ([#617](https://github.com/texane/stlink/pull/617), [#618](https://github.com/texane/stlink/pull/618)) -* Updated Linux source repositories in README.md: Gentoo, Fedora and RedHat/CentOS ([#622](https://github.com/texane/stlink/pull/622), [#635](https://github.com/texane/stlink/pull/635)) -* Updated changelog in debian package ([#630](https://github.com/texane/stlink/pull/630)) -* Added LIB_INSTALL_DIR to correct libs install on 64-bit systems ([#633](https://github.com/texane/stlink/pull/633), [#636](https://github.com/texane/stlink/pull/636)) -* Fixed write for microcontroller with RAM size less or equal to 32K ([#637](https://github.com/texane/stlink/pull/637)) -* Fixed memory map for STM32L496xx boards ([#639](https://github.com/texane/stlink/pull/639)) -* Fixed __FILE__ base name extraction ([#624](https://github.com/texane/stlink/pull/624), [#628](https://github.com/texane/stlink/pull/628), [#648](https://github.com/texane/stlink/pull/648)) -* Added debian/triggers to run ldconfig ([#664](https://github.com/texane/stlink/pull/664)) -* Fixed build on Fedora with GCC 8 ([#666](https://github.com/texane/stlink/pull/666), [#667](https://github.com/texane/stlink/pull/667), [#668](https://github.com/texane/stlink/pull/668)) +* Fixed verification of flash error for STM32L496x device ([#617](https://github.com/stlink-org/stlink/pull/617), [#618](https://github.com/stlink-org/stlink/pull/618)) +* Updated Linux source repositories in README.md: Gentoo, Fedora and RedHat/CentOS ([#622](https://github.com/stlink-org/stlink/pull/622), [#635](https://github.com/stlink-org/stlink/pull/635)) +* Updated changelog in debian package ([#630](https://github.com/stlink-org/stlink/pull/630)) +* Added LIB_INSTALL_DIR to correct libs install on 64-bit systems ([#633](https://github.com/stlink-org/stlink/pull/633), [#636](https://github.com/stlink-org/stlink/pull/636)) +* Fixed write for microcontroller with RAM size less or equal to 32K ([#637](https://github.com/stlink-org/stlink/pull/637)) +* Fixed memory map for STM32L496xx boards ([#639](https://github.com/stlink-org/stlink/pull/639)) +* Fixed __FILE__ base name extraction ([#624](https://github.com/stlink-org/stlink/pull/624), [#628](https://github.com/stlink-org/stlink/pull/628), [#648](https://github.com/stlink-org/stlink/pull/648)) +* Added debian/triggers to run ldconfig ([#664](https://github.com/stlink-org/stlink/pull/664)) +* Fixed build on Fedora with GCC 8 ([#666](https://github.com/stlink-org/stlink/pull/666), [#667](https://github.com/stlink-org/stlink/pull/667), [#668](https://github.com/stlink-org/stlink/pull/668)) v1.4.0 @@ -121,27 +121,27 @@ Release date: 2017-07-01 Major changes and added features: -* Allow building of debian package with CPack ([#554](https://github.com/texane/stlink/pull/554), commit [#5b69f25](https://github.com/texane/stlink/commit/5b69f25198a1a8f34e2ee48d1ad20f79447e3d55)) -* Added support for STM32L011 target ([#564](https://github.com/texane/stlink/pull/564), [#565](https://github.com/texane/stlink/pull/565), [#572](https://github.com/texane/stlink/pull/572)) -* Added support for flashing second bank on STM32F10x_XL ([#592](https://github.com/texane/stlink/pull/592)) -* Initial support to compile with Microsoft Visual Studio 2017 ([#602](https://github.com/texane/stlink/pull/602)) -* Added support for STM32L452 target ([#603](https://github.com/texane/stlink/pull/603), [#608](https://github.com/texane/stlink/pull/608)) +* Allow building of debian package with CPack ([#554](https://github.com/stlink-org/stlink/pull/554), commit [#5b69f25](https://github.com/stlink-org/stlink/commit/5b69f25198a1a8f34e2ee48d1ad20f79447e3d55)) +* Added support for STM32L011 target ([#564](https://github.com/stlink-org/stlink/pull/564), [#565](https://github.com/stlink-org/stlink/pull/565), [#572](https://github.com/stlink-org/stlink/pull/572)) +* Added support for flashing second bank on STM32F10x_XL ([#592](https://github.com/stlink-org/stlink/pull/592)) +* Initial support to compile with Microsoft Visual Studio 2017 ([#602](https://github.com/stlink-org/stlink/pull/602)) +* Added support for STM32L452 target ([#603](https://github.com/stlink-org/stlink/pull/603), [#608](https://github.com/stlink-org/stlink/pull/608)) Updates and fixes: -* Fixed gdb-server: STM32L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/texane/stlink/pull/273)) -* Added --flash=n[k][m] command line option to override device model ([#305](https://github.com/texane/stlink/pull/305), [#516](https://github.com/texane/stlink/pull/516), [#576](https://github.com/texane/stlink/pull/576)) -* Updated libusb to 1.0.21 for Windows ([#562](https://github.com/texane/stlink/pull/562)) -* Fixed low-voltage flashing on STM32F7 devices ([#566](https://github.com/texane/stlink/pull/566), [#567](https://github.com/texane/stlink/pull/567)) -* Fixed building with mingw64 ([#569](https://github.com/texane/stlink/pull/569), [#573](https://github.com/texane/stlink/pull/573), [#578](https://github.com/texane/stlink/pull/578), [#582](https://github.com/texane/stlink/pull/582), [#584](https://github.com/texane/stlink/pull/584), [#610](https://github.com/texane/stlink/pull/610), [#846](https://github.com/texane/stlink/pull/846)) -* Fixed possible memory leak ([#570](https://github.com/texane/stlink/pull/570), [#571](https://github.com/texane/stlink/pull/571)) -* Fixed installation path for shared objects ([#581](https://github.com/texane/stlink/pull/581)) -* Fixed a few -Wformat warnings ([#582](https://github.com/texane/stlink/pull/582)) -* Removed unused defines in mimgw.h ([#583](https://github.com/texane/stlink/pull/583)) -* Skip GTK detection when cross-compiling ([#588](https://github.com/texane/stlink/pull/588)) -* Fixed compilation with GCC 7 ([#590](https://github.com/texane/stlink/pull/590), [#591](https://github.com/texane/stlink/pull/591)) -* Fixed flashing to 'f0 device' targets ([#594](https://github.com/texane/stlink/pull/594), [#595](https://github.com/texane/stlink/pull/595)) -* Fixed wrong counting when flashing ([#605](https://github.com/texane/stlink/pull/605)) +* Fixed gdb-server: STM32L0xx has no FP_CTRL register for breakpoints ([#273](https://github.com/stlink-org/stlink/pull/273)) +* Added --flash=n[k][m] command line option to override device model ([#305](https://github.com/stlink-org/stlink/pull/305), [#516](https://github.com/stlink-org/stlink/pull/516), [#576](https://github.com/stlink-org/stlink/pull/576)) +* Updated libusb to 1.0.21 for Windows ([#562](https://github.com/stlink-org/stlink/pull/562)) +* Fixed low-voltage flashing on STM32F7 devices ([#566](https://github.com/stlink-org/stlink/pull/566), [#567](https://github.com/stlink-org/stlink/pull/567)) +* Fixed building with mingw64 ([#569](https://github.com/stlink-org/stlink/pull/569), [#573](https://github.com/stlink-org/stlink/pull/573), [#578](https://github.com/stlink-org/stlink/pull/578), [#582](https://github.com/stlink-org/stlink/pull/582), [#584](https://github.com/stlink-org/stlink/pull/584), [#610](https://github.com/stlink-org/stlink/pull/610), [#846](https://github.com/stlink-org/stlink/pull/846)) +* Fixed possible memory leak ([#570](https://github.com/stlink-org/stlink/pull/570), [#571](https://github.com/stlink-org/stlink/pull/571)) +* Fixed installation path for shared objects ([#581](https://github.com/stlink-org/stlink/pull/581)) +* Fixed a few -Wformat warnings ([#582](https://github.com/stlink-org/stlink/pull/582)) +* Removed unused defines in mimgw.h ([#583](https://github.com/stlink-org/stlink/pull/583)) +* Skip GTK detection when cross-compiling ([#588](https://github.com/stlink-org/stlink/pull/588)) +* Fixed compilation with GCC 7 ([#590](https://github.com/stlink-org/stlink/pull/590), [#591](https://github.com/stlink-org/stlink/pull/591)) +* Fixed flashing to 'f0 device' targets ([#594](https://github.com/stlink-org/stlink/pull/594), [#595](https://github.com/stlink-org/stlink/pull/595)) +* Fixed wrong counting when flashing ([#605](https://github.com/stlink-org/stlink/pull/605)) v1.3.1 @@ -151,18 +151,18 @@ Release date: 2017-02-25 Major changes and added features: -* Added support for Semihosting `SYS_READC` ([#546](https://github.com/texane/stlink/pull/546)) -* Added support for STM32F413 ([#549](https://github.com/texane/stlink/pull/549), [#550](https://github.com/texane/stlink/pull/550), [#758](https://github.com/texane/stlink/pull/758)) -* Added preliminary support for STM32L011 to see it after probe (chip-ID 0x457) ([#558](https://github.com/texane/stlink/pull/558), [#598](https://github.com/texane/stlink/pull/598)) +* Added support for Semihosting `SYS_READC` ([#546](https://github.com/stlink-org/stlink/pull/546)) +* Added support for STM32F413 ([#549](https://github.com/stlink-org/stlink/pull/549), [#550](https://github.com/stlink-org/stlink/pull/550), [#758](https://github.com/stlink-org/stlink/pull/758)) +* Added preliminary support for STM32L011 to see it after probe (chip-ID 0x457) ([#558](https://github.com/stlink-org/stlink/pull/558), [#598](https://github.com/stlink-org/stlink/pull/598)) Updates and fixes: * cmake/CPackConfig.cmake: Fixup OSX zip filename * Updated source repositories in README.md: Windows, macOS, Alpine Linux -* Compilation fixes ([#547](https://github.com/texane/stlink/pull/547), [#551](https://github.com/texane/stlink/pull/551), [#552](https://github.com/texane/stlink/pull/552)) -* Stripped full paths to source files in log ([#548](https://github.com/texane/stlink/pull/548)) -* Fixed incorrect release folder name in docs ([#560](https://github.com/texane/stlink/pull/560)) -* Fixed compilation when path includes spaces ([#561](https://github.com/texane/stlink/pull/561)) +* Compilation fixes ([#547](https://github.com/stlink-org/stlink/pull/547), [#551](https://github.com/stlink-org/stlink/pull/551), [#552](https://github.com/stlink-org/stlink/pull/552)) +* Stripped full paths to source files in log ([#548](https://github.com/stlink-org/stlink/pull/548)) +* Fixed incorrect release folder name in docs ([#560](https://github.com/stlink-org/stlink/pull/560)) +* Fixed compilation when path includes spaces ([#561](https://github.com/stlink-org/stlink/pull/561)) v1.3.0 @@ -172,48 +172,48 @@ Release date: 2017-01-28 Major changes and added features: -* Deprecation of autotools (autoconf, automake) and fixed build with MinGW ([#83](https://github.com/texane/stlink/pull/83), [#431](https://github.com/texane/stlink/pull/431), [#434](https://github.com/texane/stlink/pull/434), [#465](https://github.com/texane/stlink/pull/465)) -* Added intel hex file reading for `st-flash` ([#110](https://github.com/texane/stlink/pull/110), [#157](https://github.com/texane/stlink/pull/157), [#457](https://github.com/texane/stlink/pull/547), [#459](https://github.com/texane/stlink/pull/549)) -* Added support for ARM semihosting to `st-util` ([#147](https://github.com/texane/stlink/pull/147), [#227](https://github.com/texane/stlink/pull/227), [#454](https://github.com/texane/stlink/pull/454), [#455](https://github.com/texane/stlink/pull/455)) -* Added manpages (generated with pandoc from Markdown) ([#208](https://github.com/texane/stlink/pull/208), [#464](https://github.com/texane/stlink/pull/464), [#466](https://github.com/texane/stlink/pull/466), [#467](https://github.com/texane/stlink/pull/467)) -* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/texane/stlink/pull/228), ([#507](https://github.com/texane/stlink/pull/507), commit [#3fd0f09](https://github.com/texane/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) -* Support serial numbers argument for `st-util` and `st-flash` to probe and control multiple connected programmers ([#318](https://github.com/texane/stlink/pull/318), [#398](https://github.com/texane/stlink/pull/398), [#541](https://github.com/texane/stlink/pull/541)) -* Merge st-probe tool into st-info ([#398](https://github.com/texane/stlink/pull/398)) -* Added support for native debian packaging ([#444](https://github.com/texane/stlink/pull/444), [#472](https://github.com/texane/stlink/pull/472), [#473](https://github.com/texane/stlink/pull/473), [#482](https://github.com/texane/stlink/pull/482), [#483](https://github.com/texane/stlink/pull/483), [#484](https://github.com/texane/stlink/pull/484), [#485](https://github.com/texane/stlink/pull/485)) -* Rewritten commandline parsing for `st-flash` ([#459](https://github.com/texane/stlink/pull/459)) -* Added `--reset` command to `st-flash` ([#505](https://github.com/texane/stlink/pull/505)) -* st-util should detect when USB commands fail ([#525](https://github.com/texane/stlink/pull/525), ([#527](https://github.com/texane/stlink/pull/527), ([#528](https://github.com/texane/stlink/pull/528)) +* Deprecation of autotools (autoconf, automake) and fixed build with MinGW ([#83](https://github.com/stlink-org/stlink/pull/83), [#431](https://github.com/stlink-org/stlink/pull/431), [#434](https://github.com/stlink-org/stlink/pull/434), [#465](https://github.com/stlink-org/stlink/pull/465)) +* Added intel hex file reading for `st-flash` ([#110](https://github.com/stlink-org/stlink/pull/110), [#157](https://github.com/stlink-org/stlink/pull/157), [#457](https://github.com/stlink-org/stlink/pull/547), [#459](https://github.com/stlink-org/stlink/pull/549)) +* Added support for ARM semihosting to `st-util` ([#147](https://github.com/stlink-org/stlink/pull/147), [#227](https://github.com/stlink-org/stlink/pull/227), [#454](https://github.com/stlink-org/stlink/pull/454), [#455](https://github.com/stlink-org/stlink/pull/455)) +* Added manpages (generated with pandoc from Markdown) ([#208](https://github.com/stlink-org/stlink/pull/208), [#464](https://github.com/stlink-org/stlink/pull/464), [#466](https://github.com/stlink-org/stlink/pull/466), [#467](https://github.com/stlink-org/stlink/pull/467)) +* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature ([#228](https://github.com/stlink-org/stlink/pull/228), ([#507](https://github.com/stlink-org/stlink/pull/507), commit [#3fd0f09](https://github.com/stlink-org/stlink/commit/3fd0f099782506532198473b24f643a3f68d5ff9)) +* Support serial numbers argument for `st-util` and `st-flash` to probe and control multiple connected programmers ([#318](https://github.com/stlink-org/stlink/pull/318), [#398](https://github.com/stlink-org/stlink/pull/398), [#541](https://github.com/stlink-org/stlink/pull/541)) +* Merge st-probe tool into st-info ([#398](https://github.com/stlink-org/stlink/pull/398)) +* Added support for native debian packaging ([#444](https://github.com/stlink-org/stlink/pull/444), [#472](https://github.com/stlink-org/stlink/pull/472), [#473](https://github.com/stlink-org/stlink/pull/473), [#482](https://github.com/stlink-org/stlink/pull/482), [#483](https://github.com/stlink-org/stlink/pull/483), [#484](https://github.com/stlink-org/stlink/pull/484), [#485](https://github.com/stlink-org/stlink/pull/485)) +* Rewritten commandline parsing for `st-flash` ([#459](https://github.com/stlink-org/stlink/pull/459)) +* Added `--reset` command to `st-flash` ([#505](https://github.com/stlink-org/stlink/pull/505)) +* st-util should detect when USB commands fail ([#525](https://github.com/stlink-org/stlink/pull/525), ([#527](https://github.com/stlink-org/stlink/pull/527), ([#528](https://github.com/stlink-org/stlink/pull/528)) Chip support added for: -* STM32F401XE: Added memory map for device ([#460](https://github.com/texane/stlink/pull/460)) -* STM32F410RBTx ([#418](https://github.com/texane/stlink/pull/418)) -* STM32F412 ([#537](https://github.com/texane/stlink/pull/537), [#538](https://github.com/texane/stlink/pull/538)) -* STM32F7xx ([#324](https://github.com/texane/stlink/pull/324), [#326](https://github.com/texane/stlink/pull/326), [#327](https://github.com/texane/stlink/pull/327), [#337](https://github.com/texane/stlink/pull/337)) -* STM32F7x7x ([#433](https://github.com/texane/stlink/pull/433), [#435](https://github.com/texane/stlink/pull/435), [#436](https://github.com/texane/stlink/pull/436), [#509](https://github.com/texane/stlink/pull/509)) -* STM32L0xx Cat2 devices (chip-ID: 0x425) ([#414](https://github.com/texane/stlink/pull/414)) -* STM32L0xx Cat5 devices (chip-ID: 0x447) ([#387](https://github.com/texane/stlink/pull/387), [#406](https://github.com/texane/stlink/pull/406)) -* STM32L4xx ([#321](https://github.com/texane/stlink/pull/321)) -* STM32L432 ([#500](https://github.com/texane/stlink/pull/500), [#501](https://github.com/texane/stlink/pull/501)) +* STM32F401XE: Added memory map for device ([#460](https://github.com/stlink-org/stlink/pull/460)) +* STM32F410RBTx ([#418](https://github.com/stlink-org/stlink/pull/418)) +* STM32F412 ([#537](https://github.com/stlink-org/stlink/pull/537), [#538](https://github.com/stlink-org/stlink/pull/538)) +* STM32F7xx ([#324](https://github.com/stlink-org/stlink/pull/324), [#326](https://github.com/stlink-org/stlink/pull/326), [#327](https://github.com/stlink-org/stlink/pull/327), [#337](https://github.com/stlink-org/stlink/pull/337)) +* STM32F7x7x ([#433](https://github.com/stlink-org/stlink/pull/433), [#435](https://github.com/stlink-org/stlink/pull/435), [#436](https://github.com/stlink-org/stlink/pull/436), [#509](https://github.com/stlink-org/stlink/pull/509)) +* STM32L0xx Cat2 devices (chip-ID: 0x425) ([#414](https://github.com/stlink-org/stlink/pull/414)) +* STM32L0xx Cat5 devices (chip-ID: 0x447) ([#387](https://github.com/stlink-org/stlink/pull/387), [#406](https://github.com/stlink-org/stlink/pull/406)) +* STM32L4xx ([#321](https://github.com/stlink-org/stlink/pull/321)) +* STM32L432 ([#500](https://github.com/stlink-org/stlink/pull/500), [#501](https://github.com/stlink-org/stlink/pull/501)) Updates and fixes: -* Fixed "unaligned addr or size" when trying to write a program in RAM ([#323](https://github.com/texane/stlink/pull/323)) -* Fixed flashing on STM32_F3_SMALL ([#325](https://github.com/texane/stlink/pull/325)) -* Fixed STM32L-problem with flash loader ([#390](https://github.com/texane/stlink/pull/390), [#407](https://github.com/texane/stlink/pull/407),[#408](https://github.com/texane/stlink/pull/408)) -* Don't read the target voltage on startup, because it crashes STM32F100 ([#423](https://github.com/texane/stlink/pull/423), [#424](https://github.com/texane/stlink/pull/424)) -* Added a useful error message instead of "[!] send_recv" ([#425](https://github.com/texane/stlink/pull/425), [#426](https://github.com/texane/stlink/pull/426)) -* Do a JTAG reset prior to reading CPU information when processor is in deep sleep ([#428](https://github.com/texane/stlink/pull/428), [#430](https://github.com/texane/stlink/pull/430), [#451](https://github.com/texane/stlink/pull/451)) -* Fixed STM32F030 erase error ([#442](https://github.com/texane/stlink/pull/442)) -* Fixed memory map for STM32F7xx ([#453](https://github.com/texane/stlink/pull/453), [#456](https://github.com/texane/stlink/pull/456)) -* Redesign of `st-flash` commandline options parsing ([#459](https://github.com/texane/stlink/pull/459)) -* Set SWDCLK and fixed jtag_reset bug ([#462](https://github.com/texane/stlink/pull/462), [#475](https://github.com/texane/stlink/pull/475), [#534](https://github.com/texane/stlink/pull/534)) -* doc/compiling.md: Add note about installation and ldconfig ([#478](https://github.com/texane/stlink/pull/478), commit [#be66bbf](https://github.com/texane/stlink/commit/be66bbf200c718904514b044ba84d64a36456218)) -* Fixed Release target to generate the man-pages with pandoc ([#479](https://github.com/texane/stlink/pull/479)) -* Fixed Cygwin build ([#487](https://github.com/texane/stlink/pull/487), ([#506](https://github.com/texane/stlink/pull/506)) -* Reset flash mass erase (MER) bit after mass erase for safety ([#489](https://github.com/texane/stlink/pull/489)) -* Wrong extract command in FindLibUSB.cmake ([#510](https://github.com/texane/stlink/pull/510), [#511](https://github.com/texane/stlink/pull/511)) -* Fixed compilation error on Ubuntu 16.10 ([#514](https://github.com/texane/stlink/pull/514), [#525](https://github.com/texane/stlink/pull/525)) +* Fixed "unaligned addr or size" when trying to write a program in RAM ([#323](https://github.com/stlink-org/stlink/pull/323)) +* Fixed flashing on STM32_F3_SMALL ([#325](https://github.com/stlink-org/stlink/pull/325)) +* Fixed STM32L-problem with flash loader ([#390](https://github.com/stlink-org/stlink/pull/390), [#407](https://github.com/stlink-org/stlink/pull/407),[#408](https://github.com/stlink-org/stlink/pull/408)) +* Don't read the target voltage on startup, because it crashes STM32F100 ([#423](https://github.com/stlink-org/stlink/pull/423), [#424](https://github.com/stlink-org/stlink/pull/424)) +* Added a useful error message instead of "[!] send_recv" ([#425](https://github.com/stlink-org/stlink/pull/425), [#426](https://github.com/stlink-org/stlink/pull/426)) +* Do a JTAG reset prior to reading CPU information when processor is in deep sleep ([#428](https://github.com/stlink-org/stlink/pull/428), [#430](https://github.com/stlink-org/stlink/pull/430), [#451](https://github.com/stlink-org/stlink/pull/451)) +* Fixed STM32F030 erase error ([#442](https://github.com/stlink-org/stlink/pull/442)) +* Fixed memory map for STM32F7xx ([#453](https://github.com/stlink-org/stlink/pull/453), [#456](https://github.com/stlink-org/stlink/pull/456)) +* Redesign of `st-flash` commandline options parsing ([#459](https://github.com/stlink-org/stlink/pull/459)) +* Set SWDCLK and fixed jtag_reset bug ([#462](https://github.com/stlink-org/stlink/pull/462), [#475](https://github.com/stlink-org/stlink/pull/475), [#534](https://github.com/stlink-org/stlink/pull/534)) +* doc/compiling.md: Add note about installation and ldconfig ([#478](https://github.com/stlink-org/stlink/pull/478), commit [#be66bbf](https://github.com/stlink-org/stlink/commit/be66bbf200c718904514b044ba84d64a36456218)) +* Fixed Release target to generate the man-pages with pandoc ([#479](https://github.com/stlink-org/stlink/pull/479)) +* Fixed Cygwin build ([#487](https://github.com/stlink-org/stlink/pull/487), ([#506](https://github.com/stlink-org/stlink/pull/506)) +* Reset flash mass erase (MER) bit after mass erase for safety ([#489](https://github.com/stlink-org/stlink/pull/489)) +* Wrong extract command in FindLibUSB.cmake ([#510](https://github.com/stlink-org/stlink/pull/510), [#511](https://github.com/stlink-org/stlink/pull/511)) +* Fixed compilation error on Ubuntu 16.10 ([#514](https://github.com/stlink-org/stlink/pull/514), [#525](https://github.com/stlink-org/stlink/pull/525)) v1.2.0 @@ -245,9 +245,9 @@ Updates and fixes: * Fixed STM32F2xx memory map (Nicolas Schodet) * Memory map for STM32F42xxx and STM32F43xxx devices (Craig Lilley) * Stm32l0x flash loader (Robin Kreis) -* Send F4 memory-map and features for STM32F429 ([#188](https://github.com/texane/stlink/pull/188), [#196](https://github.com/texane/stlink/pull/196), [#250](https://github.com/texane/stlink/pull/250), [#251](https://github.com/texane/stlink/pull/251)) (Release v1.1.0) -* Added AHB3 Peripherals definition for STM32F4 ([#218](https://github.com/texane/stlink/pull/218), [#288](https://github.com/texane/stlink/pull/288)) (Release v1.1.0) -* Corrected flash size register address for STM32F2 devices ([#278](https://github.com/texane/stlink/pull/278)) (Release v1.0.0) +* Send F4 memory-map and features for STM32F429 ([#188](https://github.com/stlink-org/stlink/pull/188), [#196](https://github.com/stlink-org/stlink/pull/196), [#250](https://github.com/stlink-org/stlink/pull/250), [#251](https://github.com/stlink-org/stlink/pull/251)) (Release v1.1.0) +* Added AHB3 Peripherals definition for STM32F4 ([#218](https://github.com/stlink-org/stlink/pull/218), [#288](https://github.com/stlink-org/stlink/pull/288)) (Release v1.1.0) +* Corrected flash size register address for STM32F2 devices ([#278](https://github.com/stlink-org/stlink/pull/278)) (Release v1.0.0) Chip support added for: @@ -256,9 +256,9 @@ Chip support added for: * Added STM32L4 to CHIPID #defines and devices[], flash driver and loader (Dave Vandervies) * Basic support for STM32F446 (Pavel Kirienko) * STM32F303 High Density -* STM32F469/STM32F479 ([#345](https://github.com/texane/stlink/pull/345), [#555](https://github.com/texane/stlink/pull/555)) (Release v1.2.0) +* STM32F469/STM32F479 ([#345](https://github.com/stlink-org/stlink/pull/345), [#555](https://github.com/stlink-org/stlink/pull/555)) (Release v1.2.0) * STM32L1xx Cat.2 devices (Nicolas Schodet) -* STM32L1xx (chip-ID 0x427) ([#152](https://github.com/texane/stlink/pull/152), [#163](https://github.com/texane/stlink/pull/163), [#165](https://github.com/texane/stlink/pull/165)) (Release v1.0.0) +* STM32L1xx (chip-ID 0x427) ([#152](https://github.com/stlink-org/stlink/pull/152), [#163](https://github.com/stlink-org/stlink/pull/163), [#165](https://github.com/stlink-org/stlink/pull/165)) (Release v1.0.0) Board support added for: diff --git a/LICENSE.md b/LICENSE.md index 0a3ddd1f7..9c3b59f0f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2020, The stlink project (github.com/texane/stlink) & "Capt'ns Missing Link" authors. +Copyright (c) 2020, The stlink project (github.com/stlink-org/stlink) & "Capt'ns Missing Link" authors. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index b2ff03d54..86be05c8f 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Open source version of the STMicroelectronics STlink Tools ========================================================== [![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) -[![GitHub release](https://img.shields.io/github/release/texane/stlink.svg)](https://github.com/stlink-org/stlink/releases/latest) -[![GitHub commits](https://img.shields.io/github/commits-since/texane/stlink/v1.6.0.svg)](https://github.com/stlink-org/stlink/releases/master) -[![Downloads](https://img.shields.io/github/downloads/texane/stlink/total.svg)](https://github.com/stlink-org/stlink/releases) -[![Linux Status](https://img.shields.io/travis/texane/stlink/master.svg?label=linux)](https://travis-ci.org/stlink-org/stlink) -[![macOS Status](https://img.shields.io/travis/texane/stlink/master.svg?label=osx)](https://travis-ci.org/stlink-org/stlink) +[![GitHub release](https://img.shields.io/github/release/stlink-org/stlink.svg)](https://github.com/stlink-org/stlink/releases/latest) +[![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.0.svg)](https://github.com/stlink-org/stlink/releases/master) +[![Downloads](https://img.shields.io/github/downloads/stlink-org/stlink/total.svg)](https://github.com/stlink-org/stlink/releases) +[![Linux Status](https://img.shields.io/travis/stlink-org/stlink/master.svg?label=linux)](https://travis-ci.org/stlink-org/stlink) +[![macOS Status](https://img.shields.io/travis/stlink-org/stlink/master.svg?label=osx)](https://travis-ci.org/stlink-org/stlink) Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) of this software project. @@ -48,10 +48,12 @@ The STlink toolset includes: * a GUI-Interface (stlink-gui) _[optional]_ -## Supported hardware combinations +## Supported operating systems and hardware combinations Currently known working combinations of programmers and targets are listed in [devices_boards.md](doc/devices_boards.md). +Supported operating systems are listed in [version_support.md](doc/version_support.md). + ## Tutorial & HOWTO @@ -110,13 +112,13 @@ When there is no executable available for your platform or you need the latest ( # Current state of the project ## Known missing features -Some features are currently missing from the `texane/stlink` toolset. +Some features are currently missing from the `stlink-org/stlink` toolset. Here we would appreciate any help and would love to welcome new contributors who want to get involved: -* Instrumentation Trace Macro (ITM) Cell ([#136](https://github.com/texane/stlink/issues/136)) -* OTP & EEPROM area programming ([#202](https://github.com/texane/stlink/issues/202), [#333](https://github.com/texane/stlink/issues/333), [#686](https://github.com/texane/stlink/issues/686)) -* Protection bits area reading ([#346](https://github.com/texane/stlink/issues/346)) -* Writing external memory connected to an STM32 controller (e.g Quad SPI NOR flash) ([#412](https://github.com/texane/stlink/issues/412)) -* MCU hotplug ([#449](https://github.com/texane/stlink/issues/449)) -* Writing options bytes (region) ([#458](https://github.com/texane/stlink/issues/458)) -* Support for STLINKv3 programmer ([#820](https://github.com/texane/stlink/issues/820)) +* Instrumentation Trace Macro (ITM) Cell ([#136](https://github.com/stlink-org/stlink/issues/136)) +* OTP & EEPROM area programming ([#202](https://github.com/stlink-org/stlink/issues/202), [#333](https://github.com/stlink-org/stlink/issues/333), [#686](https://github.com/stlink-org/stlink/issues/686)) +* Protection bits area reading ([#346](https://github.com/stlink-org/stlink/issues/346)) +* Writing external memory connected to an STM32 controller (e.g Quad SPI NOR flash) ([#412](https://github.com/stlink-org/stlink/issues/412)) +* MCU hotplug ([#449](https://github.com/stlink-org/stlink/issues/449)) +* Writing options bytes (region) ([#458](https://github.com/stlink-org/stlink/issues/458)) +* Support for STLINKv3 programmer ([#820](https://github.com/stlink-org/stlink/issues/820)) diff --git a/debian/control b/debian/control index e33fc757c..3c1e9700f 100644 --- a/debian/control +++ b/debian/control @@ -1,12 +1,12 @@ Source: stlink Priority: optional -Maintainer: Andrew 'Necromant' Andrianov +Maintainer: Luca Bocassi Build-Depends: debhelper (>= 9), cmake, libusb-1.0-0-dev, libgtk-3-dev Standards-Version: 4.1.3 Section: electronics -Homepage: https://github.com/texane/stlink -Vcs-Git: https://github.com/texane/stlink.git -Vcs-Browser: https://github.com/texane/stlink +Homepage: https://github.com/stlink-org/stlink +Vcs-Git: https://github.com/stlink-org/stlink.git +Vcs-Browser: https://github.com/stlink-org/stlink Package: libstlink-dev Section: libdevel diff --git a/debian/copyright b/debian/copyright index 941a4a011..7a6d585c5 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,7 +1,7 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: stlink -Upstream-Contact: Andrew 'Necromant' Andrianov -Source: https://github.com/texane/stlink +Upstream-Contact: Luca Bocassi +Source: https://github.com/stlink-org/stlink Files: * Copyright: 2011-2018 agpanarin diff --git a/debian/watch b/debian/watch index cc653ca9f..20ad1260e 100644 --- a/debian/watch +++ b/debian/watch @@ -1,3 +1,3 @@ version=3 opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/-$1\.tar\.gz/ \ - https://github.com/texane/stlink/tags .*/v?(\d\S+)\.tar\.gz + https://github.com/stlink-org/stlink/tags .*/v?(\d\S+)\.tar\.gz diff --git a/tests/flash.c b/tests/flash.c index d193666ff..27391b244 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -4,8 +4,9 @@ #include #include + #if defined(_MSC_VER) -#include + #include #endif struct Test { @@ -15,39 +16,46 @@ struct Test { }; static bool cmp_strings(const char * s1, const char * s2) { - if (s1 == NULL || s2 == NULL) return (s1 == s2); - else return (0 == strcmp(s1, s2)); + if (s1 == NULL || s2 == NULL) { + return (s1 == s2); + } else { + return (0 == strcmp(s1, s2)); + } } static bool cmp_mem(const uint8_t * s1, const uint8_t * s2, size_t size) { - if (s1 == NULL || s2 == NULL) return (s1 == s2); - else return (0 == memcmp(s1, s2, size)); + if (s1 == NULL || s2 == NULL) { + return (s1 == s2); + } else { + return (0 == memcmp(s1, s2, size)); + } } static bool execute_test(const struct Test * test) { int ac = 0; char* av[32]; - // parse (tokenize) the test command line -#if defined(_MSC_VER) - char *cmd_line = alloca(strlen(test->cmd_line) + 1); -#else - char cmd_line[strlen(test->cmd_line) + 1]; -#endif + /* parse (tokenize) the test command line */ + #if defined(_MSC_VER) + char *cmd_line = alloca(strlen(test->cmd_line) + 1); + #else + char cmd_line[strlen(test->cmd_line) + 1]; + #endif + strcpy(cmd_line, test->cmd_line); for (char * tok = strtok(cmd_line, " "); tok; tok = strtok(NULL, " ")) { - if ((size_t)ac >= sizeof(av)/sizeof(av[0])) return false; - + if ((size_t)ac >= sizeof(av)/sizeof(av[0])) + return false; av[ac] = tok; ++ac; } - // call + /* call */ struct flash_opts opts; int res = flash_get_opts(&opts, ac, av); - // compare results + /* compare results */ bool ret = (res == test->res); if (ret && (res == 0)) { @@ -69,45 +77,115 @@ static bool execute_test(const struct Test * test) { static struct Test tests[] = { { "", -1, FLASH_OPTS_INITIALIZER }, { "--debug --reset read /dev/sg0 test.bin 0x80000000 0x1000", 0, - { .cmd = FLASH_CMD_READ, .devname = "/dev/sg0", .serial = { 0 }, .filename = "test.bin", - .addr = 0x80000000, .size = 0x1000, .reset = 1, .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_READ, + .devname = "/dev/sg0", + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0x1000, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--debug --reset write /dev/sg0 test.bin 0x80000000", 0, - { .cmd = FLASH_CMD_WRITE, .devname = "/dev/sg0", .serial = { 0 }, .filename = "test.bin", - .addr = 0x80000000, .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_WRITE, + .devname = "/dev/sg0", + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--serial A1020304 /dev/sg0 erase", -1, FLASH_OPTS_INITIALIZER }, { "/dev/sg0 erase", 0, - { .cmd = FLASH_CMD_ERASE, .devname = "/dev/sg0", .serial = { 0 }, .filename = NULL, - .addr = 0, .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_ERASE, + .devname = "/dev/sg0", + .serial = { 0 }, + .filename = NULL, + .addr = 0, + .size = 0, + .reset = 0, + .log_level = STND_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--debug --reset read test.bin 0x80000000 0x1000", 0, - { .cmd = FLASH_CMD_READ, .devname = NULL, .serial = { 0 }, .filename = "test.bin", - .addr = 0x80000000, .size = 0x1000, .reset = 1, .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_READ, + .devname = NULL, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0x1000, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--debug --reset write test.bin 0x80000000", 0, - { .cmd = FLASH_CMD_WRITE, .devname = NULL, .serial = { 0 }, .filename = "test.bin", - .addr = 0x80000000, .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_WRITE, + .devname = NULL, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "erase", 0, - { .cmd = FLASH_CMD_ERASE, .devname = NULL, .serial = { 0 }, .filename = NULL, - .addr = 0, .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_ERASE, + .devname = NULL, + .serial = { 0 }, + .filename = NULL, + .addr = 0, + .size = 0, + .reset = 0, + .log_level = STND_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--debug --reset --format=ihex write test.hex", 0, - { .cmd = FLASH_CMD_WRITE, .devname = NULL, .serial = { 0 }, .filename = "test.hex", - .addr = 0, .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_IHEX } }, + { .cmd = FLASH_CMD_WRITE, + .devname = NULL, + .serial = { 0 }, + .filename = "test.hex", + .addr = 0, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_IHEX } + }, { "--debug --reset --format=binary write test.hex", -1, FLASH_OPTS_INITIALIZER }, { "--debug --reset --format=ihex write test.hex 0x80000000", -1, FLASH_OPTS_INITIALIZER }, { "--debug --reset write test.hex sometext", -1, FLASH_OPTS_INITIALIZER }, { "--serial A1020304 erase", 0, - { .cmd = FLASH_CMD_ERASE, .devname = NULL, .serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04", .filename = NULL, - .addr = 0, .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_ERASE, + .devname = NULL, + .serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04", + .filename = NULL, + .addr = 0, + .size = 0, + .reset = 0, + .log_level = STND_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--serial=A1020304 erase", 0, - { .cmd = FLASH_CMD_ERASE, .devname = NULL, .serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04", .filename = NULL, - .addr = 0, .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { .cmd = FLASH_CMD_ERASE, + .devname = NULL, + .serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04", + .filename = NULL, + .addr = 0, + .size = 0, + .reset = 0, + .log_level = STND_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, }; -int main() -{ +int main() { bool allOk = true; for (size_t i = 0; i < sizeof(tests)/sizeof(tests[0]); ++i) { - if (!execute_test(&tests[i])) allOk = false; + if (!execute_test(&tests[i])) + allOk = false; } - return (allOk ? 0 : 1); } - diff --git a/tests/sg.c b/tests/sg.c index a014717d7..32ef55b69 100644 --- a/tests/sg.c +++ b/tests/sg.c @@ -1,6 +1,6 @@ -/* +/* * File: test_main.c - * + * * main() ripped out of old stlink-hw.c */ @@ -10,7 +10,7 @@ #include #if defined(_MSC_VER) -#define __attribute__(x) + #define __attribute__(x) #endif static void __attribute__((unused)) mark_buf(stlink_t *sl) { @@ -24,24 +24,22 @@ static void __attribute__((unused)) mark_buf(stlink_t *sl) { sl->q_buf[16] = 0x33; sl->q_buf[63] = 0x44; sl->q_buf[64] = 0x69; - sl->q_buf[1024 * 6 - 1] = 0x42; //6kB - sl->q_buf[1024 * 8 - 1] = 0x42; //8kB + sl->q_buf[1024 * 6 - 1] = 0x42; // 6kB + sl->q_buf[1024 * 8 - 1] = 0x42; // 8kB } -int main(void) -{ +int main(void) { /* Avoid unused parameter warning */ // set scpi lib debug level: 0 for no debug info, 10 for lots - - fputs( - "\nUsage: stlink-access-test [anything at all] ...\n" - "\n*** Notice: The stlink firmware violates the USB standard.\n" - "*** Because we just use libusb, we can just tell the kernel's\n" - "*** driver to simply ignore the device...\n" - "*** Unplug the stlink and execute once as root:\n" - "modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i\n\n", - stderr); + fputs( + "\nUsage: stlink-access-test [anything at all] ...\n" + "\n*** Notice: The stlink firmware violates the USB standard.\n" + "*** Because we just use libusb, we can just tell the kernel's\n" + "*** driver to simply ignore the device...\n" + "*** Unplug the stlink and execute once as root:\n" + "modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i\n\n", + stderr); stlink_t *sl = stlink_v1_open(99, 1); if (sl == NULL) @@ -51,8 +49,6 @@ int main(void) stlink_enter_swd_mode(sl); stlink_current_mode(sl); stlink_core_id(sl); - //---------------------------------------------------------------------- - stlink_status(sl); //stlink_force_debug(sl); stlink_reset(sl); @@ -67,19 +63,19 @@ int main(void) #if 0 stlink_read_mem32(sl, 0xe000edf0, 4); DD(sl, "DHCSR = 0x%08x", read_uint32(sl->q_buf, 0)); - stlink_read_mem32(sl, 0x4001100c, 4); DD(sl, "GPIOC_ODR = 0x%08x", read_uint32(sl->q_buf, 0)); #endif + #if 0 - // happy new year 2011: let blink all the leds + // let blink all the leds // see "RM0041 Reference manual - STM32F100xx advanced ARM-based 32-bit MCUs" -#define GPIOC 0x40011000 // port C -#define GPIOC_CRH (GPIOC + 0x04) // port configuration register high -#define GPIOC_ODR (GPIOC + 0x0c) // port output data register -#define LED_BLUE (1<<8) // pin 8 -#define LED_GREEN (1<<9) // pin 9 + #define GPIOC 0x40011000 // port C + #define GPIOC_CRH (GPIOC + 0x04) // port configuration register high + #define GPIOC_ODR (GPIOC + 0x0c) // port output data register + #define LED_BLUE (1<<8) // pin 8 + #define LED_GREEN (1<<9) // pin 9 stlink_read_mem32(sl, GPIOC_CRH, 4); uint32_t io_conf = read_uint32(sl->q_buf, 0); DLOG("GPIOC_CRH = 0x%08x\n", io_conf); @@ -92,8 +88,8 @@ int main(void) for (int i = 0; i < 100; i++) { write_uint32(sl->q_buf, LED_BLUE | LED_GREEN); stlink_write_mem32(sl, GPIOC_ODR, 4); - /* stlink_read_mem32(sl, 0x4001100c, 4); */ - /* DD(sl, "GPIOC_ODR = 0x%08x", read_uint32(sl->q_buf, 0)); */ + //stlink_read_mem32(sl, 0x4001100c, 4); + //DD(sl, "GPIOC_ODR = 0x%08x", read_uint32(sl->q_buf, 0)); usleep(100 * 1000); memset(sl->q_buf, 0, sizeof(sl->q_buf)); @@ -101,8 +97,8 @@ int main(void) usleep(100 * 1000); } write_uint32(sl->q_buf, io_conf); // set old state - #endif + #if 0 // TODO rtfm: stlink doesn't have flash write routines // writing to the flash area confuses the fw for the next read access @@ -119,18 +115,19 @@ int main(void) stlink_read_mem32(sl, 0x08000c00, 256); stlink_read_mem32(sl, 0x08000c00, 256); #endif + #if 0 // sram 0x20000000 8kB fputs("\n++++++++++ read/write 8bit, sram at 0x2000 0000 ++++++++++++++++\n\n", stderr); memset(sl->q_buf, 0, sizeof(sl->q_buf)); mark_buf(sl); //stlink_write_mem8(sl, 0x20000000, 16); - //stlink_write_mem8(sl, 0x20000000, 1); //stlink_write_mem8(sl, 0x20000001, 1); stlink_write_mem8(sl, 0x2000000b, 3); stlink_read_mem32(sl, 0x20000000, 16); #endif + #if 0 // a not aligned mem32 access doesn't work indeed fputs("\n++++++++++ read/write 32bit, sram at 0x2000 0000 ++++++++++++++++\n\n", stderr); @@ -149,6 +146,7 @@ int main(void) stlink_write_mem32(sl, 0x20000000, 17); stlink_read_mem32(sl, 0x20000000, 32); #endif + #if 0 // sram 0x20000000 8kB fputs("++++++++++ read/write 32bit, sram at 0x2000 0000 ++++++++++++\n", stderr); @@ -162,26 +160,30 @@ int main(void) stlink_read_mem32(sl, 0x20000000, 1024 * 6); stlink_read_mem32(sl, 0x20000000 + 1024 * 6, 1024 * 2); #endif + #if 0 stlink_run(sl); stlink_status(sl); - stlink_force_debug(sl); stlink_status(sl); #endif + #if 0 /* read the system bootloader */ fputs("\n++++++++++ reading bootloader ++++++++++++++++\n\n", stderr); stlink_fread(sl, "/tmp/barfoo", sl->sys_base, sl->sys_size); #endif + #if 0 /* read the flash memory */ fputs("\n+++++++ read flash memory\n\n", stderr); /* mark_buf(sl); */ stlink_read_mem32(sl, 0x08000000, 4); #endif + #if 0 /* flash programming */ fputs("\n+++++++ program flash memory\n\n", stderr); stlink_fwrite_flash(sl, "/tmp/foobar", 0x08000000); #endif + #if 0 /* check file contents */ fputs("\n+++++++ check flash memory\n\n", stderr); { @@ -189,6 +191,7 @@ int main(void) printf("_____ stlink_fcheck_flash() == %d\n", res); } #endif + #if 0 fputs("\n+++++++ sram write and execute\n\n", stderr); stlink_fwrite_sram(sl, "/tmp/foobar", sl->sram_base); @@ -198,13 +201,13 @@ int main(void) #if 0 stlink_run(sl); stlink_status(sl); - //---------------------------------------------------------------------- // back to mass mode, just in case ... stlink_exit_debug_mode(sl); stlink_current_mode(sl); stlink_close(sl); #endif - //fflush(stderr); fflush(stdout); + //fflush(stderr); + //fflush(stdout); return EXIT_SUCCESS; } diff --git a/tests/usb.c b/tests/usb.c index 06fd73429..082c8583b 100644 --- a/tests/usb.c +++ b/tests/usb.c @@ -1,10 +1,9 @@ #include #include -int main(int ac, char** av) -{ - (void)ac; - (void)av; +int main(int ac, char** av) { + (void)ac; + (void)av; stlink_t* sl; struct stlink_reg regs; @@ -43,12 +42,12 @@ int main(int ac, char** av) printf("FP_CTRL\n"); stlink_read_mem32(sl, STLINK_REG_CM3_FP_CTRL, 4); - // no idea what reg this is.. */ - // stlink_read_mem32(sl, 0xe000ed90, 4); + // no idea what reg this is... + //stlink_read_mem32(sl, 0xe000ed90, 4); // no idea what register this is... - // stlink_read_mem32(sl, 0xe000edf0, 4); + //stlink_read_mem32(sl, 0xe000edf0, 4); // offset 0xC into TIM11 register? TIMx_DIER? - // stlink_read_mem32(sl, 0x4001100c, 4); */ + //stlink_read_mem32(sl, 0x4001100c, 4); /* Test 32 bit Write */ write_uint32(sl->q_buf,0x01234567); @@ -72,14 +71,13 @@ int main(int ac, char** av) printf("-- reset\n"); stlink_reset(sl); stlink_force_debug(sl); - /* Test reg write*/ + /* Test reg write */ stlink_write_reg(sl, 0x01234567, 3); stlink_write_reg(sl, 0x89abcdef, 4); stlink_write_reg(sl, 0x12345678, 15); for (off = 0; off < 21; off += 1) stlink_read_reg(sl, off, ®s); - stlink_read_all_regs(sl, ®s); printf("-- status\n"); @@ -96,6 +94,5 @@ int main(int ac, char** av) stlink_close(sl); } - return 0; } From aa38587e3c357b6c09934409baa9d685994a09f9 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 12:54:43 +0200 Subject: [PATCH 121/236] Restored functionality of make test builds (Fixes #926) --- include/stlink/tools/flash.h | 3 +-- tests/flash.c | 30 +++++------------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index 659c17f28..15e020b35 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -14,7 +14,6 @@ enum flash_area {FLASH_MAIN_MEMORY = 0, FLASH_SYSTEM_MEMORY = 1,FLASH_OTP = 2, F struct flash_opts { enum flash_cmd cmd; - const char* devname; uint8_t serial[STLINK_SERIAL_MAX_SIZE]; const char* filename; stm32_addr_t addr; @@ -28,7 +27,7 @@ struct flash_opts int opt; }; -#define FLASH_OPTS_INITIALIZER {0, NULL, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} int flash_get_opts(struct flash_opts* o, int ac, char** av); diff --git a/tests/flash.c b/tests/flash.c index 27391b244..53032474a 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -60,7 +60,6 @@ static bool execute_test(const struct Test * test) { if (ret && (res == 0)) { ret &= (opts.cmd == test->opts.cmd); - ret &= cmp_strings(opts.devname, test->opts.devname); ret &= cmp_mem(opts.serial, test->opts.serial, sizeof(opts.serial)); ret &= cmp_strings(opts.filename, test->opts.filename); ret &= (opts.addr == test->opts.addr); @@ -76,9 +75,8 @@ static bool execute_test(const struct Test * test) { static struct Test tests[] = { { "", -1, FLASH_OPTS_INITIALIZER }, - { "--debug --reset read /dev/sg0 test.bin 0x80000000 0x1000", 0, + { "--debug --reset read test.bin 0x80000000 0x1000", 0, { .cmd = FLASH_CMD_READ, - .devname = "/dev/sg0", .serial = { 0 }, .filename = "test.bin", .addr = 0x80000000, @@ -87,9 +85,8 @@ static struct Test tests[] = { .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, - { "--debug --reset write /dev/sg0 test.bin 0x80000000", 0, + { "--debug --reset write test.bin 0x80000000", 0, { .cmd = FLASH_CMD_WRITE, - .devname = "/dev/sg0", .serial = { 0 }, .filename = "test.bin", .addr = 0x80000000, @@ -98,21 +95,8 @@ static struct Test tests[] = { .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, - { "--serial A1020304 /dev/sg0 erase", -1, FLASH_OPTS_INITIALIZER }, - { "/dev/sg0 erase", 0, - { .cmd = FLASH_CMD_ERASE, - .devname = "/dev/sg0", - .serial = { 0 }, - .filename = NULL, - .addr = 0, - .size = 0, - .reset = 0, - .log_level = STND_LOG_LEVEL, - .format = FLASH_FORMAT_BINARY } - }, { "--debug --reset read test.bin 0x80000000 0x1000", 0, { .cmd = FLASH_CMD_READ, - .devname = NULL, .serial = { 0 }, .filename = "test.bin", .addr = 0x80000000, @@ -123,7 +107,6 @@ static struct Test tests[] = { }, { "--debug --reset write test.bin 0x80000000", 0, { .cmd = FLASH_CMD_WRITE, - .devname = NULL, .serial = { 0 }, .filename = "test.bin", .addr = 0x80000000, @@ -134,7 +117,6 @@ static struct Test tests[] = { }, { "erase", 0, { .cmd = FLASH_CMD_ERASE, - .devname = NULL, .serial = { 0 }, .filename = NULL, .addr = 0, @@ -145,7 +127,6 @@ static struct Test tests[] = { }, { "--debug --reset --format=ihex write test.hex", 0, { .cmd = FLASH_CMD_WRITE, - .devname = NULL, .serial = { 0 }, .filename = "test.hex", .addr = 0, @@ -157,10 +138,10 @@ static struct Test tests[] = { { "--debug --reset --format=binary write test.hex", -1, FLASH_OPTS_INITIALIZER }, { "--debug --reset --format=ihex write test.hex 0x80000000", -1, FLASH_OPTS_INITIALIZER }, { "--debug --reset write test.hex sometext", -1, FLASH_OPTS_INITIALIZER }, + { "--serial A1020304 erase sometext", -1, FLASH_OPTS_INITIALIZER }, { "--serial A1020304 erase", 0, { .cmd = FLASH_CMD_ERASE, - .devname = NULL, - .serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04", + .serial = "\xA1\x02\x03\x04", .filename = NULL, .addr = 0, .size = 0, @@ -170,8 +151,7 @@ static struct Test tests[] = { }, { "--serial=A1020304 erase", 0, { .cmd = FLASH_CMD_ERASE, - .devname = NULL, - .serial = "\0\0\0\0\0\0\0\0\xA1\x02\x03\x04", + .serial = "\xA1\x02\x03\x04", .filename = NULL, .addr = 0, .size = 0, From 07c5e324a805a21763416e1a419764dd5185effa Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 13:21:07 +0200 Subject: [PATCH 122/236] Updated CHANGELOG for upcoming release --- CHANGELOG.md | 61 ++++++++++++++++++++++++++++++++++- CMakeLists.txt | 22 ++++++------- src/stlink-gui/CMakeLists.txt | 2 +- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cf102910..ce2a9e595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,65 @@ -Stlink ChangeLog +stlink ChangeLog ================ +v1.6.1 +====== + +Release date: (TBD) + +This release drops support for some older operating systems. Check project README for details. + +Features: + +- Support for STM32L1, SM32L4 option bytes write (#596, #844, #847) +- CMake now creates an uninstall target (#619, #907) +- Support for STM32G4 (#822) +- Add aliased SRAM2 region in the L496 memory map (#824) +- Improved support for STM32G0 (#825, #850, #856, #857) +- Added usb PID and udev rules for STlink v2.1 found on Nucleo-L432KC and Nucleo-L552ze boards (#900) +- STM32G0/G4 improvements (#910) + - Enable mass erase with a flash programming check + - Handle G4 Cat3 devices with configurable dual bank flash by using a helper +- Calculate checksums for flash operations (#862, #924) + +Updates & changes: + +- Improved argument parsing for CLI tools (#378, #922) +- [doc] Updated tutorial: macOS ST-Link-v1 detection (#574, #587) +- Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION (#211, #782, #895) +- [doc] Verify correct udev configuration for device access (#764) +- Added more error info to WLOGs during probe (#883) +- Added travis build for win32 (#870) +- Added check for libssp during compilation (#885) +- Silence unnecessary messages (#886) +- Set up a libusb log level accordingly to verbosity (commit 49f887d5247fdd28f163b6317790c4f087e652cc) +- [doc] Define libusb & cmake version compatibility (#896, #897, #899, commit 27aa88821197d3ffe82baff4e971c3488ec39899) +- Update for STM32G471/473/474/483/484 devices (#901) +- [doc] st-flash --flash=n[k][m] command line option to override device model (#902) +- [doc] Update compiling instructions (#113, commit 10ae5294cd03aacfc07312010f026d3cb12ea56c) +- [doc] Defined version compatibility and installation instructions for macOS (commit 23c071edea45f6e8852fef52d884a680973d6d8f) +- Deprecated old appveyor-mingw script (commit 97484422008df0f75c978627054776f35842a075) +- Enhanced error log with file path for map_file() (#650, #879, #921) + +Fixes: + +- Fixed wait-loop for flash_loader_run() (#290) +- Clear the PG bit before setting the PER bit (#579, #876) +- Fixed compilation issues with int length on 32-bit platforms (#629, #908) +- Fixed st-info --probe mechanism (#679, #918) +- Fixed sign-compare (size != rep_len) in usb.c (Regression) (#772, #869, #872, #891) +- Avoid re-define of O_BINARY on Windows (#788) +- Fixed st-flash manpage read example (#858) +- Fixed stlink support with no mass storage (#861) +- Make Version.cmake more error-resistant (#872) +- Error return in failed probe (#887, #890) +- Fixed formatting for options display in st-flash & st-info (commits c783d0e777ccc83a7a8be26a4f4d3414e0478560 and 562cd2496e696dbd22950925866aac662d81ee5f) +- Fixed dead loop after an unexpected unplug (#780, #812, #913) +- Fixed broken build on 32-bit systems (#919, #920) +- st-flash: minor usage fix and make cmdline parsing more user friendly (#925) +- Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 (#378, #922) +- Restored functionality of make test builds (Regression) (#926) + + v1.6.0 ====== diff --git a/CMakeLists.txt b/CMakeLists.txt index 87bd47aac..421ec7c6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,7 @@ set(STLINK_SOURCE src/md5.c ) -if (WIN32 OR MSYS OR MINGW) +if (WIN32 OR MINGW OR MSYS) set(STLINK_SOURCE "${STLINK_SOURCE};src/mmap.c;src/mingw/mingw.c") set(STLINK_HEADERS "${STLINK_HEADERS};src/mingw/mingw.h") endif () @@ -116,6 +116,7 @@ include_directories(${LIBUSB_INCLUDE_DIR}) include_directories(include) include_directories(${PROJECT_BINARY_DIR}/include) include_directories(src/mingw) + if (MSVC) include_directories(src/win32) include_directories(src/getopt) @@ -130,7 +131,7 @@ endif () if (NOT WIN32) set(STLINK_LIB_SHARED ${PROJECT_NAME}) -else () +else (WIN32) set(STLINK_LIB_SHARED ${PROJECT_NAME}-shared) endif () @@ -164,16 +165,13 @@ if (APPLE) target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) endif () -if (WIN32 OR MSYS OR MINGW) +if (WIN32 OR MINGW OR MSYS) target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else () target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif () -install( - TARGETS ${STLINK_LIB_SHARED} - DESTINATION ${STLINK_LIBRARY_PATH} - ) +install(TARGETS ${STLINK_LIB_SHARED} DESTINATION ${STLINK_LIBRARY_PATH}) ### TODO: Check path ### @@ -188,7 +186,7 @@ add_library( ${STLINK_SOURCE} ) -# Link shared library with Apple macOS libraries +# Link static library with Apple macOS libraries if (APPLE) find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) @@ -196,7 +194,7 @@ if (APPLE) target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) endif () -if (WIN32 OR MSYS OR MINGW) +if (WIN32 OR MINGW OR MSYS) ### TODO: MinGW OR MSYS on Linux target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else () target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB}) @@ -205,7 +203,7 @@ 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}) + install(TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH}) ### TODO: Check path endif () @@ -224,7 +222,7 @@ else () target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB}) endif () -install(TARGETS st-flash st-info RUNTIME DESTINATION bin) +install(TARGETS st-flash st-info RUNTIME DESTINATION bin) ### TODO: Check path if (CMAKE_SYSTEM_NAME STREQUAL "Linux") if (STLINK_INSTALL_MODPROBE_CONF) @@ -245,7 +243,7 @@ add_subdirectory(src/stlink-gui) ### add_subdirectory(debian/pkgconfig) -add_subdirectory(include) +add_subdirectory(include) ### TODO: Check path add_subdirectory(doc/man) add_subdirectory(tests) diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index bb6465481..64aba11a5 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -28,6 +28,6 @@ install(TARGETS stlink-gui RUNTIME DESTINATION bin) install(FILES gui.ui DESTINATION ${INSTALLED_UI_DIR}) ### TODO: Check Path if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - install(FILES stlink-gui.desktop DESTINATION share/applications) # Install desktop entry + install(FILES stlink-gui.desktop DESTINATION share/applications) # Install desktop entry install(FILES icons/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps) # Install icon endif () From 264417e4b3159cc7664768c26015a9246c828c8c Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 14:41:48 +0200 Subject: [PATCH 123/236] Fix for version string read without git --- CMakeLists.txt | 13 +++++++------ cmake/version.cmake | 9 ++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 421ec7c6f..5ea53e114 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,12 +54,14 @@ endif () ### find_package(LibUSB REQUIRED) + if (NOT APPLE AND NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) 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) @@ -71,8 +73,8 @@ if (STLINK_HAVE_UNISTD_H) endif () include(CheckLibraryExists) -CHECK_LIBRARY_EXISTS(ssp __stack_chk_fail "" _stack_chk_fail_exists) +CHECK_LIBRARY_EXISTS(ssp __stack_chk_fail "" _stack_chk_fail_exists) if (_stack_chk_fail_exists) set(SSP_LIB ssp) else () @@ -151,11 +153,10 @@ 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 macOS libraries if (APPLE) diff --git a/cmake/version.cmake b/cmake/version.cmake index 38254409f..da9d76eba 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -77,7 +77,14 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") endif(GIT_DESCRIBE_RESULT EQUAL 0) endif () -if (ERROR_FLAG EQUAL 1) +# Failure to read version via git +# Possible cases: +# -> git is not found or +# -> /.git does not exist or +# -> GIT_DESCRIBE failed or +# -> version string is of invalid format + +if (NOT GIT_FOUND OR NOT EXISTS "${PROJECT_SOURCE_DIR}/.git" OR ERROR_FLAG EQUAL 1) message(STATUS "Git and/or repository not found.") # e.g. when building from source package message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file instead...") if (EXISTS ${PROJECT_SOURCE_DIR}/.version) From 155439230a042e24812b505ab5d1f6c7e5a49c3a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 15:43:35 +0200 Subject: [PATCH 124/236] Unified naming for cmake modules & paths --- CMakeLists.txt | 4 ++-- cmake/modules/{Find7Zip.cmake => Find7zip.cmake} | 4 ++++ cmake/modules/{FindLibUSB.cmake => Findlibusb.cmake} | 4 ++-- debian/libstlink-dev.install | 3 +-- debian/{pkgconfig => pkg-config}/CMakeLists.txt | 2 +- debian/{pkgconfig => pkg-config}/pkg-config.pc.cmake | 1 - src/stlink-gui/CMakeLists.txt | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) rename cmake/modules/{Find7Zip.cmake => Find7zip.cmake} (57%) rename cmake/modules/{FindLibUSB.cmake => Findlibusb.cmake} (99%) rename debian/{pkgconfig => pkg-config}/CMakeLists.txt (91%) rename debian/{pkgconfig => pkg-config}/pkg-config.pc.cmake (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ea53e114..a8daa6e62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ endif () # Dependencies ### -find_package(LibUSB REQUIRED) +find_package(libusb REQUIRED) if (NOT APPLE AND NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) find_package(PkgConfig) @@ -243,7 +243,7 @@ add_subdirectory(src/stlink-gui) # Others ### -add_subdirectory(debian/pkgconfig) +add_subdirectory(debian/pkg-config) add_subdirectory(include) ### TODO: Check path add_subdirectory(doc/man) add_subdirectory(tests) diff --git a/cmake/modules/Find7Zip.cmake b/cmake/modules/Find7zip.cmake similarity index 57% rename from cmake/modules/Find7Zip.cmake rename to cmake/modules/Find7zip.cmake index c462f73de..0ccd23a50 100644 --- a/cmake/modules/Find7Zip.cmake +++ b/cmake/modules/Find7zip.cmake @@ -1,3 +1,7 @@ +# Find7zip.cmake +# Detect 7zip file archiver on Windows systems to extract (zip-)archives + + find_program( ZIP_EXECUTABLE NAMES 7z.exe p7zip HINTS "C:\\Program Files\\7-Zip\\" "C:\\Program Files (x86)\\7-Zip\\" diff --git a/cmake/modules/FindLibUSB.cmake b/cmake/modules/Findlibusb.cmake similarity index 99% rename from cmake/modules/FindLibUSB.cmake rename to cmake/modules/Findlibusb.cmake index b583b8491..5b3e80fe6 100644 --- a/cmake/modules/FindLibUSB.cmake +++ b/cmake/modules/Findlibusb.cmake @@ -1,4 +1,4 @@ -# FindLibUSB.cmake +# Findlibusb.cmake # Once done this will define # # LIBUSB_FOUND libusb present on system @@ -75,7 +75,7 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES " if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(7Zip REQUIRED) + find_package(7zip REQUIRED) set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) diff --git a/debian/libstlink-dev.install b/debian/libstlink-dev.install index 0c3543cd9..18fd98b03 100644 --- a/debian/libstlink-dev.install +++ b/debian/libstlink-dev.install @@ -1,5 +1,4 @@ usr/include/* usr/lib/*/lib*.a -usr/lib/*/pkgconfig/* +usr/lib/*/pkg-config/* usr/lib/*/lib*.so - diff --git a/debian/pkgconfig/CMakeLists.txt b/debian/pkg-config/CMakeLists.txt similarity index 91% rename from debian/pkgconfig/CMakeLists.txt rename to debian/pkg-config/CMakeLists.txt index 02e80cb72..a31e27e50 100644 --- a/debian/pkgconfig/CMakeLists.txt +++ b/debian/pkg-config/CMakeLists.txt @@ -11,5 +11,5 @@ configure_file( install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" - DESTINATION ${STLINK_LIBRARY_PATH}/pkgconfig/ + DESTINATION ${STLINK_LIBRARY_PATH}/pkg-config/ ) diff --git a/debian/pkgconfig/pkg-config.pc.cmake b/debian/pkg-config/pkg-config.pc.cmake similarity index 99% rename from debian/pkgconfig/pkg-config.pc.cmake rename to debian/pkg-config/pkg-config.pc.cmake index 4170bf84b..c00eb070e 100644 --- a/debian/pkgconfig/pkg-config.pc.cmake +++ b/debian/pkg-config/pkg-config.pc.cmake @@ -8,4 +8,3 @@ includedir=${PKG_CONFIG_INCLUDEDIR} libdir=${PKG_CONFIG_LIBDIR} Libs: ${PKG_CONFIG_LIBS} Cflags: ${PKG_CONFIG_CFLAGS} - diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index 64aba11a5..c51cf56af 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -1,6 +1,6 @@ if (NOT gtk_FOUND) message(STATUS "gtk not found!") - return() + return() # no GTK present => no GUI build endif () set(GUI_SOURCES gui.c gui.h) From ccd167379059b9db53d4e788fdca866b409669a1 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 17:01:36 +0200 Subject: [PATCH 125/236] Enable pkg_check for gtk on macOS --- CMakeLists.txt | 2 +- doc/compiling.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8daa6e62..ee74227fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ endif () find_package(libusb REQUIRED) -if (NOT APPLE AND NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) +if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) find_package(PkgConfig) pkg_check_modules(gtk gtk+-3.0) endif () diff --git a/doc/compiling.md b/doc/compiling.md index 59685ef17..a228817a8 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -61,6 +61,7 @@ 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) +* `pkg-config` * `libusb-1.0` * `libusb-1.0-0-dev` (development headers for building) * `libgtk-3-dev` (_optional_, needed for `stlink-gui`) @@ -168,6 +169,7 @@ Then install the following dependencies from the package repository: * `git` * `cmake` +* `pkg-config` * `libusb` To do this with only one simple command, type: From 9fd9045fdb6c1776ebbeaf634c57739f3e53c826 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 18:13:23 +0200 Subject: [PATCH 126/236] General Project Update - Added gtk-package to travis build config - Added gtk to version_support.md (GUI) - Minor correction for CHANGELOG.md - README: Removed reference to OpenBSD --- .travis.yml | 28 ++++++++++++++------------- CHANGELOG.md | 1 - README.md | 1 - doc/version_support.md | 44 +++++++++++++++++++++--------------------- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 542a25d98..b7ff93ff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,42 +9,42 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-5', 'libusb-1.0.0-dev'] + packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x64 compiler: gcc-7 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev'] + packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x64 compiler: gcc-9 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-9', 'libusb-1.0.0-dev'] + packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x64 compiler: clang-3.7 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] - packages: ['clang-3.7', 'libusb-1.0.0-dev'] + packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x64 compiler: clang-6.0 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] - packages: ['clang-6.0', 'libusb-1.0.0-dev'] + packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev'] # - os: linux # arch: x64 # compiler: clang-6.0 # addons: # apt: # sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] -# packages: ['clang-6.0', 'libusb-1.0.0-dev'] +# packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev'] # env: CFLAGS=-m32 LDFLAGS=-m32 ### 32-bit builds ### @@ -54,35 +54,35 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-5', 'libusb-1.0.0-dev'] + packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x86 compiler: gcc-7 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev'] + packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x86 compiler: gcc-9 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-9', 'libusb-1.0.0-dev'] + packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x86 compiler: clang-3.7 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] - packages: ['clang-3.7', 'libusb-1.0.0-dev'] + packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux arch: x86 compiler: clang-6.0 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] - packages: ['clang-6.0', 'libusb-1.0.0-dev'] + packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev'] ### macOS ### - os: osx @@ -90,15 +90,17 @@ matrix: addons: homebrew: packages: - - libusb - gcc + - libusb + - gtk+3 - os: osx compiler: clang addons: homebrew: packages: - - libusb - clang + - libusb + - gtk+3 script: - git fetch --tags diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2a9e595..9c6060434 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,6 @@ Updates & changes: - Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION (#211, #782, #895) - [doc] Verify correct udev configuration for device access (#764) - Added more error info to WLOGs during probe (#883) -- Added travis build for win32 (#870) - Added check for libssp during compilation (#885) - Silence unnecessary messages (#886) - Set up a libusb log level accordingly to verbosity (commit 49f887d5247fdd28f163b6317790c4f087e652cc) diff --git a/README.md b/README.md index 86be05c8f..a0147ed14 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,6 @@ We recommend to install `stlink-tools` from the package repository of the used d * 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) diff --git a/doc/version_support.md b/doc/version_support.md index 8b1a9b92d..81d1cc98c 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -16,52 +16,52 @@ Thus no user interaction regarding libusb is necessary. ### Apple macOS -| Package Repository | libusb
version | cmake
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) | +| Package Repository | libusb
version | cmake
version | gtk
version | Supported macOS versions | +| --- | --- | --- | --- | --- | +| homebrew | 1.0.23 | 3.17.0 | 3.24.18
gtk+3 | 10.12 (Sierra)- 10.15 (Catalina) | +| MacPorts | 1.0.23 | 3.17.0 | _N/A_ | 10.6 (Snow Leopard) - 10.15 (Catalina) | ### Linux-/Unix-based: -| Operating System | libusb
version | cmake
version | Notes | -| --- | --- | --- | --- | +| Operating System | libusb
version | cmake
version | gtk
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 | +| 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` | +| 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 | | +| Debian Sid | 1.0.23 | 3.16.3 | 3.24.18
libgtk-3-dev | | | OpenMandriva Lx 4.1 | 1.0.23 | 3.16.3 | | -| Ubuntu 20.04 LTS (Focal Fossa) | 1.0.23 | 3.16.3 | | +| Ubuntu 20.04 LTS (Focal Fossa) | 1.0.23 | 3.16.3 | 3.24.17
libgtk-3-dev | | | 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 | | +| Ubuntu 19.10 (Eoan Ermine) | 1.0.23 | 3.13.4 | 3.24.12
libgtk-3-dev | | | 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 | +| 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 | | +| Fedora 30 | 1.0.22 | 3.14.2 | | named `libusbx`, but `libusb`-codebase is used | +| Debian 10 (Buster) | 1.0.22 | 3.13.4 | 3.24.5
libgtk-3-dev | | | Alpine 3.9 | 1.0.22 | 3.13.0 | | -| CentOS 8 | 1.0.22 | 3.11.4 | named `libusbx`, but `libusb`-codebase is used | +| 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 | | +| Ubuntu 18.04 LTS (Bionic Beaver) | 1.0.21 | 3.10.2 | 3.22.30
libgtk-3-dev | | +| Debian 9 (Stretch) | 1.0.21 | 3.7.2 | 3.22.11
libgtk-3-dev | | | Slackware 14.2 | **1.0.20** | 3.5.2 | | -| Ubuntu 16.04 LTS (Xenial Xerus) | **1.0.20** | 3.5.1 | | +| Ubuntu 16.04 LTS (Xenial Xerus) | **1.0.20** | 3.5.1 | 3.18.9
libgtk-3-dev | | | 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) | +| 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) @@ -69,7 +69,7 @@ Thus no user interaction regarding libusb is necessary. | Operating System | libusb
version | cmake
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 | +| 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** | | From e98c7d4926ec129e272209552d802a839c743230 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:45:33 +0200 Subject: [PATCH 127/236] Updated cmake settings from GTK to GTK3 --- CMakeLists.txt | 2 +- src/stlink-gui/CMakeLists.txt | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee74227fa..e8da6c45c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ find_package(libusb REQUIRED) if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) find_package(PkgConfig) - pkg_check_modules(gtk gtk+-3.0) + pkg_check_modules(GTK3 gtk+-3.0) endif () include(CheckIncludeFile) diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index c51cf56af..dee6cc258 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -1,12 +1,14 @@ -if (NOT gtk_FOUND) - message(STATUS "gtk not found!") - return() # no GTK present => no GUI build +if (NOT GTK3_FOUND) + message(STATUS "GTK3 not found!") + return() # no GTK3 present => no GUI build +else (GTK3_FOUND) + message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}") endif () set(GUI_SOURCES gui.c gui.h) set(INSTALLED_UI_DIR share/stlink) ### TODO: Check Path -include_directories(SYSTEM ${gtk_INCLUDE_DIRS}) +include_directories(SYSTEM ${GTK3_INCLUDE_DIRS}) # stlink-gui-local add_executable(stlink-gui-local ${GUI_SOURCES}) @@ -14,7 +16,7 @@ set_target_properties( stlink-gui-local PROPERTIES COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}" ### TODO: Check Path ) -target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${gtk_LDFLAGS} ${SSP_LIB}) +target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${GTK3_LDFLAGS} ${SSP_LIB}) # stlink-gui add_executable(stlink-gui ${GUI_SOURCES}) @@ -22,7 +24,7 @@ set_target_properties( stlink-gui PROPERTIES COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}" ### TODO: Check Path ) -target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${gtk_LDFLAGS} ${SSP_LIB}) +target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${GTK3_LDFLAGS} ${SSP_LIB}) install(TARGETS stlink-gui RUNTIME DESTINATION bin) ### TODO: Check Path install(FILES gui.ui DESTINATION ${INSTALLED_UI_DIR}) ### TODO: Check Path From f48914512ceb75790abf40fb8df9ed592ab901e1 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 17 Apr 2020 21:09:05 +0200 Subject: [PATCH 128/236] [doc] Updated package requirements - Added info on GTK3 libs & versioning - Updated compiling instructions for macOS --- doc/compiling.md | 15 ++++++---- doc/version_support.md | 68 +++++++++++++++++++++--------------------- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/doc/compiling.md b/doc/compiling.md index a228817a8..15d8b4fc2 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -58,6 +58,7 @@ It can be copied from here: `build\3rdparty\libusb-1.0.21\MS32\dll\libusb-1.0.dl Install the following packages from your package repository: +* `git` * `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) @@ -162,22 +163,26 @@ Choose on of the following options _before_ connecting the device to your comput ## macOS ### Common requirements -The best way is to install a package manager for open source software, +The best and recommended 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` +* `gcc` or `llvm` (for clang) (C-compiler) * `cmake` * `pkg-config` * `libusb` +* `gtk+3` or `gtk3` (_optional_, needed for `stlink-gui`) 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). +* for homebrew: + - with gcc: `sudo brew install git gcc cmake libusb gtk+3` or + - with clang: `sudo brew install git llvm cmake libusb gtk+3` or +* for MacPorts: + - with gcc: `sudo port install git llvm-9.0 cmake libusb gtk3` or + - with clang: `sudo port install git gcc9 cmake libusb gtk3` ### Installation diff --git a/doc/version_support.md b/doc/version_support.md index 81d1cc98c..75def2e66 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -1,5 +1,5 @@ -Sources: [pkgs.org - libusb](https://pkgs.org/search/?q=libusb) & [pkgs.org - cmake](https://pkgs.org/search/?q=cmake) (as of Mar 2020): +_Source:_ pkgs.org - [libusb](https://pkgs.org/search/?q=libusb); [cmake](https://pkgs.org/search/?q=cmake); [gtk](https://pkgs.org/search/?q=gtk) (as of Apr 2020) ## Supported Operating Systems @@ -16,55 +16,55 @@ Thus no user interaction regarding libusb is necessary. ### Apple macOS -| Package Repository | libusb
version | cmake
version | gtk
version | Supported macOS versions | +| Package Repository | libusb
version | cmake
version | gtk-3
version | Supported macOS versions | | --- | --- | --- | --- | --- | | homebrew | 1.0.23 | 3.17.0 | 3.24.18
gtk+3 | 10.12 (Sierra)- 10.15 (Catalina) | -| MacPorts | 1.0.23 | 3.17.0 | _N/A_ | 10.6 (Snow Leopard) - 10.15 (Catalina) | +| MacPorts | 1.0.23 | 3.17.0 | 3.24.18
gtk3 | 10.6 (Snow Leopard) - 10.15 (Catalina) | ### Linux-/Unix-based: -| Operating System | libusb
version | cmake
version | gtk
version | Notes | +| Operating System | libusb
version | cmake
version | gtk-3
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 | | +| Alpine Edge | 1.0.23 | 3.17.0 | 3.24.18
gtk+3.0-dev | | +| ALT Linux Sisyphus | 1.0.23 | 3.17.0 | 3.24.18
libgtk+3-devel | | +| Arch Linux | 1.0.23 | 3.17.0 | 3.24.18
gtk3 | | +| Fedora Rawhide | 1.0.23 | 3.17.0 | 3.24.18
gtk3-devel | | named `libusbx`, but
`libusb`-codebase is used | +| KaOS | 1.0.23 | 3.17.0 | 3.24.18
gtk3 | | +| OpenMandriva Cooker | 1.0.23 | 3.17.0 | 3.24.18
libgtk+3.0-devel
lib64gtk+3.0-devel | | +| PCLinuxOS | 1.0.23
lib64usb1.0 | 3.17.0 | 3.24.18
lib64gtk+3.0-devel | | +| Slackware Current | 1.0.23 | 3.17.0 | 3.24.18
gtk+3 | | +| Solus | 1.0.23 | 3.16.5 | 3.24.16
libgtk-3-devel | | | Debian Sid | 1.0.23 | 3.16.3 | 3.24.18
libgtk-3-dev | | -| OpenMandriva Lx 4.1 | 1.0.23 | 3.16.3 | | +| OpenMandriva Lx 4.1 | 1.0.23 | 3.16.3 | 3.24.13
libgtk+3.0-devel
lib64gtk+3.0-devel | | | Ubuntu 20.04 LTS (Focal Fossa) | 1.0.23 | 3.16.3 | 3.24.17
libgtk-3-dev | | -| openSUSE Tumbleweed | 1.0.23 | 3.16.2 | | -| Alpine 3.11 | 1.0.23 | 3.15.5 | | +| openSUSE Tumbleweed | 1.0.23 | 3.16.2 | 3.24.16
gtk3-devel | | +| Alpine 3.11 | 1.0.23 | 3.15.5 | 3.24.13
gtk+3.0-dev | | | Ubuntu 19.10 (Eoan Ermine) | 1.0.23 | 3.13.4 | 3.24.12
libgtk-3-dev | | -| 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 | +| Mageia Cauldron | 1.0.22 | 3.17.0 | 3.24.18
libgtk+3.0-devel
lib64gtk+3.0-devel | | +| NetBSD 9.0 | 1.0.22 | 3.16.1 | 3.24.12
gtk+3 | | +| NetBSD 8.1 | 1.0.22 | 3.16.1 | 3.24.12
gtk+3 | | +| NetBSD 7.2 | 1.0.22 | 3.16.1 | _N/A_ | | +| Alpine 3.10 | 1.0.22 | 3.14.5 | 3.24.8
gtk+3.0-dev | | +| Fedora 31 | 1.0.22 | 3.14.5 | 3.24.12
gtk3-devel | named `libusbx`, but
`libusb`-codebase is used | +| Mageia 7.1 | 1.0.22 | 3.14.3 | 3.24.8
libgtk+3.0-devel
lib64gtk+3.0-devel | | +| Fedora 30 | 1.0.22 | 3.14.2 | 3.24.8
gtk3-devel | named `libusbx`, but
`libusb`-codebase is used | | Debian 10 (Buster) | 1.0.22 | 3.13.4 | 3.24.5
libgtk-3-dev | | -| 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 | | +| Alpine 3.9 | 1.0.22 | 3.13.0 | 3.24.1
gtk+3.0-dev | | +| CentOS 8 | 1.0.22 | 3.11.4 | 3.22.30
gtk3-devel | named `libusbx`, but
`libusb`-codebase is used | +| openSUSE Leap 15.2 | 1.0.21 | 3.15.5 | 3.24.14
gtk3-devel | | +| openSUSE Leap 15.1 | 1.0.21 | 3.10.2 | 3.22.30
gtk3-devel | | | Ubuntu 18.04 LTS (Bionic Beaver) | 1.0.21 | 3.10.2 | 3.22.30
libgtk-3-dev | | | Debian 9 (Stretch) | 1.0.21 | 3.7.2 | 3.22.11
libgtk-3-dev | | -| Slackware 14.2 | **1.0.20** | 3.5.2 | | +| Slackware 14.2 | **1.0.20** | 3.5.2 | 3.18.9
gtk+3 | | | Ubuntu 16.04 LTS (Xenial Xerus) | **1.0.20** | 3.5.1 | 3.18.9
libgtk-3-dev | | -| 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) | +| OpenMandriva Lx 3.0 | **1.0.20** | **3.4.2** | 3.18.9
libgtk+3.0-devel
lib64gtk+3.0-devel | | +| FreeBSD 13 | **1.0.16** - 1.0.18 | 3.15.5 | 3.24.10
gtk3 | linux_libusb-13.0r358841
(integrated) | +| FreeBSD 12 | **1.0.16** - 1.0.18 | 3.15.5 | 3.24.10
gtk3 | linux_libusb-11.0r261448_4
(integrated) | +| FreeBSD 11 | **1.0.16** - 1.0.18 | 3.15.5 | 3.24.10
gtk3 | linux_libusb-11.0r261448_4
(integrated) | -## Unsupported Operating Systems as of Release 1.6.1 (2020) +## Unsupported Operating Systems (as of Release v1.6.1) | Operating System | libusb
version | cmake
version | End of OS-Support | Notes | | --- | --- | --- | --- | --- | From 68fdd3927d9e2ae9fce662458d2be530832c946f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 18 Apr 2020 16:45:05 +0200 Subject: [PATCH 129/236] Reconfigured cmake packaging - Refactoring for package config & build - deb-pkg: postinst script with depmod -a (Fixes #845) --- CHANGELOG.md | 2 +- CMakeLists.txt | 60 +++-- Makefile | 11 +- cmake/cpack_config.cmake | 27 --- cmake/linux-mingw32.cmake | 25 -- cmake/linux-mingw64.cmake | 25 -- .../{Find7zip.cmake => Find_7zip.cmake} | 3 +- .../{Findlibusb.cmake => Find_libusb.cmake} | 6 +- cmake/{ => modules}/c_flags.cmake | 12 +- .../get_version.cmake} | 0 cmake/packaging/CMakeLists.txt | 4 + cmake/packaging/cpack_config.cmake | 85 +++++++ cmake/packaging/debian/CMakeLists.txt | 0 cmake/packaging/debian/changelog | 226 ++++++++++++++++++ {debian => cmake/packaging/debian}/copyright | 0 cmake/packaging/debian/postinst | 4 + cmake/packaging/fedora/CMakeLists.txt | 0 cmake/packaging/opensuse/CMakeLists.txt | 0 cmake/packaging/windows/CMakeLists.txt | 0 debian/changelog | 129 ---------- debian/pkg-config/CMakeLists.txt | 26 +- src/stlink-gui/CMakeLists.txt | 2 +- 22 files changed, 385 insertions(+), 262 deletions(-) delete mode 100644 cmake/cpack_config.cmake delete mode 100644 cmake/linux-mingw32.cmake delete mode 100644 cmake/linux-mingw64.cmake rename cmake/modules/{Find7zip.cmake => Find_7zip.cmake} (91%) rename cmake/modules/{Findlibusb.cmake => Find_libusb.cmake} (99%) rename cmake/{ => modules}/c_flags.cmake (88%) rename cmake/{version.cmake => modules/get_version.cmake} (100%) create mode 100644 cmake/packaging/CMakeLists.txt create mode 100644 cmake/packaging/cpack_config.cmake create mode 100644 cmake/packaging/debian/CMakeLists.txt create mode 100644 cmake/packaging/debian/changelog rename {debian => cmake/packaging/debian}/copyright (100%) create mode 100644 cmake/packaging/debian/postinst create mode 100644 cmake/packaging/fedora/CMakeLists.txt create mode 100644 cmake/packaging/opensuse/CMakeLists.txt create mode 100644 cmake/packaging/windows/CMakeLists.txt delete mode 100644 debian/changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c6060434..d0b920f71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -258,7 +258,7 @@ Updates and fixes: * Fixed "unaligned addr or size" when trying to write a program in RAM ([#323](https://github.com/stlink-org/stlink/pull/323)) * Fixed flashing on STM32_F3_SMALL ([#325](https://github.com/stlink-org/stlink/pull/325)) -* Fixed STM32L-problem with flash loader ([#390](https://github.com/stlink-org/stlink/pull/390), [#407](https://github.com/stlink-org/stlink/pull/407),[#408](https://github.com/stlink-org/stlink/pull/408)) +* Fixed STM32L-problem with flash loader ([#390](https://github.com/stlink-org/stlink/pull/390), [#407](https://github.com/stlink-org/stlink/pull/407), [#408](https://github.com/stlink-org/stlink/pull/408)) * Don't read the target voltage on startup, because it crashes STM32F100 ([#423](https://github.com/stlink-org/stlink/pull/423), [#424](https://github.com/stlink-org/stlink/pull/424)) * Added a useful error message instead of "[!] send_recv" ([#425](https://github.com/stlink-org/stlink/pull/425), [#426](https://github.com/stlink-org/stlink/pull/426)) * Do a JTAG reset prior to reading CPU information when processor is in deep sleep ([#428](https://github.com/stlink-org/stlink/pull/428), [#430](https://github.com/stlink-org/stlink/pull/430), [#451](https://github.com/stlink-org/stlink/pull/451)) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8da6c45c..ccb5fefa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,21 @@ +### +# General cmake settings +### + cmake_minimum_required(VERSION 3.4.2) cmake_policy(SET CMP0042 NEW) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + +# Define GNU standard installation directories include(GNUInstallDirs) + +### +# General project settings +### + project(stlink C) set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools") @@ -14,10 +27,23 @@ option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) +# Determine project version +include(${CMAKE_MODULE_PATH}/get_version.cmake) + +# Set C build flags +if (NOT MSVC) + include(${CMAKE_MODULE_PATH}/c_flags.cmake) +else () + 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_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") +endif () + + # ==== -#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}) @@ -36,24 +62,12 @@ else () set(STLINK_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}") endif () -include(cmake/version.cmake) - -if (NOT MSVC) - include(cmake/c_flags.cmake) -else () - 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_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") -endif () - ### # Dependencies ### -find_package(libusb REQUIRED) +find_package(_libusb REQUIRED) if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) find_package(PkgConfig) @@ -243,17 +257,21 @@ add_subdirectory(src/stlink-gui) # Others ### -add_subdirectory(debian/pkg-config) add_subdirectory(include) ### TODO: Check path add_subdirectory(doc/man) add_subdirectory(tests) -include(cmake/cpack_config.cmake) -include(CPack) - # ==== +### +# Package build +### + +add_subdirectory(cmake/packaging) +include(cmake/packaging/cpack_config.cmake) + + ### # Uninstall target ### @@ -261,11 +279,11 @@ include(CPack) if (NOT TARGET uninstall) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" IMMEDIATE @ONLY ) add_custom_target( uninstall COMMAND ${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake ) endif () diff --git a/Makefile b/Makefile index 6b44bd70c..c3bd59c52 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ help: rebuild_cache: build/Debug build/Release @$(MAKE) -C build/Debug rebuild_cache @$(MAKE) -C build/Release rebuild_cache - @$(MAKE) -C build/Binary rebuild_cache debug: build/Debug @echo "[DEBUG]" @@ -28,10 +27,6 @@ release: build/Release @echo "[RELEASE]" @$(MAKE) -C build/Release -binary: build/Binary - @echo "[BINARY]" - @$(MAKE) -C build/Binary - package: build/Release @echo "[PACKAGE] Release" @$(MAKE) -C build/Release package @@ -45,11 +40,7 @@ build/Debug: build/Release: @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ - -build/Binary: - @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Binary $(CMAKEFLAGS) ../../ + @cd $@ && cmake -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) -Wno-dev ../../ clean: @echo "[CLEAN]" diff --git a/cmake/cpack_config.cmake b/cmake/cpack_config.cmake deleted file mode 100644 index c70cf3a63..000000000 --- a/cmake/cpack_config.cmake +++ /dev/null @@ -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/stlink-org/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 () diff --git a/cmake/linux-mingw32.cmake b/cmake/linux-mingw32.cmake deleted file mode 100644 index 2b4799037..000000000 --- a/cmake/linux-mingw32.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# Sample toolchain file for building for Windows from a Debian/Ubuntu Linux system. -# -# Typical usage: -# *) install cross compiler: `sudo apt-get install mingw-w64` -# *) cd build -# *) cmake -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake .. - -set(CMAKE_SYSTEM_NAME Windows) -set(TOOLCHAIN_PREFIX i686-w64-mingw32) - -# cross compilers to use for C and C++ -set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) -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(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) - -# modify default behavior of FIND_XXX() commands to -# search for headers/libs in the target environment and -# 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) diff --git a/cmake/linux-mingw64.cmake b/cmake/linux-mingw64.cmake deleted file mode 100644 index f8b523965..000000000 --- a/cmake/linux-mingw64.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# Sample toolchain file for building for Windows from a Debian/Ubuntu Linux system. -# -# Typical usage: -# *) install cross compiler: `sudo apt-get install mingw-w64` -# *) cd build -# *) cmake -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake .. - -set(CMAKE_SYSTEM_NAME Windows) -set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) - -# cross compilers to use for C and C++ -set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) -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(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) - -# modify default behavior of FIND_XXX() commands to -# search for headers/libs in the target environment and -# 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) diff --git a/cmake/modules/Find7zip.cmake b/cmake/modules/Find_7zip.cmake similarity index 91% rename from cmake/modules/Find7zip.cmake rename to cmake/modules/Find_7zip.cmake index 0ccd23a50..c75cf1150 100644 --- a/cmake/modules/Find7zip.cmake +++ b/cmake/modules/Find_7zip.cmake @@ -1,7 +1,6 @@ -# Find7zip.cmake +# Find_7zip.cmake # Detect 7zip file archiver on Windows systems to extract (zip-)archives - find_program( ZIP_EXECUTABLE NAMES 7z.exe p7zip HINTS "C:\\Program Files\\7-Zip\\" "C:\\Program Files (x86)\\7-Zip\\" diff --git a/cmake/modules/Findlibusb.cmake b/cmake/modules/Find_libusb.cmake similarity index 99% rename from cmake/modules/Findlibusb.cmake rename to cmake/modules/Find_libusb.cmake index 5b3e80fe6..e46c6d46e 100644 --- a/cmake/modules/Findlibusb.cmake +++ b/cmake/modules/Find_libusb.cmake @@ -1,4 +1,4 @@ -# Findlibusb.cmake +# Find_libusb.cmake # Once done this will define # # LIBUSB_FOUND libusb present on system @@ -75,7 +75,9 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES " if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(7zip REQUIRED) + + find_package(_7zip REQUIRED) + set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) diff --git a/cmake/c_flags.cmake b/cmake/modules/c_flags.cmake similarity index 88% rename from cmake/c_flags.cmake rename to cmake/modules/c_flags.cmake index c7954bf54..d6b12403b 100644 --- a/cmake/c_flags.cmake +++ b/cmake/modules/c_flags.cmake @@ -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") -else() - add_cflag_if_supported("-O2") + add_cflag_if_supported("-ggdb") + add_cflag_if_supported("-O0") +else () + add_cflag_if_supported("-O2") add_cflag_if_supported("-Werror") endif () diff --git a/cmake/version.cmake b/cmake/modules/get_version.cmake similarity index 100% rename from cmake/version.cmake rename to cmake/modules/get_version.cmake diff --git a/cmake/packaging/CMakeLists.txt b/cmake/packaging/CMakeLists.txt new file mode 100644 index 000000000..e831f611f --- /dev/null +++ b/cmake/packaging/CMakeLists.txt @@ -0,0 +1,4 @@ +add_subdirectory(debian) +add_subdirectory(fedora) +add_subdirectory(opensuse) +add_subdirectory(windows) diff --git a/cmake/packaging/cpack_config.cmake b/cmake/packaging/cpack_config.cmake new file mode 100644 index 000000000..522fb7f11 --- /dev/null +++ b/cmake/packaging/cpack_config.cmake @@ -0,0 +1,85 @@ +### +# Configure package +### + +set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_SET_DESTDIR "ON") +set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist") + +if (APPLE) + set(CPACK_GENERATOR "ZIP") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-macosx-amd64") + set(CPACK_INSTALL_PREFIX "") +elseif (WIN32) ### TODO: Binary build config for windows... + set(CPACK_GENERATOR "ZIP") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win32") + set(CPACK_INSTALL_PREFIX "") + + # Sample toolchain file for building for Windows from a Debian/Ubuntu Linux system. + # Typical usage: + # *) install cross compiler: `sudo apt-get install mingw-w64` + # *) cd build + # *) cmake -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake .. + # *) cmake -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake .. + + #set(CMAKE_SYSTEM_NAME Windows) + #set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) + #set(TOOLCHAIN_PREFIX i686-w64-mingw32) + + # cross compilers to use for C and C++ + #set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) + #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(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) + + # modify default behavior of FIND_XXX() commands to + # search for headers/libs in the target environment and + # 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) + +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "/etc/debian_version") + message(STATUS "Debian-based Linux OS detected") + + ### Debian-specific + set(CPACK_GENERATOR "DEB") + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Open source STM32 MCU programming toolset") + set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/stlink-org/stlink") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luca Boccassi") + set(CPACK_PACKAGE_CONTACT "bluca@debian.org") + + ## Set debian_revision number + # Convention: Restart the debian_revision at 1 each time the upstream_version is increased. + set(CPACK_DEBIAN_PACKAGE_RELEASE "0") + + ## Debian package name + # CPack DEB generator generates package file name in deb format: + # _-_.deb + set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + + ## Add CHANGELOG in Debian-specific format + ### TODO + + ## Add license file + ### TODO + + # Include a postinst-script + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/packaging/debian/postinst") + + ### rpm-specific ### TODO: Package config for opensuse should go here... + +else () + ### TODO: Package config for fedora should go here... +endif () + + +### +# Build package +### + +include(CPack) diff --git a/cmake/packaging/debian/CMakeLists.txt b/cmake/packaging/debian/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb diff --git a/cmake/packaging/debian/changelog b/cmake/packaging/debian/changelog new file mode 100644 index 000000000..b4e942d7c --- /dev/null +++ b/cmake/packaging/debian/changelog @@ -0,0 +1,226 @@ +stlink (1.6.0) unstable; urgency=medium + +Release date: 2020-02-20 + +Major changes and added features: + +* Initial support for STM32L41X +* Working support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 +* Added preliminary support for some STM32G0 chips +* Added support for mass erasing second bank on STM32F10x_XL +* Added call to clear PG bit after writing to flash +* Added support to write option bytes for the STM32G0 +* Added support for STM32WB55 chips +* Added STLink V3SET VID:PIDs to the udev rules +* Support for "STM32+Audio" v2-1 firmware +* Build for Windows under Debian/Ubuntu +* Allow for 64 bytes serials +* Added full support for STLINK CHIP ID L4RX +* Added support for the STLink-v2.1 when flashed with no mass storage (PID 0x3752) +* Added support for writing option bytes on STM32L0xx +* Added support to read and write option bytes for STM32F2 series +* Added support to read and write option bytes for STM32F446 + +Updates and fixes: + +* Fixed "unkown chip id", piped output and st-util -v +* Fixed an issue with versioning stuck at 1.4.0 for versions cloned with git +* Updated STM32F3xx chip ID that covers a few different devices +* Made udev rules and modprobe conf installation optional +* Fixed case when __FILE__ don't contain "/" nor "\\" +* Fixed double dash issue in doc/man +* Compiling documentation: package is called libusb-1.0-0-dev on Debian +* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip-ID 0x464 for STM32L41xxx/L42xxx devices +* Added O_BINARY option to open file +* Fixed versioning when compiling from the checked out git-repo +* win32: move usleep definition to unistd.h +* Fixed relative path to the UI files needed by stlink-gui-local (GUI) +* Added howto for sending NRST signal through GDB +* Fixed package name "devscripts" in doc/compiling.md +* Fixed few potential memory/resource leaks +* Updated Linux source repositories in README.md: Debian and Ubuntu +* Do not issue JTAG reset on stlink-v1 +* Fixed flash size of STM32 Discovery vl +* Updated documentation on software structure + +General project updates: + +* Updated README.md, CHANGELOG.md and issue templates +* Fixed travis build config file +* Added CODE_OF_CONDUCT +* Archived page from github project wiki to doc/wiki_old.md + +-- Luca Boccassi Tue, 25 Feb 2020 22:08:33 +0000 + + +stlink (1.5.1) unstable; urgency=medium + +Release date: 2018-09-13 + +Major changes and added features: + +* Added reset through AIRCR +* Added creation of icons for .desktop file +* Added desktop file for linux +* Added button to export STM32 flash memory to a file +* Updated libusb to 1.0.22 +* Added icons for STLink GUI +* Added support for STM32L4R9 target +* Added memory map for STM32F411RE target +* Implemented intel hex support for GTK GUI + +Updates and fixes: + +* Fixed missing flash_loader for STM32L0x +* Fix for stlink library calls exit() or _exit() +* Added semihosting parameter documentation in doc/man +* Fixed reference to non-exisiting st-term tool in doc/man +* Fixed serial number size mismatch with stlink_open_usb() +* Debian packaging, CMake and README.md fixes +* Disabled static library installation by default +* Fix for libusb deprecation +* Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX +* Regression: stlink installation under Linux (Debian 9) is broken since #695 +* Fixed flash memory map for STM32F72xxx target +* Proper flash page size calculation for STM32F412xx target +* Return correct value on EOF for Semihosting SYS_READ +* FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION + +-- Luca Boccassi Fri, 28 Sep 2018 10:26:39 +0100 + + +stlink (1.5.0) unstable; urgency=medium + +Release date: 2018-02-16 + +Major changes and added features: + +* Added support of STM32L496xx/4A6xx devices +* Added unknown chip dummy to obtain the serial of the ST-link by a call to st-info --probe +* Added support for STM32F72xx (chip-ID: 0x452) devices + +Updates and fixes: + +* Fixed verification of flash error for STM32L496x device +* Updated Linux source repositories in README.md: Gentoo, Fedora and RedHat/CentOS +* Updated changelog in debian package +* Added LIB_INSTALL_DIR to correct libs install on 64-bit systems +* Fixed write for microcontroller with RAM size less or equal to 32K +* Fixed memory map for STM32L496xx boards +* Fixed __FILE__ base name extraction +* Added debian/triggers to run ldconfig +* Fixed build on Fedora with GCC 8 + +-- Luca Boccassi Fri, 16 Mar 2018 16:56:17 +0000 + + +stlink (1.4.0) unstable; urgency=low + +Release date: 2017-07-01 + +Major changes and added features: + +* Allow building of debian package with CPack +* Added support for STM32L011 target +* Added support for flashing second bank on STM32F10x_XL +* Initial support to compile with Microsoft Visual Studio 2017 +* Added support for STM32L452 target + +Updates and fixes: + +* Fixed gdb-server: STM32L0xx has no FP_CTRL register for breakpoints +* Added --flash=n[k][m] command line option to override device model +* Updated libusb to 1.0.21 for Windows +* Fixed low-voltage flashing on STM32F7 devices +* Fixed building with mingw64 +* Fixed possible memory leak +* Fixed installation path for shared objects +* Fixed a few -Wformat warnings +* Removed unused defines in mimgw.h +* Skip GTK detection when cross-compiling +* Fixed compilation with GCC 7 +* Fixed flashing to 'f0 device' targets +* Fixed wrong counting when flashing + +-- Andrew 'Necromant' Andrianov Sat, 01 Jul 2017 00:00:00 +0000 + + +stlink (1.3.1) unstable; urgency=low + +Release date: 2017-02-25 + +Major changes and added features: + +* Added support for Semihosting `SYS_READC` +* Added support for STM32F413 +* Added preliminary support for STM32L011 to see it after probe (chip-ID 0x457) + +Updates and fixes: + +* cmake/CPackConfig.cmake: Fixup OSX zip filename +* Updated source repositories in README.md: Windows, macOS, Alpine Linux +* Compilation fixes +* Stripped full paths to source files in log +* Fixed incorrect release folder name in docs +* Fixed compilation when path includes spaces + +-- Andrew 'Necromant' Andrianov Sat, 25 Feb 2017 00:00:00 +0000 + + +stlink (1.3.0) unstable; urgency=low + +Release date: 2017-01-28 + +Major changes and added features: + +* Deprecation of autotools (autoconf, automake) and fixed build with MinGW +* Added intel hex file reading for `st-flash` +* Added support for ARM semihosting to `st-util` +* Added manpages (generated with pandoc from Markdown) +* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature +* Support serial numbers argument for `st-util` and `st-flash` to probe and control multiple connected programmers +* Merge st-probe tool into st-info +* Added support for native debian packaging +* Rewritten commandline parsing for `st-flash` +* Added `--reset` command to `st-flash` +* st-util should detect when USB commands fail + +Chip support added for: + +* STM32F401XE: Added memory map for device +* STM32F410RBTx +* STM32F412 +* STM32F7xx +* STM32F7x7x +* STM32L0xx Cat2 devices (chip-ID: 0x425) +* STM32L0xx Cat5 devices (chip-ID: 0x447) +* STM32L4xx +* STM32L432 + +Updates and fixes: + +* Fixed "unaligned addr or size" when trying to write a program in RAM +* Fixed flashing on STM32_F3_SMALL +* Fixed STM32L-problem with flash loader +* Don't read the target voltage on startup, because it crashes STM32F100 +* Added a useful error message instead of "[!] send_recv" +* Do a JTAG reset prior to reading CPU information when processor is in deep sleep +* Fixed STM32F030 erase error +* Fixed memory map for STM32F7xx +* Redesign of `st-flash` commandline options parsing +* Set SWDCLK and fixed jtag_reset bug +* doc/compiling.md: Add note about installation and ldconfig +* Fixed Release target to generate the man-pages with pandoc +* Fixed Cygwin build +* Reset flash mass erase (MER) bit after mass erase for safety +* Wrong extract command in FindLibUSB.cmake +* Fixed compilation error on Ubuntu 16.10 + +-- Andrew 'Necromant' Andrianov Sat, 28 Jan 2017 00:00:00 +0000 + + +libstlink (1.2.1) unstable; urgency=low + +* Initial Debian-packaged release. + +-- Andrew 'Necromant' Andrianov Sat, 09 Jul 2016 23:16:07 +0300 diff --git a/debian/copyright b/cmake/packaging/debian/copyright similarity index 100% rename from debian/copyright rename to cmake/packaging/debian/copyright diff --git a/cmake/packaging/debian/postinst b/cmake/packaging/debian/postinst new file mode 100644 index 000000000..bc74428ae --- /dev/null +++ b/cmake/packaging/debian/postinst @@ -0,0 +1,4 @@ +#!/bin/bash +# This `DEBIAN/postinst` script is run post-installation + +depmod -a diff --git a/cmake/packaging/fedora/CMakeLists.txt b/cmake/packaging/fedora/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb diff --git a/cmake/packaging/opensuse/CMakeLists.txt b/cmake/packaging/opensuse/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb diff --git a/cmake/packaging/windows/CMakeLists.txt b/cmake/packaging/windows/CMakeLists.txt new file mode 100644 index 000000000..e69de29bb diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index ac18fd872..000000000 --- a/debian/changelog +++ /dev/null @@ -1,129 +0,0 @@ -stlink (1.5.0) unstable; urgency=medium - - [ Jerry Jacobs ] - * README.md: Update version badge to v1.4.0 - - [ Viallard Anthony ] - * Add support of STM32L496xx/4A6xx devices (#615) - - [ rdlim ] - * Fix verification of flash error for STM32L496x device (#617) (#618) - - [ dflogeras ] - * Add note about availability in Gentoo package manager (#622) - - [ yaofei zheng ] - * update debian package version (#630) - - [ Lyle Cheatham ] - * Minor formatting fix in FAQ section of README.md (#631) - - [ Vasiliy Glazov ] - * README.md: Added information about Fedora and RedHat/CentOS packages. - (#635) - * Added LIB_INSTALL_DIR to correct libs install on 64-bit systems (#636) - - [ Gwenhael Goavec-Merou ] - * fix write for microcontroler with RAM size less or equal to 32K (#637) - - [ Mateusz Krawiec ] - * Fix memory map for stm32l496xx boards. (#639) - - [ Rüdiger Fortanier ] - * Add unknown chip output (#641) - - [ Slyshyk Oleksiy ] - * fix __FILE__ base name extraction, #628 (#648) - - [ texane ] - * STM32F72xx73xx support, from bob.feretich@rafresearch.com - - [ Kirill Kolyshkin ] - * debian/triggers: add (to run ldconfig) (#664) - - [ Slyshyk Oleksiy ] - * Try to fix #666 issue (#667) - * Try to fix 666 issue (#668) - - [ Jerry Jacobs ] - * Update ChangeLog.md - * Update README.md - - [ texane ] - * STM32F042K6 Nucleo-32 Board reported to work, by frank@bauernoeppel.de - - [ Anatol Pomozov ] - * Update .version file to match release number (#670) - - -- Anatol Pomozov Mon, 19 Feb 2018 11:00:29 -0800 - -libstlink (1.4.0) unstable; urgency=low - - * Major changes and added features - - Add support for STM32L452 target (#608) - - Initial support to compile with Microsoft Visual Studio 2017 (#602) - - Added support for flashing second bank on STM32F10x_XL (#592) - - Add support for STM32L011 target (#572) - - Allow building of debian package with CPack (@xor-gate) - * Updates and fixes - - Fix compilation with GCC 7 (#590) - - Skip GTK detection if we're cross-compiling (#588) - - Fix possible memory leak (#570) - - Fix building with mingw64 (#569, #610) - - Update libusb to 1.0.21 for Windows (#562) - - Fixing low-voltage flashing on STM32F7 parts. (#567) - - Update libusb to 1.0.21 for Windows (#562) - - -- Andrew 'Necromant' Andrianov Sat, 01 Jul 2017 00:00:00 +0000 - -libstlink (1.3.1) unstable; urgency=low - - * Major changes and added features: - - Add preliminary support for STM32L011 to see it after probe (chipid 0x457) (@xor-gate) - - Strip full paths to source files in log (commit #2c0ab7f) - - Add support for STM32F413 target (#549) - - Add support for Semihosting SYS_READC (#546) - * Updates and fixes: - - Update documentation markdown files - - Compilation fixes (#552) - - Fix compilation when path includes spaces (#561) - - -- Andrew 'Necromant' Andrianov Sat, 25 Feb 2017 00:00:00 +0000 - -libstlink (1.3.0) unstable; urgency=low - - * Major changes and added features: - - Deprecation of autotools (autoconf, automake) (@xor-gate) - - Removal of undocumented st-term utility, which is now replaced by st-util ARM semihosting feature (#3fd0f09) - - Add support for native debian packaging (#444, #485) - - Add intel hex file reading for st-flash (#459) - - Add --reset command to st-flash (#505) - - Support serial numbers argument for st-util and st-flash for multi-programmer setups (#541) - - Add kill ('k') command to gdb-server for st-util (#9804416) - - Add manpages (generated with pandoc from Markdown) (#464) - - Rewrite commandline parsing for st-flash (#459) - - Add support for ARM semihosting to st-util (#454, #455) - * Chip support added for: - - STM32L432 (#501) - - STM32F412 (#538) - - STM32F410 (#9c635e4) - - Add memory map for STM32F401XE (#460) - - L0x Category 5 devices (#406) - - Add L0 Category 2 device (chip id: 0x425) (#72b8e5e) - * Updates and fixes: - - Fixed STM32F030 erase error (#442) - - Fixed Cygwin build (#68b0f3b) - - Reset flash mass erase (MER) bit after mass erase for safety (#489) - - Fix memory map for STM32F4 (@zulusw) - - Fix STM32L-problem with flash loader (issue #390) (Tom de Boer) - - st-util don't read target voltage on startup as it crashes STM32F100 (probably stlink/v1) (Greg Alexander) - - Do a JTAG reset prior to reading CPU information when processor is in deep sleep (@andyg24) - - Redesign of st-flash commandline options parsing (pull-request #459) (@dev26th) - - -- Andrew 'Necromant' Andrianov Sat, 28 Jan 2017 00:00:00 +0000 - -libstlink (1.2.1) unstable; urgency=low - - * Initial Debian-Packaged Release. - - -- Andrew 'Necromant' Andrianov Sat, 09 Jul 2016 23:16:07 +0300 diff --git a/debian/pkg-config/CMakeLists.txt b/debian/pkg-config/CMakeLists.txt index a31e27e50..fa3a326a8 100644 --- a/debian/pkg-config/CMakeLists.txt +++ b/debian/pkg-config/CMakeLists.txt @@ -1,15 +1,15 @@ -set(PKG_CONFIG_LIBDIR "\${prefix}/lib/\${deb_host_multiarch}") -set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/\${deb_host_multiarch}/${PROJECT_NAME}") -set(PKG_CONFIG_LIBS "-L\${libdir} -l:libstlink.so.${PROJECT_VERSION_MAJOR}") -set(PKG_CONFIG_CFLAGS "-I\${includedir}") -set(PKG_CONFIG_REQUIRES "libusb-1.0") +#set(PKG_CONFIG_LIBDIR "\${prefix}/lib/\${deb_host_multiarch}") +#set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/\${deb_host_multiarch}/${PROJECT_NAME}") +#set(PKG_CONFIG_LIBS "-L\${libdir} -l:libstlink.so.${PROJECT_VERSION_MAJOR}") +#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" - ) +#configure_file( +# "${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}/pkg-config/ - ) +#install( +# FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" +# DESTINATION ${STLINK_LIBRARY_PATH}/debian/ +# ) diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index dee6cc258..74b71cecd 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -1,6 +1,6 @@ if (NOT GTK3_FOUND) message(STATUS "GTK3 not found!") - return() # no GTK3 present => no GUI build + return() # no GTK3 present => no GUI build else (GTK3_FOUND) message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}") endif () From 1986173163cdff574abc3cadd30f59744731b6e3 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Sun, 12 Apr 2020 14:45:41 +0200 Subject: [PATCH 130/236] stlink_open_usb: load device param returning -1 is not an usb issue. do not abort in case of load device param "error" : this is supposed to return -1 if device is "unknown" or not detected, which is not reaaally an error. we want probe to tell us what is the connected device even if we can not operate it we want probe to tell us that it can not operate it, not to hide the connected stlink --- src/usb.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/usb.c b/src/usb.c index 206600f14..68c484ddd 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1054,11 +1054,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST usleep(10000); } - ret = stlink_load_device_params(sl); - if (ret == -1) { - // This one didn't have any message. - goto on_libusb_error; - } + stlink_load_device_params(sl); + return sl; on_libusb_error: From 784ea36bdc3f0a71d67590a64424f2249e8e14cc Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Sun, 12 Apr 2020 16:06:15 +0200 Subject: [PATCH 131/236] usb.c: indent, make error use ELOG, and add trace --- src/usb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/usb.c b/src/usb.c index 68c484ddd..c9ea7039a 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1045,7 +1045,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) { - stlink_enter_swd_mode(sl); + stlink_enter_swd_mode(sl); } if (reset) { @@ -1130,9 +1130,9 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { ret = libusb_open(dev, &handle); if (ret < 0) { if (ret == LIBUSB_ERROR_ACCESS) { - WLOG("failed to open USB device (LIBUSB_ERROR_ACCESS), try running as root?\n"); - } else { - WLOG("failed to open USB device (libusb error: %d)\n", ret); + ELOG("Could not open USB device %#06x:%#06x, access error.\n", desc.idVendor, desc.idProduct, ret); + } else { + ELOG("Failed to open USB device %#06x:%#06x, libusb error: %d)\n", desc.idVendor, desc.idProduct, ret); } break; } @@ -1146,8 +1146,10 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { } stlink_t *sl = stlink_open_usb(0, 1, serial); - if (!sl) + if (!sl) { + ELOG("Failed to open USB device %#06x:%#06x\n", desc.idVendor, desc.idProduct); continue; + } _sldevs[slcur++] = sl; } From 5aa001cfab6eb70e697691915c8754553bc83b92 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Sun, 12 Apr 2020 16:31:49 +0200 Subject: [PATCH 132/236] flash.c: stlink_open_usb can now return a sl with no, or unknown target. check flash type before attempting to continue flash operations --- src/tools/flash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tools/flash.c b/src/tools/flash.c index f39b6c6e4..a08581094 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -59,8 +59,14 @@ int main(int ac, char** av) sl = stlink_open_usb(o.log_level, 1, (char *)o.serial); - if (sl == NULL) + if (sl == NULL) { return -1; + } + + if (sl->flash_type == STLINK_FLASH_TYPE_UNKNOWN) { + printf("Failed to connect to target\n"); + return -1; + } if ( o.flash_size != 0u && o.flash_size != sl->flash_size ) { sl->flash_size = o.flash_size; From 8f778b2e4c33d8e5916ea3f19bf4b06f50566537 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Thu, 16 Apr 2020 16:46:27 +0200 Subject: [PATCH 133/236] st-util: open usb can return sl pointer with no target connected. Check if connected target chip id is known. Some more info regarding connected chip should be set in chipid to know if debugging / attach is possible, but not yet. some more checks should be done to generate flash map / handle flashing if flash type is not supported.. --- src/gdbserver/gdb-server.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 1c45c2538..2b5b1d3cb 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -234,7 +234,14 @@ int main(int argc, char** argv) { printf("st-util %s\n", STLINK_VERSION); sl = do_connect(&state); - if (sl == NULL) return 1; + if (sl == NULL) { + return 1; + } + + if (sl->chip_id == STLINK_CHIPID_UNKNOWN) { + ELOG("Unsupported Target (Chip ID is %#010x, Core ID is %#010x).\n", sl->chip_id, sl->core_id); + return 1; + } connected_stlink = sl; signal(SIGINT, &cleanup); @@ -245,10 +252,7 @@ int main(int argc, char** argv) { stlink_reset(sl); } - - // This is low-level information for debugging, not useful for normal use. - // So: Demoted to a debug meesage. -- REW - DLOG("Chip ID is %08x, Core ID is %08x.\n", sl->chip_id, sl->core_id); + DLOG("Chip ID is %#010x, Core ID is %#08x.\n", sl->chip_id, sl->core_id); sl->verbose=0; current_memory_map = make_memory_map(sl); @@ -1852,7 +1856,8 @@ int serve(stlink_t *sl, st_state_t *st) { stlink_close(sl); sl = do_connect(st); - if (sl == NULL) cleanup(0); + if (sl == NULL || sl->chip_id == STLINK_CHIPID_UNKNOWN) + cleanup(0); connected_stlink = sl; if (st->reset) { From 15f1c81b08a8109f314157c79416b9f3037220ac Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Thu, 16 Apr 2020 16:37:19 +0200 Subject: [PATCH 134/236] st-util: remove v1/v2 stlink version stuff, useless --- src/gdbserver/gdb-server.c | 42 ++++++++------------------------------ 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 1c45c2538..fdea6246c 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -59,7 +59,6 @@ static const char* current_memory_map = NULL; typedef struct _st_state_t { // things from command line, bleh - int stlink_version; int logging_level; int listen_port; int persistent; @@ -86,21 +85,13 @@ static void cleanup(int signum) { static stlink_t* do_connect(st_state_t *st) { - stlink_t *ret = NULL; - switch (st->stlink_version) { - case 2: - if (serial_specified){ - ret = stlink_open_usb(st->logging_level, st->reset, serialnumber); - } - else { - ret = stlink_open_usb(st->logging_level, st->reset, NULL); - } - break; - case 1: - ret = stlink_v1_open(st->logging_level, st->reset); - break; + stlink_t *sl = NULL; + if (serial_specified) { + sl = stlink_open_usb(st->logging_level, st->reset, serialnumber); + } else { + sl = stlink_open_usb(st->logging_level, st->reset, NULL); } - return ret; + return sl; } @@ -108,8 +99,6 @@ int parse_options(int argc, char** argv, st_state_t *st) { static struct option long_options[] = { {"help", no_argument, NULL, 'h'}, {"verbose", optional_argument, NULL, 'v'}, - {"stlink_version", required_argument, NULL, 's'}, - {"stlinkv1", no_argument, NULL, '1'}, {"listen_port", required_argument, NULL, 'p'}, {"multi", optional_argument, NULL, 'm'}, {"no-reset", optional_argument, NULL, 'n'}, @@ -123,7 +112,6 @@ int parse_options(int argc, char** argv, st_state_t *st) { " -V, --version\t\tPrint the version\n" " -vXX, --verbose=XX\tSpecify a specific verbosity level (0..99)\n" " -v, --verbose\t\tSpecify generally verbose logging\n" - " -s X, --stlink_version=X\n" "\t\t\tChoose what version of stlink to use, (defaults to 2)\n" " -1, --stlinkv1\tForce stlink version 1\n" " -p 4242, --listen_port=1234\n" @@ -139,7 +127,7 @@ int parse_options(int argc, char** argv, st_state_t *st) { " --serial \n" "\t\t\tUse a specific serial number.\n" "\n" - "The STLINKv2 device to use can be specified in the environment\n" + "The STLINK device to use can be specified in the environment\n" "variable STLINK_DEVICE on the format :.\n" "\n" ; @@ -148,7 +136,7 @@ int parse_options(int argc, char** argv, st_state_t *st) { int option_index = 0; int c; int q; - while ((c = getopt_long(argc, argv, "hv::s:1p:mn", long_options, &option_index)) != -1) { + while ((c = getopt_long(argc, argv, "hv::p:mn", long_options, &option_index)) != -1) { switch (c) { case 0: break; @@ -163,17 +151,6 @@ int parse_options(int argc, char** argv, st_state_t *st) { st->logging_level = DEBUG_LOGGING_LEVEL; } break; - case '1': - st->stlink_version = 1; - break; - case 's': - sscanf(optarg, "%i", &q); - if (q < 0 || q > 2) { - fprintf(stderr, "stlink version %d unknown!\n", q); - exit(EXIT_FAILURE); - } - st->stlink_version = q; - break; case 'p': sscanf(optarg, "%i", &q); if (q < 0) { @@ -225,13 +202,12 @@ int main(int argc, char** argv) { memset(&state, 0, sizeof(state)); // set defaults... - state.stlink_version = 2; state.logging_level = DEFAULT_LOGGING_LEVEL; state.listen_port = DEFAULT_GDB_LISTEN_PORT; state.reset = 1; /* By default, reset board */ parse_options(argc, argv, &state); - printf("st-util %s\n", STLINK_VERSION); + printf("st-util\n"); sl = do_connect(&state); if (sl == NULL) return 1; From 19facc978911790e4f363e4466e7a9d22e7c519a Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 17 Apr 2020 11:41:37 +0200 Subject: [PATCH 135/236] indent --- src/common.c | 132 +++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 67 deletions(-) diff --git a/src/common.c b/src/common.c index 0ccdeccdb..9694a8b8e 100644 --- a/src/common.c +++ b/src/common.c @@ -696,7 +696,7 @@ static int check_flash_error(stlink_t *sl) { uint32_t res = 0; if ((sl->flash_type == STLINK_FLASH_TYPE_G0) || - (sl->flash_type == STLINK_FLASH_TYPE_G4)) { + (sl->flash_type == STLINK_FLASH_TYPE_G4)) { res = read_flash_sr(sl) & STM32Gx_FLASH_SR_ERROR_MASK; } @@ -1172,13 +1172,13 @@ int stlink_write_unsupported_reg(stlink_t *sl, uint32_t val, int r_idx, struct s bool stlink_is_core_halted(stlink_t *sl) { - bool ret = false; + bool ret = false; - stlink_status(sl); - if (sl->q_buf[0] == STLINK_CORE_HALTED) - ret = true; + stlink_status(sl); + if (sl->q_buf[0] == STLINK_CORE_HALTED) + ret = true; - return ret; + return ret; } int stlink_step(stlink_t *sl) { @@ -1204,8 +1204,6 @@ int stlink_current_mode(stlink_t *sl) { } - - // End of delegates.... Common code below here... // Endianness @@ -2915,19 +2913,20 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ if (len==8) { - /* Clear errors */ - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_SR_OFF, 0x00003F00); + /* Clear errors */ + stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_SR_OFF, 0x00003F00); stlink_read_debug32(sl, addr+4, &val); WLOG("2nd option bytes 0x%08x is 0x%08x\n",addr,val); /* Write options bytes */ - write_uint32((unsigned char*) &data, *(uint32_t*) (base+4)); - if ( data != val ) { - WLOG("Writing 2nd option bytes 0x%04x\n", data); - stlink_write_debug32(sl, addr+4, data); - stlink_read_debug32(sl, addr+4, &val); - WLOG("2nd option bytes is 0x%08x\n",val); + write_uint32((unsigned char*) &data, *(uint32_t*) (base+4)); + + if ( data != val ) { + WLOG("Writing 2nd option bytes 0x%04x\n", data); + stlink_write_debug32(sl, addr+4, data); + stlink_read_debug32(sl, addr+4, &val); + WLOG("2nd option bytes is 0x%08x\n",val); } } @@ -3120,7 +3119,6 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_ stlink_write_debug32(sl, FLASH_F4_OPT_CR, (option_byte & 0x0FFFFFFC)|0x00000002); - stlink_read_debug32(sl, FLASH_F4_SR, &val); WLOG("wait BSY flag to be 0\n"); @@ -3210,7 +3208,7 @@ int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte) { } stlink_read_debug32(sl, FLASH_F4_OPT_CR, option_byte); - WLOG("option bytes CR = %x\n",option_byte); + WLOG("option bytes CR = %x\n", option_byte); WLOG("Option flash re-lock\n"); stlink_write_debug32(sl, FLASH_F4_OPT_CR, val | 0x00000001); @@ -3236,23 +3234,23 @@ int stlink_read_option_bytes_generic(stlink_t *sl, uint32_t* option_byte) */ int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte) { - if (sl->option_base == 0) { - ELOG("Option bytes read is currently not supported for connected chip\n"); - return -1; - } - switch (sl->chip_id) { - case STLINK_CHIPID_STM32_F2: - return stlink_read_option_bytes_f2(sl, option_byte); - case STLINK_CHIPID_STM32_F446: - return stlink_read_option_bytes_f4(sl, option_byte); - case STLINK_CHIPID_STM32_G0_CAT1: - case STLINK_CHIPID_STM32_G0_CAT2: - case STLINK_CHIPID_STM32_G4_CAT2: - case STLINK_CHIPID_STM32_G4_CAT3: - return stlink_read_option_bytes_Gx(sl, option_byte); - default: - return stlink_read_option_bytes_generic(sl, option_byte); - } + if (sl->option_base == 0) { + ELOG("Option bytes read is currently not supported for connected chip\n"); + return -1; + } + switch (sl->chip_id) { + case STLINK_CHIPID_STM32_F2: + return stlink_read_option_bytes_f2(sl, option_byte); + case STLINK_CHIPID_STM32_F446: + return stlink_read_option_bytes_f4(sl, option_byte); + case STLINK_CHIPID_STM32_G0_CAT1: + case STLINK_CHIPID_STM32_G0_CAT2: + case STLINK_CHIPID_STM32_G4_CAT2: + case STLINK_CHIPID_STM32_G4_CAT3: + return stlink_read_option_bytes_Gx(sl, option_byte); + default: + return stlink_read_option_bytes_generic(sl, option_byte); + } } /** @@ -3276,43 +3274,43 @@ int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte) */ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len) { - if (sl->option_base == 0) { - ELOG("Option bytes writing is currently not supported for connected chip\n"); - return -1; - } - - if ((addr < sl->option_base) || addr > sl->option_base + sl->option_size) { - ELOG("Option bytes start address out of Option bytes range\n"); - return -1; - } + if (sl->option_base == 0) { + ELOG("Option bytes writing is currently not supported for connected chip\n"); + return -1; + } - if (addr + len > sl->option_base + sl->option_size) { - ELOG("Option bytes data too long\n"); - return -1; - } + if ((addr < sl->option_base) || addr > sl->option_base + sl->option_size) { + ELOG("Option bytes start address out of Option bytes range\n"); + return -1; + } - switch (sl->chip_id) { - case STLINK_CHIPID_STM32_F2: - return stlink_write_option_bytes_f2(sl, base, addr, len); - case STLINK_CHIPID_STM32_F446: - return stlink_write_option_bytes_f4(sl, base, addr, len); - case STLINK_CHIPID_STM32_L0_CAT2: - return stlink_write_option_bytes_l0_cat2(sl, base, addr, len); - case STLINK_CHIPID_STM32_L496X: - return stlink_write_option_bytes_l496x(sl, base, addr, len); - case STLINK_CHIPID_STM32_L152_RE: - case STLINK_CHIPID_STM32_L1_HIGH: - return stlink_write_option_bytes_l1(sl, base, addr, len); - case STLINK_CHIPID_STM32_G0_CAT1: - case STLINK_CHIPID_STM32_G0_CAT2: - case STLINK_CHIPID_STM32_G4_CAT2: - case STLINK_CHIPID_STM32_G4_CAT3: - return stlink_write_option_bytes_gx(sl, base, addr, len); - default: - ELOG("Option bytes writing is currently not implemented for connected chip\n"); + if (addr + len > sl->option_base + sl->option_size) { + ELOG("Option bytes data too long\n"); return -1; } + switch (sl->chip_id) { + case STLINK_CHIPID_STM32_F2: + return stlink_write_option_bytes_f2(sl, base, addr, len); + case STLINK_CHIPID_STM32_F446: + return stlink_write_option_bytes_f4(sl, base, addr, len); + case STLINK_CHIPID_STM32_L0_CAT2: + return stlink_write_option_bytes_l0_cat2(sl, base, addr, len); + case STLINK_CHIPID_STM32_L496X: + return stlink_write_option_bytes_l496x(sl, base, addr, len); + case STLINK_CHIPID_STM32_L152_RE: + case STLINK_CHIPID_STM32_L1_HIGH: + return stlink_write_option_bytes_l1(sl, base, addr, len); + case STLINK_CHIPID_STM32_G0_CAT1: + case STLINK_CHIPID_STM32_G0_CAT2: + case STLINK_CHIPID_STM32_G4_CAT2: + case STLINK_CHIPID_STM32_G4_CAT3: + return stlink_write_option_bytes_gx(sl, base, addr, len); + default: + ELOG("Option bytes writing is currently not implemented for connected chip\n"); + return -1; + } + } /** From 2cccbd91beda0145fe89ba70af8d675029191d4d Mon Sep 17 00:00:00 2001 From: Jochen Wilhelmy Date: Sun, 19 Apr 2020 14:18:32 +0200 Subject: [PATCH 136/236] Add CMAKEFLAGS and install target --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6b44bd70c..9bdea88a9 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ ## # This Makefile is used to drive building of Debug and Release targets of CMake ## -MAKEFLAGS += -s + +# additional flags for cmake, e.g. install path -DCMAKE_INSTALL_PREFIX=$(HOME)/.local +CMAKEFLAGS += all: release ci: debug release binary test @@ -10,6 +12,8 @@ help: @echo " debug: Run a debug build" @echo " release: Run a release build" @echo " binary: Build Windows-Binary" + @echo " install: Install release build" + @echo " package: Package release build" @echo " lint: Lint check all source-code" @echo " test: Build and run tests" @echo " clean: Clean all build output" @@ -32,6 +36,10 @@ binary: build/Binary @echo "[BINARY]" @$(MAKE) -C build/Binary +install: build/Release + @echo "[INSTALL] Release" + @$(MAKE) -C build/Release install + package: build/Release @echo "[PACKAGE] Release" @$(MAKE) -C build/Release package From e93c51691e4541ea3fa62b2c1022280f54e3231c Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 19 Apr 2020 21:19:06 +0200 Subject: [PATCH 137/236] Removed unused build target --- Makefile | 10 ---------- cmake/modules/Findlibusb.cmake | 4 +--- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 9bdea88a9..a35400617 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,6 @@ ci: debug release binary test help: @echo " debug: Run a debug build" @echo " release: Run a release build" - @echo " binary: Build Windows-Binary" @echo " install: Install release build" @echo " package: Package release build" @echo " lint: Lint check all source-code" @@ -22,7 +21,6 @@ help: rebuild_cache: build/Debug build/Release @$(MAKE) -C build/Debug rebuild_cache @$(MAKE) -C build/Release rebuild_cache - @$(MAKE) -C build/Binary rebuild_cache debug: build/Debug @echo "[DEBUG]" @@ -32,10 +30,6 @@ release: build/Release @echo "[RELEASE]" @$(MAKE) -C build/Release -binary: build/Binary - @echo "[BINARY]" - @$(MAKE) -C build/Binary - install: build/Release @echo "[INSTALL] Release" @$(MAKE) -C build/Release install @@ -55,10 +49,6 @@ build/Release: @mkdir -p $@ @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ -build/Binary: - @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Binary $(CMAKEFLAGS) ../../ - clean: @echo "[CLEAN]" @rm -Rf build diff --git a/cmake/modules/Findlibusb.cmake b/cmake/modules/Findlibusb.cmake index 5b3e80fe6..c5366377e 100644 --- a/cmake/modules/Findlibusb.cmake +++ b/cmake/modules/Findlibusb.cmake @@ -41,9 +41,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.") endif () -elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES "Binary")) - # Windows & Windows-Binary-Build on Debian/Ubuntu - +elseif (WIN32) # Windows # for MinGW/MSYS/MSVC: 64-bit or 32-bit? if (CMAKE_SIZEOF_VOID_P EQUAL 8) set(ARCH 64) From 145ca6d64a44ed867a59229db403ec121086d511 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 19 Apr 2020 23:39:40 +0200 Subject: [PATCH 138/236] General Project Update - Updated github branch template - Updated project CHANGELOG.md --- CHANGELOG.md | 8 ++++++-- README.md | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0b920f71..a5cf843c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,14 +12,16 @@ Features: - Support for STM32L1, SM32L4 option bytes write (#596, #844, #847) - CMake now creates an uninstall target (#619, #907) +- Added CMAKEFLAGS and install target (#804, #935) - Support for STM32G4 (#822) - Add aliased SRAM2 region in the L496 memory map (#824) - Improved support for STM32G0 (#825, #850, #856, #857) +- Added postinst script with 'depmod -a' for 'make package' (#845, #931) +- Calculate checksums for flash operations (#862, #924) - Added usb PID and udev rules for STlink v2.1 found on Nucleo-L432KC and Nucleo-L552ze boards (#900) - STM32G0/G4 improvements (#910) - Enable mass erase with a flash programming check - Handle G4 Cat3 devices with configurable dual bank flash by using a helper -- Calculate checksums for flash operations (#862, #924) Updates & changes: @@ -38,6 +40,8 @@ Updates & changes: - [doc] Defined version compatibility and installation instructions for macOS (commit 23c071edea45f6e8852fef52d884a680973d6d8f) - Deprecated old appveyor-mingw script (commit 97484422008df0f75c978627054776f35842a075) - Enhanced error log with file path for map_file() (#650, #879, #921) +- Refactoring: Overall option code rework (#927) +- Refactoring: Build settings / GUI-Build on UNIX-based systems if GTK3 is detected (#929) Fixes: @@ -56,7 +60,7 @@ Fixes: - Fixed broken build on 32-bit systems (#919, #920) - st-flash: minor usage fix and make cmdline parsing more user friendly (#925) - Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 (#378, #922) -- Restored functionality of make test builds (Regression) (#926) +- Restored functionality of make test builds (Regression) (#926, #929) v1.6.0 diff --git a/README.md b/README.md index a0147ed14..735712329 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Open source version of the STMicroelectronics STlink Tools [![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/stlink-org/stlink.svg)](https://github.com/stlink-org/stlink/releases/latest) -[![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.0.svg)](https://github.com/stlink-org/stlink/releases/master) +[![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.0.svg)](https://github.com/stlink-org/stlink/releases/develop) [![Downloads](https://img.shields.io/github/downloads/stlink-org/stlink/total.svg)](https://github.com/stlink-org/stlink/releases) [![Linux Status](https://img.shields.io/travis/stlink-org/stlink/master.svg?label=linux)](https://travis-ci.org/stlink-org/stlink) [![macOS Status](https://img.shields.io/travis/stlink-org/stlink/master.svg?label=osx)](https://travis-ci.org/stlink-org/stlink) From c7874f805c63c60285f2b190f6589da8ae5e47fa Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 20 Apr 2020 01:28:29 +0200 Subject: [PATCH 139/236] Fixes to prevent merge conflict --- CMakeLists.txt | 2 +- Makefile | 3 ++- cmake/modules/{Find7zip.cmake => Find_7zip.cmake} | 3 +-- cmake/modules/{Findlibusb.cmake => Find_libusb.cmake} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename cmake/modules/{Find7zip.cmake => Find_7zip.cmake} (91%) rename cmake/modules/{Findlibusb.cmake => Find_libusb.cmake} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8da6c45c..19a3e24c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ endif () # Dependencies ### -find_package(libusb REQUIRED) +find_package(_libusb REQUIRED) if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) find_package(PkgConfig) diff --git a/Makefile b/Makefile index a35400617..5272c74d2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ ## # This Makefile is used to drive building of Debug and Release targets of CMake ## +MAKEFLAGS += -s # additional flags for cmake, e.g. install path -DCMAKE_INSTALL_PREFIX=$(HOME)/.local CMAKEFLAGS += @@ -47,7 +48,7 @@ build/Debug: build/Release: @mkdir -p $@ - @cd $@ && cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ + @cd $@ && cmake -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) -Wno-dev ../../ clean: @echo "[CLEAN]" diff --git a/cmake/modules/Find7zip.cmake b/cmake/modules/Find_7zip.cmake similarity index 91% rename from cmake/modules/Find7zip.cmake rename to cmake/modules/Find_7zip.cmake index 0ccd23a50..c75cf1150 100644 --- a/cmake/modules/Find7zip.cmake +++ b/cmake/modules/Find_7zip.cmake @@ -1,7 +1,6 @@ -# Find7zip.cmake +# Find_7zip.cmake # Detect 7zip file archiver on Windows systems to extract (zip-)archives - find_program( ZIP_EXECUTABLE NAMES 7z.exe p7zip HINTS "C:\\Program Files\\7-Zip\\" "C:\\Program Files (x86)\\7-Zip\\" diff --git a/cmake/modules/Findlibusb.cmake b/cmake/modules/Find_libusb.cmake similarity index 99% rename from cmake/modules/Findlibusb.cmake rename to cmake/modules/Find_libusb.cmake index c5366377e..d9dd706c8 100644 --- a/cmake/modules/Findlibusb.cmake +++ b/cmake/modules/Find_libusb.cmake @@ -1,4 +1,4 @@ -# Findlibusb.cmake +# Find_libusb.cmake # Once done this will define # # LIBUSB_FOUND libusb present on system @@ -73,7 +73,7 @@ elseif (WIN32) # Windows if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(7zip REQUIRED) + find_package(_7zip REQUIRED) set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) From 48a9db00be3fe6fa3682fbb538d2db03fb78a899 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 20 Apr 2020 01:45:19 +0200 Subject: [PATCH 140/236] Removed remnants of unused build target --- Makefile | 1 - cmake/modules/Find_libusb.cmake | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c3bd59c52..354f114fc 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,6 @@ ci: debug release binary test help: @echo " debug: Run a debug build" @echo " release: Run a release build" - @echo " binary: Build Windows-Binary" @echo " lint: Lint check all source-code" @echo " test: Build and run tests" @echo " clean: Clean all build output" diff --git a/cmake/modules/Find_libusb.cmake b/cmake/modules/Find_libusb.cmake index e46c6d46e..d9dd706c8 100644 --- a/cmake/modules/Find_libusb.cmake +++ b/cmake/modules/Find_libusb.cmake @@ -41,9 +41,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.") endif () -elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES "Binary")) - # Windows & Windows-Binary-Build on Debian/Ubuntu - +elseif (WIN32) # Windows # for MinGW/MSYS/MSVC: 64-bit or 32-bit? if (CMAKE_SIZEOF_VOID_P EQUAL 8) set(ARCH 64) @@ -75,9 +73,7 @@ elseif (WIN32 OR (EXISTS "/etc/debian_version" AND ${CMAKE_BUILD_TYPE} MATCHES " if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(_7zip REQUIRED) - set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) From bc869d75e56d3878e2db3e5941b971c548f0ae22 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 20 Apr 2020 01:46:26 +0200 Subject: [PATCH 141/236] Fixes to prevent merge conflict --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 354f114fc..b6d2a2a31 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ ci: debug release binary test help: @echo " debug: Run a debug build" @echo " release: Run a release build" + @echo " install: Install release build" + @echo " package: Package release build" @echo " lint: Lint check all source-code" @echo " test: Build and run tests" @echo " clean: Clean all build output" @@ -26,6 +28,10 @@ release: build/Release @echo "[RELEASE]" @$(MAKE) -C build/Release +install: build/Release + @echo "[INSTALL] Release" + @$(MAKE) -C build/Release install + package: build/Release @echo "[PACKAGE] Release" @$(MAKE) -C build/Release package From 5f983a60958c8476b40260c851eb50bd95b86c83 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 20 Apr 2020 14:39:00 +0800 Subject: [PATCH 142/236] Fix uninitialized cpuid --- src/common.c | 8 ++++++-- tests/usb.c | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/common.c b/src/common.c index 6226c893b..0bd914828 100644 --- a/src/common.c +++ b/src/common.c @@ -814,9 +814,13 @@ int stlink_chip_id(stlink_t *sl, uint32_t *chip_id) { int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid) { uint32_t raw; - if (stlink_read_debug32(sl, STLINK_REG_CM3_CPUID, &raw)) + if (stlink_read_debug32(sl, STLINK_REG_CM3_CPUID, &raw)) { + cpuid->implementer_id = 0; + cpuid->variant = 0; + cpuid->part = 0; + cpuid->revision = 0; return -1; - + } cpuid->implementer_id = (raw >> 24) & 0x7f; cpuid->variant = (raw >> 20) & 0xf; cpuid->part = (raw >> 4) & 0xfff; diff --git a/tests/usb.c b/tests/usb.c index 06fd73429..4558c8d69 100644 --- a/tests/usb.c +++ b/tests/usb.c @@ -30,9 +30,13 @@ int main(int ac, char** av) printf("-- core_id: %#x\n", sl->core_id); cortex_m3_cpuid_t cpuid; - stlink_cpu_id(sl, &cpuid); - printf("cpuid:impl_id = %0#x, variant = %#x\n", cpuid.implementer_id, cpuid.variant); - printf("cpuid:part = %#x, rev = %#x\n", cpuid.part, cpuid.revision); + if (stlink_cpu_id(sl, &cpuid)) { + printf("Failed reading stlink_cpu_id\n"); + } else { + printf("cpuid:impl_id = %0#x, variant = %#x\n", cpuid.implementer_id, cpuid.variant); + printf("cpuid:part = %#x, rev = %#x\n", cpuid.part, cpuid.revision); + } + printf("-- read_sram\n"); static const uint32_t sram_base = STM32_SRAM_BASE; From 629314c44f801f82d478fe49e7b409cdb7364077 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 20 Apr 2020 14:46:36 +0200 Subject: [PATCH 143/236] Corrections in cmake build - Name pattern for libusb detection - Include of GNUInstallDirs module - Removed old ci-leftover in Makefile (Fixes #936) --- CMakeLists.txt | 4 +--- Makefile | 2 +- cmake/modules/Find_libusb.cmake | 8 ++++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccb5fefa9..2a923be5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,6 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -# Define GNU standard installation directories -include(GNUInstallDirs) - ### # General project settings @@ -18,6 +15,7 @@ include(GNUInstallDirs) project(stlink C) set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools") +include(GNUInstallDirs) # Define GNU standard installation directories 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") diff --git a/Makefile b/Makefile index 5272c74d2..444f1920b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ MAKEFLAGS += -s CMAKEFLAGS += all: release -ci: debug release binary test +ci: debug release test help: @echo " debug: Run a debug build" diff --git a/cmake/modules/Find_libusb.cmake b/cmake/modules/Find_libusb.cmake index d9dd706c8..a44e02236 100644 --- a/cmake/modules/Find_libusb.cmake +++ b/cmake/modules/Find_libusb.cmake @@ -19,7 +19,7 @@ if (APPLE) # macOS LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(_libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) if (NOT LIBUSB_FOUND) message(FATAL_ERROR "No libusb library found on your system! Install libusb-1.0 from Homebrew or MacPorts") @@ -35,7 +35,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(_libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) if (NOT LIBUSB_FOUND) message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.") @@ -131,7 +131,7 @@ elseif (WIN32) # Windows endif () message(STATUS "Missing libusb library has been installed") endif () - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(_libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) else () # all other OS (unix-based) @@ -145,7 +145,7 @@ else () # all other OS (unix-based) LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + 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) From e8503fb9b0a54483ab7d5dfc9f4989973711f1ef Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 17 Apr 2020 15:36:47 +0200 Subject: [PATCH 144/236] stlink.h: document a bit flash types. f1 xl should probably merged back into f0, with dual bank bit set. --- include/stlink.h | 10 +++++----- src/common.c | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index db737acb0..87d708ef3 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -81,11 +81,11 @@ extern "C" { enum stlink_flash_type { STLINK_FLASH_TYPE_UNKNOWN = 0, - STLINK_FLASH_TYPE_F0, - STLINK_FLASH_TYPE_L0, - STLINK_FLASH_TYPE_F4, - STLINK_FLASH_TYPE_L4, - STLINK_FLASH_TYPE_F1_XL, + STLINK_FLASH_TYPE_F0, /* used by f0, f1 (except f1xl),f3. */ + STLINK_FLASH_TYPE_F1_XL, /* f0 flash with dual bank, apparently */ + STLINK_FLASH_TYPE_F4, /* used by f2, f4, f7 */ + STLINK_FLASH_TYPE_L0, /* l0, l1 */ + STLINK_FLASH_TYPE_L4, /* l4, l4+ */ STLINK_FLASH_TYPE_G0, STLINK_FLASH_TYPE_G4, STLINK_FLASH_TYPE_WB diff --git a/src/common.c b/src/common.c index 9694a8b8e..7ca017eb4 100644 --- a/src/common.c +++ b/src/common.c @@ -3238,6 +3238,7 @@ int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte) ELOG("Option bytes read is currently not supported for connected chip\n"); return -1; } + switch (sl->chip_id) { case STLINK_CHIPID_STM32_F2: return stlink_read_option_bytes_f2(sl, option_byte); @@ -3289,6 +3290,7 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui return -1; } + /* filter out on chip_id, until complete flash family are handled */ switch (sl->chip_id) { case STLINK_CHIPID_STM32_F2: return stlink_write_option_bytes_f2(sl, base, addr, len); From 498de0cc8cb44c30ca401afdf7d36f9cbda5c5e8 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 17 Apr 2020 11:38:54 +0200 Subject: [PATCH 145/236] option write : remove size check, this has already been done earlier --- src/common.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/common.c b/src/common.c index 7ca017eb4..9fda97cdf 100644 --- a/src/common.c +++ b/src/common.c @@ -3028,12 +3028,8 @@ static int stlink_write_option_bytes_f2(stlink_t *sl, uint8_t *base, stm32_addr_ uint32_t val; uint32_t option_byte; - (void) addr; /* todo: add sanitary check */ - - if(len != 4) { - ELOG("Wrong length for writting option bytes, must be 4 is %d\n", len); - return -1; - } + (void) addr; + (void) len; option_byte = *(uint32_t*) (base); @@ -3088,12 +3084,8 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_ uint32_t val; uint32_t option_byte; - (void) addr; /* todo: add sanitary check */ - - if(len != 4) { - ELOG("Wrong length for writing option bytes, must be 4 is %d\n", len); - return -1; - } + (void) addr; + (void) len; option_byte = *(uint32_t*) (base); From 598af1c1aff066a61494b611d41ad62b35f0be92 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 17 Apr 2020 11:41:10 +0200 Subject: [PATCH 146/236] use constant for optkey --- src/common.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/common.c b/src/common.c index 9fda97cdf..afeb6106a 100644 --- a/src/common.c +++ b/src/common.c @@ -53,6 +53,9 @@ #define FLASH_KEY1 0x45670123 #define FLASH_KEY2 0xcdef89ab +#define FLASH_OPTKEY1 0x08192A3B +#define FLASH_OPTKEY2 0x4C5D6E7F + #define FLASH_SR_BSY 0 #define FLASH_SR_EOP 5 @@ -2753,8 +2756,8 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_ if ((val & (1 << STM32Gx_FLASH_CR_OPTLOCK))) { /* disable option byte write protection. */ - stlink_write_debug32(sl, STM32Gx_FLASH_OPTKEYR, 0x08192A3B); - stlink_write_debug32(sl, STM32Gx_FLASH_OPTKEYR, 0x4C5D6E7F); + stlink_write_debug32(sl, STM32Gx_FLASH_OPTKEYR, FLASH_OPTKEY1); + stlink_write_debug32(sl, STM32Gx_FLASH_OPTKEYR, FLASH_OPTKEY2); /* check that the lock is no longer set. */ stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); @@ -2973,8 +2976,8 @@ static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, stm32_ad if ((val & (1 << STM32L4_FLASH_CR_OPTLOCK))) { /* disable option byte write protection. */ - stlink_write_debug32(sl, STM32L4_FLASH_OPTKEYR, 0x08192A3B); - stlink_write_debug32(sl, STM32L4_FLASH_OPTKEYR, 0x4C5D6E7F); + stlink_write_debug32(sl, STM32L4_FLASH_OPTKEYR, FLASH_OPTKEY1); + stlink_write_debug32(sl, STM32L4_FLASH_OPTKEYR, FLASH_OPTKEY2); /* check that the lock is no longer set. */ stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); @@ -3038,8 +3041,8 @@ static int stlink_write_option_bytes_f2(stlink_t *sl, uint8_t *base, stm32_addr_ WLOG("Unlocking option flash\n"); //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, 0x08192A3B); - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, 0x4C5D6E7F); + stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY1); + stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY2); stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); if (val & FLASH_F2_OPT_LOCK_BIT) { @@ -3094,8 +3097,8 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_ WLOG("Unlocking option flash\n"); //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, 0x08192A3B); - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, 0x4C5D6E7F); + stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY1); + stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY2); stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); if (val & FLASH_F4_OPT_LOCK_BIT) { @@ -3156,8 +3159,8 @@ int stlink_read_option_bytes_f2(stlink_t *sl, uint32_t* option_byte) { WLOG("Unlocking option flash\n"); //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, 0x08192A3B); - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, 0x4C5D6E7F); + stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY1); + stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY2); stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); if (val & FLASH_F2_OPT_LOCK_BIT) { @@ -3189,8 +3192,8 @@ int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte) { WLOG("Unlocking option flash\n"); //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, 0x08192A3B); - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, 0x4C5D6E7F); + stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY1); + stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY2); stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); if (val & FLASH_F4_OPT_LOCK_BIT) { From 7640daae4c0ade48a4179b3a7750272471b8c8e5 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 20 Apr 2020 18:34:12 +0200 Subject: [PATCH 147/236] Fixed compilation error on windows Extraction of downloaded libusb archive failed due to wrong command option formatting since commit a8c1f41f1b1c9dd1314f99a1d42de1008f5a4f74. --- cmake/modules/Find_libusb.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/modules/Find_libusb.cmake b/cmake/modules/Find_libusb.cmake index a44e02236..8da0090d8 100644 --- a/cmake/modules/Find_libusb.cmake +++ b/cmake/modules/Find_libusb.cmake @@ -73,7 +73,7 @@ elseif (WIN32) # Windows if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(_7zip REQUIRED) + find_package(7zip REQUIRED) set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) @@ -100,8 +100,8 @@ elseif (WIN32) # Windows ) else () execute_process( - COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o ${LIBUSB_WIN_OUTPUT_FOLDER} - ) + COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o${LIBUSB_WIN_OUTPUT_FOLDER} + ) # <-- Note the absence of a space character following the -o option! endif () # Find path to libusb library From a7568d3cf93c00705b1809186e069fc52210445f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 20 Apr 2020 20:00:12 +0200 Subject: [PATCH 148/236] Fixed package name in Find_libusb module Regression from previous commit 7640daae4c0ade48a4179b3a7750272471b8c8e5. --- cmake/modules/Find_libusb.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/Find_libusb.cmake b/cmake/modules/Find_libusb.cmake index 8da0090d8..57e0fa8cf 100644 --- a/cmake/modules/Find_libusb.cmake +++ b/cmake/modules/Find_libusb.cmake @@ -73,7 +73,7 @@ elseif (WIN32) # Windows if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(7zip REQUIRED) + find_package(_7zip REQUIRED) set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) From d7e1e6a11e439256abe36a02663d065320cbc4df Mon Sep 17 00:00:00 2001 From: Glaeqen Date: Tue, 21 Apr 2020 00:13:49 +0200 Subject: [PATCH 149/236] Added compilation guideline for MSVC toolchain --- doc/compiling.md | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/doc/compiling.md b/doc/compiling.md index 15d8b4fc2..7296af650 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -19,13 +19,27 @@ On Windows users should ensure that the following software is installed: Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant. 4. Install - _EITHER_: **MinGW-w64** from (mingw-w64-install.exe)
- - _OR_: **Visual Studio 2017 CE** (other versions will likely work as well, but are untested; the Community edition is free for open source - development) + - _OR_: **MSVC toolchain** from Visual Studio Build Tools 2019 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/stlink-org/stlink.git`from the command-line (cmd.exe)
or download the stlink zip-sourcefolder from the Release page on GitHub +#### MSVC toolchain - minimal installation + +Visual Studio IDE is not necessary, only Windows SDK & build tools are required (~3,3GB). + +1. Open +2. Navigate through menus as follows (might change overtime) + + `All downloads > Tools for Visual Studio 2019 > Build Tools for Visual Studio 2019 > Download` +3. Start downloaded executable. After Visual Studio Installer bootstraps and main window pops up, open `Individual Components` tab, and pick + - latest build tools (eg. `MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.25)`) + - latest Windows SDK (eg. `Windows 10 SDK (10.0.18362.0)`) +4. After installation finishes, you can press `Launch` button in Visual Studio Installer's main menu. + - Thus you can open `Developer Command Prompt for VS 2019`. It is `cmd.exe` instance with adjusted PATHs including eg. `msbuild`. + - Alternatively, you can use `Developer Powershell for VS 2019` which is the same thing for `powershell.exe`. Both are available from Start menu. + - Another option is to add `msbuild` to PATH manually. Its location should be `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin`. Then, it should be available from any `powershell.exe` or `cmd.exe` session. ### Building #### MinGW-w64 @@ -39,19 +53,32 @@ When installing different toolchains make sure to update the path in the `mingw6 This can be achieved by opening the .bat file with a common text editor. -#### Visual Studio (32 bit) +#### MSVC toolchain 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). +This will create a solution file `stlink.sln` in the build folder. +Now, you can build whole `stlink` suite using following command: +``` +msbuild /m /p:Configuration=Release stlink.sln +``` +Options: +- `/m` - compilation runs in parallel utilizing multiple cores +- `/p:Configuration=Release` - generates *Release*, optimized build. + +Directory `\build\Release` contains final executables. +(`st-util.exe` is located in `\build\src\gdbserver\Release`). -NOTE:
-This solution will link to the dll version of libusb-1.0.y
-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\3rdparty\libusb-1.0.21\MS32\dll\libusb-1.0.dll`. +**NOTE 1:** + +Executables link against libusb.dll library. It has to be placed in the same directory as binaries or in PATH. +It can be copied from: `\build\3rdparty\libusb-{version}\MS{arch}\dll\libusb-1.0.dll`. + +**NOTE 2:** + +[ST-LINK drivers](https://www.st.com/en/development-tools/stsw-link009.html) are required for `stlink` to work. ## Linux ### Common requirements From abaa8f5782df7b8cfe4e3171b168d373bd680fa8 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Tue, 21 Apr 2020 09:50:50 +0800 Subject: [PATCH 150/236] Add cleanroom document --rebased --- flashloaders/cleanroom.md | 232 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 flashloaders/cleanroom.md diff --git a/flashloaders/cleanroom.md b/flashloaders/cleanroom.md new file mode 100644 index 000000000..594e7191a --- /dev/null +++ b/flashloaders/cleanroom.md @@ -0,0 +1,232 @@ +English version can be found below. + +# 净室工程文档 + +代码位于的section:`.text` +编译制导添加`.syntax unified` + +传入参数约定: + +参数全部通过寄存器传递 + +`r0`: 拷贝源点起始地址 +`r1`: 拷贝终点起始地址 +`r2`: 拷贝word(4字节)数(存在例外) + +程序功能:将数据从源点拷贝到终点,在拷贝完毕后触发断点以结束执行,结束时`r2`值需清零表明传输完毕。 + +限制:不可使用栈,可自由使用的临时寄存器为`R3`到`R12`。`R13`为`sp`(stack pointer),`R14`为lr(一般用于储存跳转地址),`R15`为`pc`(program counter)。 + +要求:每完成一次拷贝,需等待flash完成写入,单次拷贝宽度、检查写入完成的方式见每个文件的具体要求。 + +特殊地址`flash_base`存放地址需2字节对齐。 + +## stm32f0.s + +例外:`r2`:拷贝half word(2字节)数 + +特殊地址定义:`flash_base`:定义为0x40022000 + +`FLASH_CR`: 相对`flash_base`的offset为16 + +`FLASH_SR`: 相对`flash_base`的offset为12 + +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h) +[https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +特殊要求: +每次拷贝开始前需要读出FLASH_CR处的4字节内容,将其最低bit设置为1,写回FLASH_CR。 + +每次写入数据宽度为2字节(半字)。 + +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处4字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待;否则需要检查FLASH_SR处值是否为4,若是4,则应直接准备退出。 + +退出:全部拷贝执行完毕后触发断点前,将FLASH_CR处4字节内容最低bit清为0,写回FLASH_CR。 + + + +## stm32f4.s + +特殊地址定义: `flash_base`:定义为0x40023c00 + +`FLASH_SR`:相对flash_base的offset为0xe(14) + +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +[https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) + +特殊要求: + +每次写入的数据宽度为4字节(字)。 + +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处2字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待。 + +## stm32f4lv.s + +特殊地址定义:`flash_base`:定义为0x40023c00 + +`FLASH_SR`:相对`flash_base`的offset为0xe (14) + +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +[https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) + +特殊要求: + +每次写入的数据宽度为1字节(1/4字)。 + +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处2字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待。 + +## stm32f7.s + +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +[https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +要求同stm32f4.s,额外要求在每次拷贝执行完毕、flash写入成功检测前,执行`dsb sy`指令以建立内存屏障。 + + +## stm32f7lv.s + +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +[https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) +要求基本同stm32f7.s,差异要求为每次写入的数据宽度为1字节(1/4字)。 + +## stm32l0x.s + +特殊要求: + +每次写入的数据宽度为4字节(字) + +无需实现检查flash写入完成功能 + +## stm32l4.s + +例外:`r2`: 拷贝双字(8字节)数 + +特殊地址定义:`flash_base`: 0x40022000 + +`FLASH_BSY`:相对flash_base的offset为0x12 + +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h) +[https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +拷贝方式:一次性拷贝连续的8个字节(使用两个连续寄存器作中转)并写入 + +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_BSY处半字(2字节),若其最低位非1,可继续拷贝。 + +## stm32lx.s + +要求与stm32l0x.s相同 + +# Clean Room Documentation English Version + +Code is situated in section `.text` + +Shall add a compile directive at the head: `.syntax unified` + +**Calling convention**: + +All parameters would be passed over registers + +`r0`: the base address of the copy source +`r1`: the base address of the copy destination +`r2`: the total word (4 bytes) count to be copied (with expeptions) + +**What the program is expected to do**: + +Copy data from source to destination, after which trigger a breakpint to exit. Before exit, `r2` must be cleared to zero to indicate that the copy is done. + +**Limitation**: No stack operations are permitted. Registers ranging from `r3` to `r12` are free to use. Note that `r13` is `sp`(stack pointer), `r14` is `lr`(commonly used to store jump address), `r15` is `pc`(program counter). + +**Requirement**: After every single copy, wait until the flash finishes. The detailed single copy length and the way to check can be found below. Address of `flash_base` shall be two-bytes aligned. + +## stm32f0.s + +**Exception**: `r2` stores the total half word (2 bytes) count to be copied + +`flash_base`: 0x40022000 + +`FLASH_CR`: offset from `flash_base` is 16 + +`FLASH_SR`: offset from `flash_base` is 12 + +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h) +[https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +**Special requirements**: + +Before every copy, read a word from FLASH_CR, set the lowest bit to 1 and write back. Copy one half word each time. + +How to wait for the write process: read a word from FLASH_SR, loop until the content is not 1. After that, check FLASH_SR, proceed if the content is not 4, otherwise exit. + +Exit: after the copying process and before triggering the breakpoint, clear the lowest bit in FLASH_CR. + +## stm32f4.s + +`flash_base`: 0x40023c00 + +`FLASH_SR`: offset from `flash_base` is 0xe (14) + +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +[https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) + + +**Special requirements**: + +Copy one word each time. +How to wait for the write process: read a half word from FLASH_SR, loop until the content is not 1. + +## stm32f4lv.s + +`flash_base`: 0x40023c00 + +`FLASH_SR`: offset from `flash_base` is 0xe (14) + +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +[https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) + +**Special Requirements**: + +Copy one byte each time. + +How to wait from the write process: read a half word from FLASH_SR, loop until the content is not 1. + +## stm32f7.s + +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +[https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +Mostly same with `stm32f4.s`. Require establishing a memory barrier after every copy and before checking for finished writing by `dsb sy` + +## stm32f7lv.s + +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +[https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +**Special Requirements**: + +Mostly same with `stm32f7.s`. Copy one byte each time. + +## stm32l0x.s + +**Special Requirements**: + +Copy one word each time. No wait for write. + +## stm32l4.s + +**Exception**: r2 stores the double word count to be copied. + +`flash_base`: 0x40022000 +`FLASH_BSY`: offset from `flash_base` is 0x12 + +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h) +[https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) + +**Special Requirements**: + +Copy one double word each time (More than one registers are allowed). + +How to wait for the write process: read a half word from `FLASH_BSY`, loop until the lowest bit turns non-1. + +## stm32lx.s + +Same with stm32l0x.s. \ No newline at end of file From 9b19f9225460472af9d98959b7217d0a840ee972 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:49:25 +0200 Subject: [PATCH 151/236] Fixed compilation errors - Moved include of GNUInstallDirs module in cmake-routine - Removed old ci-leftover in Makefile - cmake: Fixed name pattern for libusb module (Fixes #940) - Wrong command option formatting for 7zip (Fixes #936) Extraction of downloaded libusb archive on Windows failed since commit a8c1f41f1b1c9dd1314f99a1d42de1008f5a4f74. --- CMakeLists.txt | 6 ++---- Makefile | 2 +- .../modules/{Find_7zip.cmake => Find7zip.cmake} | 2 +- .../{Find_libusb.cmake => Findlibusb.cmake} | 16 ++++++++-------- 4 files changed, 12 insertions(+), 14 deletions(-) rename cmake/modules/{Find_7zip.cmake => Find7zip.cmake} (91%) rename cmake/modules/{Find_libusb.cmake => Findlibusb.cmake} (92%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccb5fefa9..fd79ac10e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,9 +8,6 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -# Define GNU standard installation directories -include(GNUInstallDirs) - ### # General project settings @@ -18,6 +15,7 @@ include(GNUInstallDirs) project(stlink C) set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools") +include(GNUInstallDirs) # Define GNU standard installation directories 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") @@ -67,7 +65,7 @@ endif () # Dependencies ### -find_package(_libusb REQUIRED) +find_package(libusb REQUIRED) if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) find_package(PkgConfig) diff --git a/Makefile b/Makefile index 5272c74d2..444f1920b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ MAKEFLAGS += -s CMAKEFLAGS += all: release -ci: debug release binary test +ci: debug release test help: @echo " debug: Run a debug build" diff --git a/cmake/modules/Find_7zip.cmake b/cmake/modules/Find7zip.cmake similarity index 91% rename from cmake/modules/Find_7zip.cmake rename to cmake/modules/Find7zip.cmake index c75cf1150..83eb912d4 100644 --- a/cmake/modules/Find_7zip.cmake +++ b/cmake/modules/Find7zip.cmake @@ -1,4 +1,4 @@ -# Find_7zip.cmake +# Find7zip.cmake # Detect 7zip file archiver on Windows systems to extract (zip-)archives find_program( diff --git a/cmake/modules/Find_libusb.cmake b/cmake/modules/Findlibusb.cmake similarity index 92% rename from cmake/modules/Find_libusb.cmake rename to cmake/modules/Findlibusb.cmake index d9dd706c8..13f70d7b7 100644 --- a/cmake/modules/Find_libusb.cmake +++ b/cmake/modules/Findlibusb.cmake @@ -1,4 +1,4 @@ -# Find_libusb.cmake +# Findlibusb.cmake # Once done this will define # # LIBUSB_FOUND libusb present on system @@ -19,7 +19,7 @@ if (APPLE) # macOS LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) if (NOT LIBUSB_FOUND) message(FATAL_ERROR "No libusb library found on your system! Install libusb-1.0 from Homebrew or MacPorts") @@ -35,7 +35,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) if (NOT LIBUSB_FOUND) message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.") @@ -73,7 +73,7 @@ elseif (WIN32) # Windows if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(_7zip REQUIRED) + find_package(7zip REQUIRED) set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) @@ -100,8 +100,8 @@ elseif (WIN32) # Windows ) else () execute_process( - COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o ${LIBUSB_WIN_OUTPUT_FOLDER} - ) + COMMAND ${ZIP_EXECUTABLE} x -y ${LIBUSB_WIN_ARCHIVE_PATH} -o${LIBUSB_WIN_OUTPUT_FOLDER} + ) # <-- Note the absence of a space character following the -o option! endif () # Find path to libusb library @@ -131,7 +131,7 @@ elseif (WIN32) # Windows endif () message(STATUS "Missing libusb library has been installed") endif () - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) else () # all other OS (unix-based) @@ -145,7 +145,7 @@ else () # all other OS (unix-based) LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS /usr /usr/local /opt ) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) + 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) From 9373f133935e967182518bbdfa9501d7ebbcc2d8 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 21 Apr 2020 15:47:56 +0200 Subject: [PATCH 152/236] Updated CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5cf843c9..9ad6b6497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Features: - STM32G0/G4 improvements (#910) - Enable mass erase with a flash programming check - Handle G4 Cat3 devices with configurable dual bank flash by using a helper +- Display programmer serial when no target is connected (#432, #933, #943) Updates & changes: @@ -42,6 +43,7 @@ Updates & changes: - Enhanced error log with file path for map_file() (#650, #879, #921) - Refactoring: Overall option code rework (#927) - Refactoring: Build settings / GUI-Build on UNIX-based systems if GTK3 is detected (#929) +- Reconfiguration of package build process (#931, #936, #940, commit 9b19f9225460472af9d98959b7217d0a840ee972) Fixes: @@ -61,6 +63,7 @@ Fixes: - st-flash: minor usage fix and make cmdline parsing more user friendly (#925) - Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 (#378, #922) - Restored functionality of make test builds (Regression) (#926, #929) +- Fixed compilation error due to uninitialized cpuid (#937, #938) v1.6.0 From 09ea99aea51f741ce9c8c0e2ad755d40b3d86021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20M=C3=A1rton?= Date: Mon, 24 Feb 2020 21:34:36 +0100 Subject: [PATCH 153/236] Add support for STLink V3 Flash programming is broken --- include/stlink.h | 68 ++++++- include/stlink/commands.h | 48 +++-- include/stlink/tools/flash.h | 2 +- include/stlink/usb.h | 14 +- src/common.c | 100 ++++++---- src/flash_loader.c | 4 +- src/gdbserver/gdb-server.c | 2 +- src/logging.c | 2 +- src/sg.c | 20 +- src/tools/flash.c | 10 +- src/usb.c | 368 ++++++++++++++++++++++++++++------- 11 files changed, 479 insertions(+), 159 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index d4170c7a7..f9de94fd4 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -24,10 +24,17 @@ extern "C" { //#define Q_BUF_LEN 96 #define Q_BUF_LEN (1024 * 100) - // STLINK_DEBUG_RESETSYS, etc: +// STLINK_DEBUG_RESETSYS, etc: +enum target_state { + TARGET_UNKNOWN = 0, + TARGET_RUNNING = 1, + TARGET_HALTED = 2, + TARGET_RESET = 3, + TARGET_DEBUG_RUNNING = 4, +}; + #define STLINK_CORE_RUNNING 0x80 #define STLINK_CORE_HALTED 0x81 -#define STLINK_CORE_STAT_UNKNOWN -1 #define STLINK_GET_VERSION 0xf1 #define STLINK_GET_CURRENT_MODE 0xf5 @@ -52,6 +59,11 @@ extern "C" { #define STLINK_DEBUG_APIV2_SWD_SET_FREQ 0x43 +#define STLINK_APIV3_SET_COM_FREQ 0x61 +#define STLINK_APIV3_GET_COM_FREQ 0x62 + +#define STLINK_APIV3_GET_VERSION_EX 0xFB + // Baud rate divisors for SWDCLK #define STLINK_SWDCLK_4MHZ_DIVISOR 0 #define STLINK_SWDCLK_1P8MHZ_DIVISOR 1 @@ -68,7 +80,45 @@ extern "C" { #define STLINK_SERIAL_MAX_SIZE 64 - /* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/ +#define STLINK_V3_MAX_FREQ_NB 10 + +/* Cortex Debug Control Block */ +#define DCB_DHCSR 0xE000EDF0 +#define DCB_DCRSR 0xE000EDF4 +#define DCB_DCRDR 0xE000EDF8 +#define DCB_DEMCR 0xE000EDFC + +/* DCB_DHCSR bit and field definitions */ +#define DBGKEY (0xA05F << 16) +#define C_DEBUGEN (1 << 0) +#define C_HALT (1 << 1) +#define C_STEP (1 << 2) +#define C_MASKINTS (1 << 3) +#define S_REGRDY (1 << 16) +#define S_HALT (1 << 17) +#define S_SLEEP (1 << 18) +#define S_LOCKUP (1 << 19) +#define S_RETIRE_ST (1 << 24) +#define S_RESET_ST (1 << 25) + + +/* + * Map the relevant features, quirks and workaround for specific firmware + * version of stlink + */ +#define STLINK_F_HAS_TRACE (1<<0) +#define STLINK_F_HAS_SWD_SET_FREQ (1<<1) +#define STLINK_F_HAS_JTAG_SET_FREQ (1<<2) +#define STLINK_F_HAS_MEM_16BIT (1<<3) +#define STLINK_F_HAS_GETLASTRWSTATUS2 (1<<4) +#define STLINK_F_HAS_DAP_REG (1<<5) +#define STLINK_F_QUIRK_JTAG_DP_READ (1<<6) +#define STLINK_F_HAS_AP_INIT (1<<7) +#define STLINK_F_HAS_DPBANKSEL (1<<8) +#define STLINK_F_HAS_RW8_512BYTES (1<<9) + + +/* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/ #define C_BUF_LEN 32 enum stlink_flash_type { @@ -111,12 +161,22 @@ typedef struct flash_loader { uint8_t revision; } cortex_m3_cpuid_t; + enum stlink_jtag_api_version { + STLINK_JTAG_API_V1 = 1, + STLINK_JTAG_API_V2, + STLINK_JTAG_API_V3, + }; + typedef struct stlink_version_ { uint32_t stlink_v; uint32_t jtag_v; uint32_t swim_v; uint32_t st_vid; uint32_t stlink_pid; + /** jtag api version supported */ + enum stlink_jtag_api_version jtag_api; + /** one bit for each feature supported. See macros STLINK_F_* */ + uint32_t flags; } stlink_version_t; enum transport_type { @@ -144,7 +204,7 @@ typedef struct flash_loader { int verbose; uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram - int core_stat; // set by stlink_status(), values STLINK_CORE_xxxxx + enum target_state core_stat; // set by stlink_status() char serial[STLINK_SERIAL_MAX_SIZE]; int serial_size; diff --git a/include/stlink/commands.h b/include/stlink/commands.h index 9ff5a8fb9..a6830ff26 100644 --- a/include/stlink/commands.h +++ b/include/stlink/commands.h @@ -2,25 +2,35 @@ #define STLINK_COMMANDS_H_ enum stlink_debug_commands { - STLINK_DEBUG_ENTER_JTAG = 0x00, - STLINK_DEBUG_GETSTATUS = 0x01, - STLINK_DEBUG_FORCEDEBUG = 0x02, - STLINK_DEBUG_RESETSYS = 0x03, - STLINK_DEBUG_READALLREGS = 0x04, - STLINK_DEBUG_READREG = 0x05, - STLINK_DEBUG_WRITEREG = 0x06, - STLINK_DEBUG_READMEM_32BIT = 0x07, - STLINK_DEBUG_WRITEMEM_32BIT = 0x08, - STLINK_DEBUG_RUNCORE = 0x09, - STLINK_DEBUG_STEPCORE = 0x0a, - STLINK_DEBUG_SETFP = 0x0b, - STLINK_DEBUG_WRITEMEM_8BIT = 0x0d, - STLINK_DEBUG_CLEARFP = 0x0e, - STLINK_DEBUG_WRITEDEBUGREG = 0x0f, - STLINK_DEBUG_ENTER = 0x20, - STLINK_DEBUG_EXIT = 0x21, - STLINK_DEBUG_READCOREID = 0x22, - STLINK_DEBUG_ENTER_SWD = 0xa3 + STLINK_DEBUG_ENTER_JTAG = 0x00, + STLINK_DEBUG_GETSTATUS = 0x01, + STLINK_DEBUG_FORCEDEBUG = 0x02, + STLINK_DEBUG_APIV1_RESETSYS = 0x03, + STLINK_DEBUG_APIV1_READALLREGS = 0x04, + STLINK_DEBUG_APIV1_READREG = 0x05, + STLINK_DEBUG_APIV1_WRITEREG = 0x06, + STLINK_DEBUG_READMEM_32BIT = 0x07, + STLINK_DEBUG_WRITEMEM_32BIT = 0x08, + STLINK_DEBUG_RUNCORE = 0x09, + STLINK_DEBUG_STEPCORE = 0x0a, + STLINK_DEBUG_APIV1_SETFP = 0x0b, + STLINK_DEBUG_WRITEMEM_8BIT = 0x0d, + STLINK_DEBUG_APIV1_CLEARFP = 0x0e, + STLINK_DEBUG_APIV1_WRITEDEBUGREG = 0x0f, + STLINK_DEBUG_APIV1_ENTER = 0x20, + STLINK_DEBUG_EXIT = 0x21, + STLINK_DEBUG_READCOREID = 0x22, + STLINK_DEBUG_APIV2_ENTER = 0x30, + STLINK_DEBUG_APIV2_READ_IDCODES = 0x31, + STLINK_DEBUG_APIV2_RESETSYS = 0x32, + STLINK_DEBUG_APIV2_READREG = 0x33, + STLINK_DEBUG_APIV2_WRITEREG = 0x34, + STLINK_DEBUG_APIV2_WRITEDEBUGREG = 0x35, + STLINK_DEBUG_APIV2_READDEBUGREG = 0x36, + STLINK_DEBUG_APIV2_READALLREGS = 0x3A, + STLINK_DEBUG_APIV2_GETLASTRWSTATUS = 0x3B, + STLINK_DEBUG_APIV2_GETLASTRWSTATUS2 = 0x3E, + STLINK_DEBUG_ENTER_SWD = 0xa3 }; #endif /* STLINK_COMMANDS_H_ */ diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index 8ca1eddf9..6851ede8b 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -5,7 +5,7 @@ #include #define DEBUG_LOG_LEVEL 100 -#define STND_LOG_LEVEL 50 +#define STND_LOG_LEVEL 100 enum flash_cmd {FLASH_CMD_NONE = 0, FLASH_CMD_WRITE = 1, FLASH_CMD_READ = 2, FLASH_CMD_ERASE = 3, CMD_RESET = 4}; enum flash_format {FLASH_FORMAT_BINARY = 0, FLASH_FORMAT_IHEX = 1}; diff --git a/include/stlink/usb.h b/include/stlink/usb.h index 621695ea4..a69101c1f 100644 --- a/include/stlink/usb.h +++ b/include/stlink/usb.h @@ -18,11 +18,15 @@ extern "C" { #endif -#define STLINK_USB_VID_ST 0x0483 -#define STLINK_USB_PID_STLINK 0x3744 -#define STLINK_USB_PID_STLINK_32L 0x3748 -#define STLINK_USB_PID_STLINK_32L_AUDIO 0x374a -#define STLINK_USB_PID_STLINK_NUCLEO 0x374b +#define STLINK_USB_VID_ST 0x0483 +#define STLINK_USB_PID_STLINK 0x3744 +#define STLINK_USB_PID_STLINK_32L 0x3748 +#define STLINK_USB_PID_STLINK_32L_AUDIO 0x374a +#define STLINK_USB_PID_STLINK_NUCLEO 0x374b +#define STLINK_USB_PID_STLINK_V3_USBLOADER 0x374d +#define STLINK_USB_PID_STLINK_V3E_PID 0x374e +#define STLINK_USB_PID_STLINK_V3S_PID 0x374f +#define STLINK_USB_PID_STLINK_V3_2VCP_PID 0x3753 #define STLINK_SG_SIZE 31 #define STLINK_CMD_SIZE 16 diff --git a/src/common.c b/src/common.c index 9a3098114..db0ab445e 100644 --- a/src/common.c +++ b/src/common.c @@ -892,23 +892,48 @@ int stlink_status(stlink_t *sl) { * @param sl stlink context, assumed to contain valid data in the buffer * @param slv output parsed version object */ -void _parse_version(stlink_t *sl, stlink_version_t *slv) { - uint32_t b0 = sl->q_buf[0]; //lsb - uint32_t b1 = sl->q_buf[1]; - uint32_t b2 = sl->q_buf[2]; - uint32_t b3 = sl->q_buf[3]; - uint32_t b4 = sl->q_buf[4]; - uint32_t b5 = sl->q_buf[5]; //msb - - // b0 b1 || b2 b3 | b4 b5 - // 4b | 6b | 6b || 2B | 2B - // stlink_v | jtag_v | swim_v || st_vid | stlink_pid - - slv->stlink_v = (b0 & 0xf0) >> 4; - slv->jtag_v = ((b0 & 0x0f) << 2) | ((b1 & 0xc0) >> 6); - slv->swim_v = b1 & 0x3f; - slv->st_vid = (b3 << 8) | b2; - slv->stlink_pid = (b5 << 8) | b4; +void _parse_version(stlink_t *sl, stlink_version_t *slv) +{ + sl->version.flags = 0; + if (sl->version.stlink_v < 3) { + uint32_t b0 = sl->q_buf[0]; //lsb + uint32_t b1 = sl->q_buf[1]; + uint32_t b2 = sl->q_buf[2]; + uint32_t b3 = sl->q_buf[3]; + uint32_t b4 = sl->q_buf[4]; + uint32_t b5 = sl->q_buf[5]; //msb + + // b0 b1 || b2 b3 | b4 b5 + // 4b | 6b | 6b || 2B | 2B + // stlink_v | jtag_v | swim_v || st_vid | stlink_pid + + slv->stlink_v = (b0 & 0xf0) >> 4; + slv->jtag_v = ((b0 & 0x0f) << 2) | ((b1 & 0xc0) >> 6); + slv->swim_v = b1 & 0x3f; + slv->st_vid = (b3 << 8) | b2; + slv->stlink_pid = (b5 << 8) | b4; + /* ST-LINK/V1 from J11 switch to api-v2 (and support SWD) */ + if (slv->stlink_v == 1) + slv->jtag_api = slv->jtag_v > 11? STLINK_JTAG_API_V2 : STLINK_JTAG_API_V1; + else { + slv->jtag_api = STLINK_JTAG_API_V2; + /* preferred API to get last R/W status from J15 */ + if (sl->version.jtag_v >= 15) + sl->version.flags |= STLINK_F_HAS_GETLASTRWSTATUS2; + } + } else { + // V3 uses different version format, for reference see OpenOCD source + // (that was written from docs available from ST under NDA): + // https://github.com/ntfreak/openocd/blob/a6dacdff58ef36fcdac00c53ec27f19de1fbce0d/src/jtag/drivers/stlink_usb.c#L965 + slv->stlink_v = sl->q_buf[0]; + slv->swim_v = sl->q_buf[1]; + slv->jtag_v = sl->q_buf[2]; + slv->st_vid = (uint32_t)((sl->q_buf[9] << 8) | sl->q_buf[8]); + slv->stlink_pid = (uint32_t)((sl->q_buf[11] << 8) | sl->q_buf[10]); + slv->jtag_api = STLINK_JTAG_API_V3; + /* preferred API to get last R/W status */ + sl->version.flags |= STLINK_F_HAS_GETLASTRWSTATUS2; + } return; } @@ -1065,13 +1090,8 @@ int stlink_write_unsupported_reg(stlink_t *sl, uint32_t val, int r_idx, struct s bool stlink_is_core_halted(stlink_t *sl) { - bool ret = false; - - stlink_status(sl); - if (sl->q_buf[0] == STLINK_CORE_HALTED) - ret = true; - - return ret; + stlink_status(sl); + return sl->core_stat == TARGET_HALTED; } int stlink_step(stlink_t *sl) { @@ -1140,21 +1160,21 @@ void stlink_run_at(stlink_t *sl, stm32_addr_t addr) { // this function is called by stlink_status() // do not call stlink_core_stat() directly, always use stlink_status() void stlink_core_stat(stlink_t *sl) { - if (sl->q_len <= 0) - return; - - switch (sl->q_buf[0]) { - case STLINK_CORE_RUNNING: - sl->core_stat = STLINK_CORE_RUNNING; + switch (sl->core_stat ) { + case TARGET_RUNNING: DLOG(" core status: running\n"); return; - case STLINK_CORE_HALTED: - sl->core_stat = STLINK_CORE_HALTED; + case TARGET_HALTED: DLOG(" core status: halted\n"); return; + case TARGET_RESET: + DLOG(" core status: reset\n"); + return; + case TARGET_DEBUG_RUNNING: + DLOG(" core status: debug running\n"); + return; default: - sl->core_stat = STLINK_CORE_STAT_UNKNOWN; - fprintf(stderr, " core status: unknown\n"); + DLOG(" core status: unknown\n"); } } @@ -1162,7 +1182,7 @@ void stlink_print_data(stlink_t * sl) { if (sl->q_len <= 0 || sl->verbose < UDEBUG) return; if (sl->verbose > 2) - fprintf(stdout, "data_len = %d 0x%x\n", sl->q_len, sl->q_len); + DLOG("data_len = %d 0x%x\n", sl->q_len, sl->q_len); for (int i = 0; i < sl->q_len; i++) { if (i % 16 == 0) { @@ -1173,9 +1193,9 @@ void stlink_print_data(stlink_t * sl) { fprintf(stdout, "\n-> 0x%08x ", sl->q_addr + i); */ } - fprintf(stdout, " %02x", (unsigned int) sl->q_buf[i]); + DLOG(" %02x", (unsigned int) sl->q_buf[i]); } - fputs("\n\n", stdout); + DLOG("\n\n"); } /* memory mapped file */ @@ -2059,17 +2079,15 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t /* erase each page */ int page_count = 0; for (off = 0; off < len; off += stlink_calculate_pagesize(sl, addr + (uint32_t) off)) { - /* addr must be an addr inside the page */ + // addr must be an addr inside the page if (stlink_erase_flash_page(sl, addr + (uint32_t) off) == -1) { ELOG("Failed to erase_flash_page(%#zx) == -1\n", addr + off); return -1; } - fprintf(stdout,"\rFlash page at addr: 0x%08lx erased", + ILOG("Flash page at addr: 0x%08lx erased\n", (unsigned long)(addr + off)); - fflush(stdout); page_count++; } - fprintf(stdout,"\n"); ILOG("Finished erasing %d pages of %d (%#x) bytes\n", page_count, sl->flash_pgsz, sl->flash_pgsz); diff --git a/src/flash_loader.c b/src/flash_loader.c index 73db427a7..eaf81019e 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -321,7 +321,9 @@ int stlink_flash_loader_write_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* } memcpy(sl->q_buf, loader_code, loader_size); - stlink_write_mem32(sl, sl->sram_base, loader_size); + int ret = stlink_write_mem32(sl, sl->sram_base, loader_size); + if (ret) + return ret; *addr = sl->sram_base; *size = loader_size; diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index bdfeb703d..2dfbc7454 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -1384,7 +1384,7 @@ int serve(stlink_t *sl, st_state_t *st) { } stlink_status(sl); - if(sl->core_stat == STLINK_CORE_HALTED) { + if(sl->core_stat == TARGET_HALTED) { struct stlink_reg reg; int ret; stm32_addr_t pc; diff --git a/src/logging.c b/src/logging.c index d4fb96b2e..d2ca11f2a 100644 --- a/src/logging.c +++ b/src/logging.c @@ -11,7 +11,7 @@ #include "stlink/logging.h" -static int max_level = UINFO; +static int max_level = UDEBUG; int ugly_init(int maximum_threshold) { max_level = maximum_threshold; diff --git a/src/sg.c b/src/sg.c index e7ff5d14e..4e8349bc2 100644 --- a/src/sg.c +++ b/src/sg.c @@ -435,7 +435,7 @@ int _stlink_sg_current_mode(stlink_t *stl) { int _stlink_sg_enter_swd_mode(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_ENTER; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_ENTER; sg->cdb_cmd_blk[2] = STLINK_DEBUG_ENTER_SWD; sl->q_len = 0; // >0 -> aboard return stlink_q(sl); @@ -448,7 +448,7 @@ int _stlink_sg_enter_jtag_mode(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; DLOG("\n*** stlink_enter_jtag_mode ***\n"); clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_ENTER; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_ENTER; sg->cdb_cmd_blk[2] = STLINK_DEBUG_ENTER_JTAG; sl->q_len = 0; return stlink_q(sl); @@ -529,7 +529,7 @@ int _stlink_sg_core_id(stlink_t *sl) { int _stlink_sg_reset(stlink_t *sl) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_RESETSYS; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_RESETSYS; sl->q_len = 2; sg->q_addr = 0; if (stlink_q(sl)) @@ -593,7 +593,7 @@ int _stlink_sg_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_READALLREGS; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_READALLREGS; sl->q_len = 84; sg->q_addr = 0; if (stlink_q(sl)) @@ -634,7 +634,7 @@ int _stlink_sg_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { int _stlink_sg_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_READREG; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_READREG; sg->cdb_cmd_blk[2] = r_idx; sl->q_len = 4; sg->q_addr = 0; @@ -679,7 +679,7 @@ int _stlink_sg_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp) { int _stlink_sg_write_reg(stlink_t *sl, uint32_t reg, int idx) { struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_WRITEREG; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_WRITEREG; // 2: reg index // 3-6: reg content sg->cdb_cmd_blk[2] = idx; @@ -701,7 +701,7 @@ void stlink_write_dreg(stlink_t *sl, uint32_t reg, uint32_t addr) { struct stlink_libsg *sg = sl->backend_data; DLOG("\n*** stlink_write_dreg ***\n"); clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_WRITEDEBUGREG; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_WRITEDEBUGREG; // 2-5: address of reg of the debug module // 6-9: reg content write_uint32(sg->cdb_cmd_blk + 2, addr); @@ -750,7 +750,7 @@ void stlink_set_hw_bp(stlink_t *sl, int fp_nr, uint32_t addr, int fp) { DLOG("\n*** stlink_set_hw_bp ***\n"); struct stlink_libsg *sg = sl->backend_data; clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_SETFP; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_SETFP; // 2:The number of the flash patch used to set the breakpoint // 3-6: Address of the breakpoint (LSB) // 7: FP_ALL (0x02) / FP_UPPER (0x01) / FP_LOWER (0x00) @@ -770,7 +770,7 @@ void stlink_clr_hw_bp(stlink_t *sl, int fp_nr) { struct stlink_libsg *sg = sl->backend_data; DLOG("\n*** stlink_clr_hw_bp ***\n"); clear_cdb(sg); - sg->cdb_cmd_blk[1] = STLINK_DEBUG_CLEARFP; + sg->cdb_cmd_blk[1] = STLINK_DEBUG_APIV1_CLEARFP; sg->cdb_cmd_blk[2] = fp_nr; sl->q_len = 2; @@ -1045,7 +1045,7 @@ static stlink_t* stlink_open(const int verbose) { sl->backend_data = slsg; sl->backend = &_stlink_sg_backend; - sl->core_stat = STLINK_CORE_STAT_UNKNOWN; + sl->core_stat = TARGET_UNKNOWN; slsg->q_addr = 0; return sl; diff --git a/src/tools/flash.c b/src/tools/flash.c index f5fd1a386..a8d937930 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -29,11 +29,11 @@ static void cleanup(int signum) { static void usage(void) { - puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--format ] [--flash=] {read|write} /dev/sgX "); - puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); - puts("stlinkv2 command line: ./st-flash [--debug] [--reset] [--serial ] [--format ] [--flash=] {read|write} "); - puts("stlinkv2 command line: ./st-flash [--debug] [--serial ] erase"); - puts("stlinkv2 command line: ./st-flash [--debug] [--serial ] reset"); + puts("stlinkv1 command line: ./st-flash [--debug] [--reset] [--format ] [--flash=] {read|write} /dev/sgX "); + puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase"); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--reset] [--serial ] [--format ] [--flash=] {read|write} "); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] erase"); + puts("stlinkv2/3 command line: ./st-flash [--debug] [--serial ] reset"); puts(" Use hex format for addr, and ."); puts(" fsize: Use decimal, octal or hex by prefix 0xXXX for hex, optionally followed by k=KB, or m=MB (eg. --flash=128k)"); puts(" Format may be 'binary' (default) or 'ihex', although must be specified for binary format only."); diff --git a/src/usb.c b/src/usb.c index 7f5c21283..12945d6d2 100644 --- a/src/usb.c +++ b/src/usb.c @@ -22,6 +22,53 @@ enum SCSI_Generic_Direction {SG_DXFER_TO_DEV=0, SG_DXFER_FROM_DEV=0x80}; +static inline uint32_t le_to_h_u32(const uint8_t* buf) +{ + return (uint32_t)((uint32_t)buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24); +} + +static int _stlink_match_speed_map(const uint32_t *map, unsigned int map_size, uint32_t khz) +{ + unsigned int i; + int speed_index = -1; + int speed_diff = INT_MAX; + int last_valid_speed = -1; + bool match = true; + + for (i = 0; i < map_size; i++) { + if (!map[i]) + continue; + last_valid_speed = i; + if (khz == map[i]) { + speed_index = i; + break; + } else { + int current_diff = khz - map[i]; + /* get abs value for comparison */ + current_diff = (current_diff > 0) ? current_diff : -current_diff; + if ((current_diff < speed_diff) && khz >= map[i]) { + speed_diff = current_diff; + speed_index = i; + } + } + } + + if (speed_index == -1) { + /* this will only be here if we cannot match the slow speed. + * use the slowest speed we support.*/ + speed_index = last_valid_speed; + match = false; + } else if (i == map_size) + match = false; + + if (!match) { + ILOG("Unable to match requested speed %d kHz, using %d kHz\n", \ + khz, map[speed_index]); + } + + return speed_index; +} + void _stlink_usb_close(stlink_t* sl) { if (!sl) return; @@ -39,34 +86,34 @@ void _stlink_usb_close(stlink_t* sl) { } ssize_t send_recv(struct stlink_libusb* handle, int terminate, - unsigned char* txbuf, size_t txsize, - unsigned char* rxbuf, size_t rxsize) { + unsigned char* txbuf, size_t txsize, + unsigned char* rxbuf, size_t rxsize) { /* note: txbuf and rxbuf can point to the same area */ int res = 0; int t; t = libusb_bulk_transfer(handle->usb_handle, handle->ep_req, - txbuf, - (int) txsize, - &res, - 3000); + txbuf, + (int) txsize, + &res, + 3000); if (t) { printf("[!] send_recv send request failed: %s\n", libusb_error_name(t)); 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) { t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, - rxbuf, - (int) rxsize, - &res, - 3000); + rxbuf, + (int) rxsize, + &res, + 3000); if (t) { printf("[!] send_recv read reply failed: %s\n", - libusb_error_name(t)); + libusb_error_name(t)); return -1; } } @@ -75,13 +122,13 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate, /* Read the SG reply */ unsigned char sg_buf[13]; t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, - sg_buf, - 13, - &res, - 3000); + sg_buf, + 13, + &res, + 3000); if (t) { printf("[!] send_recv read storage failed: %s\n", - libusb_error_name(t)); + libusb_error_name(t)); return -1; } /* The STLink doesn't seem to evaluate the sequence number */ @@ -135,6 +182,19 @@ int _stlink_usb_version(stlink_t *sl) { return (int) size; } + /* STLINK-V3 requires a specific command */ + if (sl->version.stlink_v == 3) { + rep_len = 12; + i = fill_command(sl, SG_DXFER_FROM_DEV, 16); + cmd[i++] = STLINK_APIV3_GET_VERSION_EX; + + size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); + if (size != rep_len) { + printf("[!] send_recv STLINK_APIV3_GET_VERSION_EX\n"); + return (int) size; + } + } + return 0; } @@ -207,6 +267,30 @@ int _stlink_usb_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data) { return 0; } +int _stlink_usb_get_rw_status(stlink_t *sl) +{ + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + return -1; + + unsigned char* const rdata = sl->q_buf; + struct stlink_libusb * const slu = sl->backend_data; + unsigned char* const cmd = sl->c_buf; + int i, ret = 0; + + i = fill_command(sl, SG_DXFER_FROM_DEV, 12); + cmd[i++] = STLINK_DEBUG_COMMAND; + if (sl->version.flags & STLINK_F_HAS_GETLASTRWSTATUS2) { + cmd[i++] = STLINK_DEBUG_APIV2_GETLASTRWSTATUS2; + ret = send_recv(slu, 1, cmd, slu->cmd_len, rdata, 12); + } else { + cmd[i++] = STLINK_DEBUG_APIV2_GETLASTRWSTATUS; + ret = send_recv(slu, 1, cmd, slu->cmd_len, rdata, 2); + } + if (ret < 0) + return -1; + return 0; +} + int _stlink_usb_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { struct stlink_libusb * const slu = sl->backend_data; unsigned char* const data = sl->q_buf; @@ -221,12 +305,11 @@ int _stlink_usb_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { ret = send_only(slu, 0, cmd, slu->cmd_len); if (ret == -1) return ret; - - ret = send_only(slu, 1, data, len); + ret = send_only(slu, 0, data, len); if (ret == -1) return ret; - return 0; + return _stlink_usb_get_rw_status(sl); } int _stlink_usb_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len) { @@ -274,11 +357,14 @@ int _stlink_usb_core_id(stlink_t * sl) { unsigned char* const cmd = sl->c_buf; unsigned char* const data = sl->q_buf; ssize_t size; - int rep_len = 4; + int rep_len = sl->version.jtag_api == STLINK_JTAG_API_V1 ? 4 : 12; int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - cmd[i++] = STLINK_DEBUG_READCOREID; + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + cmd[i++] = STLINK_DEBUG_READCOREID; + else + cmd[i++] = STLINK_DEBUG_APIV2_READ_IDCODES; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { @@ -286,11 +372,39 @@ int _stlink_usb_core_id(stlink_t * sl) { return -1; } - sl->core_id = read_uint32(data, 0); + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + sl->core_id = read_uint32(data, 0); + else + sl->core_id = read_uint32(data, 4); return 0; } +int _stlink_usb_status_v2(stlink_t *sl) +{ + int result; + uint32_t status; + + result = _stlink_usb_read_debug32(sl, DCB_DHCSR, &status); + DLOG("core status: %08X\n", status); + if (result != 0) { + sl->core_stat = TARGET_UNKNOWN; + } else { + if (status & S_HALT) { + sl->core_stat = TARGET_HALTED; + } else if (status & S_RESET_ST) { + sl->core_stat = TARGET_RESET; + } else { + sl->core_stat = TARGET_RUNNING; + } + } + + return result; +} int _stlink_usb_status(stlink_t * sl) { + if (sl->version.jtag_api != STLINK_JTAG_API_V1) { + return _stlink_usb_status_v2(sl); + } + struct stlink_libusb * const slu = sl->backend_data; unsigned char* const data = sl->q_buf; unsigned char* const cmd = sl->c_buf; @@ -307,6 +421,14 @@ int _stlink_usb_status(stlink_t * sl) { return (int) size; } sl->q_len = (int) size; + if (sl->q_len > 1) { + if (sl->q_buf[0] == STLINK_CORE_RUNNING) + sl->core_stat = TARGET_RUNNING; + else if (sl->q_buf[0] == STLINK_CORE_HALTED) + sl->core_stat = TARGET_HALTED; + else + sl->core_stat = TARGET_UNKNOWN; + } return 0; } @@ -334,14 +456,19 @@ int _stlink_usb_enter_swd_mode(stlink_t * sl) { struct stlink_libusb * const slu = sl->backend_data; unsigned char* const cmd = sl->c_buf; ssize_t size; - const int rep_len = 0; + unsigned char* const data = sl->q_buf; + const uint32_t rep_len = sl->version.stlink_v > 1 ? 2 : 0; int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - cmd[i++] = STLINK_DEBUG_ENTER; + cmd[i++] = sl->version.jtag_api == STLINK_JTAG_API_V1 ? STLINK_DEBUG_APIV1_ENTER : STLINK_DEBUG_APIV2_ENTER; cmd[i++] = STLINK_DEBUG_ENTER_SWD; - size = send_only(slu, 1, cmd, slu->cmd_len); + if (rep_len == 0) { + size = send_only(slu, 1, cmd, slu->cmd_len); + } else { + size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); + } if (size == -1) { printf("[!] send_recv STLINK_DEBUG_ENTER\n"); return (int) size; @@ -378,7 +505,10 @@ int _stlink_usb_reset(stlink_t * sl) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - cmd[i++] = STLINK_DEBUG_RESETSYS; + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + cmd[i++] = STLINK_DEBUG_APIV1_RESETSYS; + else + cmd[i++] = STLINK_DEBUG_APIV2_RESETSYS; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { @@ -388,7 +518,7 @@ int _stlink_usb_reset(stlink_t * sl) { // Reset through AIRCR so NRST does not need to be connected return stlink_write_debug32(sl, STLINK_REG_AIRCR, - STLINK_REG_AIRCR_VECTKEY | STLINK_REG_AIRCR_SYSRESETREQ); + STLINK_REG_AIRCR_VECTKEY | STLINK_REG_AIRCR_SYSRESETREQ); } @@ -440,6 +570,14 @@ int _stlink_usb_step(stlink_t* sl) { */ int _stlink_usb_run(stlink_t* sl) { struct stlink_libusb * const slu = sl->backend_data; + + int res; + if (sl->version.jtag_api != STLINK_JTAG_API_V1) { + res = _stlink_usb_write_debug32(sl, DCB_DHCSR, DBGKEY|C_DEBUGEN); + return res; + } + + unsigned char* const data = sl->q_buf; unsigned char* const cmd = sl->c_buf; ssize_t size; @@ -466,9 +604,8 @@ int _stlink_usb_set_swdclk(stlink_t* sl, uint16_t clk_divisor) { ssize_t size; int rep_len = 2; int i; - // clock speed only supported by stlink/v2 and for firmware >= 22 - if (sl->version.stlink_v >= 2 && sl->version.jtag_v >= 22) { + if (sl->version.stlink_v == 2 && sl->version.jtag_v >= 22) { i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; @@ -483,9 +620,55 @@ int _stlink_usb_set_swdclk(stlink_t* sl, uint16_t clk_divisor) { } return 0; - } else { - return -1; + } else if (sl->version.stlink_v == 3) { + int speed_index; + uint32_t map[STLINK_V3_MAX_FREQ_NB]; + i = fill_command(sl, SG_DXFER_FROM_DEV, 16); + + cmd[i++] = STLINK_DEBUG_COMMAND; + cmd[i++] = STLINK_APIV3_GET_COM_FREQ; + cmd[i++] = 0; // SWD mode + + size = send_recv(slu, 1, cmd, slu->cmd_len, data, 52); + if (size == -1) { + printf("[!] send_recv STLINK_APIV3_GET_COM_FREQ\n"); + return (int) size; + } + + int speeds_size = data[8]; + + if (speeds_size > STLINK_V3_MAX_FREQ_NB) + speeds_size = STLINK_V3_MAX_FREQ_NB; + + for (i = 0; i < speeds_size; i++) + map[i] = le_to_h_u32(&data[12 + 4 * i]); + + /* set to zero all the next entries */ + for (i = speeds_size; i < STLINK_V3_MAX_FREQ_NB; i++) + map[i] = 0; + + speed_index = _stlink_match_speed_map(map, STLINK_ARRAY_SIZE(map), 1800); + + i = fill_command(sl, SG_DXFER_FROM_DEV, 16); + + cmd[i++] = STLINK_DEBUG_COMMAND; + cmd[i++] = STLINK_APIV3_SET_COM_FREQ; + cmd[i++] = 0; // SWD mode + cmd[i++] = 0; + cmd[i++] = (uint8_t)((map[speed_index] >> 0) & 0xFF); + cmd[i++] = (uint8_t)((map[speed_index] >> 8) & 0xFF); + cmd[i++] = (uint8_t)((map[speed_index] >> 16) & 0xFF); + cmd[i++] = (uint8_t)((map[speed_index] >> 24) & 0xFF); + + size = send_recv(slu, 1, cmd, slu->cmd_len, data, 8); + if (size == -1) { + printf("[!] send_recv STLINK_APIV3_SET_COM_FREQ\n"); + return (int) size; + } + + return 0; } + return -1; } int _stlink_usb_exit_debug_mode(stlink_t *sl) { @@ -535,33 +718,40 @@ int _stlink_usb_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { unsigned char* const cmd = sl->c_buf; unsigned char* const data = sl->q_buf; ssize_t size; - uint32_t rep_len = 84; + uint32_t rep_len = sl->version.jtag_api == STLINK_JTAG_API_V1 ? 84 : 88; int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - cmd[i++] = STLINK_DEBUG_READALLREGS; + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + cmd[i++] = STLINK_DEBUG_APIV1_READALLREGS; + else + cmd[i++] = STLINK_DEBUG_APIV2_READALLREGS; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_DEBUG_READALLREGS\n"); return (int) size; } + + /* V1: regs data from offset 0 */ + /* V2: status at offset 0, regs data from offset 4 */ + int reg_offset = sl->version.jtag_api == STLINK_JTAG_API_V1 ? 0 : 4; sl->q_len = (int) size; stlink_print_data(sl); - for(i=0; i<16; i++) + for(i=reg_offset; i<16; i++) regp->r[i]= read_uint32(sl->q_buf, i*4); - regp->xpsr = read_uint32(sl->q_buf, 64); - regp->main_sp = read_uint32(sl->q_buf, 68); - regp->process_sp = read_uint32(sl->q_buf, 72); - regp->rw = read_uint32(sl->q_buf, 76); - regp->rw2 = read_uint32(sl->q_buf, 80); + regp->xpsr = read_uint32(sl->q_buf, reg_offset + 64); + regp->main_sp = read_uint32(sl->q_buf, reg_offset + 68); + regp->process_sp = read_uint32(sl->q_buf, reg_offset + 72); + regp->rw = read_uint32(sl->q_buf, reg_offset + 76); + regp->rw2 = read_uint32(sl->q_buf, reg_offset + 80); if (sl->verbose < 2) return 0; - DLOG("xpsr = 0x%08x\n", read_uint32(sl->q_buf, 64)); - DLOG("main_sp = 0x%08x\n", read_uint32(sl->q_buf, 68)); - DLOG("process_sp = 0x%08x\n", read_uint32(sl->q_buf, 72)); - DLOG("rw = 0x%08x\n", read_uint32(sl->q_buf, 76)); - DLOG("rw2 = 0x%08x\n", read_uint32(sl->q_buf, 80)); + DLOG("xpsr = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 64)); + DLOG("main_sp = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 68)); + DLOG("process_sp = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 72)); + DLOG("rw = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 76)); + DLOG("rw2 = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 80)); return 0; } @@ -572,11 +762,15 @@ int _stlink_usb_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp) { unsigned char* const cmd = sl->c_buf; ssize_t size; uint32_t r; - uint32_t rep_len = 4; + uint32_t rep_len = sl->version.jtag_api == STLINK_JTAG_API_V1 ? 4 : 8; + int reg_offset = sl->version.jtag_api == STLINK_JTAG_API_V1 ? 0 : 4; int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - cmd[i++] = STLINK_DEBUG_READREG; + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + cmd[i++] = STLINK_DEBUG_APIV1_READREG; + else + cmd[i++] = STLINK_DEBUG_APIV2_READREG; cmd[i++] = (uint8_t) r_idx; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { @@ -585,7 +779,7 @@ int _stlink_usb_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp) { } sl->q_len = (int) size; stlink_print_data(sl); - r = read_uint32(sl->q_buf, 0); + r = read_uint32(sl->q_buf, reg_offset); DLOG("r_idx (%2d) = 0x%08x\n", r_idx, r); switch (r_idx) { @@ -723,7 +917,10 @@ int _stlink_usb_write_reg(stlink_t *sl, uint32_t reg, int idx) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - cmd[i++] = STLINK_DEBUG_WRITEREG; + if (sl->version.jtag_api == STLINK_JTAG_API_V1) + cmd[i++] = STLINK_DEBUG_APIV1_WRITEREG; + else + cmd[i++] = STLINK_DEBUG_APIV2_WRITEREG; cmd[i++] = idx; write_uint32(&cmd[i], reg); size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); @@ -731,7 +928,7 @@ int _stlink_usb_write_reg(stlink_t *sl, uint32_t reg, int idx) { printf("[!] send_recv STLINK_DEBUG_WRITEREG\n"); return (int) size; } -sl->q_len = (int) size; + sl->q_len = (int) size; stlink_print_data(sl); return 0; @@ -785,7 +982,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST sl->backend = &_stlink_usb_backend; sl->backend_data = slu; - sl->core_stat = STLINK_CORE_STAT_UNKNOWN; + sl->core_stat = TARGET_UNKNOWN; if (libusb_init(&(slu->libusb_ctx))) { WLOG("failed to init libusb context, wrong version of libraries?\n"); goto on_error; @@ -822,36 +1019,54 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST if (devBus && devAddr) { if ((libusb_get_bus_number(list[cnt]) != devBus) - || (libusb_get_device_address(list[cnt]) != devAddr)) { + || (libusb_get_device_address(list[cnt]) != devAddr)) { continue; } } - if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO)) { + if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) + || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) + || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3_2VCP_PID)) { struct libusb_device_handle *handle; ret = libusb_open(list[cnt], &handle); if (ret) - continue; + continue; sl->serial_size = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)sl->serial, sizeof(sl->serial)); libusb_close(handle); + if ((desc.idProduct == STLINK_USB_PID_STLINK_32L) + || (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO) + || (desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO)) { + sl->version.stlink_v = 2; + } else if ((desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID) + || (desc.idProduct == STLINK_USB_PID_STLINK_V3_2VCP_PID)) { + sl->version.stlink_v = 3; + } + if ((serial == NULL) || (*serial == 0)) - break; + break; if (sl->serial_size < 0) - continue; + continue; if (memcmp(serial, &sl->serial, sl->serial_size) == 0) - break; + break; continue; } if (desc.idProduct == STLINK_USB_PID_STLINK) { slu->protocoll = 1; + sl->version.stlink_v = 1; break; } } @@ -901,7 +1116,12 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST // TODO - could use the scanning techniq from stm8 code here... slu->ep_rep = 1 /* ep rep */ | LIBUSB_ENDPOINT_IN; - if (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO || desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO) { + if (desc.idProduct == STLINK_USB_PID_STLINK_NUCLEO + || desc.idProduct == STLINK_USB_PID_STLINK_32L_AUDIO + || desc.idProduct == STLINK_USB_PID_STLINK_V3_USBLOADER + || desc.idProduct == STLINK_USB_PID_STLINK_V3E_PID + || desc.idProduct == STLINK_USB_PID_STLINK_V3S_PID + || desc.idProduct == STLINK_USB_PID_STLINK_V3_2VCP_PID) { slu->ep_req = 1 /* ep req */ | LIBUSB_ENDPOINT_OUT; } else { slu->ep_req = 2 /* ep req */ | LIBUSB_ENDPOINT_OUT; @@ -911,21 +1131,23 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST // TODO - never used at the moment, always CMD_SIZE slu->cmd_len = (slu->protocoll == 1)? STLINK_SG_SIZE: STLINK_CMD_SIZE; + // Initialize stlink version (sl->version) + stlink_version(sl); + if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE) { ILOG("-- exit_dfu_mode\n"); stlink_exit_dfu_mode(sl); } + // set the speed before entering the mode + // as the chip discovery phase should be done at this speed too + // Set the stlink clock speed (default is 1800kHz) + stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); + if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) { stlink_enter_swd_mode(sl); } - - // Initialize stlink version (sl->version) - stlink_version(sl); - // Set the stlink clock speed (default is 1800kHz) - stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); - if (reset) { if( sl->version.stlink_v > 1 ) stlink_jtag_reset(sl, 2); stlink_reset(sl); @@ -972,9 +1194,13 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { break; } - if (desc.idProduct != STLINK_USB_PID_STLINK_32L && - desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO && - desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO) + if (desc.idProduct != STLINK_USB_PID_STLINK_32L + && desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO + && desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO + && desc.idProduct != STLINK_USB_PID_STLINK_V3_USBLOADER + && desc.idProduct != STLINK_USB_PID_STLINK_V3E_PID + && desc.idProduct != STLINK_USB_PID_STLINK_V3S_PID + && desc.idProduct != STLINK_USB_PID_STLINK_V3_2VCP_PID) continue; slcnt++; @@ -997,9 +1223,9 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { break; } - if (desc.idProduct != STLINK_USB_PID_STLINK_32L && - desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO && - desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO) + if (desc.idProduct != STLINK_USB_PID_STLINK_32L && + desc.idProduct != STLINK_USB_PID_STLINK_32L_AUDIO && + desc.idProduct != STLINK_USB_PID_STLINK_NUCLEO) continue; struct libusb_device_handle* handle; @@ -1014,7 +1240,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)&serial, sizeof(serial)); if (ret < 0) - *serial = 0; + *serial = 0; libusb_close(handle); From 1752c123b4633521e0c04baa4c60ea59c61228a5 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Wed, 22 Apr 2020 14:54:42 +0800 Subject: [PATCH 154/236] Fix issue 663 with enhanced error output --- src/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.c b/src/common.c index 0dc6bc967..50f87f42c 100644 --- a/src/common.c +++ b/src/common.c @@ -949,7 +949,7 @@ int stlink_load_device_params(stlink_t *sl) { sl->sram_size, sl->sram_size / 1024, sl->flash_size, sl->flash_size / 1024, (unsigned int)sl->flash_pgsz); #else - ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n", + ILOG("%s: %zd KiB SRAM, %zd KiB flash in at least %zd %s pages.\n", params->description, sl->sram_size / 1024, sl->flash_size / 1024, (sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024, (sl->flash_pgsz < 1024)? "byte" : "KiB"); @@ -2223,7 +2223,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t WLOG("unaligned len 0x%x -- padding with zero\n", len); len += 1; } else if (addr & (sl->flash_pgsz - 1)) { - ELOG("addr not a multiple of pagesize, not supported\n"); + ELOG("addr not a multiple of current pagesize (%zd bytes), not supported\n", sl->flash_pgsz); return -1; } From 4a2881413af584bc53a19789c4e317d0ec2be9a2 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 17 Apr 2020 11:20:29 +0200 Subject: [PATCH 155/236] common: add some flash option lock/unlock helpers --- src/common.c | 180 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 174 insertions(+), 6 deletions(-) diff --git a/src/common.c b/src/common.c index afeb6106a..2f226f016 100644 --- a/src/common.c +++ b/src/common.c @@ -1,5 +1,4 @@ #define DEBUG_FLASH 0 - #include #include #include @@ -35,6 +34,7 @@ #define FLASH_ACR (FLASH_REGS_ADDR + 0x00) #define FLASH_KEYR (FLASH_REGS_ADDR + 0x04) +#define FLASH_OPTKEYR (FLASH_REGS_ADDR + 0x08) #define FLASH_SR (FLASH_REGS_ADDR + 0x0c) #define FLASH_CR (FLASH_REGS_ADDR + 0x10) #define FLASH_AR (FLASH_REGS_ADDR + 0x14) @@ -56,6 +56,12 @@ #define FLASH_OPTKEY1 0x08192A3B #define FLASH_OPTKEY2 0x4C5D6E7F +#define FLASH_F0_OPTKEY1 0x45670123 +#define FLASH_F0_OPTKEY2 0xCDEF89AB + +#define FLASH_L0_OPTKEY1 0xFBEAD9C8 +#define FLASH_L0_OPTKEY2 0x24252627 + #define FLASH_SR_BSY 0 #define FLASH_SR_EOP 5 @@ -64,6 +70,7 @@ #define FLASH_CR_MER 2 #define FLASH_CR_STRT 6 #define FLASH_CR_LOCK 7 +#define FLASH_CR_OPTWRE 9 //32L = 32F1 same CoreID as 32F4! @@ -167,6 +174,7 @@ // WB Flash control register. #define STM32WB_FLASH_CR_STRT (16) /* FLASH_CR Start */ +#define STM32WB_FLASH_CR_OPTLOCK (30) /* FLASH_CR Option Lock */ #define STM32WB_FLASH_CR_LOCK (31) /* FLASH_CR Lock */ // WB Flash status register. #define STM32WB_FLASH_SR_BSY (16) /* FLASH_SR Busy */ @@ -230,8 +238,9 @@ #define FLASH_F4_OPT_KEYR (FLASH_F4_REGS_ADDR + 0x08) #define FLASH_F4_SR (FLASH_F4_REGS_ADDR + 0x0c) #define FLASH_F4_CR (FLASH_F4_REGS_ADDR + 0x10) -#define FLASH_F4_OPT_CR (FLASH_F4_REGS_ADDR + 0x14) -#define FLASH_F4_OPT_LOCK_BIT (1u << 0) +#define FLASH_F4_OPTCR (FLASH_F4_REGS_ADDR + 0x14) +#define FLASH_F4_OPTCR_LOCK 0 +#define FLASH_F4_OPTCR_START 1 #define FLASH_F4_CR_STRT 16 #define FLASH_F4_CR_LOCK 31 #define FLASH_F4_CR_SER 1 @@ -301,6 +310,19 @@ uint32_t read_uint32(const unsigned char *c, const int pt) { return ui; } +static uint32_t get_stm32l0_flash_base(stlink_t *sl) +{ + switch (sl->chip_id) { + case STLINK_CHIPID_STM32_L1_CAT2: + case STLINK_CHIPID_STM32_L1_MEDIUM: + case STLINK_CHIPID_STM32_L1_MEDIUM_PLUS: + case STLINK_CHIPID_STM32_L1_HIGH: + return STM32L1_FLASH_REGS_ADDR; + default: + return STM32L0_FLASH_REGS_ADDR; + } +} + static uint32_t __attribute__((unused)) read_flash_rdp(stlink_t *sl) { uint32_t rdp; stlink_read_debug32(sl, FLASH_WRPR, &rdp); @@ -386,9 +408,8 @@ static void unlock_flash(stlink_t *sl) { } } +/* unlock flash if already locked */ static int unlock_flash_if(stlink_t *sl) { - /* unlock flash if already locked */ - if (is_flash_locked(sl)) { unlock_flash(sl); if (is_flash_locked(sl)) { @@ -430,6 +451,154 @@ static void lock_flash(stlink_t *sl) { } } +static bool is_flash_option_locked(stlink_t *sl) { + uint32_t optlock_shift, optcr_reg; + int active_bit_level = 1; + uint32_t n; + + switch (sl->flash_type) { + case STLINK_FLASH_TYPE_F0: + case STLINK_FLASH_TYPE_F1_XL: + optcr_reg = FLASH_CR; + optlock_shift = FLASH_CR_OPTWRE; + active_bit_level = 0; /* bit is "option write enable", not lock */ + break; + case STLINK_FLASH_TYPE_F4: + optcr_reg = FLASH_F4_OPTCR; + optlock_shift = FLASH_F4_OPTCR_LOCK; + break; + case STLINK_FLASH_TYPE_L0: + optcr_reg = get_stm32l0_flash_base(sl) + FLASH_PECR_OFF; + optlock_shift = STM32L0_FLASH_OPTLOCK; + break; + case STLINK_FLASH_TYPE_L4: + optcr_reg = STM32L4_FLASH_CR; + optlock_shift = STM32L4_FLASH_CR_OPTLOCK; + break; + case STLINK_FLASH_TYPE_G0: + case STLINK_FLASH_TYPE_G4: + optcr_reg = STM32Gx_FLASH_CR; + optlock_shift = STM32Gx_FLASH_CR_OPTLOCK; + break; + case STLINK_FLASH_TYPE_WB: + optcr_reg = STM32WB_FLASH_CR; + optlock_shift = STM32WB_FLASH_CR_OPTLOCK; + break; + default: + return -1; + } + + stlink_read_debug32(sl, optcr_reg, &n); + + if (active_bit_level == 0) + return !(n & (1u << optlock_shift)); + return n & (1u << optlock_shift); + +} + +static int lock_flash_option(stlink_t *sl) { + uint32_t optlock_shift, optcr_reg, n; + int active_bit_level = 1; + + switch (sl->flash_type) { + case STLINK_FLASH_TYPE_F0: + case STLINK_FLASH_TYPE_F1_XL: + optcr_reg = FLASH_CR; + optlock_shift = FLASH_CR_OPTWRE; + active_bit_level = 0; + break; + case STLINK_FLASH_TYPE_F4: + optcr_reg = FLASH_F4_OPTCR; + optlock_shift = FLASH_F4_OPTCR_LOCK; + break; + case STLINK_FLASH_TYPE_L0: + optcr_reg = get_stm32l0_flash_base(sl) + FLASH_PECR_OFF; + optlock_shift = STM32L0_FLASH_OPTLOCK; + break; + case STLINK_FLASH_TYPE_L4: + optcr_reg = STM32L4_FLASH_CR; + optlock_shift = STM32L4_FLASH_CR_OPTLOCK; + break; + case STLINK_FLASH_TYPE_G0: + case STLINK_FLASH_TYPE_G4: + optcr_reg = STM32Gx_FLASH_CR; + optlock_shift = STM32Gx_FLASH_CR_OPTLOCK; + break; + case STLINK_FLASH_TYPE_WB: + optcr_reg = STM32WB_FLASH_CR; + optlock_shift = STM32WB_FLASH_CR_OPTLOCK; + break; + + default: + return -1; + } + + stlink_read_debug32(sl, optcr_reg, &n); + if (active_bit_level == 0) + n &= ~(1u << optlock_shift); + else + n |= (1u << optlock_shift); + stlink_write_debug32(sl, optcr_reg, n); + + return 0; +} + +static int unlock_flash_option(stlink_t *sl) +{ + uint32_t optkey_reg; + uint32_t optkey1 = FLASH_OPTKEY1; + uint32_t optkey2 = FLASH_OPTKEY2; + + switch (sl->flash_type) { + case STLINK_FLASH_TYPE_F0: + case STLINK_FLASH_TYPE_F1_XL: + optkey_reg = FLASH_OPTKEYR; + optkey1 = FLASH_F0_OPTKEY1; + optkey2 = FLASH_F0_OPTKEY2; + break; + case STLINK_FLASH_TYPE_F4: + optkey_reg = FLASH_F4_OPT_KEYR; + break; + case STLINK_FLASH_TYPE_L0: + optkey_reg = get_stm32l0_flash_base(sl) + FLASH_OPTKEYR_OFF; + optkey1 = FLASH_L0_OPTKEY1; + optkey2 = FLASH_L0_OPTKEY2; + break; + case STLINK_FLASH_TYPE_L4: + optkey_reg = STM32L4_FLASH_OPTKEYR; + break; + case STLINK_FLASH_TYPE_G0: + case STLINK_FLASH_TYPE_G4: + optkey_reg = STM32Gx_FLASH_OPTKEYR; + break; + case STLINK_FLASH_TYPE_WB: + optkey_reg = STM32WB_FLASH_OPT_KEYR; + break; + + default: + return -1; + } + + stlink_write_debug32(sl, optkey_reg, optkey1); + stlink_write_debug32(sl, optkey_reg, optkey2); + + return 0; +} + +static int unlock_flash_option_if(stlink_t *sl) { + if (is_flash_option_locked(sl)) { + if (unlock_flash_option(sl)) { + ELOG("Could not unlock flash option!\n"); + return -1; + } + if (is_flash_option_locked(sl)) { + ELOG("Failed to unlock flash option!\n"); + return -1; + } + } + DLOG("Successfully unlocked flash option\n"); + return 0; +} static void set_flash_cr_pg(stlink_t *sl) { uint32_t cr_reg, x; @@ -3307,7 +3476,6 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui ELOG("Option bytes writing is currently not implemented for connected chip\n"); return -1; } - } /** From 29cfb7deb6d5c253f93c10c27965aa3bd1aa3912 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 20 Apr 2020 17:40:30 +0200 Subject: [PATCH 156/236] common: add some l0/l1 support in helpers give l0/l1 some love - l0/l1 are a bit specific regarding keys, bits, and lock registers. Also make handling of f0/f1 explicit: ultimate goal is to have some sanity check and clear codepath in that code in case some new target is added - and that the whole code uses these helpers. some work should be done to refactor a bit the flash register mapping based on family, but not yet. lo lock --- src/common.c | 101 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 28 deletions(-) diff --git a/src/common.c b/src/common.c index 2f226f016..6281d5332 100644 --- a/src/common.c +++ b/src/common.c @@ -53,6 +53,12 @@ #define FLASH_KEY1 0x45670123 #define FLASH_KEY2 0xcdef89ab +#define FLASH_L0_PRGKEY1 0x8c9daebf +#define FLASH_L0_PRGKEY2 0x13141516 + +#define FLASH_L0_PEKEY1 0x89abcdef +#define FLASH_L0_PEKEY2 0x02030405 + #define FLASH_OPTKEY1 0x08192A3B #define FLASH_OPTKEY2 0x4C5D6E7F @@ -363,48 +369,74 @@ static inline uint32_t read_flash_cr2(stlink_t *sl) { static inline unsigned int is_flash_locked(stlink_t *sl) { /* return non zero for true */ - uint32_t cr_lock_shift, cr = read_flash_cr(sl); + uint32_t cr_lock_shift; + uint32_t cr_reg; + uint32_t n; - if (sl->flash_type == STLINK_FLASH_TYPE_F4) + if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || + (sl->flash_type == STLINK_FLASH_TYPE_F1_XL)) { + cr_reg = FLASH_CR; + cr_lock_shift = FLASH_CR_LOCK; + } else if (sl->flash_type == STLINK_FLASH_TYPE_F4) { + cr_reg = FLASH_F4_CR; cr_lock_shift = FLASH_F4_CR_LOCK; - else if (sl->flash_type == STLINK_FLASH_TYPE_L4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_L0) { + cr_reg = get_stm32l0_flash_base(sl) + FLASH_PECR_OFF; + cr_lock_shift = STM32L0_FLASH_PELOCK; + } else if (sl->flash_type == STLINK_FLASH_TYPE_L4) { + cr_reg = STM32L4_FLASH_CR; cr_lock_shift = STM32L4_FLASH_CR_LOCK; - else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || - sl->flash_type == STLINK_FLASH_TYPE_G4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || + sl->flash_type == STLINK_FLASH_TYPE_G4) { + cr_reg = STM32Gx_FLASH_CR; cr_lock_shift = STM32Gx_FLASH_CR_LOCK; - else if (sl->flash_type == STLINK_FLASH_TYPE_WB) + } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { + cr_reg = STM32WB_FLASH_CR; cr_lock_shift = STM32WB_FLASH_CR_LOCK; - else - cr_lock_shift = FLASH_CR_LOCK; + } else { + return -1; + } - return cr & (1u << cr_lock_shift); + stlink_read_debug32(sl, cr_reg, &n); + return n & (1u << cr_lock_shift); } static void unlock_flash(stlink_t *sl) { uint32_t key_reg; + uint32_t flash_key1 = FLASH_KEY1; + uint32_t flash_key2 = FLASH_KEY2; /* the unlock sequence consists of 2 write cycles where 2 key values are written to the FLASH_KEYR register. an invalid sequence results in a definitive lock of the FPEC block until next reset. */ - if (sl->flash_type == STLINK_FLASH_TYPE_F4) + + if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || + (sl->flash_type == STLINK_FLASH_TYPE_F1_XL)) { + key_reg = FLASH_KEYR; + } else if (sl->flash_type == STLINK_FLASH_TYPE_F4) { key_reg = FLASH_F4_KEYR; - else if (sl->flash_type == STLINK_FLASH_TYPE_L4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_L0) { + key_reg = get_stm32l0_flash_base(sl) + FLASH_PEKEYR_OFF; + flash_key1 = FLASH_L0_PEKEY1; + flash_key2 = FLASH_L0_PEKEY2; + } else if (sl->flash_type == STLINK_FLASH_TYPE_L4) { key_reg = STM32L4_FLASH_KEYR; - else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || - sl->flash_type == STLINK_FLASH_TYPE_G4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || + sl->flash_type == STLINK_FLASH_TYPE_G4) { key_reg = STM32Gx_FLASH_KEYR; - else if (sl->flash_type == STLINK_FLASH_TYPE_WB) + } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { key_reg = STM32WB_FLASH_KEYR; - else - key_reg = FLASH_KEYR; + } else { + return; + } - stlink_write_debug32(sl, key_reg, FLASH_KEY1); - stlink_write_debug32(sl, key_reg, FLASH_KEY2); + stlink_write_debug32(sl, key_reg, flash_key1); + stlink_write_debug32(sl, key_reg, flash_key2); if (sl->flash_type == STLINK_FLASH_TYPE_F1_XL) { - stlink_write_debug32(sl, FLASH_KEYR2, FLASH_KEY1); - stlink_write_debug32(sl, FLASH_KEYR2, FLASH_KEY2); + stlink_write_debug32(sl, FLASH_KEYR2, flash_key1); + stlink_write_debug32(sl, FLASH_KEYR2, flash_key2); } } @@ -424,9 +456,16 @@ static int unlock_flash_if(stlink_t *sl) { static void lock_flash(stlink_t *sl) { uint32_t cr_lock_shift, cr_reg, n; - if (sl->flash_type == STLINK_FLASH_TYPE_F4) { + if (sl->flash_type == STLINK_FLASH_TYPE_F0 || + sl->flash_type == STLINK_FLASH_TYPE_F1_XL) { + cr_reg = FLASH_CR; + cr_lock_shift = FLASH_CR_LOCK; + } else if (sl->flash_type == STLINK_FLASH_TYPE_F4) { cr_reg = FLASH_F4_CR; cr_lock_shift = FLASH_F4_CR_LOCK; + } else if (sl->flash_type == STLINK_FLASH_TYPE_L0) { + cr_reg = get_stm32l0_flash_base(sl) + FLASH_PECR_OFF; + cr_lock_shift = STM32L0_FLASH_PELOCK; } else if (sl->flash_type == STLINK_FLASH_TYPE_L4) { cr_reg = STM32L4_FLASH_CR; cr_lock_shift = STM32L4_FLASH_CR_LOCK; @@ -438,11 +477,11 @@ static void lock_flash(stlink_t *sl) { cr_reg = STM32WB_FLASH_CR; cr_lock_shift = STM32WB_FLASH_CR_LOCK; } else { - cr_reg = FLASH_CR; - cr_lock_shift = FLASH_CR_LOCK; + return; } - n = read_flash_cr(sl) | (1u << cr_lock_shift); + stlink_read_debug32(sl, cr_reg, &n); + n |= (1u << cr_lock_shift); stlink_write_debug32(sl, cr_reg, n); if (sl->flash_type == STLINK_FLASH_TYPE_F1_XL) { @@ -795,7 +834,11 @@ static void set_flash_cr2_strt(stlink_t *sl) { static inline uint32_t read_flash_sr(stlink_t *sl) { uint32_t res, sr_reg; - if (sl->flash_type == STLINK_FLASH_TYPE_F4) + if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_F1_XL)) + sr_reg = FLASH_SR; + else if (sl->flash_type == STLINK_FLASH_TYPE_L0) + sr_reg = get_stm32l0_flash_base(sl) + FLASH_SR_OFF; + else if (sl->flash_type == STLINK_FLASH_TYPE_F4) sr_reg = FLASH_F4_SR; else if (sl->flash_type == STLINK_FLASH_TYPE_L4) sr_reg = STM32L4_FLASH_SR; @@ -805,7 +848,7 @@ static inline uint32_t read_flash_sr(stlink_t *sl) { else if (sl->flash_type == STLINK_FLASH_TYPE_WB) sr_reg = STM32WB_FLASH_SR; else - sr_reg = FLASH_SR; + return -1; stlink_read_debug32(sl, sr_reg, &res); @@ -822,7 +865,9 @@ static inline unsigned int is_flash_busy(stlink_t *sl) { uint32_t sr_busy_shift; unsigned int res; - if (sl->flash_type == STLINK_FLASH_TYPE_F4) + if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_L0)) + sr_busy_shift = FLASH_SR_BSY; + else if (sl->flash_type == STLINK_FLASH_TYPE_F4) sr_busy_shift = FLASH_F4_SR_BSY; else if (sl->flash_type == STLINK_FLASH_TYPE_L4) sr_busy_shift = STM32L4_FLASH_SR_BSY; @@ -832,7 +877,7 @@ static inline unsigned int is_flash_busy(stlink_t *sl) { else if (sl->flash_type == STLINK_FLASH_TYPE_WB) sr_busy_shift = STM32WB_FLASH_SR_BSY; else - sr_busy_shift = FLASH_SR_BSY; + return -1; res = read_flash_sr(sl) & (1 << sr_busy_shift); From 2cff67a59bf959a4c1dea9863b47401748ec0e5e Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 20 Apr 2020 15:57:48 +0200 Subject: [PATCH 157/236] update f2 and f4 option read/write code routines 1) no need to unlock option flash to read it. "The option byte are always read-accessible and write-protected by default." current device specific option read code now only differs from generic read code by reading option bytes in the flash option byte register instead of option base. 2) f4 and f2 have similar registers : use the same write code, with flash/option lock helpers. add flash busy wait and relock at end of access. 3) add f446 option info to chip id --- src/chipid.c | 4 +- src/common.c | 168 +++++++-------------------------------------------- 2 files changed, 26 insertions(+), 146 deletions(-) diff --git a/src/chipid.c b/src/chipid.c index 60d0787e9..ee85aaf65 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -218,7 +218,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x20000, .sram_size = 0x20000, .bootrom_base = 0x1fff0000, - .bootrom_size = 0x7800 + .bootrom_size = 0x7800, + .option_base = 0x1FFFC000, + .option_size = 4, }, { // STM32F410 MCUs. Support based on DM00180366.pdf (RM0401) document. diff --git a/src/common.c b/src/common.c index 6281d5332..6770aca3f 100644 --- a/src/common.c +++ b/src/common.c @@ -3235,62 +3235,6 @@ static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, stm32_ad } -/** - * Write option bytes - * @param sl - * @param option_byte value to write - * @return 0 on success, -ve on failure. - */ -static int stlink_write_option_bytes_f2(stlink_t *sl, uint8_t *base, stm32_addr_t addr, size_t len) { - uint32_t val; - uint32_t option_byte; - - (void) addr; - (void) len; - - option_byte = *(uint32_t*) (base); - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); - if (val & FLASH_F2_OPT_LOCK_BIT) { - WLOG("Unlocking option flash\n"); - //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) - //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY1); - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY2); - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); - if (val & FLASH_F2_OPT_LOCK_BIT) { - ELOG("Option flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - } - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); - WLOG("option bytes CR = %x\n",val); - - stlink_write_debug32(sl, FLASH_F2_OPT_CR, option_byte & 0x0FFFFFFC); - - stlink_write_debug32(sl, FLASH_F2_OPT_CR, (option_byte & 0x0FFFFFFC)|0x00000002); - - - stlink_read_debug32(sl, FLASH_F2_SR, &val); - WLOG("wait BSY flag to be 0\n"); - - while (val & 0x00010000){ - stlink_read_debug32(sl, FLASH_F2_SR, &val); - } - WLOG("BSY flag is 0\n"); - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); - WLOG("option bytes CR = %x\n",val); - WLOG("Option flash re-lock\n"); - stlink_write_debug32(sl, FLASH_F2_OPT_CR, val | 0x00000001); - - DLOG("STM32 F2 option bytes are written\n"); - - return 0; -} - /** * Write option bytes * @param sl @@ -3298,52 +3242,37 @@ static int stlink_write_option_bytes_f2(stlink_t *sl, uint8_t *base, stm32_addr_ * @return 0 on success, -ve on failure. */ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { - uint32_t val; uint32_t option_byte; (void) addr; (void) len; - option_byte = *(uint32_t*) (base); - - stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); - if (val & FLASH_F4_OPT_LOCK_BIT) { - WLOG("Unlocking option flash\n"); - //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) - //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY1); - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY2); + wait_flash_busy(sl); - stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); - if (val & FLASH_F4_OPT_LOCK_BIT) { - ELOG("Option flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_if(sl)) { + ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); + return -1; } - stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); - WLOG("option bytes CR = %x\n",val); - - stlink_write_debug32(sl, FLASH_F4_OPT_CR, option_byte & 0x0FFFFFFC); + if (unlock_flash_option_if(sl)) { + ELOG("Flash option unlock failed!\n"); + return -1; + } + write_uint32((unsigned char*) &option_byte, *(uint32_t*) (base)); - stlink_write_debug32(sl, FLASH_F4_OPT_CR, (option_byte & 0x0FFFFFFC)|0x00000002); + /* write option byte, ensuring we dont lock opt, and set strt bit */ + stlink_write_debug32(sl, FLASH_F4_OPTCR, (option_byte & ~(1 << FLASH_F4_OPTCR_LOCK)) | (1 << FLASH_F4_OPTCR_START)); - stlink_read_debug32(sl, FLASH_F4_SR, &val); - WLOG("wait BSY flag to be 0\n"); + wait_flash_busy(sl); - while (val & 0x00010000){ - stlink_read_debug32(sl, FLASH_F4_SR, &val); - } - WLOG("BSY flag is 0\n"); + check_flash_error(sl); - stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); - WLOG("option bytes CR = %x\n",val); - WLOG("Option flash re-lock\n"); - stlink_write_debug32(sl, FLASH_F4_OPT_CR, val | 0x00000001); + /* option bytes are reloaded at reset only, no obl. */ - DLOG("STM32 F4 option bytes are written\n"); + lock_flash_option(sl); + lock_flash(sl); - return 0; + return 0; } /** @@ -3352,11 +3281,8 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_ * @param option_byte value to write * @return 0 on success, -ve on failure. */ -int stlink_read_option_bytes_Gx(stlink_t *sl, uint32_t* option_byte) -{ - uint32_t ret = stlink_read_debug32(sl, STM32Gx_FLASH_OPTR, option_byte); - WLOG("option bytes CR = %#010x\n", *option_byte); - return ret; +int stlink_read_option_bytes_Gx(stlink_t *sl, uint32_t* option_byte) { + return stlink_read_debug32(sl, STM32Gx_FLASH_OPTR, option_byte); } /** @@ -3366,30 +3292,7 @@ int stlink_read_option_bytes_Gx(stlink_t *sl, uint32_t* option_byte) * @return 0 on success, -ve on failure. */ int stlink_read_option_bytes_f2(stlink_t *sl, uint32_t* option_byte) { - uint32_t val; - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); - if (val & FLASH_F2_OPT_LOCK_BIT) { - WLOG("Unlocking option flash\n"); - //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) - //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY1); - stlink_write_debug32(sl, FLASH_F2_OPT_KEYR, FLASH_OPTKEY2); - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, &val); - if (val & FLASH_F2_OPT_LOCK_BIT) { - ELOG("Option flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - } - - stlink_read_debug32(sl, FLASH_F2_OPT_CR, option_byte); - WLOG("option bytes CR = %x\n",option_byte); - - WLOG("Option flash re-lock\n"); - stlink_write_debug32(sl, FLASH_F2_OPT_CR, val | 0x00000001); - - return 0; + return stlink_read_debug32(sl, FLASH_F2_OPT_CR, option_byte); } /** @@ -3399,39 +3302,15 @@ int stlink_read_option_bytes_f2(stlink_t *sl, uint32_t* option_byte) { * @return 0 on success, -ve on failure. */ int stlink_read_option_bytes_f4(stlink_t *sl, uint32_t* option_byte) { - uint32_t val; - - stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); - if (val & FLASH_F4_OPT_LOCK_BIT) { - WLOG("Unlocking option flash\n"); - //Unlock the FLASH_OPT_CR register (FLASH Programming manual page 15) - //https://www.st.com/resource/en/programming_manual/cd00233952.pdf - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY1); - stlink_write_debug32(sl, FLASH_F4_OPT_KEYR, FLASH_OPTKEY2); - - stlink_read_debug32(sl, FLASH_F4_OPT_CR, &val); - if (val & FLASH_F4_OPT_LOCK_BIT) { - ELOG("Option flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - } - - stlink_read_debug32(sl, FLASH_F4_OPT_CR, option_byte); - WLOG("option bytes CR = %x\n", option_byte); - - WLOG("Option flash re-lock\n"); - stlink_write_debug32(sl, FLASH_F4_OPT_CR, val | 0x00000001); - - return 0; + return stlink_read_debug32(sl, FLASH_F4_OPTCR, option_byte); } /** -* Read first option bytes + * Read first option bytes * @param sl * @param option_byte option value * @return 0 on success, -ve on failure. */ -int stlink_read_option_bytes_generic(stlink_t *sl, uint32_t* option_byte) -{ +int stlink_read_option_bytes_generic(stlink_t *sl, uint32_t* option_byte) { return stlink_read_debug32(sl, sl->option_base, option_byte); } @@ -3502,7 +3381,6 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui /* filter out on chip_id, until complete flash family are handled */ switch (sl->chip_id) { case STLINK_CHIPID_STM32_F2: - return stlink_write_option_bytes_f2(sl, base, addr, len); case STLINK_CHIPID_STM32_F446: return stlink_write_option_bytes_f4(sl, base, addr, len); case STLINK_CHIPID_STM32_L0_CAT2: From 9e53550d24a9434c4c01754cb5fd69f1f3fc705d Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 20 Apr 2020 15:57:40 +0200 Subject: [PATCH 158/236] update l4 option code to use helpers, based on l496. use generic unlock for l4, rename l496 to l4x, add wait flash busy, complete chip id for l476 (and other) --- src/chipid.c | 4 +++- src/common.c | 56 ++++++++++++++-------------------------------------- 2 files changed, 18 insertions(+), 42 deletions(-) diff --git a/src/chipid.c b/src/chipid.c index ee85aaf65..17cb4d546 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -53,7 +53,9 @@ static const struct stlink_chipid_params devices[] = { .flash_pagesize = 0x20000, .sram_size = 0x20000, .bootrom_base = 0x1fff0000, - .bootrom_size = 0x7800 + .bootrom_size = 0x7800, + .option_base = 0x1FFFC000, + .option_size = 4, }, { // PM0063 .chip_id = STLINK_CHIPID_STM32_F1_LOW, diff --git a/src/common.c b/src/common.c index 6770aca3f..79d346e46 100644 --- a/src/common.c +++ b/src/common.c @@ -78,8 +78,6 @@ #define FLASH_CR_LOCK 7 #define FLASH_CR_OPTWRE 9 - -//32L = 32F1 same CoreID as 32F4! #define STM32L_FLASH_REGS_ADDR ((uint32_t)0x40023c00) #define STM32L_FLASH_ACR (STM32L_FLASH_REGS_ADDR + 0x00) #define STM32L_FLASH_PECR (STM32L_FLASH_REGS_ADDR + 0x04) @@ -3162,43 +3160,23 @@ static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_ * @param base option bytes to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { +static int stlink_write_option_bytes_l4(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; (void) addr; (void) len; - /* Unlock flash if necessary */ - stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); - if ((val & (1u << STM32L4_FLASH_CR_LOCK))) { - - /* disable flash write protection. */ - stlink_write_debug32(sl, STM32L4_FLASH_KEYR, 0x45670123); - stlink_write_debug32(sl, STM32L4_FLASH_KEYR, 0xCDEF89AB); + wait_flash_busy(sl); - // check that the lock is no longer set. - stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); - if ((val & (1u << STM32L4_FLASH_CR_LOCK))) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_if(sl)) { + ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); + return -1; } - /* Unlock option bytes if necessary (ref manuel page 61) */ - stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); - if ((val & (1 << STM32L4_FLASH_CR_OPTLOCK))) { - - /* disable option byte write protection. */ - stlink_write_debug32(sl, STM32L4_FLASH_OPTKEYR, FLASH_OPTKEY1); - stlink_write_debug32(sl, STM32L4_FLASH_OPTKEYR, FLASH_OPTKEY2); - - /* check that the lock is no longer set. */ - stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); - if ((val & (1 << STM32L4_FLASH_CR_OPTLOCK))) { - ELOG("Options bytes unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_option_if(sl)) { + ELOG("Flash option unlock failed!\n"); + return -1; } /* Write options bytes */ @@ -3213,23 +3191,18 @@ static int stlink_write_option_bytes_l496x(stlink_t *sl, uint8_t* base, stm32_ad stlink_write_debug32(sl, STM32L4_FLASH_CR, val); /* Wait for 'busy' bit in FLASH_SR to clear. */ - do { - stlink_read_debug32(sl, STM32L4_FLASH_SR, &val); - } while ((val & (1 << 16)) != 0); + wait_flash_busy(sl); + + check_flash_error(sl); /* apply options bytes immediate */ stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); val |= (1 << STM32L4_FLASH_CR_OBL_LAUNCH); stlink_write_debug32(sl, STM32L4_FLASH_CR, val); - /* Re-lock option bytes */ - stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); - val |= (1u << STM32L4_FLASH_CR_OPTLOCK); - stlink_write_debug32(sl, STM32L4_FLASH_CR, val); /* Re-lock flash. */ - stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); - val |= (1u << STM32L4_FLASH_CR_LOCK); - stlink_write_debug32(sl, STM32L4_FLASH_CR, val); + lock_flash_option(sl); + lock_flash(sl); return 0; } @@ -3386,7 +3359,8 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui case STLINK_CHIPID_STM32_L0_CAT2: return stlink_write_option_bytes_l0_cat2(sl, base, addr, len); case STLINK_CHIPID_STM32_L496X: - return stlink_write_option_bytes_l496x(sl, base, addr, len); + case STLINK_CHIPID_STM32_L4: + return stlink_write_option_bytes_l4(sl, base, addr, len); case STLINK_CHIPID_STM32_L152_RE: case STLINK_CHIPID_STM32_L1_HIGH: return stlink_write_option_bytes_l1(sl, base, addr, len); From 70043c426cc8f590ace5b4997759721161bfa88c Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 20 Apr 2020 15:31:37 +0200 Subject: [PATCH 159/236] update gx option code: use helpers. --- src/common.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/common.c b/src/common.c index 79d346e46..0a29a5716 100644 --- a/src/common.c +++ b/src/common.c @@ -2958,25 +2958,16 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_ (void) addr; (void) len; + wait_flash_busy(sl); + if (unlock_flash_if(sl)) { ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); return -1; } - /* Unlock option bytes if necessary (ref manuel page 61) */ - stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); - if ((val & (1 << STM32Gx_FLASH_CR_OPTLOCK))) { - - /* disable option byte write protection. */ - stlink_write_debug32(sl, STM32Gx_FLASH_OPTKEYR, FLASH_OPTKEY1); - stlink_write_debug32(sl, STM32Gx_FLASH_OPTKEYR, FLASH_OPTKEY2); - - /* check that the lock is no longer set. */ - stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); - if ((val & (1 << STM32Gx_FLASH_CR_OPTLOCK))) { - ELOG("Options bytes unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_option_if(sl)) { + ELOG("Flash option unlock failed!\n"); + return -1; } /* Write options bytes */ @@ -3003,12 +2994,8 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_ val |= (1 << STM32Gx_FLASH_CR_OBL_LAUNCH); stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); - /* Re-lock option bytes */ - stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); - val |= (1u << STM32Gx_FLASH_CR_OPTLOCK); - stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); - /* Re-lock flash. */ + lock_flash_option(sl); lock_flash(sl); return 0; From f23de8741a27ed46ccff4b9fa7806fc278b5961e Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 20 Apr 2020 16:06:54 +0200 Subject: [PATCH 160/236] update l0/l1 option code: merge l0/l1, code is the same except flash base, add wait states and relock --- src/common.c | 168 ++++++++++++--------------------------------------- 1 file changed, 39 insertions(+), 129 deletions(-) diff --git a/src/common.c b/src/common.c index 0a29a5716..147fee1ea 100644 --- a/src/common.c +++ b/src/common.c @@ -24,8 +24,6 @@ #define __attribute__(x) #endif -/* todo: stm32l15xxx flash memory, pm0062 manual */ - /* stm32f FPEC flash controller interface, pm0063 manual */ // TODO - all of this needs to be abstracted out.... // STM32F05x is identical, based on RM0091 (DM00031936, Doc ID 018940 Rev 2, August 2012) @@ -213,13 +211,14 @@ #define STM32L4_FLASH_OPTR_DUALBANK 21 -//STM32L0x flash register base and offsets -//same as 32L1 above -// RM0090 - DM00031020.pdf +//STM32L0x flash register base and offsets RM0090 - DM00031020.pdf #define STM32L0_FLASH_REGS_ADDR ((uint32_t)0x40022000) -#define STM32L0_FLASH_PELOCK_BIT (1u << 0) -#define STM32L0_FLASH_OPTLOCK_BIT (1u << 2) -#define STM32L0_FLASH_OBL_LAUNCH_BIT (1u << 18) +#define STM32L1_FLASH_REGS_ADDR ((uint32_t)0x40023c00) + +#define STM32L0_FLASH_PELOCK (0) +#define STM32L0_FLASH_OPTLOCK (2) +#define STM32L0_FLASH_OBL_LAUNCH (18) + #define FLASH_ACR_OFF ((uint32_t) 0x00) #define FLASH_PECR_OFF ((uint32_t) 0x04) #define FLASH_PDKEYR_OFF ((uint32_t) 0x08) @@ -230,12 +229,6 @@ #define FLASH_OBR_OFF ((uint32_t) 0x1c) #define FLASH_WRPR_OFF ((uint32_t) 0x20) -//STM32L1 -#define STM32L1_FLASH_REGS_ADDR ((uint32_t)0x40023c00) -#define STM32L1_FLASH_PELOCK_BIT (1u << 0) -#define STM32L1_FLASH_OPTLOCK_BIT (1u << 2) -#define STM32L1_FLASH_OBL_LAUNCH_BIT (1u << 18) - //STM32F4 #define FLASH_F4_REGS_ADDR ((uint32_t)0x40023c00) #define FLASH_F4_KEYR (FLASH_F4_REGS_ADDR + 0x04) @@ -268,7 +261,6 @@ #define FLASH_F2_CR_SNB_MASK 0x78 #define FLASH_F2_SR_BSY 16 - #define L1_WRITE_BLOCK_SIZE 0x80 #define L0_WRITE_BLOCK_SIZE 0x40 @@ -3001,62 +2993,6 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_ return 0; } - -/** - * Write option bytes - * @param sl - * @param addr of the memory mapped option bytes - * @param base option bytes to write - * @return 0 on success, -ve on failure. - */ -static int stlink_write_option_bytes_l0_cat2(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { - - uint32_t val; - (void) addr; - (void) len; - - stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if (val & STM32L0_FLASH_PELOCK_BIT) { - WLOG("Unlocking flash\n"); - //Unlock data EEPROM and the FLASH_PECR register (reference page 74) - stlink_write_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PEKEYR_OFF, 0x89ABCDEF); - stlink_write_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PEKEYR_OFF, 0x02030405); - - stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if (val & STM32L0_FLASH_PELOCK_BIT) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - } - - stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if ((val & (STM32L0_FLASH_OPTLOCK_BIT))) { - WLOG("Unlocking options\n"); - //Unlock the Option bytes area (reference page 76) - stlink_write_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_OPTKEYR_OFF, 0xFBEAD9C8); - stlink_write_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_OPTKEYR_OFF, 0x24252627); - - stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if (val & STM32L0_FLASH_OPTLOCK_BIT) { - ELOG("Options unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - } - - /* Write options bytes */ - uint32_t data; - write_uint32((unsigned char*) &data, *(uint32_t*) (base)); - WLOG("Writing option bytes 0x%04x\n", data); - stlink_write_debug32(sl, STM32_L0_CATx_OPTION_BYTES_BASE, data); - - /* Reload options */ - stlink_read_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - val |= (STM32L0_FLASH_OBL_LAUNCH_BIT); - stlink_write_debug32(sl, STM32L0_FLASH_REGS_ADDR + FLASH_PECR_OFF, val); - - return 0; -} - /** * Write option bytes * @param sl @@ -3064,78 +3000,51 @@ static int stlink_write_option_bytes_l0_cat2(stlink_t *sl, uint8_t* base, stm32_ * @param base option bytes to write * @return 0 on success, -ve on failure. */ -static int stlink_write_option_bytes_l1(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { - +static int stlink_write_option_bytes_l0(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) +{ + uint32_t flash_base = get_stm32l0_flash_base(sl); uint32_t val; uint32_t data; - stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if (val & STM32L1_FLASH_PELOCK_BIT) { - WLOG("Unlocking flash\n"); - //Unlock data EEPROM and the FLASH_PECR register (reference page 74) - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PEKEYR_OFF, 0x89ABCDEF); - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PEKEYR_OFF, 0x02030405); + wait_flash_busy(sl); - stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if (val & STM32L1_FLASH_PELOCK_BIT) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_if(sl)) { + ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); + return -1; } - stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if ((val & (STM32L1_FLASH_OPTLOCK_BIT))) { - WLOG("Unlocking options\n"); - //Unlock the Option bytes area (reference page 76) - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_OPTKEYR_OFF, 0xFBEAD9C8); - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_OPTKEYR_OFF, 0x24252627); - - stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - if (val & STM32L1_FLASH_OPTLOCK_BIT) { - ELOG("Options unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } + if (unlock_flash_option_if(sl)) { + ELOG("Flash option unlock failed!\n"); + return -1; } - /* Clear errors */ - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_SR_OFF, 0x00003F00); + stlink_write_debug32(sl, flash_base + FLASH_SR_OFF, STM32L0_FLASH_REGS_ADDR); - stlink_read_debug32(sl, addr, &val); - WLOG("Option bytes 0x%08x is 0x%08x\n",addr,val); + while (len != 0) { + /* Write options bytes */ + write_uint32((unsigned char*) &data, *(uint32_t*) (base)); - /* Write options bytes */ - write_uint32((unsigned char*) &data, *(uint32_t*) (base)); - if ( data != val ) { - WLOG("Writing option bytes 0x%04x\n", data); + WLOG("Writing option bytes %#10x to %#10x\n", data, addr); stlink_write_debug32(sl, addr, data); - stlink_read_debug32(sl, addr, &val); - WLOG("Option bytes is 0x%08x\n",val); - } - - if (len==8) { - /* Clear errors */ - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_SR_OFF, 0x00003F00); - - stlink_read_debug32(sl, addr+4, &val); - WLOG("2nd option bytes 0x%08x is 0x%08x\n",addr,val); + wait_flash_busy(sl); - /* Write options bytes */ - write_uint32((unsigned char*) &data, *(uint32_t*) (base+4)); + if (check_flash_error(sl)) + break; - if ( data != val ) { - WLOG("Writing 2nd option bytes 0x%04x\n", data); - stlink_write_debug32(sl, addr+4, data); - stlink_read_debug32(sl, addr+4, &val); - WLOG("2nd option bytes is 0x%08x\n",val); - } + len-=4; + addr+=4; + base+=4; } /* Reload options */ - stlink_read_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, &val); - val |= (STM32L1_FLASH_OBL_LAUNCH_BIT); - stlink_write_debug32(sl, STM32L1_FLASH_REGS_ADDR + FLASH_PECR_OFF, val); + stlink_read_debug32(sl, flash_base + FLASH_PECR_OFF, &val); + val |= (1 << STM32L0_FLASH_OBL_LAUNCH); + stlink_write_debug32(sl, flash_base + FLASH_PECR_OFF, val); + + lock_flash_option(sl); + lock_flash(sl); return 0; } @@ -3218,6 +3127,7 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_ ELOG("Flash option unlock failed!\n"); return -1; } + write_uint32((unsigned char*) &option_byte, *(uint32_t*) (base)); /* write option byte, ensuring we dont lock opt, and set strt bit */ @@ -3344,13 +3254,13 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui case STLINK_CHIPID_STM32_F446: return stlink_write_option_bytes_f4(sl, base, addr, len); case STLINK_CHIPID_STM32_L0_CAT2: - return stlink_write_option_bytes_l0_cat2(sl, base, addr, len); + case STLINK_CHIPID_STM32_L0_CAT5: + case STLINK_CHIPID_STM32_L152_RE: + case STLINK_CHIPID_STM32_L1_HIGH: + return stlink_write_option_bytes_l0(sl, base, addr, len); case STLINK_CHIPID_STM32_L496X: case STLINK_CHIPID_STM32_L4: return stlink_write_option_bytes_l4(sl, base, addr, len); - case STLINK_CHIPID_STM32_L152_RE: - case STLINK_CHIPID_STM32_L1_HIGH: - return stlink_write_option_bytes_l1(sl, base, addr, len); case STLINK_CHIPID_STM32_G0_CAT1: case STLINK_CHIPID_STM32_G0_CAT2: case STLINK_CHIPID_STM32_G4_CAT2: From c4d9936976032cd863b7bce23ef2f25813ab2370 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Fri, 17 Apr 2020 16:23:47 +0200 Subject: [PATCH 161/236] common: implement flash check error for l0 and f0 --- src/common.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/common.c b/src/common.c index 147fee1ea..461e74a75 100644 --- a/src/common.c +++ b/src/common.c @@ -67,11 +67,16 @@ #define FLASH_L0_OPTKEY2 0x24252627 #define FLASH_SR_BSY 0 +#define FLASH_SR_PG_ERR 2 +#define FLASH_SR_WRPRT_ERR 4 #define FLASH_SR_EOP 5 +#define FLASH_SR_ERROR_MASK ((1 << FLASH_SR_PG_ERR) | (1 << FLASH_SR_WRPRT_ERR)) + #define FLASH_CR_PG 0 #define FLASH_CR_PER 1 #define FLASH_CR_MER 2 +#define FLASH_CR_OPTPG 4 #define FLASH_CR_STRT 6 #define FLASH_CR_LOCK 7 #define FLASH_CR_OPTWRE 9 @@ -219,6 +224,8 @@ #define STM32L0_FLASH_OPTLOCK (2) #define STM32L0_FLASH_OBL_LAUNCH (18) +#define STM32L0_FLASH_SR_ERROR_MASK 0x00003F00 + #define FLASH_ACR_OFF ((uint32_t) 0x00) #define FLASH_PECR_OFF ((uint32_t) 0x04) #define FLASH_PDKEYR_OFF ((uint32_t) 0x08) @@ -902,10 +909,19 @@ static void wait_flash_busy_progress(stlink_t *sl) { static int check_flash_error(stlink_t *sl) { uint32_t res = 0; - if ((sl->flash_type == STLINK_FLASH_TYPE_G0) || - (sl->flash_type == STLINK_FLASH_TYPE_G4)) { - res = read_flash_sr(sl) & STM32Gx_FLASH_SR_ERROR_MASK; - } + switch (sl->flash_type) { + case STLINK_FLASH_TYPE_F0: + res = read_flash_sr(sl) & FLASH_SR_ERROR_MASK; + break; + case STLINK_FLASH_TYPE_G0: + case STLINK_FLASH_TYPE_G4: + res = read_flash_sr(sl) & STM32Gx_FLASH_SR_ERROR_MASK; + break; + case STLINK_FLASH_TYPE_L0: + res = read_flash_sr(sl) & STM32L0_FLASH_SR_ERROR_MASK; + default: + break; + } if (res) { ELOG("Flash programming error : %#010x\n", res); From a69a6fb68153e74bc93b397137be018c8dd0bb02 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Mon, 20 Apr 2020 18:35:45 +0200 Subject: [PATCH 162/236] use defines --- src/common.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common.c b/src/common.c index 461e74a75..019e21756 100644 --- a/src/common.c +++ b/src/common.c @@ -2091,8 +2091,8 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) stlink_read_debug32(sl, flash_regs_base + FLASH_PECR_OFF, &val); if ((val & (1<<0))||(val & (1<<1))) { /* disable pecr protection */ - stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, 0x89abcdef); - stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, 0x02030405); + stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, FLASH_L0_PEKEY1); + stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, FLASH_L0_PEKEY2); /* check pecr.pelock is cleared */ stlink_read_debug32(sl, flash_regs_base + FLASH_PECR_OFF, &val); @@ -2102,8 +2102,8 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) } /* unlock program memory */ - stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, 0x8c9daebf); - stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, 0x13141516); + stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, FLASH_L0_PRGKEY1); + stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, FLASH_L0_PRGKEY2); /* check pecr.prglock is cleared */ stlink_read_debug32(sl, flash_regs_base + FLASH_PECR_OFF, &val); @@ -2603,8 +2603,8 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t /* todo: check write operation */ /* disable pecr protection */ - stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, 0x89abcdef); - stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, 0x02030405); + stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, FLASH_L0_PEKEY1); + stlink_write_debug32(sl, flash_regs_base + FLASH_PEKEYR_OFF, FLASH_L0_PEKEY2); /* check pecr.pelock is cleared */ stlink_read_debug32(sl, flash_regs_base + FLASH_PECR_OFF, &val); @@ -2614,8 +2614,8 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t } /* unlock program memory */ - stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, 0x8c9daebf); - stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, 0x13141516); + stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, FLASH_L0_PRGKEY1); + stlink_write_debug32(sl, flash_regs_base + FLASH_PRGKEYR_OFF, FLASH_L0_PRGKEY2); /* check pecr.prglock is cleared */ stlink_read_debug32(sl, flash_regs_base + FLASH_PECR_OFF, &val); From 853468d1744d0c116bffa017e01f6d29ae735fdf Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 21 Apr 2020 10:27:40 +0200 Subject: [PATCH 163/236] common: whitespace fixes --- src/common.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common.c b/src/common.c index 019e21756..e0c5fde2a 100644 --- a/src/common.c +++ b/src/common.c @@ -734,8 +734,8 @@ static void set_flash_cr_mer(stlink_t *sl, bool v) { cr_reg = STM32Gx_FLASH_CR; cr_mer = (1 << STM32Gx_FLASH_CR_MER1); if (sl->has_dual_bank) { - cr_mer |= (1 << STM32Gx_FLASH_CR_MER2); - } + cr_mer |= (1 << STM32Gx_FLASH_CR_MER2); + } cr_pg = (1 << FLASH_CR_PG); } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { cr_reg = STM32WB_FLASH_CR; @@ -1100,7 +1100,7 @@ int stlink_load_device_params(stlink_t *sl) { sl->chip_id = 0x413; } - params = stlink_chipid_get_params(sl->chip_id); // chipid.c + params = stlink_chipid_get_params(sl->chip_id); if (params == NULL) { WLOG("unknown chip id! %#x\n", chip_id); return -1; @@ -1166,12 +1166,12 @@ int stlink_load_device_params(stlink_t *sl) { // TODO make note of variable page size here..... ILOG("SRAM size: %#x bytes (%d KiB), Flash: %#x bytes (%d KiB) in pages of %u bytes\n", sl->sram_size, sl->sram_size / 1024, sl->flash_size, sl->flash_size / 1024, - (unsigned int)sl->flash_pgsz); + (unsigned int)sl->flash_pgsz); #else ILOG("%s: %d KiB SRAM, %d KiB flash in %d %s pages.\n", - params->description, sl->sram_size / 1024, sl->flash_size / 1024, - (sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024, - (sl->flash_pgsz < 1024)? "byte" : "KiB"); + params->description, sl->sram_size / 1024, sl->flash_size / 1024, + (sl->flash_pgsz < 1024)? sl->flash_pgsz : sl->flash_pgsz/1024, + (sl->flash_pgsz < 1024)? "byte" : "KiB"); #endif return 0; } @@ -1285,9 +1285,9 @@ int stlink_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data) { ret = sl->backend->read_debug32(sl, addr, data); if (!ret) - DLOG("*** stlink_read_debug32 %x is %#x\n", *data, addr); + DLOG("*** stlink_read_debug32 %x is %#x\n", *data, addr); - return ret; + return ret; } int stlink_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data) { @@ -1955,7 +1955,7 @@ uint32_t calculate_F4_sectornum(uint32_t flashaddr){ uint32_t calculate_F7_sectornum(uint32_t flashaddr){ flashaddr &= ~STM32_FLASH_BASE; //Page now holding the actual flash address - if (flashaddr<0x20000) return(flashaddr/0x8000); + if (flashaddr<0x20000) return(flashaddr/0x8000); else if (flashaddr<0x40000) return(4); else return(flashaddr/0x40000) +4; @@ -2347,7 +2347,7 @@ int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, stlink_read_mem32(sl, address + (uint32_t) off, aligned_size); if (memcmp(sl->q_buf, data + off, cmp_size)) { - ELOG("Verification of flash failed at offset: %u\n", (unsigned int)off); + ELOG("Verification of flash failed at offset: %u\n", (unsigned int)off); return -1; } } @@ -2521,7 +2521,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t /* set programming mode */ set_flash_cr_pg(sl); - size_t buf_size = (sl->sram_size > 0x8000) ? 0x8000 : 0x4000; + size_t buf_size = (sl->sram_size > 0x8000) ? 0x8000 : 0x4000; for (off = 0; off < len;) { size_t size = len - off > buf_size ? buf_size : len - off; @@ -2642,7 +2642,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t if ((off % sl->flash_pgsz) > (sl->flash_pgsz -5)) { fprintf(stdout, "\r%3u/%3u pages written", (unsigned int)(off/sl->flash_pgsz), - (unsigned int)(len/sl->flash_pgsz)); + (unsigned int)(len/sl->flash_pgsz)); fflush(stdout); } @@ -3236,8 +3236,8 @@ int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte) */ int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte) { - WLOG("About to write option byte %#10x to target.\n", option_byte); - return stlink_write_option_bytes(sl, sl->option_base, (uint8_t *) &option_byte, 4); + WLOG("About to write option byte %#10x to target.\n", option_byte); + return stlink_write_option_bytes(sl, sl->option_base, (uint8_t *) &option_byte, 4); } /** From f29e1a6a03733cc8839f297d264a5168bd4e0361 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 21 Apr 2020 10:49:00 +0200 Subject: [PATCH 164/236] common: warn on unsupported access. should only happen currently after adding a new flash family. --- src/common.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/common.c b/src/common.c index e0c5fde2a..c124e6091 100644 --- a/src/common.c +++ b/src/common.c @@ -391,6 +391,7 @@ static inline unsigned int is_flash_locked(stlink_t *sl) { cr_reg = STM32WB_FLASH_CR; cr_lock_shift = STM32WB_FLASH_CR_LOCK; } else { + ELOG("unsupported flash method, abort\n"); return -1; } @@ -425,6 +426,7 @@ static void unlock_flash(stlink_t *sl) { } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { key_reg = STM32WB_FLASH_KEYR; } else { + ELOG("unsupported flash method, abort\n"); return; } @@ -474,6 +476,7 @@ static void lock_flash(stlink_t *sl) { cr_reg = STM32WB_FLASH_CR; cr_lock_shift = STM32WB_FLASH_CR_LOCK; } else { + ELOG("unsupported flash method, abort\n"); return; } @@ -521,6 +524,7 @@ static bool is_flash_option_locked(stlink_t *sl) { optlock_shift = STM32WB_FLASH_CR_OPTLOCK; break; default: + ELOG("unsupported flash method, abort\n"); return -1; } @@ -564,8 +568,8 @@ static int lock_flash_option(stlink_t *sl) { optcr_reg = STM32WB_FLASH_CR; optlock_shift = STM32WB_FLASH_CR_OPTLOCK; break; - default: + ELOG("unsupported flash method, abort\n"); return -1; } @@ -612,6 +616,7 @@ static int unlock_flash_option(stlink_t *sl) break; default: + ELOG("unsupported flash method, abort\n"); return -1; } @@ -831,21 +836,23 @@ static void set_flash_cr2_strt(stlink_t *sl) { static inline uint32_t read_flash_sr(stlink_t *sl) { uint32_t res, sr_reg; - if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_F1_XL)) + if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_F1_XL)) { sr_reg = FLASH_SR; - else if (sl->flash_type == STLINK_FLASH_TYPE_L0) + } else if (sl->flash_type == STLINK_FLASH_TYPE_L0) { sr_reg = get_stm32l0_flash_base(sl) + FLASH_SR_OFF; - else if (sl->flash_type == STLINK_FLASH_TYPE_F4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_F4) { sr_reg = FLASH_F4_SR; - else if (sl->flash_type == STLINK_FLASH_TYPE_L4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_L4) { sr_reg = STM32L4_FLASH_SR; - else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || - sl->flash_type == STLINK_FLASH_TYPE_G4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || + sl->flash_type == STLINK_FLASH_TYPE_G4) { sr_reg = STM32Gx_FLASH_SR; - else if (sl->flash_type == STLINK_FLASH_TYPE_WB) + } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { sr_reg = STM32WB_FLASH_SR; - else + } else { + ELOG("unsupported flash method, abort"); return -1; + } stlink_read_debug32(sl, sr_reg, &res); @@ -862,19 +869,21 @@ static inline unsigned int is_flash_busy(stlink_t *sl) { uint32_t sr_busy_shift; unsigned int res; - if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_L0)) + if ((sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_F0) || (sl->flash_type == STLINK_FLASH_TYPE_L0)) { sr_busy_shift = FLASH_SR_BSY; - else if (sl->flash_type == STLINK_FLASH_TYPE_F4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_F4) { sr_busy_shift = FLASH_F4_SR_BSY; - else if (sl->flash_type == STLINK_FLASH_TYPE_L4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_L4) { sr_busy_shift = STM32L4_FLASH_SR_BSY; - else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || - sl->flash_type == STLINK_FLASH_TYPE_G4) + } else if (sl->flash_type == STLINK_FLASH_TYPE_G0 || + sl->flash_type == STLINK_FLASH_TYPE_G4) { sr_busy_shift = STM32Gx_FLASH_SR_BSY; - else if (sl->flash_type == STLINK_FLASH_TYPE_WB) + } else if (sl->flash_type == STLINK_FLASH_TYPE_WB) { sr_busy_shift = STM32WB_FLASH_SR_BSY; - else + } else { + ELOG("unsupported flash method, abort"); return -1; + } res = read_flash_sr(sl) & (1 << sr_busy_shift); From 8e69625531ec8f6def7a50a60a21f2aeffcd272a Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Tue, 21 Apr 2020 10:52:52 +0200 Subject: [PATCH 165/236] write option byte: final refactor now that all flash family methods are aligned, refactor main method to avoid duplicated lock/unlock, add info traces, and map methods based on familly instead of a small subset of selected devices. nb1: f0/f1 support is still missing nb2: option read/write is still conditioned by presence of option_base and option_size in chipid.c, but adding more chips should only be a matter of adding these two informations. --- src/common.c | 152 +++++++++++++++++++-------------------------------- 1 file changed, 55 insertions(+), 97 deletions(-) diff --git a/src/common.c b/src/common.c index c124e6091..f6cf08e2f 100644 --- a/src/common.c +++ b/src/common.c @@ -2971,27 +2971,14 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; - - (void) addr; + int ret = 0; (void) len; - wait_flash_busy(sl); - - if (unlock_flash_if(sl)) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - - if (unlock_flash_option_if(sl)) { - ELOG("Flash option unlock failed!\n"); - return -1; - } - /* Write options bytes */ uint32_t data; write_uint32((unsigned char*) &data, *(uint32_t*) (base)); WLOG("Writing option bytes %#10x to %#10x\n", data, addr); - //stlink_write_debug32(sl, addr, data); + stlink_write_debug32(sl, STM32Gx_FLASH_OPTR, data); /* Set Options Start bit */ @@ -2999,23 +2986,16 @@ static int stlink_write_option_bytes_gx(stlink_t *sl, uint8_t* base, stm32_addr_ val |= (1 << STM32Gx_FLASH_CR_OPTSTRT); stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); - /* Wait for 'busy' bit in FLASH_SR to clear. */ - do { - stlink_read_debug32(sl, STM32Gx_FLASH_SR, &val); - } while ((val & (1 << STM32Gx_FLASH_SR_BSY)) != 0); + wait_flash_busy(sl); - check_flash_error(sl); + ret = check_flash_error(sl); - /* apply options bytes immediate */ + /* Reload options */ stlink_read_debug32(sl, STM32Gx_FLASH_CR, &val); val |= (1 << STM32Gx_FLASH_CR_OBL_LAUNCH); stlink_write_debug32(sl, STM32Gx_FLASH_CR, val); - /* Re-lock flash. */ - lock_flash_option(sl); - lock_flash(sl); - - return 0; + return ret; } /** @@ -3030,18 +3010,7 @@ static int stlink_write_option_bytes_l0(stlink_t *sl, uint8_t* base, stm32_addr_ uint32_t flash_base = get_stm32l0_flash_base(sl); uint32_t val; uint32_t data; - - wait_flash_busy(sl); - - if (unlock_flash_if(sl)) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - - if (unlock_flash_option_if(sl)) { - ELOG("Flash option unlock failed!\n"); - return -1; - } + int ret = 0; /* Clear errors */ stlink_write_debug32(sl, flash_base + FLASH_SR_OFF, STM32L0_FLASH_REGS_ADDR); @@ -3055,7 +3024,7 @@ static int stlink_write_option_bytes_l0(stlink_t *sl, uint8_t* base, stm32_addr_ wait_flash_busy(sl); - if (check_flash_error(sl)) + if ((ret = check_flash_error(sl))) break; len-=4; @@ -3068,10 +3037,7 @@ static int stlink_write_option_bytes_l0(stlink_t *sl, uint8_t* base, stm32_addr_ val |= (1 << STM32L0_FLASH_OBL_LAUNCH); stlink_write_debug32(sl, flash_base + FLASH_PECR_OFF, val); - lock_flash_option(sl); - lock_flash(sl); - - return 0; + return ret; } /** @@ -3084,22 +3050,11 @@ static int stlink_write_option_bytes_l0(stlink_t *sl, uint8_t* base, stm32_addr_ static int stlink_write_option_bytes_l4(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t val; + int ret = 0; (void) addr; (void) len; - wait_flash_busy(sl); - - if (unlock_flash_if(sl)) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - - if (unlock_flash_option_if(sl)) { - ELOG("Flash option unlock failed!\n"); - return -1; - } - /* Write options bytes */ uint32_t data; write_uint32((unsigned char*) &data, *(uint32_t*) (base)); @@ -3114,18 +3069,14 @@ static int stlink_write_option_bytes_l4(stlink_t *sl, uint8_t* base, stm32_addr_ /* Wait for 'busy' bit in FLASH_SR to clear. */ wait_flash_busy(sl); - check_flash_error(sl); + ret = check_flash_error(sl); /* apply options bytes immediate */ stlink_read_debug32(sl, STM32L4_FLASH_CR, &val); val |= (1 << STM32L4_FLASH_CR_OBL_LAUNCH); stlink_write_debug32(sl, STM32L4_FLASH_CR, val); - /* Re-lock flash. */ - lock_flash_option(sl); - lock_flash(sl); - - return 0; + return ret; } @@ -3137,22 +3088,11 @@ static int stlink_write_option_bytes_l4(stlink_t *sl, uint8_t* base, stm32_addr_ */ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_t addr, uint32_t len) { uint32_t option_byte; + int ret = 0; (void) addr; (void) len; - wait_flash_busy(sl); - - if (unlock_flash_if(sl)) { - ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); - return -1; - } - - if (unlock_flash_option_if(sl)) { - ELOG("Flash option unlock failed!\n"); - return -1; - } - write_uint32((unsigned char*) &option_byte, *(uint32_t*) (base)); /* write option byte, ensuring we dont lock opt, and set strt bit */ @@ -3160,14 +3100,11 @@ static int stlink_write_option_bytes_f4(stlink_t *sl, uint8_t* base, stm32_addr_ wait_flash_busy(sl); - check_flash_error(sl); + ret = check_flash_error(sl); /* option bytes are reloaded at reset only, no obl. */ - lock_flash_option(sl); - lock_flash(sl); - - return 0; + return ret; } /** @@ -3258,6 +3195,8 @@ int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte) */ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len) { + int ret = -1; + if (sl->option_base == 0) { ELOG("Option bytes writing is currently not supported for connected chip\n"); return -1; @@ -3273,28 +3212,47 @@ int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, ui return -1; } - /* filter out on chip_id, until complete flash family are handled */ - switch (sl->chip_id) { - case STLINK_CHIPID_STM32_F2: - case STLINK_CHIPID_STM32_F446: - return stlink_write_option_bytes_f4(sl, base, addr, len); - case STLINK_CHIPID_STM32_L0_CAT2: - case STLINK_CHIPID_STM32_L0_CAT5: - case STLINK_CHIPID_STM32_L152_RE: - case STLINK_CHIPID_STM32_L1_HIGH: - return stlink_write_option_bytes_l0(sl, base, addr, len); - case STLINK_CHIPID_STM32_L496X: - case STLINK_CHIPID_STM32_L4: - return stlink_write_option_bytes_l4(sl, base, addr, len); - case STLINK_CHIPID_STM32_G0_CAT1: - case STLINK_CHIPID_STM32_G0_CAT2: - case STLINK_CHIPID_STM32_G4_CAT2: - case STLINK_CHIPID_STM32_G4_CAT3: - return stlink_write_option_bytes_gx(sl, base, addr, len); + wait_flash_busy(sl); + + if (unlock_flash_if(sl)) { + ELOG("Flash unlock failed! System reset required to be able to unlock it again!\n"); + return -1; + } + + if (unlock_flash_option_if(sl)) { + ELOG("Flash option unlock failed!\n"); + return -1; + } + + switch (sl->flash_type) { + case STLINK_FLASH_TYPE_F4: + ret = stlink_write_option_bytes_f4(sl, base, addr, len); + break; + case STLINK_FLASH_TYPE_L0: + ret = stlink_write_option_bytes_l0(sl, base, addr, len); + break; + case STLINK_FLASH_TYPE_L4: + ret = stlink_write_option_bytes_l4(sl, base, addr, len); + break; + case STLINK_FLASH_TYPE_G0: + case STLINK_FLASH_TYPE_G4: + ret = stlink_write_option_bytes_gx(sl, base, addr, len); + break; default: ELOG("Option bytes writing is currently not implemented for connected chip\n"); - return -1; + break; } + + if (ret) + ELOG("Flash option write failed!\n"); + else + ILOG("Wrote %d option bytes to %#010x!\n", len, addr); + + /* Re-lock flash. */ + lock_flash_option(sl); + lock_flash(sl); + + return ret; } /** From e9facddc3cd2243f663a69d429432a1695ab1051 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Wed, 22 Apr 2020 14:54:42 +0800 Subject: [PATCH 166/236] Add more note about flash page size --- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index 50f87f42c..a833ab0ea 100644 --- a/src/common.c +++ b/src/common.c @@ -2223,7 +2223,7 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t WLOG("unaligned len 0x%x -- padding with zero\n", len); len += 1; } else if (addr & (sl->flash_pgsz - 1)) { - ELOG("addr not a multiple of current pagesize (%zd bytes), not supported\n", sl->flash_pgsz); + ELOG("addr not a multiple of current pagesize (%zd bytes), not supported, check page start address and compare with flash module organisation in related ST reference manual of your device.\n", sl->flash_pgsz); return -1; } From ad0e52540e4003f05b7f6fa488e91c1d52c78df2 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Wed, 22 Apr 2020 10:57:45 +0200 Subject: [PATCH 167/236] doc: update doc to mention STLINK_DEVICE and --probe parameters if applicable in all man files --- doc/man/st-flash.md | 3 +++ doc/man/st-info.md | 3 +++ doc/man/st-util.md | 5 ++--- doc/tutorial.md | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/man/st-flash.md b/doc/man/st-flash.md index b787e8dd7..d5565e923 100644 --- a/doc/man/st-flash.md +++ b/doc/man/st-flash.md @@ -20,6 +20,9 @@ You can use this instead of st-util(1) if you prefer, but remember to use the Use hexadecimal format for the *ADDR* and *SIZE*. +The STLink device to use can be specified using the --serial parameter, or via +the environment variable STLINK_DEVICE on the format :. + # COMMANDS write *FILE* *ADDR* diff --git a/doc/man/st-info.md b/doc/man/st-info.md index ca2579785..94a430000 100644 --- a/doc/man/st-info.md +++ b/doc/man/st-info.md @@ -11,9 +11,12 @@ st-info - Provides information about connected STLink and STM32 devices # DESCRIPTION + Provides information about connected STLink programmers and STM32 devices: Serial code, OpenOCD hla-serial, flash, page size, sram, chipid, description. +The STLink device to probe can be specified via the environment variable +STLINK_DEVICE on the format :. # OPTIONS diff --git a/doc/man/st-util.md b/doc/man/st-util.md index e62261213..3582bc06d 100644 --- a/doc/man/st-util.md +++ b/doc/man/st-util.md @@ -18,9 +18,8 @@ If a port number is not specified using the **--listen_port** option, the default **4242** port will be used. Stlink version 2 is used by default unless the option **--stlinkv1** is given. - -The STLinkV2 device to use can be specified in the environment -variable STLINK_DEVICE on the format :. +The STLink device to use can be specified using the --serial parameter, or via +the environment variable STLINK_DEVICE on the format :. # OPTIONS diff --git a/doc/tutorial.md b/doc/tutorial.md index 75e03f1bc..2ff0188ce 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -285,8 +285,8 @@ There are a few options: Do not reset board on connection. ``` -The STLINKv2 device to use can be specified in the environment -variable `STLINK_DEVICE` in the format `:`. +The STLink device to use can be specified using the --serial parameter, or via +the environment variable STLINK_DEVICE on the format :. Then, in your project directory, someting like this... (remember, you need to run an _ARM_ gdb, not an x86 gdb) From 5e0fd8b61c81f47f40592f9844b0f4507069137d Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Wed, 22 Apr 2020 11:00:27 +0200 Subject: [PATCH 168/236] doc: remove stlink version parameter selectors doc and examples --- doc/man/st-util.md | 7 ------- doc/tutorial.md | 25 ++++++------------------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/doc/man/st-util.md b/doc/man/st-util.md index 3582bc06d..9a54fb309 100644 --- a/doc/man/st-util.md +++ b/doc/man/st-util.md @@ -17,7 +17,6 @@ Run the main binary of the local package (src/main.rs). If a port number is not specified using the **--listen_port** option, the default **4242** port will be used. -Stlink version 2 is used by default unless the option **--stlinkv1** is given. The STLink device to use can be specified using the --serial parameter, or via the environment variable STLINK_DEVICE on the format :. @@ -35,12 +34,6 @@ the environment variable STLINK_DEVICE on the format :. -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) diff --git a/doc/tutorial.md b/doc/tutorial.md index 2ff0188ce..929aa3250 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -168,18 +168,14 @@ will help you verify that: - Your arm-none-eabi-gdb is functional - Your board is functional -A GDB server must be started to interact with the STM32. Depending on -the discovery kit you are using, you must run one of the 2 commands: +A GDB server must be started to interact with the STM32 by running +st-util tool : ``` -# STM32VL discovery kit (onboard ST-link) -$> ./st-util --stlinkv1 - -# STM32L or STM32F4 discovery kit (onboard ST-link/V2) -$> ./st-util +$> st-util # Full help for other options (listen port, version) -$> ./st-util --help +$> st-util --help ``` Then, GDB can be used to interact with the kit: @@ -226,16 +222,10 @@ memory, or read arbitary addresses of memory out to a binary file, use the st-flash tool, as shown below: ``` -# stlinkv1 command to read 4096 from flash into out.bin -$> ./st-flash read out.bin 0x8000000 4096 - -# stlinkv2 command +# stlink command to read 4096 from flash into out.bin $> ./st-flash read out.bin 0x8000000 4096 -# stlinkv1 command to write the file in.bin into flash -$> ./st-flash write in.bin 0x8000000 - -# stlinkv2 command +# stlinkv command to write the file in.bin into flash $> ./st-flash write in.bin 0x8000000 ``` @@ -273,9 +263,6 @@ There are a few options: -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 From 5db2dc4c0410ace65308cddcc03d1c0cfa4855cf Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 23 Apr 2020 11:03:15 +0200 Subject: [PATCH 169/236] cmake replaces 7zip for package extraction The exctraction of the libusb library archive on windows no longer requires an external unarchiver. --- cmake/modules/Find7zip.cmake | 7 ------- cmake/modules/Findlibusb.cmake | 17 +++++------------ 2 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 cmake/modules/Find7zip.cmake diff --git a/cmake/modules/Find7zip.cmake b/cmake/modules/Find7zip.cmake deleted file mode 100644 index 83eb912d4..000000000 --- a/cmake/modules/Find7zip.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Find7zip.cmake -# Detect 7zip file archiver on Windows systems to extract (zip-)archives - -find_program( - ZIP_EXECUTABLE NAMES 7z.exe p7zip - HINTS "C:\\Program Files\\7-Zip\\" "C:\\Program Files (x86)\\7-Zip\\" -) diff --git a/cmake/modules/Findlibusb.cmake b/cmake/modules/Findlibusb.cmake index 13f70d7b7..898820033 100644 --- a/cmake/modules/Findlibusb.cmake +++ b/cmake/modules/Findlibusb.cmake @@ -73,7 +73,6 @@ elseif (WIN32) # Windows if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") # Preparations for installing libusb library - find_package(7zip REQUIRED) set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version set(LIBUSB_WIN_ARCHIVE libusb-${LIBUSB_WIN_VERSION}.7z) set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) @@ -92,17 +91,11 @@ elseif (WIN32) # Windows file(MAKE_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER}) - # 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} - ) # <-- Note the absence of a space character following the -o option! - endif () + # Extract libusb package with cmake + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xv ${LIBUSB_WIN_ARCHIVE_PATH} + WORKING_DIRECTORY ${LIBUSB_WIN_OUTPUT_FOLDER} + ) # Find path to libusb library FIND_PATH( From 39f22639ef461d5cd082e07df67d16de3082d9e3 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 23 Apr 2020 11:04:38 +0200 Subject: [PATCH 170/236] Updated license file for deb package --- LICENSE.md | 2 +- cmake/packaging/debian/copyright | 321 +++++++++++++++---------------- 2 files changed, 153 insertions(+), 170 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 9c3b59f0f..4cb795b18 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2020, The stlink project (github.com/stlink-org/stlink) & "Capt'ns Missing Link" authors. +Copyright (c) 2020, stlink-org All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/cmake/packaging/debian/copyright b/cmake/packaging/debian/copyright index 7a6d585c5..4a7b110ae 100644 --- a/cmake/packaging/debian/copyright +++ b/cmake/packaging/debian/copyright @@ -2,173 +2,156 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: stlink Upstream-Contact: Luca Bocassi Source: https://github.com/stlink-org/stlink - -Files: * -Copyright: 2011-2018 agpanarin - 2011-2018 Alexey Cherevatenko - 2011-2018 Anatoli - 2011-2018 Andrea Mucignat - 2011-2018 Andrew 'Necromant' Andrianov - 2011-2018 Andrey Yurovsky - 2011-2018 Andy Isaacson - 2011-2018 Áron RADICS - 2011-2018 A Sheaff - 2011-2018 Björn Hauffe - 2011-2018 bob - 2011-2018 Breton M. Saunders - 2011-2018 Bruno Dal Bo - 2011-2018 Burns - 2011-2018 Chris Dew - 2011-2018 Chris Hiszpanski - 2011-2018 Chris Li - 2011-2018 Chris Samuelson - 2011-2018 Christophe Levantis - 2011-2018 Craig Lilley - 2011-2018 dandev37 - 2011-2018 Dan Hepler - 2011-2018 Daniel Campoverde [alx741] - 2011-2018 Daniel O'Connor - 2011-2018 Dave Flogeras - 2011-2018 Dave Murphy - 2011-2018 Dave Vandervies - 2011-2018 Denis Fokin - 2011-2018 Denis Osterland - 2011-2018 Dmitry Bravikov - 2011-2018 Efe Can İçöz - 2011-2018 Ethan Zonca - 2011-2018 Fabien Chouteau - 2011-2018 Fabien Le Mentec - 2011-2018 fhars - 2011-2018 Friedrich Beckmann - 2011-2018 Geoffrey Brown - 2011-2018 George Talusan - 2011-2018 Georg von Zengen - 2011-2018 giuseppe barba - 2011-2018 Greg Alexander - 2011-2018 Greg Meiste - 2011-2018 Hakkavélin - 2011-2018 htk - 2011-2018 Ian Griffiths <6thimage@gmail.com> - 2011-2018 Jack Peel - 2011-2018 Jakub Tyszkowski - 2011-2018 Jan Sarenik - 2011-2018 Jean-Luc Béchennec - 2011-2018 Jean-Marie Lemetayer - 2011-2018 Jeff Kent - 2011-2018 Jeffrey Nelson - 2011-2018 Jens Hoffmann - 2011-2018 Jerome Lambourg - 2011-2018 Jerry Jacobs - 2011-2018 Jim Paris - 2011-2018 Jiří Netolický - 2011-2018 jnosky - 2011-2018 jnosky - 2011-2018 JohannesTaelman - 2011-2018 Jonas Danielsson - 2011-2018 Jonas Norling - 2011-2018 Josh Bialkowski - 2011-2018 Karl Palsson - 2011-2018 kevin - 2011-2018 Kyle Manna - 2011-2018 Lari Lehtomäki - 2011-2018 le mentec fabien - 2011-2018 Martin Nowak - 2011-2018 Matteo Collina - 2011-2018 Max Chen - 2011-2018 Maxime Coquelin - 2011-2018 Maxime Vincent - 2011-2018 Michael Pratt - 2011-2018 Michael Sparmann - 2011-2018 Mike Szczys - 2011-2018 mlundinse - 2011-2018 mux - 2011-2018 Ned Konz - 2011-2018 Nic McDonald - 2011-2018 Nicolas Schodet - 2011-2018 Nikolay - 2011-2018 nullsub - 2011-2018 Olivier Croquette - 2011-2018 Olivier Gay - 2011-2018 Onno Kortmann - 2011-2018 orangeudav - 2011-2018 Pavel Kirienko - 2011-2018 Pekka Nikander - 2011-2018 Pete - 2011-2018 Peter Zotov - 2011-2018 Petteri Aimonen - 2011-2018 Piotr Haber - 2011-2018 Rene Hopf - 2011-2018 Robin Kreis - 2011-2018 Rob Spanton - 2011-2018 Rytis Karpuska - 2011-2018 Sean Simmons - 2011-2018 Sergey Alirzaev - 2011-2018 Simon Wright - 2011-2018 Stany MARCEL - 2011-2018 Stefan Misik - 2011-2018 Sven Wegener - 2011-2018 Tectu - 2011-2018 tekaikko - 2011-2018 texane - 2011-2018 Theodore A. Roth - 2011-2018 Thomas Gärtner - 2011-2018 Tobias Badertscher - 2011-2018 Tom de Boer - 2011-2018 Tristan Gingold - 2011-2018 Uli Köhler - 2011-2018 Uwe Bonnes - 2011-2018 Vadim Kaushan - 2011-2018 Vegard Storheil Eriksen - 2011-2018 Viacheslav Dobromyslov - 2011-2018 Victor Mayoral Vilches - 2011-2018 Wojciech A. Koszek - 2011-2018 Woodrow Douglass - 2011-2018 The "Capt'ns Missing Link" Authors. +Disclaimer: +Comment: License: BSD-3-clause - 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 Intel Corporation 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. - -Files: flashloaders/stm32l0x.s - flashloaders/stm32lx.s -Copyright: 2010 Spencer Oliver - 2011 Øyvind Harboe - 2011 Clement Burin des Roziers -License: GPL-2+ - This package is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program. If not, see - . - On Debian systems, the complete text of the GNU General - Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. 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. + 3. Neither the name of the copyright holder 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 HOLDER 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. +Files: * +Copyright: 2011-2020 stlink-org + Martin Capitanio [capnm] + Fabien Le Mentec [texane] + Jerry Jacobs [xor-gate] + [Nightwalker-87] + . + Alexey Cherevatenko + Alexey Panarin + Anatoli Klassen [dev26th] + Andrea Mucignat + Andrew Andrianov [necromant] + Andrey Yurovsky + Andy Isaacson + Áron Radics + A. Sheaff + Björn Hauffe + Ihor Bobalo + Breton M. Saunders + Bruno Dal Bo + Burns Fisher + Chris Dew + Chris Hiszpanski + Chris Li + Chris Samuelson + Christian Deussen [nullsub] + Christophe Levantis + Craig Lilley + Dan Dev + Dan Hepler + Daniel Campoverde [alx741] + Daniel O'Connor + Dave Flogeras + Dave Murphy [WinterMute] + Dave Vandervies [dj3vande] + Denis Fokin + Denis Osterland + Dmitry Bravikov [bravikov] + Efe Can İçöz + Ethan Zonca + Fabien Chouteau + Florian Hars + Friedrich Beckmann + Geoffrey Brown + George Talusan [gtalusan] + Georg von Zengen + Giuseppe Barba + Greg Alexander [galexander1] + Greg Meiste [meisteg] + Guillaume Revaillot [grevaillot] + Hakkavélin + Halt Hammerzeit + htk + Ian Griffiths + Jack Peel + Jakub Tyszkowski + Jan Sarenik + Jean-Luc Béchennec + Jean-Marie Lemetayer + Jeff Kent + Jeffrey Nelson + Jens Hoffmann + Jerome Lambourg + Jim Paris + Jiří Netolický + Jerry Nosky [jnosky] + Johannes Taelman + Jonas Danielsson + Jonas Norling + Josh Bialkowski + Karl Palsson [karlp] + Kevlar Harness + Kyle Manna + Lari Lehtomäki + Martin Nowak + Matteo Collina + Max Chen + Maxime Coquelin [mcoquelin-stm32] + Maxime Vincent + Michael Pratt [prattmic] + Michael Sparmann + Mike Szczys + Magnus Lundin [mlu] + mux + Ned Konz + Nic McDonald + Nicolas Schodet + Oleksiy Slyshyk [slyshykO] + Olivier Croquette + Olivier Gay + Onno Kortmann + orangeudav + Pavel Kirienko + Pekka Nikander + Pete Nelson + Peter Zotov + Petteri Aimonen + Piotr Haber + Rene Hopf [rene-dev] + Robin Kreis + Roger Wolff [rewolff] + Rob Spanton + Rytis Karpuska + Sean Simmons + Sergey Alirzaev + Simon Wright + Stany Marcel + Stefan Misik + Sven Wegener + Joel Bodenmann [Tectu] + Tuomo Kaikkonen + Theodore A. Roth + Thomas Gärtner + Tobias Badertscher + Tom de Boer + Tristan Gingold + Uli Köhler + Uwe Bonnes [UweBonnes] + Vadim Kaushan + Vasiliy Glazov [Vascom] + Vegard Storheil Eriksen + Viacheslav Dobromyslov + Victor Mayoral Vilches + William Ransohoff [WRansohoff] + Wojciech A. Koszek + Woodrow Douglass + Xim [chenguokai] + ... and others From 3e3f782e5e4e98570c41e9f139e8d07c743e311a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 23 Apr 2020 22:52:00 +0200 Subject: [PATCH 171/236] Updated pkgconfig (Closes #944) --- CMakeLists.txt | 2 +- cmake/pkgconfig/CMakeLists.txt | 15 +++++++++++++++ .../pkgconfig/pkgconfig.pc.cmake | 9 +++++---- debian/pkg-config/CMakeLists.txt | 15 --------------- 4 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 cmake/pkgconfig/CMakeLists.txt rename debian/pkg-config/pkg-config.pc.cmake => cmake/pkgconfig/pkgconfig.pc.cmake (99%) delete mode 100644 debian/pkg-config/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index fd79ac10e..3ec381239 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,7 @@ endif () find_package(libusb REQUIRED) if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) + add_subdirectory(cmake/pkgconfig) find_package(PkgConfig) pkg_check_modules(GTK3 gtk+-3.0) endif () @@ -269,7 +270,6 @@ add_subdirectory(tests) add_subdirectory(cmake/packaging) include(cmake/packaging/cpack_config.cmake) - ### # Uninstall target ### diff --git a/cmake/pkgconfig/CMakeLists.txt b/cmake/pkgconfig/CMakeLists.txt new file mode 100644 index 000000000..53870fee4 --- /dev/null +++ b/cmake/pkgconfig/CMakeLists.txt @@ -0,0 +1,15 @@ +set(PKG_CONFIG_LIBDIR "\${prefix}/lib/\${deb_host_multiarch}") +set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/\${deb_host_multiarch}/${PROJECT_NAME}") +set(PKG_CONFIG_LIBS "-L\${libdir} -l:libstlink.so.${PROJECT_VERSION_MAJOR}") +set(PKG_CONFIG_CFLAGS "-I\${includedir}") +set(PKG_CONFIG_REQUIRES "libusb-1.0") + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.pc.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" + ) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" + DESTINATION ${STLINK_LIBRARY_PATH}/pkgconfig + ) diff --git a/debian/pkg-config/pkg-config.pc.cmake b/cmake/pkgconfig/pkgconfig.pc.cmake similarity index 99% rename from debian/pkg-config/pkg-config.pc.cmake rename to cmake/pkgconfig/pkgconfig.pc.cmake index c00eb070e..4f881daec 100644 --- a/debian/pkg-config/pkg-config.pc.cmake +++ b/cmake/pkgconfig/pkgconfig.pc.cmake @@ -1,10 +1,11 @@ +prefix=${CMAKE_INSTALL_PREFIX} deb_host_multiarch=${CMAKE_LIBRARY_PATH} +libdir=${PKG_CONFIG_LIBDIR} +includedir=${PKG_CONFIG_INCLUDEDIR} + Name: ${PROJECT_NAME} Description: ${PROJECT_DESCRIPTION} Version: ${PROJECT_VERSION} -Requires: ${PKG_CONFIG_REQUIRES} -prefix=${CMAKE_INSTALL_PREFIX} -includedir=${PKG_CONFIG_INCLUDEDIR} -libdir=${PKG_CONFIG_LIBDIR} Libs: ${PKG_CONFIG_LIBS} Cflags: ${PKG_CONFIG_CFLAGS} +Requires: ${PKG_CONFIG_REQUIRES} diff --git a/debian/pkg-config/CMakeLists.txt b/debian/pkg-config/CMakeLists.txt deleted file mode 100644 index fa3a326a8..000000000 --- a/debian/pkg-config/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -#set(PKG_CONFIG_LIBDIR "\${prefix}/lib/\${deb_host_multiarch}") -#set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/\${deb_host_multiarch}/${PROJECT_NAME}") -#set(PKG_CONFIG_LIBS "-L\${libdir} -l:libstlink.so.${PROJECT_VERSION_MAJOR}") -#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" -# ) - -#install( -# FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" -# DESTINATION ${STLINK_LIBRARY_PATH}/debian/ -# ) From 22f44856abe4f272f33c48a31c7167e3b45dd0ab Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 24 Apr 2020 01:08:02 +0200 Subject: [PATCH 172/236] Updated compiling manual - Removed requirement for 7zip on Windows - Added note on GNUInstallDir presets (#557) --- doc/compiling.md | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/doc/compiling.md b/doc/compiling.md index 15d8b4fc2..38e680f03 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -5,25 +5,23 @@ On Windows users should ensure that the following software is installed: -* `7zip` -* `git` +* `git` (_optional, but recommended_) * `cmake` (3.17.0 or later) * `MinGW-w64` (7.0.0 or later) with GCC toolchain 8.1.0 ### Installation -1. Install `7zip` from -2. Install `git` from -3. Install `cmake` from
+1. Install `git` from +2. Install `cmake` from
Ensure that you add cmake to the $PATH system variable when following the instructions by the setup assistant. -4. Install +3. Install - _EITHER_: **MinGW-w64** from (mingw-w64-install.exe)
- _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/stlink-org/stlink.git`from the command-line (cmd.exe)
+4. Create a new destination folder at a place of your choice +5. Open the command-line (cmd.exe) and execute `cd C:\$Path-to-your-destination-folder$\` +6. Fetch the project sourcefiles by running `git clone https://github.com/stlink-org/stlink.git`from the command-line (cmd.exe)
or download the stlink zip-sourcefolder from the Release page on GitHub @@ -201,10 +199,22 @@ To do this with only one simple command, type: 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 +## Build options +### 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" ..`. +### Standard installation directories + +The cmake build system of this toolset includes `GNUInstallDirs` to define GNU standard installation directories. +This module provides install directory variables as defined by the GNU Coding Standards. + +Below are the preset default cmake options, which apply if none of these options are redefined: + +* `-DCMAKE_INSTALL_SYSCONFDIR=/etc` +* `-DCMAKE_INSTALL_PREFIX=/usr/local` + + Author: nightwalker-87 From 44e2a4fdbd3ad4398ab483c27275ea86540c31b6 Mon Sep 17 00:00:00 2001 From: xp Date: Fri, 24 Apr 2020 13:45:00 +0800 Subject: [PATCH 173/236] rewrite as clean room doc --- flashloaders/stm32f0.s | 85 +++++++++++++++++++++++++--------------- flashloaders/stm32f4.s | 53 +++++++++++++------------ flashloaders/stm32f4lv.s | 54 +++++++++++++------------ flashloaders/stm32f7.s | 65 ++++++++++++++++-------------- flashloaders/stm32f7lv.s | 66 ++++++++++++++++--------------- flashloaders/stm32l0x.s | 74 +++++++--------------------------- flashloaders/stm32l4.s | 60 ++++++++++++++-------------- flashloaders/stm32lx.s | 70 +++++++-------------------------- 8 files changed, 238 insertions(+), 289 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index fe12f90f3..885353912 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -1,32 +1,53 @@ -/* Adopted from STM AN4065 stm32f0xx_flash.c:FLASH_ProgramWord */ - -write: - ldr r4, STM32_FLASH_BASE - mov r5, #1 /* FLASH_CR_PG, FLASH_SR_BUSY */ - mov r6, #4 /* PGERR */ -write_half_word: - ldr r3, [r4, #16] /* FLASH->CR */ - orr r3, r5 - str r3, [r4, #16] /* FLASH->CR |= FLASH_CR_PG */ - ldrh r3, [r0] /* r3 = *sram */ - strh r3, [r1] /* *flash = r3 */ -busy: - ldr r3, [r4, #12] /* FLASH->SR */ - tst r3, r5 /* FLASH_SR_BUSY */ - beq busy - - tst r3, r6 /* PGERR */ - bne exit - - add r0, r0, #2 /* sram += 2 */ - add r1, r1, #2 /* flash += 2 */ - sub r2, r2, #0x01 /* count-- */ - cmp r2, #0 - bne write_half_word -exit: - ldr r3, [r4, #16] /* FLASH->CR */ - bic r3, r5 - str r3, [r4, #16] /* FLASH->CR &= ~FLASH_CR_PG */ - bkpt #0x00 - -STM32_FLASH_BASE: .word 0x40022000 + .syntax unified + .text + + .global mycopy +mycopy: + ldr r12, flash_base + ldr r11, flash_off_cr + add r11, r11, r12 + ldr r10, flash_off_sr + add r10, r10, r12 + +myloop: + # FLASH_CR ^= 1 + ldr r3, [r11] + orr r3, r3, #0x1 + str r3, [r11] + + # copy 2 bytes + ldrh r3, [r0] + strh r3, [r1] + + add r0, r0, #2 + add r1, r1, #2 + + # wait if FLASH_SR == 1 +mywait: + ldr r3, [r10] + tst r3, #0x1 + beq mywait + + # exit if FLASH_SR == 4 + tst r3, #0x4 + beq myexit + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop + +myexit: + # FLASH_CR &= ~1 + ldr r3, [r11] + bic r3, r3, #0x1 + str r3, [r11] + + bkpt + +flash_base: + .word 0x40022000 +flash_off_cr: + .word 0x10 +flash_off_sr: + .word 0x0c diff --git a/flashloaders/stm32f4.s b/flashloaders/stm32f4.s index 21f5a8f7f..a47054dae 100644 --- a/flashloaders/stm32f4.s +++ b/flashloaders/stm32f4.s @@ -1,32 +1,35 @@ -.global start -.syntax unified + .syntax unified + .text -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 -start: - ldr r3, flash_base -next: - cbz r2, done - ldr r4, [r0] - str r4, [r1] +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait + add r0, r0, #4 + add r1, r1, #4 - add r0, #4 - add r1, #4 - sub r2, #1 - b next -done: - bkpt + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop -.align 2 +myexit: + bkpt flash_base: - .word 0x40023c00 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index f60ee8797..cfbbe8520 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -1,33 +1,35 @@ -.global start -.syntax unified + .syntax unified + .text -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 -start: - lsls r2, r2, #2 - ldr r3, flash_base -next: - cbz r2, done - ldrb r4, [r0] - strb r4, [r1] +myloop: + # copy 1 bytes + ldrb r3, [r0] + strb r3, [r1] -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait + add r0, r0, #1 + add r1, r1, #1 - add r0, #1 - add r1, #1 - sub r2, #1 - b next -done: - bkpt + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop -.align 2 +myexit: + bkpt flash_base: - .word 0x40023c00 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32f7.s b/flashloaders/stm32f7.s index 0334c80a0..f873f0ebd 100644 --- a/flashloaders/stm32f7.s +++ b/flashloaders/stm32f7.s @@ -1,33 +1,38 @@ -.global start -.syntax unified - -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp - -start: - ldr r3, flash_base -next: - cbz r2, done - ldr r4, [r0] - str r4, [r1] - dsb sy - -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait - - add r0, #4 - add r1, #4 - sub r2, #1 - b next -done: - bkpt + .syntax unified + .text + + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 + +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] + + add r0, r0, #4 + add r1, r1, #4 -.align 2 + # memory barrier + dsb sy + + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop + +myexit: + bkpt flash_base: - .word 0x40023c00 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index 650922719..fe5be0529 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -1,34 +1,38 @@ -.global start -.syntax unified - -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp - -start: - lsls r2, r2, #2 - ldr r3, flash_base -next: - cbz r2, done - ldrb r4, [r0] - strb r4, [r1] - dsb sy - -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait - - add r0, #1 - add r1, #1 - sub r2, #1 - b next -done: - bkpt + .syntax unified + .text + + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 + +myloop: + # copy 1 byte + ldrb r3, [r0] + strb r3, [r1] + + add r0, r0, #1 + add r1, r1, #1 -.align 2 + # memory barrier + dsb sy + + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop + +myexit: + bkpt flash_base: - .word 0x40023c00 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32l0x.s b/flashloaders/stm32l0x.s index fcbd06e39..1ce7dd144 100644 --- a/flashloaders/stm32l0x.s +++ b/flashloaders/stm32l0x.s @@ -1,64 +1,20 @@ -/*************************************************************************** - * Copyright (C) 2010 by Spencer Oliver * - * spen@spen-soft.co.uk * - * * - * Copyright (C) 2011 Øyvind Harboe * - * oyvind.harboe@zylin.com * - * * - * Copyright (C) 2011 Clement Burin des Roziers * - * clement.burin-des-roziers@hikob.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -// Build : arm-eabi-gcc -c stm32lx.S - .text .syntax unified - .cpu cortex-m0plus - .thumb - .thumb_func - .global write - -/* - r0 - source address - r1 - destination address - r2 - count -*/ + .text - // Go to compare - b test_done + .global mycopy +mycopy: +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] -write_word: - // Load one word from address in r0, increment by 4 - ldr r4, [r0] - // Store the word to address in r1, increment by 4 - str r4, [r1] - // Decrement r2 - subs r2, #1 - adds r1, #4 - // does not matter, only first addr is important - // next 15 bytes are in sequnce RM0367 page 66 - adds r0, #4 + add r0, r0, #4 + add r1, r1, #4 -test_done: - // Test r2 - cmp r2, #0 - // Loop if not zero - bcc.n write_word + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop - // Set breakpoint to exit - bkpt #0x00 +myexit: + bkpt diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index 6aa2be050..0a68b687a 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -1,39 +1,37 @@ -.global start -.syntax unified + .syntax unified + .text -@ Adapted from stm32f4.s -@ STM32L4's flash controller expects double-word writes, has the flash -@ controller mapped in a different location with the registers we care about -@ moved down from the base address, and has BSY moved to bit 16 of SR. -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp -@ r5 = temp + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_bsy + add r10, r10, r12 -start: - ldr r3, flash_base -next: - cbz r2, done - ldr r4, [r0] /* copy doubleword from source to target */ - ldr r5, [r0, #4] - str r4, [r1] - str r5, [r1, #4] +myloop: + # copy 8 bytes + ldr r3, [r0] + ldr r3, [r0, #4] + str r3, [r1] + str r3, [r1, #4] -wait: - ldrh r4, [r3, #0x12] /* high half of status register */ - tst r4, #1 /* BSY = bit 16 */ - bne wait + add r0, r0, #8 + add r1, r1, #8 - add r0, #8 - add r1, #8 - sub r2, #1 - b next -done: - bkpt + # wait if FLASH_BSY[0b] == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop -.align 2 +myexit: + bkpt flash_base: .word 0x40022000 +flash_off_bsy: + .word 0x12 diff --git a/flashloaders/stm32lx.s b/flashloaders/stm32lx.s index 10e5644bf..1ce7dd144 100644 --- a/flashloaders/stm32lx.s +++ b/flashloaders/stm32lx.s @@ -1,60 +1,20 @@ -/*************************************************************************** - * Copyright (C) 2010 by Spencer Oliver * - * spen@spen-soft.co.uk * - * * - * Copyright (C) 2011 Øyvind Harboe * - * oyvind.harboe@zylin.com * - * * - * Copyright (C) 2011 Clement Burin des Roziers * - * clement.burin-des-roziers@hikob.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -// Build : arm-eabi-gcc -c stm32lx.s - .text .syntax unified - .cpu cortex-m3 - .thumb - .thumb_func - .global write - -/* - r0 - source address - r1 - destination address - r2 - output, remaining word count -*/ + .text - // Go to compare - b test_done + .global mycopy +mycopy: +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] -write_word: - // Load one word from address in r0, increment by 4 - ldr.w ip, [r0], #4 - // Store the word to address in r1, increment by 4 - str.w ip, [r1], #4 - // Decrement r2 - subs r2, #1 + add r0, r0, #4 + add r1, r1, #4 -test_done: - // Test r2 - cmp r2, #0 - // Loop if not zero - bhi write_word + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop - // Set breakpoint to exit - bkpt #0x00 +myexit: + bkpt From 14518803dd2dbdaf15a1cd3e9216b6f0a919aeeb Mon Sep 17 00:00:00 2001 From: xp Date: Fri, 24 Apr 2020 14:31:52 +0800 Subject: [PATCH 174/236] bugfix --- flashloaders/stm32l4.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index 0a68b687a..79abac0d4 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -10,9 +10,9 @@ mycopy: myloop: # copy 8 bytes ldr r3, [r0] - ldr r3, [r0, #4] + ldr r4, [r0, #4] str r3, [r1] - str r3, [r1, #4] + str r4, [r1, #4] add r0, r0, #8 add r1, r1, #8 From 43085438f2c674d2fa3506dcb698930b87b71432 Mon Sep 17 00:00:00 2001 From: xp Date: Fri, 24 Apr 2020 16:39:56 +0800 Subject: [PATCH 175/236] update --- flashloaders/stm32f0.s | 58 +++++++++++++++++++++++----------------- flashloaders/stm32f4.s | 11 ++++---- flashloaders/stm32f4lv.s | 11 ++++---- flashloaders/stm32f7.s | 11 ++++---- flashloaders/stm32f7lv.s | 11 ++++---- flashloaders/stm32l0x.s | 8 +++--- flashloaders/stm32l4.s | 15 ++++++----- flashloaders/stm32lx.s | 8 +++--- 8 files changed, 76 insertions(+), 57 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index 885353912..1adeada05 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -1,53 +1,63 @@ .syntax unified .text +flash_base: + .align 2 + .word 0x40022000 +flash_off_cr: + .word 0x10 +flash_off_sr: + .word 0x0c + .global mycopy mycopy: - ldr r12, flash_base - ldr r11, flash_off_cr - add r11, r11, r12 - ldr r10, flash_off_sr - add r10, r10, r12 + ldr r7, =flash_base + ldr r4, [r7] + ldr r7, =flash_off_cr + ldr r6, [r7] + adds r6, r6, r4 + ldr r7, =flash_off_sr + ldr r5, [r7] + adds r5, r5, r4 myloop: # FLASH_CR ^= 1 - ldr r3, [r11] - orr r3, r3, #0x1 - str r3, [r11] + ldr r7, =0x1 + ldr r3, [r6] + orrs r3, r3, r7 + str r3, [r6] # copy 2 bytes ldrh r3, [r0] strh r3, [r1] - add r0, r0, #2 - add r1, r1, #2 + ldr r7, =2 + adds r0, r0, r7 + adds r1, r1, r7 # wait if FLASH_SR == 1 mywait: - ldr r3, [r10] - tst r3, #0x1 + ldr r7, =0x1 + ldr r3, [r5] + tst r3, r7 beq mywait # exit if FLASH_SR == 4 - tst r3, #0x4 + ldr r7, =0x4 + tst r3, r7 beq myexit # loop if r2 != 0 - sub r2, r2, #1 + ldr r7, =0x1 + subs r2, r2, r7 cmp r2, #0 bne myloop myexit: # FLASH_CR &= ~1 - ldr r3, [r11] - bic r3, r3, #0x1 - str r3, [r11] + ldr r7, =0x1 + ldr r3, [r6] + bics r3, r3, r7 + str r3, [r6] bkpt - -flash_base: - .word 0x40022000 -flash_off_cr: - .word 0x10 -flash_off_sr: - .word 0x0c diff --git a/flashloaders/stm32f4.s b/flashloaders/stm32f4.s index a47054dae..938ca8401 100644 --- a/flashloaders/stm32f4.s +++ b/flashloaders/stm32f4.s @@ -1,6 +1,12 @@ .syntax unified .text +flash_base: + .align 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e + .global mycopy mycopy: ldr r12, flash_base @@ -28,8 +34,3 @@ mywait: myexit: bkpt - -flash_base: - .word 0x40023c00 -flash_off_sr: - .word 0x0e diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index cfbbe8520..fa8bedbaa 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -1,6 +1,12 @@ .syntax unified .text +flash_base: + .align 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e + .global mycopy mycopy: ldr r12, flash_base @@ -28,8 +34,3 @@ mywait: myexit: bkpt - -flash_base: - .word 0x40023c00 -flash_off_sr: - .word 0x0e diff --git a/flashloaders/stm32f7.s b/flashloaders/stm32f7.s index f873f0ebd..604ab0465 100644 --- a/flashloaders/stm32f7.s +++ b/flashloaders/stm32f7.s @@ -1,6 +1,12 @@ .syntax unified .text +flash_base: + .align 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e + .global mycopy mycopy: ldr r12, flash_base @@ -31,8 +37,3 @@ mywait: myexit: bkpt - -flash_base: - .word 0x40023c00 -flash_off_sr: - .word 0x0e diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index fe5be0529..157347542 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -1,6 +1,12 @@ .syntax unified .text +flash_base: + .algin 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e + .global mycopy mycopy: ldr r12, flash_base @@ -31,8 +37,3 @@ mywait: myexit: bkpt - -flash_base: - .word 0x40023c00 -flash_off_sr: - .word 0x0e diff --git a/flashloaders/stm32l0x.s b/flashloaders/stm32l0x.s index 1ce7dd144..893aa6f9b 100644 --- a/flashloaders/stm32l0x.s +++ b/flashloaders/stm32l0x.s @@ -8,11 +8,13 @@ myloop: ldr r3, [r0] str r3, [r1] - add r0, r0, #4 - add r1, r1, #4 + ldr r7, =4 + add r0, r0, r7 + add r1, r1, r7 # loop if r2 != 0 - sub r2, r2, #1 + ldr r7, =1 + subs r2, r2, r7 cmp r2, #0 bne myloop diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index 0a68b687a..b136e59e7 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -1,6 +1,12 @@ .syntax unified .text +flash_base: + .align 2 + .word 0x40022000 +flash_off_bsy: + .word 0x12 + .global mycopy mycopy: ldr r12, flash_base @@ -10,9 +16,9 @@ mycopy: myloop: # copy 8 bytes ldr r3, [r0] - ldr r3, [r0, #4] + ldr r4, [r0, #4] str r3, [r1] - str r3, [r1, #4] + str r4, [r1, #4] add r0, r0, #8 add r1, r1, #8 @@ -30,8 +36,3 @@ mywait: myexit: bkpt - -flash_base: - .word 0x40022000 -flash_off_bsy: - .word 0x12 diff --git a/flashloaders/stm32lx.s b/flashloaders/stm32lx.s index 1ce7dd144..893aa6f9b 100644 --- a/flashloaders/stm32lx.s +++ b/flashloaders/stm32lx.s @@ -8,11 +8,13 @@ myloop: ldr r3, [r0] str r3, [r1] - add r0, r0, #4 - add r1, r1, #4 + ldr r7, =4 + add r0, r0, r7 + add r1, r1, r7 # loop if r2 != 0 - sub r2, r2, #1 + ldr r7, =1 + subs r2, r2, r7 cmp r2, #0 bne myloop From 8aaf95abf6dedef3f5de1f6659aecfb0e7eb60eb Mon Sep 17 00:00:00 2001 From: xp Date: Fri, 24 Apr 2020 16:59:47 +0800 Subject: [PATCH 176/236] rewrite flashloaders as clean room doc --- flashloaders/stm32f0.s | 95 ++++++++++++++++++++++++++-------------- flashloaders/stm32f4.s | 54 ++++++++++++----------- flashloaders/stm32f4lv.s | 55 ++++++++++++----------- flashloaders/stm32f7.s | 66 +++++++++++++++------------- flashloaders/stm32f7lv.s | 67 +++++++++++++++------------- flashloaders/stm32l0x.s | 76 +++++++------------------------- flashloaders/stm32l4.s | 61 +++++++++++++------------- flashloaders/stm32lx.s | 72 +++++++----------------------- 8 files changed, 257 insertions(+), 289 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index fe12f90f3..8eaf81905 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -1,32 +1,63 @@ -/* Adopted from STM AN4065 stm32f0xx_flash.c:FLASH_ProgramWord */ - -write: - ldr r4, STM32_FLASH_BASE - mov r5, #1 /* FLASH_CR_PG, FLASH_SR_BUSY */ - mov r6, #4 /* PGERR */ -write_half_word: - ldr r3, [r4, #16] /* FLASH->CR */ - orr r3, r5 - str r3, [r4, #16] /* FLASH->CR |= FLASH_CR_PG */ - ldrh r3, [r0] /* r3 = *sram */ - strh r3, [r1] /* *flash = r3 */ -busy: - ldr r3, [r4, #12] /* FLASH->SR */ - tst r3, r5 /* FLASH_SR_BUSY */ - beq busy - - tst r3, r6 /* PGERR */ - bne exit - - add r0, r0, #2 /* sram += 2 */ - add r1, r1, #2 /* flash += 2 */ - sub r2, r2, #0x01 /* count-- */ - cmp r2, #0 - bne write_half_word -exit: - ldr r3, [r4, #16] /* FLASH->CR */ - bic r3, r5 - str r3, [r4, #16] /* FLASH->CR &= ~FLASH_CR_PG */ - bkpt #0x00 - -STM32_FLASH_BASE: .word 0x40022000 + .syntax unified + .text + + .global mycopy +mycopy: + ldr r7, =flash_base + ldr r4, [r7] + ldr r7, =flash_off_cr + ldr r6, [r7] + adds r6, r6, r4 + ldr r7, =flash_off_sr + ldr r5, [r7] + adds r5, r5, r4 + +myloop: + # FLASH_CR ^= 1 + ldr r7, =0x1 + ldr r3, [r6] + orrs r3, r3, r7 + str r3, [r6] + + # copy 2 bytes + ldrh r3, [r0] + strh r3, [r1] + + ldr r7, =2 + adds r0, r0, r7 + adds r1, r1, r7 + + # wait if FLASH_SR == 1 +mywait: + ldr r7, =0x1 + ldr r3, [r5] + tst r3, r7 + beq mywait + + # exit if FLASH_SR == 4 + ldr r7, =0x4 + tst r3, r7 + beq myexit + + # loop if r2 != 0 + ldr r7, =0x1 + subs r2, r2, r7 + cmp r2, #0 + bne myloop + +myexit: + # FLASH_CR &= ~1 + ldr r7, =0x1 + ldr r3, [r6] + bics r3, r3, r7 + str r3, [r6] + + bkpt + +flash_base: + .align 2 + .word 0x40022000 +flash_off_cr: + .word 0x10 +flash_off_sr: + .word 0x0c diff --git a/flashloaders/stm32f4.s b/flashloaders/stm32f4.s index 21f5a8f7f..085e6870c 100644 --- a/flashloaders/stm32f4.s +++ b/flashloaders/stm32f4.s @@ -1,32 +1,36 @@ -.global start -.syntax unified + .syntax unified + .text -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 -start: - ldr r3, flash_base -next: - cbz r2, done - ldr r4, [r0] - str r4, [r1] +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait + add r0, r0, #4 + add r1, r1, #4 - add r0, #4 - add r1, #4 - sub r2, #1 - b next -done: - bkpt + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop -.align 2 +myexit: + bkpt flash_base: - .word 0x40023c00 + .align 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index f60ee8797..f0adfd208 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -1,33 +1,36 @@ -.global start -.syntax unified + .syntax unified + .text -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 -start: - lsls r2, r2, #2 - ldr r3, flash_base -next: - cbz r2, done - ldrb r4, [r0] - strb r4, [r1] +myloop: + # copy 1 bytes + ldrb r3, [r0] + strb r3, [r1] -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait + add r0, r0, #1 + add r1, r1, #1 - add r0, #1 - add r1, #1 - sub r2, #1 - b next -done: - bkpt + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop -.align 2 +myexit: + bkpt flash_base: - .word 0x40023c00 + .align 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32f7.s b/flashloaders/stm32f7.s index 0334c80a0..5d87515be 100644 --- a/flashloaders/stm32f7.s +++ b/flashloaders/stm32f7.s @@ -1,33 +1,39 @@ -.global start -.syntax unified - -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp - -start: - ldr r3, flash_base -next: - cbz r2, done - ldr r4, [r0] - str r4, [r1] - dsb sy - -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait - - add r0, #4 - add r1, #4 - sub r2, #1 - b next -done: - bkpt + .syntax unified + .text + + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 + +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] + + add r0, r0, #4 + add r1, r1, #4 -.align 2 + # memory barrier + dsb sy + + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop + +myexit: + bkpt flash_base: - .word 0x40023c00 + .align 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index 650922719..70cd948bd 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -1,34 +1,39 @@ -.global start -.syntax unified - -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp - -start: - lsls r2, r2, #2 - ldr r3, flash_base -next: - cbz r2, done - ldrb r4, [r0] - strb r4, [r1] - dsb sy - -wait: - ldrh r4, [r3, #0x0e] - tst.w r4, #1 - bne wait - - add r0, #1 - add r1, #1 - sub r2, #1 - b next -done: - bkpt + .syntax unified + .text + + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_sr + add r10, r10, r12 + +myloop: + # copy 1 byte + ldrb r3, [r0] + strb r3, [r1] + + add r0, r0, #1 + add r1, r1, #1 -.align 2 + # memory barrier + dsb sy + + # wait if FLASH_SR == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop + +myexit: + bkpt flash_base: - .word 0x40023c00 + .algin 2 + .word 0x40023c00 +flash_off_sr: + .word 0x0e diff --git a/flashloaders/stm32l0x.s b/flashloaders/stm32l0x.s index fcbd06e39..893aa6f9b 100644 --- a/flashloaders/stm32l0x.s +++ b/flashloaders/stm32l0x.s @@ -1,64 +1,22 @@ -/*************************************************************************** - * Copyright (C) 2010 by Spencer Oliver * - * spen@spen-soft.co.uk * - * * - * Copyright (C) 2011 Øyvind Harboe * - * oyvind.harboe@zylin.com * - * * - * Copyright (C) 2011 Clement Burin des Roziers * - * clement.burin-des-roziers@hikob.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -// Build : arm-eabi-gcc -c stm32lx.S - .text .syntax unified - .cpu cortex-m0plus - .thumb - .thumb_func - .global write - -/* - r0 - source address - r1 - destination address - r2 - count -*/ + .text - // Go to compare - b test_done + .global mycopy +mycopy: +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] -write_word: - // Load one word from address in r0, increment by 4 - ldr r4, [r0] - // Store the word to address in r1, increment by 4 - str r4, [r1] - // Decrement r2 - subs r2, #1 - adds r1, #4 - // does not matter, only first addr is important - // next 15 bytes are in sequnce RM0367 page 66 - adds r0, #4 + ldr r7, =4 + add r0, r0, r7 + add r1, r1, r7 -test_done: - // Test r2 - cmp r2, #0 - // Loop if not zero - bcc.n write_word + # loop if r2 != 0 + ldr r7, =1 + subs r2, r2, r7 + cmp r2, #0 + bne myloop - // Set breakpoint to exit - bkpt #0x00 +myexit: + bkpt diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index 6aa2be050..5b5252a54 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -1,39 +1,38 @@ -.global start -.syntax unified + .syntax unified + .text -@ Adapted from stm32f4.s -@ STM32L4's flash controller expects double-word writes, has the flash -@ controller mapped in a different location with the registers we care about -@ moved down from the base address, and has BSY moved to bit 16 of SR. -@ r0 = source -@ r1 = target -@ r2 = wordcount -@ r3 = flash_base -@ r4 = temp -@ r5 = temp + .global mycopy +mycopy: + ldr r12, flash_base + ldr r10, flash_off_bsy + add r10, r10, r12 -start: - ldr r3, flash_base -next: - cbz r2, done - ldr r4, [r0] /* copy doubleword from source to target */ - ldr r5, [r0, #4] - str r4, [r1] - str r5, [r1, #4] +myloop: + # copy 8 bytes + ldr r3, [r0] + ldr r4, [r0, #4] + str r3, [r1] + str r4, [r1, #4] -wait: - ldrh r4, [r3, #0x12] /* high half of status register */ - tst r4, #1 /* BSY = bit 16 */ - bne wait + add r0, r0, #8 + add r1, r1, #8 - add r0, #8 - add r1, #8 - sub r2, #1 - b next -done: - bkpt + # wait if FLASH_BSY[0b] == 1 +mywait: + ldrh r3, [r10] + tst r3, #0x1 + beq mywait + + # loop if r2 != 0 + sub r2, r2, #1 + cmp r2, #0 + bne myloop -.align 2 +myexit: + bkpt flash_base: + .align 2 .word 0x40022000 +flash_off_bsy: + .word 0x12 diff --git a/flashloaders/stm32lx.s b/flashloaders/stm32lx.s index 10e5644bf..893aa6f9b 100644 --- a/flashloaders/stm32lx.s +++ b/flashloaders/stm32lx.s @@ -1,60 +1,22 @@ -/*************************************************************************** - * Copyright (C) 2010 by Spencer Oliver * - * spen@spen-soft.co.uk * - * * - * Copyright (C) 2011 Øyvind Harboe * - * oyvind.harboe@zylin.com * - * * - * Copyright (C) 2011 Clement Burin des Roziers * - * clement.burin-des-roziers@hikob.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -// Build : arm-eabi-gcc -c stm32lx.s - .text .syntax unified - .cpu cortex-m3 - .thumb - .thumb_func - .global write - -/* - r0 - source address - r1 - destination address - r2 - output, remaining word count -*/ + .text - // Go to compare - b test_done + .global mycopy +mycopy: +myloop: + # copy 4 bytes + ldr r3, [r0] + str r3, [r1] -write_word: - // Load one word from address in r0, increment by 4 - ldr.w ip, [r0], #4 - // Store the word to address in r1, increment by 4 - str.w ip, [r1], #4 - // Decrement r2 - subs r2, #1 + ldr r7, =4 + add r0, r0, r7 + add r1, r1, r7 -test_done: - // Test r2 - cmp r2, #0 - // Loop if not zero - bhi write_word + # loop if r2 != 0 + ldr r7, =1 + subs r2, r2, r7 + cmp r2, #0 + bne myloop - // Set breakpoint to exit - bkpt #0x00 +myexit: + bkpt From 8bbedab02055519312445b9d95bff1b52becc172 Mon Sep 17 00:00:00 2001 From: xp Date: Fri, 24 Apr 2020 17:21:32 +0800 Subject: [PATCH 177/236] fix typo --- flashloaders/stm32f7lv.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index 70cd948bd..c144205f2 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -33,7 +33,7 @@ myexit: bkpt flash_base: - .algin 2 + .align 2 .word 0x40023c00 flash_off_sr: .word 0x0e From 5a1efc01f705e60bbec4a328b169e528106bb8f7 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 24 Apr 2020 15:01:28 +0200 Subject: [PATCH 178/236] Updated cmake settings - Distinguish test binaries from binaries - Build all binaries to /bin subfolder - Added comments to explain settings - Moved header files for logging and mmap --- CMakeLists.txt | 35 +++++++++++++------------------ Makefile | 1 + include/stlink.h | 2 +- include/stlink/usb.h | 2 +- src/common.c | 24 ++++++++++----------- src/gdbserver/gdb-server.c | 2 +- src/gdbserver/semihosting.c | 4 ++-- src/logging.c | 2 +- {include/stlink => src}/logging.h | 0 src/mmap.c | 2 +- {include/stlink => src}/mmap.h | 0 src/sg.c | 2 +- tests/CMakeLists.txt | 18 ++++++++-------- 13 files changed, 45 insertions(+), 49 deletions(-) rename {include/stlink => src}/logging.h (100%) rename {include/stlink => src}/mmap.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ec381239..8e6501dc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ cmake_policy(SET CMP0042 NEW) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/modules") 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) ### @@ -25,10 +26,10 @@ option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) -# Determine project version +## Determine project version include(${CMAKE_MODULE_PATH}/get_version.cmake) -# Set C build flags +## Set C build flags if (NOT MSVC) include(${CMAKE_MODULE_PATH}/c_flags.cmake) else () @@ -39,11 +40,7 @@ else () set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") endif () - -# ==== - -#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - +## Set installation directories for libraries 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}") @@ -52,6 +49,7 @@ else () set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}") endif () +## Set installation directories for header files 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}") @@ -67,12 +65,14 @@ endif () find_package(libusb REQUIRED) +## Package configuration (pkg-config) on unix-based systems if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) add_subdirectory(cmake/pkgconfig) find_package(PkgConfig) pkg_check_modules(GTK3 gtk+-3.0) endif () +## Check for system-specific additional header files and libraries include(CheckIncludeFile) CHECK_INCLUDE_FILE(sys/mman.h STLINK_HAVE_SYS_MMAN_H) @@ -94,20 +94,13 @@ else () set(SSP_LIB "") endif () -if (CMAKE_BUILD_TYPE STREQUAL "") - set(CMAKE_BUILD_TYPE "Debug") -endif () -if (${CMAKE_BUILD_TYPE} MATCHES "Debug") - 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 ) @@ -115,11 +108,11 @@ set(STLINK_HEADERS set(STLINK_SOURCE src/chipid.c src/common.c - src/usb.c - src/sg.c - src/logging.c src/flash_loader.c + src/logging.c src/md5.c + src/sg.c + src/usb.c ) if (WIN32 OR MINGW OR MSYS) @@ -139,6 +132,10 @@ if (MSVC) add_definitions(-DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS /wd4710) endif () +# Include test execution for test-targets for target Debug +if (${CMAKE_BUILD_TYPE} MATCHES "Debug") + include(CTest) +endif () ### # Shared library @@ -236,8 +233,6 @@ else () target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB}) endif () -install(TARGETS st-flash st-info RUNTIME DESTINATION bin) ### TODO: Check path - if (CMAKE_SYSTEM_NAME STREQUAL "Linux") if (STLINK_INSTALL_MODPROBE_CONF) install(FILES etc/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}/) diff --git a/Makefile b/Makefile index 444f1920b..57043ac97 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ package: build/Release @$(MAKE) -C build/Release package test: debug + @echo "[TEST]" @$(MAKE) -C build/Debug test build/Debug: diff --git a/include/stlink.h b/include/stlink.h index db737acb0..c311a527b 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -252,7 +252,7 @@ typedef struct flash_loader { #include "stlink/chipid.h" #include "stlink/flash_loader.h" #include "stlink/version.h" -#include "stlink/logging.h" +#include "../src/logging.h" #ifdef __cplusplus } diff --git a/include/stlink/usb.h b/include/stlink/usb.h index 1448481be..88a9a981a 100644 --- a/include/stlink/usb.h +++ b/include/stlink/usb.h @@ -12,7 +12,7 @@ #include "stlink.h" #include "stlinkusb.h" -#include "stlink/logging.h" +#include "../src/logging.h" #ifdef __cplusplus extern "C" { diff --git a/src/common.c b/src/common.c index 0dc6bc967..9dff4e768 100644 --- a/src/common.c +++ b/src/common.c @@ -13,8 +13,8 @@ #include #include "stlink.h" -#include "stlink/mmap.h" -#include "stlink/logging.h" +#include "mmap.h" +#include "logging.h" #include "md5.h" #ifndef O_BINARY @@ -2672,12 +2672,12 @@ int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr } else { num_empty = 0; } - /* + /* * TODO: investigate: - * a kind of weird behaviour here: + * a kind of weird behaviour here: * if the file is identified to be all-empty and four-bytes aligned, - * still flash the whole file even if ignoring message is printed - */ + * still flash the whole file even if ignoring message is printed + */ err = stlink_write_flash(sl, addr, data, (num_empty == length) ? (uint32_t) length : (uint32_t) length - num_empty, num_empty == length); stlink_fwrite_finalize(sl, addr); return err; @@ -2721,12 +2721,12 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) { } else { num_empty = 0; } - /* + /* * TODO: investigate: - * a kind of weird behaviour here: + * a kind of weird behaviour here: * if the file is identified to be all-empty and four-bytes aligned, - * still flash the whole file even if ignoring message is printed - */ + * still flash the whole file even if ignoring message is printed + */ err = stlink_write_flash(sl, addr, mf.base, (num_empty == mf.len) ? (uint32_t) mf.len : (uint32_t) mf.len - num_empty, num_empty == mf.len); stlink_fwrite_finalize(sl, addr); unmap_file(&mf); @@ -3258,9 +3258,9 @@ int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte) } /** - * Write option bytes + * Write option bytes * @param sl - * @param option_byte value to write + * @param option_byte value to write * @return 0 on success, -ve on failure. */ int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte) diff --git a/src/gdbserver/gdb-server.c b/src/gdbserver/gdb-server.c index 2b5b1d3cb..219c3424b 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/gdbserver/gdb-server.c @@ -24,7 +24,7 @@ #endif #include -#include +#include "../logging.h" #include "gdb-remote.h" #include "gdb-server.h" diff --git a/src/gdbserver/semihosting.c b/src/gdbserver/semihosting.c index 40758b61d..d41a83246 100644 --- a/src/gdbserver/semihosting.c +++ b/src/gdbserver/semihosting.c @@ -8,7 +8,7 @@ #include "semihosting.h" #include -#include +#include "../logging.h" static int mem_read_u8(stlink_t *sl, uint32_t addr, uint8_t *data) { @@ -100,7 +100,7 @@ static int mem_write(stlink_t *sl, uint32_t addr, void *data, uint16_t len) // the requested bytes. (perhaps reading the whole area is faster??). // // If 16 and 8 bit writes are available, then they could be used instead. - + // Just return when the length is zero avoiding unneeded work. if (len == 0) return 0; diff --git a/src/logging.c b/src/logging.c index 59c2ea298..4ad89a5ed 100644 --- a/src/logging.c +++ b/src/logging.c @@ -9,7 +9,7 @@ #include #include -#include "stlink/logging.h" +#include "logging.h" static int max_level = UINFO; diff --git a/include/stlink/logging.h b/src/logging.h similarity index 100% rename from include/stlink/logging.h rename to src/logging.h diff --git a/src/mmap.c b/src/mmap.c index 90ae5fc17..b76e4ad64 100644 --- a/src/mmap.c +++ b/src/mmap.c @@ -3,7 +3,7 @@ #include #include -#include "stlink/mmap.h" +#include "mmap.h" void *mmap (void *addr, size_t len, int prot, int flags, int fd, long long offset) { diff --git a/include/stlink/mmap.h b/src/mmap.h similarity index 100% rename from include/stlink/mmap.h rename to src/mmap.h diff --git a/src/sg.c b/src/sg.c index 031cc64e5..eee6be498 100644 --- a/src/sg.c +++ b/src/sg.c @@ -83,7 +83,7 @@ #include #include "stlink.h" -#include "stlink/logging.h" +#include "logging.h" #define STLINK_OK 0x80 #define STLINK_FALSE 0x81 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c6b04ddb3..d6fe9fdd5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,12 +1,12 @@ -set(TESTS usb sg) +set(TESTEXEC usb sg) -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}) +foreach (test ${TESTEXEC}) + add_executable(test-${test} ${test}.c) + add_dependencies(test-${test} ${STLINK_LIB_STATIC}) + target_link_libraries(test-${test} ${STLINK_LIB_STATIC} ${SSP_LIB}) + add_test(test-${test} ${CMAKE_BINARY_DIR}/bin/test-${test}) endforeach () -add_executable(flash flash.c "${CMAKE_SOURCE_DIR}/src/tools/flash_opts.c") -target_link_libraries(flash ${STLINK_LIB_STATIC} ${SSP_LIB}) -add_test(flash ${CMAKE_CURRENT_BINARY_DIR}/flash) +add_executable(test-flash flash.c "${CMAKE_SOURCE_DIR}/src/tools/flash_opts.c") +target_link_libraries(test-flash ${STLINK_LIB_STATIC} ${SSP_LIB}) +add_test(test-flash ${CMAKE_BINARY_DIR}/bin/test-flash) From 15e2e1d811a384421aa78bcf5f9a28e91214a770 Mon Sep 17 00:00:00 2001 From: xp Date: Sat, 25 Apr 2020 14:08:58 +0800 Subject: [PATCH 179/236] fix align --- flashloaders/stm32f0.s | 2 +- flashloaders/stm32f4.s | 2 +- flashloaders/stm32f4lv.s | 2 +- flashloaders/stm32f7.s | 2 +- flashloaders/stm32f7lv.s | 2 +- flashloaders/stm32l4.s | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index 8eaf81905..489e30672 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -54,8 +54,8 @@ myexit: bkpt -flash_base: .align 2 +flash_base: .word 0x40022000 flash_off_cr: .word 0x10 diff --git a/flashloaders/stm32f4.s b/flashloaders/stm32f4.s index 085e6870c..836f6e1f2 100644 --- a/flashloaders/stm32f4.s +++ b/flashloaders/stm32f4.s @@ -29,8 +29,8 @@ mywait: myexit: bkpt -flash_base: .align 2 +flash_base: .word 0x40023c00 flash_off_sr: .word 0x0e diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index f0adfd208..ef9f3a0bb 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -29,8 +29,8 @@ mywait: myexit: bkpt -flash_base: .align 2 +flash_base: .word 0x40023c00 flash_off_sr: .word 0x0e diff --git a/flashloaders/stm32f7.s b/flashloaders/stm32f7.s index 5d87515be..3f02e75f8 100644 --- a/flashloaders/stm32f7.s +++ b/flashloaders/stm32f7.s @@ -32,8 +32,8 @@ mywait: myexit: bkpt -flash_base: .align 2 +flash_base: .word 0x40023c00 flash_off_sr: .word 0x0e diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index c144205f2..99eb37d88 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -32,8 +32,8 @@ mywait: myexit: bkpt -flash_base: .align 2 +flash_base: .word 0x40023c00 flash_off_sr: .word 0x0e diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index 5b5252a54..16c6d1063 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -31,8 +31,8 @@ mywait: myexit: bkpt -flash_base: .align 2 +flash_base: .word 0x40022000 flash_off_bsy: .word 0x12 From 36bb77dd6f9aa3f4c2cb99845c827c75810047c6 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 25 Apr 2020 15:25:27 +0800 Subject: [PATCH 180/236] Cleanroom for flashloaders done --- flashloaders/Makefile | 38 ++++++ flashloaders/linker.ld | 9 ++ src/flash_loader.c | 273 +++++++++++++++++++---------------------- 3 files changed, 175 insertions(+), 145 deletions(-) create mode 100644 flashloaders/Makefile create mode 100644 flashloaders/linker.ld diff --git a/flashloaders/Makefile b/flashloaders/Makefile new file mode 100644 index 000000000..7b17cb2a0 --- /dev/null +++ b/flashloaders/Makefile @@ -0,0 +1,38 @@ +# Note that according to the original GPLed code, compiling is noted to be +# as simple as gcc -c, this fails with my tests where this will lead to a wrong +# address read by the program. +# This makefile will save your time from dealing with compile errors +# Adjust CC if needed + +CC = /opt/local/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc + +CFLAGS_thumb1 = -mcpu=Cortex-M0 -Tlinker.ld -ffreestanding -nostdlib +CFLAGS_thumb2 = -mcpu=Cortex-M3 -Tlinker.ld -ffreestanding -nostdlib + +all: stm32vl.o stm32f0.o stm32l.o stm32f4.o stm32f4_lv.o stm32l4.o stm32f7.o stm32f7_lv.o + +stm32vl.o: stm32f0.s + $(CC) stm32f0.s $(CFLAGS_thumb2) -o stm32vl.o +stm32f0.o: stm32f0.s + $(CC) stm32f0.s $(CFLAGS_thumb1) -o stm32f0.o +stm32l.o: stm32lx.s + $(CC) stm32lx.s $(CFLAGS_thumb2) -o stm32l.o +stm32f4.o: stm32f4.s + $(CC) stm32f4.s $(CFLAGS_thumb2) -o stm32f4.o +stm32f4_lv.o: stm32f4lv.s + $(CC) stm32f4lv.s $(CFLAGS_thumb2) -o stm32f4_lv.o +stm32l4.o: stm32l4.s + $(CC) stm32l4.s $(CFLAGS_thumb2) -o stm32l4.o +stm32f7.o: stm32f7.s + $(CC) stm32f7.s $(CFLAGS_thumb2) -o stm32f7.o +stm32f7_lv.o: stm32f7lv.s + $(CC) stm32f7lv.s $(CFLAGS_thumb2) -o stm32f7_lv.o + +clean: + rm *.o + + + + + + diff --git a/flashloaders/linker.ld b/flashloaders/linker.ld new file mode 100644 index 000000000..5bc738966 --- /dev/null +++ b/flashloaders/linker.ld @@ -0,0 +1,9 @@ +/*. Entry Point *./ +ENTRY( mycopy ) + + +/*. Specify the memory areas .*/ +MEMORY +{ + RAM ( xrw) : ORIGIN = 0x20000000 , LENGTH = 64K +} \ No newline at end of file diff --git a/src/flash_loader.c b/src/flash_loader.c index a1c9c3757..cee2aaba1 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -7,26 +7,34 @@ #define FLASH_REGS_BANK2_OFS 0x40 #define FLASH_BANK2_START_ADDR 0x08080000 -/* from openocd, contrib/loaders/flash/stm32.s */ -static const uint8_t loader_code_stm32vl[] = { - 0x08, 0x4c, /* ldr r4, STM32_FLASH_BASE */ - 0x1c, 0x44, /* add r4, r3 */ - /* write_half_word: */ - 0x01, 0x23, /* movs r3, #0x01 */ - 0x23, 0x61, /* str r3, [r4, #STM32_FLASH_CR_OFFSET] */ - 0x30, 0xf8, 0x02, 0x3b, /* ldrh r3, [r0], #0x02 */ - 0x21, 0xf8, 0x02, 0x3b, /* strh r3, [r1], #0x02 */ - /* busy: */ - 0xe3, 0x68, /* ldr r3, [r4, #STM32_FLASH_SR_OFFSET] */ - 0x13, 0xf0, 0x01, 0x0f, /* tst r3, #0x01 */ - 0xfb, 0xd0, /* beq busy */ - 0x13, 0xf0, 0x14, 0x0f, /* tst r3, #0x14 */ - 0x01, 0xd1, /* bne exit */ - 0x01, 0x3a, /* subs r2, r2, #0x01 */ - 0xf0, 0xd1, /* bne write_half_word */ - /* exit: */ - 0x00, 0xbe, /* bkpt #0x00 */ - 0x00, 0x20, 0x02, 0x40, /* STM32_FLASH_BASE: .word 0x40022000 */ + /* 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, 0xd0, + 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 */ @@ -47,157 +55,132 @@ static const uint8_t loader_code_stm32vl[] = { 0x00, 0x30, // nop /* add r0,#0 */ 0x00, 0x30, // nop /* add r0,#0 */ #endif - 0x0A, 0x4C, // ldr r4, STM32_FLASH_BASE - 0x01, 0x25, // mov r5, #1 /* FLASH_CR_PG, FLASH_SR_BUSY */ - 0x04, 0x26, // mov r6, #4 /* PGERR */ - // write_half_word: - 0x23, 0x69, // ldr r3, [r4, #16] /* FLASH->CR */ - 0x2B, 0x43, // orr r3, r5 - 0x23, 0x61, // str r3, [r4, #16] /* FLASH->CR |= FLASH_CR_PG */ - 0x03, 0x88, // ldrh r3, [r0] /* r3 = *sram */ - 0x0B, 0x80, // strh r3, [r1] /* *flash = r3 */ - // busy: - 0xE3, 0x68, // ldr r3, [r4, #12] /* FLASH->SR */ - 0x2B, 0x42, // tst r3, r5 /* FLASH_SR_BUSY */ - 0xFC, 0xD0, // beq busy - - 0x33, 0x42, // tst r3, r6 /* PGERR */ - 0x04, 0xD1, // bne exit - - 0x02, 0x30, // add r0, r0, #2 /* sram += 2 */ - 0x02, 0x31, // add r1, r1, #2 /* flash += 2 */ - 0x01, 0x3A, // sub r2, r2, #0x01 /* count-- */ - 0x00, 0x2A, // cmp r2, #0 - 0xF0, 0xD1, // bne write_half_word - // exit: - 0x23, 0x69, // ldr r3, [r4, #16] /* FLASH->CR */ - 0xAB, 0x43, // bic r3, r5 - 0x23, 0x61, // str r3, [r4, #16] /* FLASH->CR &= ~FLASH_CR_PG */ - 0x00, 0xBE, // bkpt #0x00 - 0x00, 0x20, 0x02, 0x40, /* STM32_FLASH_BASE: .word 0x40022000 */ + 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, 0xd0, + 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, + 0x44, 0x00, 0x00, 0x20, + 0x48, 0x00, 0x00, 0x20, + 0x4c, 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 - 0x04, 0xe0, // b test_done ; Go to compare - // write_word: - 0x04, 0x68, // ldr r4, [r0] ; Load one word from address in r0 - 0x0c, 0x60, // str r4, [r1] ; Store the word to address in r1 - 0x04, 0x30, // adds r0, #4 ; Increment r0 - 0x04, 0x31, // adds r1, #4 ; Increment r1 - 0x01, 0x3a, // subs r2, #1 ; Decrement r2 - // test_done: - 0x00, 0x2a, // cmp r2, #0 ; Compare r2 to 0 - 0xf8, 0xd8, // bhi write_word ; Loop if above 0 - 0x00, 0xbe, // bkpt #0x00 ; Set breakpoint to exit - 0x00, 0x00 + 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 - 0x07, 0x4b, - - 0x62, 0xb1, - 0x04, 0x68, - 0x0c, 0x60, - - 0xdc, 0x89, - 0x14, 0xf0, 0x01, 0x0f, - 0xfb, 0xd1, - 0x00, 0xf1, 0x04, 0x00, - 0x01, 0xf1, 0x04, 0x01, - 0xa2, 0xf1, 0x01, 0x02, - 0xf1, 0xe7, - - 0x00, 0xbe, - - 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 - 0x92, 0x00, - - 0x08, 0x4b, - 0x62, 0xb1, - 0x04, 0x78, - 0x0c, 0x70, - - 0xdc, 0x89, - 0x14, 0xf0, 0x01, 0x0f, - 0xfb, 0xd1, - 0x00, 0xf1, 0x01, 0x00, - 0x01, 0xf1, 0x01, 0x01, - 0xa2, 0xf1, 0x01, 0x02, - 0xf1, 0xe7, - - 0x00, 0xbe, - 0x00, 0xbf, - - 0x00, 0x3c, 0x02, 0x40, + 0xdf, 0xf8, 0x28, 0xc0, + 0xdf, 0xf8, 0x28, 0xa0, + 0xe2, 0x44, 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 - 0x08, 0x4b, // start: ldr r3, [pc, #32] ; - 0x72, 0xb1, // next: cbz r2, - 0x04, 0x68, // ldr r4, [r0, #0] - 0x45, 0x68, // ldr r5, [r0, #4] - 0x0c, 0x60, // str r4, [r1, #0] - 0x4d, 0x60, // str r5, [r1, #4] - 0x5c, 0x8a, // wait: ldrh r4, [r3, #18] - 0x14, 0xf0, 0x01, 0x0f, // tst.w r4, #1 - 0xfb, 0xd1, // bne.n - 0x00, 0xf1, 0x08, 0x00, // add.w r0, r0, #8 - 0x01, 0xf1, 0x08, 0x01, // add.w r1, r1, #8 - 0xa2, 0xf1, 0x01, 0x02, // sub.w r2, r2, #1 - 0xef, 0xe7, // b.n - 0x00, 0xbe, // done: bkpt 0x0000 - 0x00, 0x20, 0x02, 0x40 // flash_base: .word 0x40022000 + 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 - 0x08, 0x4b, - 0x72, 0xb1, - 0x04, 0x68, - 0x0c, 0x60, - 0xbf, 0xf3, 0x4f, 0x8f, // DSB Memory barrier for in order flash write - 0xdc, 0x89, - 0x14, 0xf0, 0x01, 0x0f, - 0xfb, 0xd1, - 0x00, 0xf1, 0x04, 0x00, - 0x01, 0xf1, 0x04, 0x01, - 0xa2, 0xf1, 0x01, 0x02, - 0xef, 0xe7, - 0x00, 0xbe, // bkpt #0x00 - 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 - 0x92, 0x00, // lsls r2, r2, #2 - 0x09, 0x4b, // ldr r3, [pc, #36] ; (0x20000028 ) - // next: - 0x72, 0xb1, // cbz r2, 24 - 0x04, 0x78, // ldrb r4, [r0, #0] - 0x0c, 0x70, // strb r4, [r1, #0] - 0xbf, 0xf3, 0x4f, 0x8f, // dsb sy - // wait: - 0xdc, 0x89, // ldrh r4, [r3, #14] - 0x14, 0xf0, 0x01, 0x0f, // tst.w r4, #1 - 0xfb, 0xd1, // bne.n e - 0x00, 0xf1, 0x01, 0x00, // add r0, r0, #1 - 0x01, 0xf1, 0x01, 0x01, // add r1, r1, #1 - 0xa2, 0xf1, 0x01, 0x02, // sub r2, r2, #1 - 0xef, 0xe7, // b next - // done: - 0x00, 0xbe, // bkpt - 0x00, 0xbf, // nop - // flash_base: - 0x00, 0x3c, 0x02, 0x40 // .word 0x40023c00 + 0xdf, 0xf8, 0x2c, 0xc0, + 0xdf, 0xf8, 0x2c, 0xa0, + 0xe2, 0x44, 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 }; From 489a37e3c72858ca5fdcdcfb3af09decc397cbb6 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 25 Apr 2020 18:13:08 +0800 Subject: [PATCH 181/236] Document error fix --- flashloaders/cleanroom.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flashloaders/cleanroom.md b/flashloaders/cleanroom.md index 594e7191a..1bae4535d 100644 --- a/flashloaders/cleanroom.md +++ b/flashloaders/cleanroom.md @@ -39,7 +39,7 @@ English version can be found below. 每次写入数据宽度为2字节(半字)。 -每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处4字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待;否则需要检查FLASH_SR处值是否为4,若是4,则应直接准备退出。 +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处4字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待;否则需要检查FLASH_SR处值是否为4,若非4,则应直接准备退出。 退出:全部拷贝执行完毕后触发断点前,将FLASH_CR处4字节内容最低bit清为0,写回FLASH_CR。 @@ -155,7 +155,7 @@ Copy data from source to destination, after which trigger a breakpint to exit. B Before every copy, read a word from FLASH_CR, set the lowest bit to 1 and write back. Copy one half word each time. -How to wait for the write process: read a word from FLASH_SR, loop until the content is not 1. After that, check FLASH_SR, proceed if the content is not 4, otherwise exit. +How to wait for the write process: read a word from FLASH_SR, loop until the content is not 1. After that, check FLASH_SR, proceed if the content is 4, otherwise exit. Exit: after the copying process and before triggering the breakpoint, clear the lowest bit in FLASH_CR. From 9096984a8361c05b0d7b6205e212651c616f65cb Mon Sep 17 00:00:00 2001 From: xp Date: Sat, 25 Apr 2020 19:52:51 +0800 Subject: [PATCH 182/236] fix stm32f0 loop condition --- flashloaders/stm32f0.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index 489e30672..3dd0ae6e8 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -34,10 +34,10 @@ mywait: tst r3, r7 beq mywait - # exit if FLASH_SR == 4 + # exit if FLASH_SR != 4 ldr r7, =0x4 tst r3, r7 - beq myexit + bne myexit # loop if r2 != 0 ldr r7, =0x1 From b0971737c89e872bce134fb1c38cdf819fb963de Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 25 Apr 2020 19:55:35 +0800 Subject: [PATCH 183/236] Sync flashloader.c with stm32f0.s --- src/flash_loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flash_loader.c b/src/flash_loader.c index cee2aaba1..ba12b0b64 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -22,7 +22,7 @@ 0x01, 0x07, 0x2b, 0x68, 0x3b, 0x42, 0xfa, 0xd0, 0x4f, 0xf0, 0x04, 0x07, - 0x3b, 0x42, 0x04, 0xd0, + 0x3b, 0x42, 0x04, 0xd1, 0x4f, 0xf0, 0x01, 0x07, 0xd2, 0x1b, 0x00, 0x2a, 0xe6, 0xd1, 0x4f, 0xf0, @@ -66,7 +66,7 @@ 0xc9, 0x19, 0x0e, 0x4f, 0x2b, 0x68, 0x3b, 0x42, 0xfb, 0xd0, 0x0e, 0x4f, - 0x3b, 0x42, 0x03, 0xd0, + 0x3b, 0x42, 0x03, 0xd1, 0x0a, 0x4f, 0xd2, 0x1b, 0x00, 0x2a, 0xeb, 0xd1, 0x08, 0x4f, 0x33, 0x68, From 8b77d027d37fe21ea3fce1db6d63ae3042eb9a35 Mon Sep 17 00:00:00 2001 From: xp Date: Sat, 25 Apr 2020 20:21:13 +0800 Subject: [PATCH 184/236] fix: stm32-lv r2(4) and copy(1) has different data unit size --- flashloaders/stm32f4lv.s | 12 +++++++++--- flashloaders/stm32f7lv.s | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index ef9f3a0bb..92f70facc 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -8,12 +8,18 @@ mycopy: add r10, r10, r12 myloop: - # copy 1 bytes + # copy 1 byte each time and 4 times as one group ldrb r3, [r0] + ldrb r4, [r0, #1] + ldrb r5, [r0, #2] + ldrb r6, [r0, #3] strb r3, [r1] + strb r4, [r1, #1] + strb r5, [r1, #2] + strb r6, [r1, #3] - add r0, r0, #1 - add r1, r1, #1 + add r0, r0, #4 + add r1, r1, #4 # wait if FLASH_SR == 1 mywait: diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index 99eb37d88..013b56f87 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -8,12 +8,18 @@ mycopy: add r10, r10, r12 myloop: - # copy 1 byte + # copy 1 byte each time and 4 times as one group ldrb r3, [r0] + ldrb r4, [r0, #1] + ldrb r5, [r0, #2] + ldrb r6, [r0, #3] strb r3, [r1] + strb r4, [r1, #1] + strb r5, [r1, #2] + strb r6, [r1, #3] - add r0, r0, #1 - add r1, r1, #1 + add r0, r0, #4 + add r1, r1, #4 # memory barrier dsb sy From 09b40ca7bcb8e30df0cf374946327f858771f456 Mon Sep 17 00:00:00 2001 From: xp Date: Sat, 25 Apr 2020 20:37:26 +0800 Subject: [PATCH 185/236] update --- flashloaders/stm32f4lv.s | 18 +++++++++--------- flashloaders/stm32f7lv.o | Bin 0 -> 792 bytes flashloaders/stm32f7lv.s | 18 +++++++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 flashloaders/stm32f7lv.o diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index 92f70facc..c338b984a 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -7,19 +7,19 @@ mycopy: ldr r10, flash_off_sr add r10, r10, r12 + # original r2 indicates the count of 4 bytes need to copy, + # but we can only copy one byte each time. + # as we have no flash larger than 1GB, we do a little trick here. + ldr r3, =4 + mul r2, r2, r3 + myloop: - # copy 1 byte each time and 4 times as one group + # copy 1 byte ldrb r3, [r0] - ldrb r4, [r0, #1] - ldrb r5, [r0, #2] - ldrb r6, [r0, #3] strb r3, [r1] - strb r4, [r1, #1] - strb r5, [r1, #2] - strb r6, [r1, #3] - add r0, r0, #4 - add r1, r1, #4 + add r0, r0, #1 + add r1, r1, #1 # wait if FLASH_SR == 1 mywait: diff --git a/flashloaders/stm32f7lv.o b/flashloaders/stm32f7lv.o new file mode 100644 index 0000000000000000000000000000000000000000..f71d5e6366b415ff04a5340db3c4e011bef88b53 GIT binary patch literal 792 zcmah{y-EW?5dQWqQG-8;T56*P3_%ZtfPyI^sFfk$3&cHhA%TQDaw{g4kD$Gc_!t)I zBgD>5@BzeV6SQ$Acbi-aabV{AX7}5<*_*vQJU$XaK$}1YqYQWnl6Y<)$Y2VScJ542RLe&berkQfu3RXob3Cs3+vm#hbw~drkAnZ%L@4FE z7DCPt3;7Bm>&!4$A!^_~wsrC;^8a)jfyN^k7}w)jXw&r=qf@@7yi3mg@@%=k6nTPN cf0HOq>EIrd&~!b1Z&BS1ZH(SSa7RA!3p%Ax&;S4c literal 0 HcmV?d00001 diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index 013b56f87..55c9add1a 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -7,19 +7,19 @@ mycopy: ldr r10, flash_off_sr add r10, r10, r12 + # original r2 indicates the count of 4 bytes need to copy, + # but we can only copy one byte each time. + # as we have no flash larger than 1GB, we do a little trick here. + ldr r3, =4 + mul r2, r2, r3 + myloop: - # copy 1 byte each time and 4 times as one group + # copy 1 byte ldrb r3, [r0] - ldrb r4, [r0, #1] - ldrb r5, [r0, #2] - ldrb r6, [r0, #3] strb r3, [r1] - strb r4, [r1, #1] - strb r5, [r1, #2] - strb r6, [r1, #3] - add r0, r0, #4 - add r1, r1, #4 + add r0, r0, #1 + add r1, r1, #1 # memory barrier dsb sy From a4fec73a27516f787fa0853b1fab9ecaa7225f61 Mon Sep 17 00:00:00 2001 From: xp Date: Sat, 25 Apr 2020 20:53:05 +0800 Subject: [PATCH 186/236] update --- flashloaders/stm32f4lv.s | 10 +++++----- flashloaders/stm32f7lv.o | Bin 792 -> 0 bytes flashloaders/stm32f7lv.s | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 flashloaders/stm32f7lv.o diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index c338b984a..4ba351faa 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -7,11 +7,11 @@ mycopy: ldr r10, flash_off_sr add r10, r10, r12 - # original r2 indicates the count of 4 bytes need to copy, - # but we can only copy one byte each time. - # as we have no flash larger than 1GB, we do a little trick here. - ldr r3, =4 - mul r2, r2, r3 + # tip 1: original r2 indicates the count of 4 bytes need to copy, + # but we can only copy one byte each time. + # as we have no flash larger than 1GB, we do a little trick here. + # tip 2: r2 is always a power of 2 + mov r2, r2, lsl#2 myloop: # copy 1 byte diff --git a/flashloaders/stm32f7lv.o b/flashloaders/stm32f7lv.o deleted file mode 100644 index f71d5e6366b415ff04a5340db3c4e011bef88b53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 792 zcmah{y-EW?5dQWqQG-8;T56*P3_%ZtfPyI^sFfk$3&cHhA%TQDaw{g4kD$Gc_!t)I zBgD>5@BzeV6SQ$Acbi-aabV{AX7}5<*_*vQJU$XaK$}1YqYQWnl6Y<)$Y2VScJ542RLe&berkQfu3RXob3Cs3+vm#hbw~drkAnZ%L@4FE z7DCPt3;7Bm>&!4$A!^_~wsrC;^8a)jfyN^k7}w)jXw&r=qf@@7yi3mg@@%=k6nTPN cf0HOq>EIrd&~!b1Z&BS1ZH(SSa7RA!3p%Ax&;S4c diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index 55c9add1a..d82726eeb 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -7,11 +7,11 @@ mycopy: ldr r10, flash_off_sr add r10, r10, r12 - # original r2 indicates the count of 4 bytes need to copy, - # but we can only copy one byte each time. - # as we have no flash larger than 1GB, we do a little trick here. - ldr r3, =4 - mul r2, r2, r3 + # tip 1: original r2 indicates the count in 4 bytes need to copy, + # but we can only copy one byte each time. + # as we have no flash larger than 1GB, we do a little trick here. + # tip 2: r2 is always a power of 2 + mov r2, r2, lsl#2 myloop: # copy 1 byte From 65ca384008ed8516d3f582b22ef7cd4a39c8ed6a Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Sat, 25 Apr 2020 21:01:21 +0800 Subject: [PATCH 187/236] Sync flashloader.c with commit a4fec73a27516f787fa0853b1fab9ecaa7225f61 --- src/flash_loader.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/flash_loader.c b/src/flash_loader.c index ba12b0b64..a3fd2cefd 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -114,9 +114,10 @@ static const uint8_t loader_code_stm32f4_lv[] = { // flashloaders/stm32f4lv.s - 0xdf, 0xf8, 0x28, 0xc0, - 0xdf, 0xf8, 0x28, 0xa0, - 0xe2, 0x44, 0x03, 0x78, + 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, @@ -167,9 +168,10 @@ static const uint8_t loader_code_stm32f7_lv[] = { // flashloaders/stm32f7lv.s - 0xdf, 0xf8, 0x2c, 0xc0, - 0xdf, 0xf8, 0x2c, 0xa0, - 0xe2, 0x44, 0x03, 0x78, + 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, From f82700623127538c8cf5cddbbeba6afc12d3adbf Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 25 Apr 2020 22:34:18 +0200 Subject: [PATCH 188/236] Refactoring for cmake build settings - Moved additional header files to /src - Simplified header-paths - Added missing license title for getopt - Added comments and sections to CMakeLists - Improved file structure (partially) - Co-build st-util with st-info & st-flash - GUI: Renamed .ui file to match executable - Added install targets for executables - Added missing "uninstall" cmd to Makefile --- CMakeLists.txt | 126 +++++++++++------- Makefile | 5 + cmake/packaging/CMakeLists.txt | 2 + doc/man/CMakeLists.txt | 4 + include/CMakeLists.txt | 1 + include/stlink.h | 18 +-- include/stlink/flash_loader.h | 2 +- include/stlink/tools/flash.h | 1 + src/chipid.c | 7 +- src/common.c | 2 +- src/flash_loader.c | 18 +-- src/gdbserver/CMakeLists.txt | 23 ---- src/getopt/LICENSE.txt | 2 + src/getopt/getopt.c | 38 +++--- .../stlinkusb.h => src/libusb_settings.h | 4 +- src/md5.c | 3 +- src/sg.c | 2 +- {include/stlink => src}/sg.h | 7 +- src/{gdbserver => st-util}/gdb-remote.c | 4 +- src/{gdbserver => st-util}/gdb-remote.h | 0 src/{gdbserver => st-util}/gdb-server.c | 4 +- src/{gdbserver => st-util}/gdb-server.h | 0 src/{gdbserver => st-util}/semihosting.c | 5 +- src/{gdbserver => st-util}/semihosting.h | 0 src/stlink-gui/CMakeLists.txt | 28 ++-- src/stlink-gui/gui.c | 4 +- src/stlink-gui/{gui.ui => stlink-gui.ui} | 0 src/tools/flash.c | 3 +- src/tools/flash_opts.c | 4 +- src/usb.c | 6 +- {include/stlink => src}/usb.h | 8 +- tests/CMakeLists.txt | 4 + tests/flash.c | 2 +- tests/sg.c | 1 + tests/usb.c | 2 +- 35 files changed, 185 insertions(+), 155 deletions(-) delete mode 100644 src/gdbserver/CMakeLists.txt rename include/stlink/stlinkusb.h => src/libusb_settings.h (91%) rename {include/stlink => src}/sg.h (95%) rename src/{gdbserver => st-util}/gdb-remote.c (99%) rename src/{gdbserver => st-util}/gdb-remote.h (100%) rename src/{gdbserver => st-util}/gdb-server.c (99%) rename src/{gdbserver => st-util}/gdb-server.h (100%) rename src/{gdbserver => st-util}/semihosting.c (99%) rename src/{gdbserver => st-util}/semihosting.h (100%) rename src/stlink-gui/{gui.ui => stlink-gui.ui} (100%) rename {include/stlink => src}/usb.h (96%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e6501dc9..95e27d215 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,36 +95,51 @@ else () endif () +### +# Main build process +### + +## Define include directories to avoid absolute paths for header defines +include_directories(${LIBUSB_INCLUDE_DIR}) + # ==== +include_directories(include) ### TODO: Clean this up... +include_directories(${PROJECT_BINARY_DIR}/include/stlink) +include_directories(include/stlink) +include_directories(include/stlink/tools) +# ==== + +include_directories(src) set(STLINK_HEADERS - include/stlink.h - include/stlink/usb.h - include/stlink/sg.h - include/stlink/chipid.h - include/stlink/flash_loader.h - ) + 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 + ) set(STLINK_SOURCE - src/chipid.c - src/common.c - src/flash_loader.c - src/logging.c - src/md5.c - src/sg.c - src/usb.c - ) + src/common.c + src/chipid.c + src/flash_loader.c + src/logging.c + src/md5.c + src/sg.c + src/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/mingw/mingw.h") + set(STLINK_HEADERS "${STLINK_HEADERS};src/mmap.h;src/mingw/mingw.h") endif () -include_directories(${LIBUSB_INCLUDE_DIR}) -include_directories(include) -include_directories(${PROJECT_BINARY_DIR}/include) -include_directories(src/mingw) - if (MSVC) include_directories(src/win32) include_directories(src/getopt) @@ -132,11 +147,12 @@ if (MSVC) add_definitions(-DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS /wd4710) endif () -# Include test execution for test-targets for target Debug +## Include test execution for test-targets for target Debug if (${CMAKE_BUILD_TYPE} MATCHES "Debug") include(CTest) endif () + ### # Shared library ### @@ -148,14 +164,15 @@ else (WIN32) endif () add_library( - ${STLINK_LIB_SHARED} SHARED - ${STLINK_HEADERS} # header files for ide projects generated by cmake - ${STLINK_SOURCE} - ) + ${STLINK_LIB_SHARED} SHARED + ${STLINK_HEADERS} # header files for ide projects generated by cmake + ${STLINK_SOURCE} + ) + target_link_libraries( - ${STLINK_LIB_SHARED} - ${LIBUSB_LIBRARY} - ) + ${STLINK_LIB_SHARED} + ${LIBUSB_LIBRARY} + ) set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) @@ -163,7 +180,8 @@ 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 +set_target_properties( + ${STLINK_LIB_SHARED} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${STLINK_SHARED_VERSION} ) @@ -182,7 +200,7 @@ else () target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif () -install(TARGETS ${STLINK_LIB_SHARED} DESTINATION ${STLINK_LIBRARY_PATH}) ### TODO: Check path +install(TARGETS ${STLINK_LIB_SHARED} DESTINATION ${STLINK_LIBRARY_PATH}) ### @@ -197,6 +215,11 @@ add_library( ${STLINK_SOURCE} ) +set_target_properties( + ${STLINK_LIB_STATIC} PROPERTIES + OUTPUT_NAME ${PROJECT_NAME} + ) + # Link static library with Apple macOS libraries if (APPLE) find_library(ObjC objc) @@ -205,32 +228,40 @@ if (APPLE) target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) endif () -if (WIN32 OR MINGW OR MSYS) ### TODO: MinGW OR MSYS on Linux +if (WIN32 OR MINGW OR MSYS) target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) else () target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB}) 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}) ### TODO: Check path + install(TARGETS ${STLINK_LIB_STATIC} ARCHIVE DESTINATION ${STLINK_LIBRARY_PATH}) endif () ### -# Tools +# Build toolset executables ### +set(ST-UTIL_SOURCES src/st-util/gdb-remote.c src/st-util/gdb-server.c src/st-util/semihosting.c) + +if (MSVC) + # Add getopt to sources + 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-util ${ST-UTIL_SOURCES}) if (WIN32 OR APPLE) target_link_libraries(st-flash ${STLINK_LIB_STATIC} ${SSP_LIB}) target_link_libraries(st-info ${STLINK_LIB_STATIC} ${SSP_LIB}) + target_link_libraries(st-util ${STLINK_LIB_STATIC} ${SSP_LIB}) else () target_link_libraries(st-flash ${STLINK_LIB_SHARED} ${SSP_LIB}) target_link_libraries(st-info ${STLINK_LIB_SHARED} ${SSP_LIB}) + target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB}) endif () if (CMAKE_SYSTEM_NAME STREQUAL "Linux") @@ -243,27 +274,24 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") endif () endif () -add_subdirectory(src/gdbserver) -add_subdirectory(src/stlink-gui) - +install(TARGETS st-flash DESTINATION bin) +install(TARGETS st-info DESTINATION bin) +install(TARGETS st-util DESTINATION bin) ### -# Others +# Additional build tasks ### -add_subdirectory(include) ### TODO: Check path -add_subdirectory(doc/man) -add_subdirectory(tests) - +# ==== +add_subdirectory(include) # contains subordinate CMakeLists for version config and old header includes + ### TODO: Clean this up ... # ==== +add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI +add_subdirectory(tests) # contains subordinate CMakeLists to build test executables +add_subdirectory(doc/man) # contains subordinate CMakeLists to generate manpages +add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages -### -# Package build -### - -add_subdirectory(cmake/packaging) -include(cmake/packaging/cpack_config.cmake) ### # Uninstall target diff --git a/Makefile b/Makefile index 57043ac97..74a4fece5 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ help: @echo " debug: Run a debug build" @echo " release: Run a release build" @echo " install: Install release build" + @echo " uninstall: Uninstall release build" @echo " package: Package release build" @echo " lint: Lint check all source-code" @echo " test: Build and run tests" @@ -35,6 +36,10 @@ install: build/Release @echo "[INSTALL] Release" @$(MAKE) -C build/Release install +uninstall: build/Release + @echo "[UNINSTALL] Release" + @$(MAKE) -C build/Release uninstall + package: build/Release @echo "[PACKAGE] Release" @$(MAKE) -C build/Release package diff --git a/cmake/packaging/CMakeLists.txt b/cmake/packaging/CMakeLists.txt index e831f611f..431c85d2d 100644 --- a/cmake/packaging/CMakeLists.txt +++ b/cmake/packaging/CMakeLists.txt @@ -2,3 +2,5 @@ add_subdirectory(debian) add_subdirectory(fedora) add_subdirectory(opensuse) add_subdirectory(windows) + +include(cpack_config.cmake) diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 090a2237e..221c84d7b 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,3 +1,7 @@ +### +# Generate manpages +### + set(MANPAGES st-util st-flash st-info) # Only generate manpages with pandoc in Debug builds diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 6e5e3c279..6cf397659 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -2,6 +2,7 @@ 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}) diff --git a/include/stlink.h b/include/stlink.h index a28b60116..74c366d1c 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -137,7 +137,7 @@ typedef struct flash_loader { typedef struct _stlink stlink_t; -#include "stlink/backend.h" +#include struct _stlink { struct _stlink_backend *backend; @@ -245,14 +245,14 @@ typedef struct flash_loader { int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len); int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); -#include "stlink/sg.h" -#include "stlink/usb.h" -#include "stlink/reg.h" -#include "stlink/commands.h" -#include "stlink/chipid.h" -#include "stlink/flash_loader.h" -#include "stlink/version.h" -#include "../src/logging.h" +#include +#include +#include +#include +#include +#include +#include +#include #ifdef __cplusplus } diff --git a/include/stlink/flash_loader.h b/include/stlink/flash_loader.h index 95042f7b6..5f4526114 100644 --- a/include/stlink/flash_loader.h +++ b/include/stlink/flash_loader.h @@ -10,7 +10,7 @@ #include #include -#include "stlink.h" +#include #ifdef __cplusplus extern "C" { diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index 15e020b35..8c3f7d766 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -2,6 +2,7 @@ #define STLINK_TOOLS_FLASH_H_ #include + #include #define DEBUG_LOG_LEVEL 100 diff --git a/src/chipid.c b/src/chipid.c index 17cb4d546..fcc1c55eb 100644 --- a/src/chipid.c +++ b/src/chipid.c @@ -1,5 +1,5 @@ -#include "stlink.h" -#include "stlink/chipid.h" +#include +#include static const struct stlink_chipid_params devices[] = { { @@ -580,7 +580,6 @@ static const struct stlink_chipid_params devices[] = { .bootrom_size = 0x7000, // 28K (table 2) .option_base = STM32_G4_OPTION_BYTES_BASE, .option_size = 4, - }, { // STM32G471/473/474/483/484 (from RM0440) @@ -621,8 +620,6 @@ static const struct stlink_chipid_params devices[] = { .bootrom_base = 0x0, .bootrom_size = 0x0 }, - - }; const struct stlink_chipid_params *stlink_chipid_get_params(uint32_t chipid) diff --git a/src/common.c b/src/common.c index 99cc0b513..9d21624f8 100644 --- a/src/common.c +++ b/src/common.c @@ -11,7 +11,7 @@ #include #include -#include "stlink.h" +#include #include "mmap.h" #include "logging.h" #include "md5.h" diff --git a/src/flash_loader.c b/src/flash_loader.c index a1c9c3757..ed253f92b 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -1,9 +1,9 @@ -#include "stlink.h" - #include #include #include +#include + #define FLASH_REGS_BANK2_OFS 0x40 #define FLASH_BANK2_START_ADDR 0x08080000 @@ -384,16 +384,16 @@ int stlink_flash_loader_run(stlink_t *sl, flash_loader_t* fl, stm32_addr_t targe /* run loader */ stlink_run(sl); -// This piece of code used to try to spin for .1 second by waiting +// This piece of code used to try to spin for .1 second by waiting // doing 10000 rounds of 10 microseconds. But because this usually runs -// on Unix-like OSes, the 10 microseconds get rounded up to the "tick" +// on Unix-like OSes, the 10 microseconds get rounded up to the "tick" // (actually almost two ticks) of the system. 1 milisecond. Thus, the -// ten thousand attempts, when "something goes wrong" that requires -// the error message "flash loader run error" would wait for something -// like 20 seconds before coming up with the error. -// by increasing the sleep-per-round to the same order-of-magnitude as +// ten thousand attempts, when "something goes wrong" that requires +// the error message "flash loader run error" would wait for something +// like 20 seconds before coming up with the error. +// by increasing the sleep-per-round to the same order-of-magnitude as // the tick-rounding that the OS uses, the wait until the error message is -// reduced to the same order of magnitude as what was intended. -- REW. +// reduced to the same order of magnitude as what was intended. -- REW. #define WAIT_ROUNDS 100 /* wait until done (reaches breakpoint) */ for (i = 0; i < WAIT_ROUNDS; i++) { diff --git a/src/gdbserver/CMakeLists.txt b/src/gdbserver/CMakeLists.txt deleted file mode 100644 index ff9bde165..000000000 --- a/src/gdbserver/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -set(STUTIL_SOURCE - gdb-remote.c - gdb-remote.h - gdb-server.c - gdb-server.h - semihosting.c - semihosting.h - ) - -if (MSVC) - # We need a getopt from somewhere... - set(STUTIL_SOURCE "${STUTIL_SOURCE};../getopt/getopt.c") -endif () - -add_executable(st-util ${STUTIL_SOURCE}) - -if (WIN32 OR APPLE) - target_link_libraries(st-util ${STLINK_LIB_STATIC} ${SSP_LIB}) -else () - target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB}) -endif () - -install(TARGETS st-util RUNTIME DESTINATION bin) diff --git a/src/getopt/LICENSE.txt b/src/getopt/LICENSE.txt index 340303a96..4e4ed8bd5 100644 --- a/src/getopt/LICENSE.txt +++ b/src/getopt/LICENSE.txt @@ -1,3 +1,5 @@ +BSD 3-Clause License + Copyright (c) 2012, Kim Gräsman All rights reserved. diff --git a/src/getopt/getopt.c b/src/getopt/getopt.c index 72dce14d6..5dd45bff7 100644 --- a/src/getopt/getopt.c +++ b/src/getopt/getopt.c @@ -1,8 +1,8 @@ -#include "getopt.h" - #include #include +#include "getopt.h" + #if !defined(_MSC_VER) const int no_argument = 0; const int required_argument = 1; @@ -19,8 +19,8 @@ static char* optcursor = NULL; /* Implemented based on [1] and [2] for optional arguments. optopt is handled FreeBSD-style, per [3]. - Other GNU and FreeBSD extensions are purely accidental. - + Other GNU and FreeBSD extensions are purely accidental. + [1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html [2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html [3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE @@ -37,22 +37,22 @@ int getopt(int argc, char* const argv[], const char* optstring) { if (optind >= argc) goto no_more_optchars; - /* If, when getopt() is called argv[optind] is a null pointer, getopt() + /* If, when getopt() is called argv[optind] is a null pointer, getopt() shall return -1 without changing optind. */ if (argv[optind] == NULL) goto no_more_optchars; - /* If, when getopt() is called *argv[optind] is not the character '-', + /* If, when getopt() is called *argv[optind] is not the character '-', getopt() shall return -1 without changing optind. */ if (*argv[optind] != '-') goto no_more_optchars; - /* If, when getopt() is called argv[optind] points to the string "-", + /* If, when getopt() is called argv[optind] points to the string "-", getopt() shall return -1 without changing optind. */ if (strcmp(argv[optind], "-") == 0) goto no_more_optchars; - /* If, when getopt() is called argv[optind] points to the string "--", + /* If, when getopt() is called argv[optind] points to the string "--", getopt() shall return -1 after incrementing optind. */ if (strcmp(argv[optind], "--") == 0) { ++optind; @@ -64,12 +64,12 @@ int getopt(int argc, char* const argv[], const char* optstring) { optchar = *optcursor; - /* FreeBSD: The variable optopt saves the last known option character + /* FreeBSD: The variable optopt saves the last known option character returned by getopt(). */ optopt = optchar; - /* The getopt() function shall return the next option character (if one is - found) from argv that matches a character in optstring, if there is + /* The getopt() function shall return the next option character (if one is + found) from argv that matches a character in optstring, if there is one that matches. */ optdecl = strchr(optstring, optchar); if (optdecl) { @@ -79,15 +79,15 @@ int getopt(int argc, char* const argv[], const char* optstring) { optarg = ++optcursor; if (*optarg == '\0') { /* GNU extension: Two colons mean an option takes an - optional arg; if there is text in the current argv-element - (i.e., in the same word as the option name itself, for example, + optional arg; if there is text in the current argv-element + (i.e., in the same word as the option name itself, for example, "-oarg"), then it is returned in optarg, otherwise optarg is set to zero. */ if (optdecl[2] != ':') { /* If the option was the last character in the string pointed to by an element of argv, then optarg shall contain the next element of argv, and optind shall be incremented by 2. If the resulting - value of optind is greater than argc, this indicates a missing + value of optind is greater than argc, this indicates a missing option-argument, and getopt() shall return an error indication. Otherwise, optarg shall point to the string following the @@ -97,7 +97,7 @@ int getopt(int argc, char* const argv[], const char* optstring) { if (++optind < argc) { optarg = argv[optind]; } else { - /* If it detects a missing option-argument, it shall return the + /* If it detects a missing option-argument, it shall return the colon character ( ':' ) if the first character of optstring was a colon, or a question-mark character ( '?' ) otherwise. */ @@ -112,7 +112,7 @@ int getopt(int argc, char* const argv[], const char* optstring) { optcursor = NULL; } } else { - /* If getopt() encounters an option character that is not contained in + /* If getopt() encounters an option character that is not contained in optstring, it shall return the question-mark ( '?' ) character. */ optchar = '?'; } @@ -131,7 +131,7 @@ int getopt(int argc, char* const argv[], const char* optstring) { [1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html */ -int getopt_long(int argc, char* const argv[], const char* optstring, +int getopt_long(int argc, char* const argv[], const char* optstring, const struct option* longopts, int* longindex) { const struct option* o = longopts; const struct option* match = NULL; @@ -165,7 +165,7 @@ int getopt_long(int argc, char* const argv[], const char* optstring, if (longindex) *longindex = (match - longopts); - /* If flag is NULL, then getopt_long() shall return val. + /* If flag is NULL, then getopt_long() shall return val. Otherwise, getopt_long() returns 0, and flag shall point to a variable which shall be set to val if the option is found, but left unchanged if the option is not found. */ @@ -190,7 +190,7 @@ int getopt_long(int argc, char* const argv[], const char* optstring, retval = ':'; } } else if (strchr(argv[optind], '=')) { - /* An argument was provided to a non-argument option. + /* An argument was provided to a non-argument option. I haven't seen this specified explicitly, but both GNU and BSD-based implementations show this behavior. */ diff --git a/include/stlink/stlinkusb.h b/src/libusb_settings.h similarity index 91% rename from include/stlink/stlinkusb.h rename to src/libusb_settings.h index 633d82bd0..c2e2df923 100644 --- a/include/stlink/stlinkusb.h +++ b/src/libusb_settings.h @@ -1,5 +1,5 @@ -#ifndef STLINKUSB_H -#define STLINKUSB_H +#ifndef LIBUSB_SETTINGS_H +#define LIBUSB_SETTINGS_H #include diff --git a/src/md5.c b/src/md5.c index e2b526c7d..521c52969 100755 --- a/src/md5.c +++ b/src/md5.c @@ -15,9 +15,10 @@ // IMPORTS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#include "md5.h" #include +#include "md5.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // INTERNAL FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/sg.c b/src/sg.c index eee6be498..a0790f3c7 100644 --- a/src/sg.c +++ b/src/sg.c @@ -82,7 +82,7 @@ #include #include -#include "stlink.h" +#include #include "logging.h" #define STLINK_OK 0x80 diff --git a/include/stlink/sg.h b/src/sg.h similarity index 95% rename from include/stlink/sg.h rename to src/sg.h index 98efd4e58..3a8a7a239 100644 --- a/include/stlink/sg.h +++ b/src/sg.h @@ -1,5 +1,5 @@ /* - * File: stlink/sg.h + * File: sg.h * Author: karl * * Created on October 1, 2011, 11:29 PM @@ -8,8 +8,8 @@ #ifndef STLINK_SG_H #define STLINK_SG_H -#include "stlinkusb.h" -#include "stlink.h" +#include "libusb_settings.h" +#include #ifdef __cplusplus extern "C" { @@ -70,4 +70,3 @@ stlink_t* stlink_v1_open(const int verbose, int reset); #endif #endif /* STLINK_SG_H */ - diff --git a/src/gdbserver/gdb-remote.c b/src/st-util/gdb-remote.c similarity index 99% rename from src/gdbserver/gdb-remote.c rename to src/st-util/gdb-remote.c index 3b1794f3e..24636e8c9 100644 --- a/src/gdbserver/gdb-remote.c +++ b/src/st-util/gdb-remote.c @@ -8,6 +8,7 @@ #include #include #include + #if defined(__MINGW32__) || defined(_MSC_VER) #include #else @@ -15,6 +16,8 @@ #include #endif +#include "gdb-remote.h" + static const char hex[] = "0123456789abcdef"; int gdb_send_packet(int fd, char* data) { @@ -169,4 +172,3 @@ int gdb_check_for_interrupt(int fd) { return 0; } - diff --git a/src/gdbserver/gdb-remote.h b/src/st-util/gdb-remote.h similarity index 100% rename from src/gdbserver/gdb-remote.h rename to src/st-util/gdb-remote.h diff --git a/src/gdbserver/gdb-server.c b/src/st-util/gdb-server.c similarity index 99% rename from src/gdbserver/gdb-server.c rename to src/st-util/gdb-server.c index ce9f6eef7..a3839cfc8 100644 --- a/src/gdbserver/gdb-server.c +++ b/src/st-util/gdb-server.c @@ -14,6 +14,7 @@ #include #define __attribute__(x) #endif + #if defined(_WIN32) #include #else @@ -24,8 +25,7 @@ #endif #include -#include "../logging.h" - +#include #include "gdb-remote.h" #include "gdb-server.h" #include "semihosting.h" diff --git a/src/gdbserver/gdb-server.h b/src/st-util/gdb-server.h similarity index 100% rename from src/gdbserver/gdb-server.h rename to src/st-util/gdb-server.h diff --git a/src/gdbserver/semihosting.c b/src/st-util/semihosting.c similarity index 99% rename from src/gdbserver/semihosting.c rename to src/st-util/semihosting.c index d41a83246..fed66ab60 100644 --- a/src/gdbserver/semihosting.c +++ b/src/st-util/semihosting.c @@ -5,10 +5,9 @@ #include #include -#include "semihosting.h" - #include -#include "../logging.h" +#include +#include "semihosting.h" static int mem_read_u8(stlink_t *sl, uint32_t addr, uint8_t *data) { diff --git a/src/gdbserver/semihosting.h b/src/st-util/semihosting.h similarity index 100% rename from src/gdbserver/semihosting.h rename to src/st-util/semihosting.h diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index 74b71cecd..b5ef99df9 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -1,35 +1,41 @@ +### +# Build GUI +### + +## GUI-Building requires the presence of a GTK3 toolset if (NOT GTK3_FOUND) message(STATUS "GTK3 not found!") - return() # no GTK3 present => no GUI build + return() # no GTK3 present => no GUI build else (GTK3_FOUND) message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}") endif () -set(GUI_SOURCES gui.c gui.h) -set(INSTALLED_UI_DIR share/stlink) ### TODO: Check Path - include_directories(SYSTEM ${GTK3_INCLUDE_DIRS}) -# stlink-gui-local +set(GUI_SOURCES gui.c gui.h) + +## stlink-gui-local add_executable(stlink-gui-local ${GUI_SOURCES}) set_target_properties( stlink-gui-local PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}" ### TODO: Check Path + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}" + # Note: ${CMAKE_CURRENT_SOURCE_DIR} is src/stlink-gui ) target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${GTK3_LDFLAGS} ${SSP_LIB}) -# stlink-gui +## stlink-gui add_executable(stlink-gui ${GUI_SOURCES}) set_target_properties( stlink-gui PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/${INSTALLED_UI_DIR}" ### TODO: Check Path + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/bin" + # Note: ${CMAKE_INSTALL_PREFIX} defaults to /usr/local ) target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${GTK3_LDFLAGS} ${SSP_LIB}) -install(TARGETS stlink-gui RUNTIME DESTINATION bin) ### TODO: Check Path -install(FILES gui.ui DESTINATION ${INSTALLED_UI_DIR}) ### TODO: Check Path +install(TARGETS stlink-gui DESTINATION bin) +install(FILES stlink-gui.ui DESTINATION bin) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - install(FILES stlink-gui.desktop DESTINATION share/applications) # Install desktop entry + install(FILES stlink-gui.desktop DESTINATION share/applications) # Install desktop application entry install(FILES icons/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps) # Install icon endif () diff --git a/src/stlink-gui/gui.c b/src/stlink-gui/gui.c index f90196c06..5d5a422d5 100644 --- a/src/stlink-gui/gui.c +++ b/src/stlink-gui/gui.c @@ -779,10 +779,10 @@ static void stlink_gui_build_ui (STlinkGUI *gui) { GtkBuilder *builder; GtkListStore *devmem_store; GtkListStore *filemem_store; - gchar *ui_file = STLINK_UI_DIR "/gui.ui"; + gchar *ui_file = STLINK_UI_DIR "/stlink-gui.ui"; if (!g_file_test (ui_file, G_FILE_TEST_EXISTS)) - ui_file = "gui.ui"; + ui_file = "stlink-gui.ui"; builder = gtk_builder_new (); if (!gtk_builder_add_from_file (builder, ui_file, NULL)) { g_printerr ("Failed to load UI file: %s\n", ui_file); diff --git a/src/stlink-gui/gui.ui b/src/stlink-gui/stlink-gui.ui similarity index 100% rename from src/stlink-gui/gui.ui rename to src/stlink-gui/stlink-gui.ui diff --git a/src/tools/flash.c b/src/tools/flash.c index 3a9cc3674..841b93c3c 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -2,7 +2,6 @@ // TODO - this should be done as just a simple flag to the st-util command line... - #include #include #include @@ -10,7 +9,7 @@ #include #include -#include +#include static stlink_t *connected_stlink = NULL; diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 085d278db..544d4ad90 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -1,9 +1,9 @@ -#include - #include #include #include +#include + static bool starts_with(const char * str, const char * prefix) { size_t n = strlen(prefix); if (strlen(str) < n) return false; diff --git a/src/usb.c b/src/usb.c index c9ea7039a..4e7a2983f 100644 --- a/src/usb.c +++ b/src/usb.c @@ -7,11 +7,13 @@ #include #endif #include -#include #include #include -#include "stlink.h" +#if defined(__MINGW32__) || defined(_MSC_VER) +#include +#endif +#include enum SCSI_Generic_Direction {SG_DXFER_TO_DEV=0, SG_DXFER_FROM_DEV=0x80}; diff --git a/include/stlink/usb.h b/src/usb.h similarity index 96% rename from include/stlink/usb.h rename to src/usb.h index 88a9a981a..968f38ba4 100644 --- a/include/stlink/usb.h +++ b/src/usb.h @@ -1,5 +1,5 @@ /* - * File: stlink/usb.h + * File: usb.h * Author: karl * * Created on October 1, 2011, 11:29 PM @@ -10,9 +10,9 @@ #include -#include "stlink.h" -#include "stlinkusb.h" -#include "../src/logging.h" +#include +#include "libusb_settings.h" +#include "logging.h" #ifdef __cplusplus extern "C" { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d6fe9fdd5..40d2203db 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,7 @@ +### +# Build test executables +### + set(TESTEXEC usb sg) foreach (test ${TESTEXEC}) diff --git a/tests/flash.c b/tests/flash.c index 53032474a..903370cc3 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -3,7 +3,7 @@ #include #include -#include +#include #if defined(_MSC_VER) #include diff --git a/tests/sg.c b/tests/sg.c index 32ef55b69..1af177174 100644 --- a/tests/sg.c +++ b/tests/sg.c @@ -7,6 +7,7 @@ #include #include #include + #include #if defined(_MSC_VER) diff --git a/tests/usb.c b/tests/usb.c index a2c3ef8cd..d4098834d 100644 --- a/tests/usb.c +++ b/tests/usb.c @@ -1,4 +1,5 @@ #include + #include int main(int ac, char** av) { @@ -35,7 +36,6 @@ int main(int ac, char** av) { printf("cpuid:impl_id = %0#x, variant = %#x\n", cpuid.implementer_id, cpuid.variant); printf("cpuid:part = %#x, rev = %#x\n", cpuid.part, cpuid.revision); } - printf("-- read_sram\n"); static const uint32_t sram_base = STM32_SRAM_BASE; From 6a768d36f5c95ded5fb5ebc203d0ef2fa4a28802 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 27 Apr 2020 14:41:01 +0800 Subject: [PATCH 189/236] Add a documentation about flashloaders and adjust clean room document version order --- doc/flashloaders.md | 54 ++++++++++ flashloaders/cleanroom.md | 211 +++++++++++++++++++------------------- 2 files changed, 160 insertions(+), 105 deletions(-) create mode 100644 doc/flashloaders.md diff --git a/doc/flashloaders.md b/doc/flashloaders.md new file mode 100644 index 000000000..6a7cb3504 --- /dev/null +++ b/doc/flashloaders.md @@ -0,0 +1,54 @@ +# Flashloaders + +## What do flashloaders do + +The on-chip FLASH of STM32 needs to be written once a byte/half word/word/double word, which would lead to a unbearably long flashing time if the process is solely done by `stlink` from the host side. Flashloaders are introduced to cooperate with `stlink` so that the flashing process is divided into two stages. In the first stage, `stlink` loads flashloaders and flash data to SRAM where busy check is not applied. In the second stage, flashloaders are kick-started, writing data from SRAM to FLASH, where a busy check is applied. Thus the write-check\_if\_busy cycle of flashing is done solely by STM32 chip, which saves considerable time in communications between `stlink` and STM32. + +As SRAM is usually less in size than FLASH, `stlink` only flashes one page (may be less if SRAM is insufficient) at a time. The whole flashing process may consist of server launches of flashloaders. + +## The flahsing process + +1. `st-flash` loads compiled binary of corresponding flashloader to SRAM by calling `stlink_flash_loader_init` in `src/flash_loader.c` +2. `st-flash` erases corresponding flash page by calling `stlink_erase_flash_page` in `common.c`. +3. `st-flash` calls `stlink_flash_loader_run` in `flash_loader.c`. In this function + + buffer of one flash page is written to SRAM following the flashloader + + the buffer start address (in SRAM) is written to register `r0` + + the target start address (in FLASH, page aligned) is written to register `r1` + + the buffer size is written to register `r2` + + the start address (for now 0x20000000) of flash loader is written to `r15` (`pc`) + + After that, launching the flashloader and waiting for a halted core (triggered by our flashloader) and confirming that flashing is completed with a zeroed `r2` +4. flashloader part: much like a `memcpy` with busy check + + copy a single unit of data from SRAM to FLASH + + (for most devices) wait until flash is not busy + + trigger a breakpoint which halts the core when finished + +## Constraints + +Thus for developers who want to modify flashloaders, the following constraints should be satisfied. + +* only thumb-1 (for stm32f0 etc) or (thumb-1 and thumb-2) (for stm32f1 etc) instructions can be used, no ARM instructions. +* no stack, since it may overwrite buffer data. +* for most devices, after writing a single unit data, wait until FLASH is not busy. +* for some devices, check if there are any errors during flashing process. +* respect unit size of a single copy. +* after flashing, trigger a breakpint to halt the core. +* a sucessful run ends with `r2` set to zero when halted. +* be sure that flashloaders are at least be capable of running at 0x20000000 (the base address of SRAM) + + +For devices that need to wait until the flash is not busy, check FLASH_SR_BUSY bit. For devices that need to check if there is any errors during flash, check FLASH\_SR\_(X)ERR where `X` can be any error state + +FLASH_SR related offset and copy unit size may be found in ST official reference manuals and/or some header files in other open source projects. Clean room document provides some of them. + + +## Debug tricks + +If you find some flashloaders to be broken or you need to write a new flashloader for new devices, the following tricks may help. + +1. Modify `WAIT_ROUNDS` marco to a bigger value so that you will have time to kill st-flash when it is waiting for a halted core. +2. run `st-flash` and kill it after the flashloader is loaded to SRAM +3. launch `st-util` and `gdb`/`lldb` +4. set a breakpoint at the base address of SRAM +5. jump to the base address and start your debug + +The tricks work because by this means, most work (flash unlock, flash erase, load flashloader to SRAM) would have been done automatically, saving time to construct a debug environment. \ No newline at end of file diff --git a/flashloaders/cleanroom.md b/flashloaders/cleanroom.md index 1bae4535d..a468efe49 100644 --- a/flashloaders/cleanroom.md +++ b/flashloaders/cleanroom.md @@ -1,232 +1,233 @@ -English version can be found below. +Original Chinese version can be found below. -# 净室工程文档 +# Clean Room Documentation English Version -代码位于的section:`.text` -编译制导添加`.syntax unified` +Code is situated in section `.text` -传入参数约定: +Shall add a compile directive at the head: `.syntax unified` -参数全部通过寄存器传递 +**Calling convention**: -`r0`: 拷贝源点起始地址 -`r1`: 拷贝终点起始地址 -`r2`: 拷贝word(4字节)数(存在例外) +All parameters would be passed over registers -程序功能:将数据从源点拷贝到终点,在拷贝完毕后触发断点以结束执行,结束时`r2`值需清零表明传输完毕。 +`r0`: the base address of the copy source +`r1`: the base address of the copy destination +`r2`: the total word (4 bytes) count to be copied (with expeptions) -限制:不可使用栈,可自由使用的临时寄存器为`R3`到`R12`。`R13`为`sp`(stack pointer),`R14`为lr(一般用于储存跳转地址),`R15`为`pc`(program counter)。 +**What the program is expected to do**: -要求:每完成一次拷贝,需等待flash完成写入,单次拷贝宽度、检查写入完成的方式见每个文件的具体要求。 +Copy data from source to destination, after which trigger a breakpint to exit. Before exit, `r2` must be cleared to zero to indicate that the copy is done. -特殊地址`flash_base`存放地址需2字节对齐。 +**Limitation**: No stack operations are permitted. Registers ranging from `r3` to `r12` are free to use. Note that `r13` is `sp`(stack pointer), `r14` is `lr`(commonly used to store jump address), `r15` is `pc`(program counter). + +**Requirement**: After every single copy, wait until the flash finishes. The detailed single copy length and the way to check can be found below. Address of `flash_base` shall be two-bytes aligned. ## stm32f0.s -例外:`r2`:拷贝half word(2字节)数 +**Exception**: `r2` stores the total half word (2 bytes) count to be copied -特殊地址定义:`flash_base`:定义为0x40022000 +`flash_base`: 0x40022000 -`FLASH_CR`: 相对`flash_base`的offset为16 +`FLASH_CR`: offset from `flash_base` is 16 -`FLASH_SR`: 相对`flash_base`的offset为12 +`FLASH_SR`: offset from `flash_base` is 12 -参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h) +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h) [https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -特殊要求: -每次拷贝开始前需要读出FLASH_CR处的4字节内容,将其最低bit设置为1,写回FLASH_CR。 - -每次写入数据宽度为2字节(半字)。 - -每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处4字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待;否则需要检查FLASH_SR处值是否为4,若非4,则应直接准备退出。 +**Special requirements**: -退出:全部拷贝执行完毕后触发断点前,将FLASH_CR处4字节内容最低bit清为0,写回FLASH_CR。 +Before every copy, read a word from FLASH_CR, set the lowest bit to 1 and write back. Copy one half word each time. +How to wait for the write process: read a word from FLASH_SR, loop until the content is not 1. After that, check FLASH_SR, proceed if the content is 4, otherwise exit. +Exit: after the copying process and before triggering the breakpoint, clear the lowest bit in FLASH_CR. ## stm32f4.s -特殊地址定义: `flash_base`:定义为0x40023c00 +`flash_base`: 0x40023c00 -`FLASH_SR`:相对flash_base的offset为0xe(14) +`FLASH_SR`: offset from `flash_base` is 0xe (14) -参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) [https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) -特殊要求: -每次写入的数据宽度为4字节(字)。 +**Special requirements**: -每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处2字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待。 +Copy one word each time. +How to wait for the write process: read a half word from FLASH_SR, loop until the content is not 1. ## stm32f4lv.s -特殊地址定义:`flash_base`:定义为0x40023c00 +`flash_base`: 0x40023c00 -`FLASH_SR`:相对`flash_base`的offset为0xe (14) +`FLASH_SR`: offset from `flash_base` is 0xe (14) -参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) [https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) -特殊要求: +**Special Requirements**: -每次写入的数据宽度为1字节(1/4字)。 +Copy one byte each time. -每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处2字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待。 +How to wait from the write process: read a half word from FLASH_SR, loop until the content is not 1. ## stm32f7.s -参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) [https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -要求同stm32f4.s,额外要求在每次拷贝执行完毕、flash写入成功检测前,执行`dsb sy`指令以建立内存屏障。 - +Mostly same with `stm32f4.s`. Require establishing a memory barrier after every copy and before checking for finished writing by `dsb sy` ## stm32f7lv.s -参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) [https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -要求基本同stm32f7.s,差异要求为每次写入的数据宽度为1字节(1/4字)。 -## stm32l0x.s +**Special Requirements**: -特殊要求: +Mostly same with `stm32f7.s`. Copy one byte each time. -每次写入的数据宽度为4字节(字) +## stm32l0x.s -无需实现检查flash写入完成功能 +**Special Requirements**: -## stm32l4.s +Copy one word each time. No wait for write. -例外:`r2`: 拷贝双字(8字节)数 +## stm32l4.s -特殊地址定义:`flash_base`: 0x40022000 +**Exception**: r2 stores the double word count to be copied. -`FLASH_BSY`:相对flash_base的offset为0x12 +`flash_base`: 0x40022000 +`FLASH_BSY`: offset from `flash_base` is 0x12 -参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h) +**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h) [https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -拷贝方式:一次性拷贝连续的8个字节(使用两个连续寄存器作中转)并写入 +**Special Requirements**: -每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_BSY处半字(2字节),若其最低位非1,可继续拷贝。 +Copy one double word each time (More than one registers are allowed). + +How to wait for the write process: read a half word from `FLASH_BSY`, loop until the lowest bit turns non-1. ## stm32lx.s -要求与stm32l0x.s相同 +Same with stm32l0x.s. -# Clean Room Documentation English Version -Code is situated in section `.text` +# 净室工程文档-原始中文版 -Shall add a compile directive at the head: `.syntax unified` +代码位于的section:`.text` +编译制导添加`.syntax unified` -**Calling convention**: +传入参数约定: -All parameters would be passed over registers +参数全部通过寄存器传递 -`r0`: the base address of the copy source -`r1`: the base address of the copy destination -`r2`: the total word (4 bytes) count to be copied (with expeptions) +`r0`: 拷贝源点起始地址 +`r1`: 拷贝终点起始地址 +`r2`: 拷贝word(4字节)数(存在例外) -**What the program is expected to do**: +程序功能:将数据从源点拷贝到终点,在拷贝完毕后触发断点以结束执行,结束时`r2`值需清零表明传输完毕。 -Copy data from source to destination, after which trigger a breakpint to exit. Before exit, `r2` must be cleared to zero to indicate that the copy is done. +限制:不可使用栈,可自由使用的临时寄存器为`R3`到`R12`。`R13`为`sp`(stack pointer),`R14`为lr(一般用于储存跳转地址),`R15`为`pc`(program counter)。 -**Limitation**: No stack operations are permitted. Registers ranging from `r3` to `r12` are free to use. Note that `r13` is `sp`(stack pointer), `r14` is `lr`(commonly used to store jump address), `r15` is `pc`(program counter). +要求:每完成一次拷贝,需等待flash完成写入,单次拷贝宽度、检查写入完成的方式见每个文件的具体要求。 -**Requirement**: After every single copy, wait until the flash finishes. The detailed single copy length and the way to check can be found below. Address of `flash_base` shall be two-bytes aligned. +特殊地址`flash_base`存放地址需2字节对齐。 ## stm32f0.s -**Exception**: `r2` stores the total half word (2 bytes) count to be copied +例外:`r2`:拷贝half word(2字节)数 -`flash_base`: 0x40022000 +特殊地址定义:`flash_base`:定义为0x40022000 -`FLASH_CR`: offset from `flash_base` is 16 +`FLASH_CR`: 相对`flash_base`的offset为16 -`FLASH_SR`: offset from `flash_base` is 12 +`FLASH_SR`: 相对`flash_base`的offset为12 -**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h) +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f0.h) [https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -**Special requirements**: +特殊要求: +每次拷贝开始前需要读出FLASH_CR处的4字节内容,将其最低bit设置为1,写回FLASH_CR。 -Before every copy, read a word from FLASH_CR, set the lowest bit to 1 and write back. Copy one half word each time. +每次写入数据宽度为2字节(半字)。 + +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处4字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待;否则需要检查FLASH_SR处值是否为4,若非4,则应直接准备退出。 + +退出:全部拷贝执行完毕后触发断点前,将FLASH_CR处4字节内容最低bit清为0,写回FLASH_CR。 -How to wait for the write process: read a word from FLASH_SR, loop until the content is not 1. After that, check FLASH_SR, proceed if the content is 4, otherwise exit. -Exit: after the copying process and before triggering the breakpoint, clear the lowest bit in FLASH_CR. ## stm32f4.s -`flash_base`: 0x40023c00 +特殊地址定义: `flash_base`:定义为0x40023c00 -`FLASH_SR`: offset from `flash_base` is 0xe (14) +`FLASH_SR`:相对flash_base的offset为0xe(14) -**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) [https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) +特殊要求: -**Special requirements**: +每次写入的数据宽度为4字节(字)。 -Copy one word each time. -How to wait for the write process: read a half word from FLASH_SR, loop until the content is not 1. +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处2字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待。 ## stm32f4lv.s -`flash_base`: 0x40023c00 +特殊地址定义:`flash_base`:定义为0x40023c00 -`FLASH_SR`: offset from `flash_base` is 0xe (14) +`FLASH_SR`:相对`flash_base`的offset为0xe (14) -**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f4.h) [https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf](https://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf) -**Special Requirements**: +特殊要求: -Copy one byte each time. +每次写入的数据宽度为1字节(1/4字)。 -How to wait from the write process: read a half word from FLASH_SR, loop until the content is not 1. +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_SR处2字节内容,若取值为1,则说明写入尚未完成,需继续轮询等待。 ## stm32f7.s -**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) [https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -Mostly same with `stm32f4.s`. Require establishing a memory barrier after every copy and before checking for finished writing by `dsb sy` +要求同stm32f4.s,额外要求在每次拷贝执行完毕、flash写入成功检测前,执行`dsb sy`指令以建立内存屏障。 + ## stm32f7lv.s -**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32f7.h) [https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00124865-stm32f75xxx-and-stm32f74xxx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) - -**Special Requirements**: - -Mostly same with `stm32f7.s`. Copy one byte each time. +要求基本同stm32f7.s,差异要求为每次写入的数据宽度为1字节(1/4字)。 ## stm32l0x.s -**Special Requirements**: +特殊要求: -Copy one word each time. No wait for write. +每次写入的数据宽度为4字节(字) + +无需实现检查flash写入完成功能 ## stm32l4.s -**Exception**: r2 stores the double word count to be copied. +例外:`r2`: 拷贝双字(8字节)数 -`flash_base`: 0x40022000 -`FLASH_BSY`: offset from `flash_base` is 0x12 +特殊地址定义:`flash_base`: 0x40022000 -**Reference**: [https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h) -[https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) +`FLASH_BSY`:相对flash_base的offset为0x12 -**Special Requirements**: +参考:[https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/chip/stm32/registers-stm32l4.h) +[https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf](https://www.st.com/resource/en/reference_manual/dm00310109-stm32l4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf) -Copy one double word each time (More than one registers are allowed). +拷贝方式:一次性拷贝连续的8个字节(使用两个连续寄存器作中转)并写入 -How to wait for the write process: read a half word from `FLASH_BSY`, loop until the lowest bit turns non-1. +每完成一次写入,需等待flash完成写入,检查方式为读取FLASH_BSY处半字(2字节),若其最低位非1,可继续拷贝。 ## stm32lx.s -Same with stm32l0x.s. \ No newline at end of file +要求与stm32l0x.s相同 \ No newline at end of file From e87bdff95b946ebfbfed7d5157d6e3bcd32e6f67 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 27 Apr 2020 20:20:50 +0200 Subject: [PATCH 190/236] General Project Update - Updated project README - Updated .gitignore - Updated project contributors - Added contribution guidelines --- .gitignore | 1 + .travis.yml | 12 ++++++++ CMakeLists.txt | 1 + CONTRIBUTING.md | 49 ++++++++++++++++++++++++++++++++ README.md | 16 +++++++---- cmake/packaging/debian/copyright | 2 +- 6 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.gitignore b/.gitignore index 23e7ddc07..09b9b33de 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build build-mingw obj-* *.user* +.project diff --git a/.travis.yml b/.travis.yml index b7ff93ff9..3e015dd07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ matrix: include: ### 64-bit builds ### - os: linux + env: BADGE=linux arch: x64 compiler: gcc-5 addons: @@ -11,6 +12,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x64 compiler: gcc-7 addons: @@ -18,6 +20,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x64 compiler: gcc-9 addons: @@ -25,6 +28,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x64 compiler: clang-3.7 addons: @@ -32,6 +36,7 @@ matrix: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x64 compiler: clang-6.0 addons: @@ -49,6 +54,7 @@ matrix: ### 32-bit builds ### - os: linux + env: BADGE=linux arch: x86 compiler: gcc-5 addons: @@ -56,6 +62,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x86 compiler: gcc-7 addons: @@ -63,6 +70,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x86 compiler: gcc-9 addons: @@ -70,6 +78,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x86 compiler: clang-3.7 addons: @@ -77,6 +86,7 @@ matrix: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] - os: linux + env: BADGE=linux arch: x86 compiler: clang-6.0 addons: @@ -86,6 +96,7 @@ matrix: ### macOS ### - os: osx + env: BADGE=osx compiler: gcc addons: homebrew: @@ -94,6 +105,7 @@ matrix: - libusb - gtk+3 - os: osx + env: BADGE=osx compiler: clang addons: homebrew: diff --git a/CMakeLists.txt b/CMakeLists.txt index 95e27d215..b5301fb0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,6 +278,7 @@ install(TARGETS st-flash DESTINATION bin) install(TARGETS st-info DESTINATION bin) install(TARGETS st-util DESTINATION bin) + ### # Additional build tasks ### diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..a9bb02661 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,49 @@ +# Contribution guidelines + +## Contributing to the stlink project +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features +- Assistance with maintaining + +We use GitHub to host code, to track issues and feature requests, as well as accept pull requests. +Report a bug by [opening a new issue]() with one of the available templates. It's that easy! + + +## Coding conventions +To read code written by other contributors can turn out to be quite demanding - a variable which seems to self-explaining, may appear cryptic to other readers. If you plan to contribute, please take this into account and feel encouraged to help others understand your code. In order to help you along, we have composed some contribution guidelines for this project. As this project already has a history you may find parts in the codebase that do not seem to comply with these guidelines, but we are trying to improve continuosly. However we can do even better, if every contributor considers the following points: + +* Naming of all source code elements as well as comments should exclusively be written in English. +* All functions and global variables should be fully explained. This includes a short description on _what_ the respective function does (but not necessarily _how_ this is achieved), an explantion of transfer parameters and/or return values (if applicable). +* Use [fixed width integer types](http://en.cppreference.com/w/c/types/integer) wherever possible and size-appropiate datatypes. +* Only make use of the datatype `char` for specific characters, otherwise use `int8_t` or `uint8_t` respectively. + + +### Coding Style +* Use 4 spaces for indentation rather than tabs (the latter results in inconsistent appearance on different platforms) +* Use `/* your comment */` formatting for multi-line comments or section titles and `// your comment` for inline comments. +* Please try to avoid special characters where possible, as they are interpreted differently on particular platforms and systems. Otherwise these may result in mojibake within the sourcecode or cause translation errors when compiling. +* Use state-of-the-art UTF-8 encoding whereever possible. + + +## Github Flow +We Use [Github Flow](https://guides.github.com/introduction/flow/index.html) which implies that all code changes happen through Pull Requests (PRs). +They are the best way to propose changes to the codebase and we actively welcome your own ones: + +1. PRs should focus on _one_ single topic. +2. Fork the repo and create your branch from `develop`. +3. Begin to implement your changes on a local or personal branch. +4. Take a look at existing PR and check if these target the same part of the codebase. + Should this be the case, you are encouraged to get in touch with the respective author and discuss on how to proceed. +5. Keep your personal feature-branch up to date with the current development branch, by merging in recent changes regularly. +6. Don't open a PR unless your contribution has evolved to a somehow completed set of changes. +7. If you've changed major features, update the documentation. +8. Ensure your PR passes our travis CI tests. +9. Issue that pull request! + + +## License +When you submit code changes, your submissions are understood to be under the same [BSD-3 License](LICENSE.md) that covers this project.
Feel free to contact the project maintainers should there be any related questions. diff --git a/README.md b/README.md index 735712329..4bf663e34 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,12 @@ Open source version of the STMicroelectronics STlink Tools [![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/stlink-org/stlink.svg)](https://github.com/stlink-org/stlink/releases/latest) -[![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.0.svg)](https://github.com/stlink-org/stlink/releases/develop) -[![Downloads](https://img.shields.io/github/downloads/stlink-org/stlink/total.svg)](https://github.com/stlink-org/stlink/releases) -[![Linux Status](https://img.shields.io/travis/stlink-org/stlink/master.svg?label=linux)](https://travis-ci.org/stlink-org/stlink) -[![macOS Status](https://img.shields.io/travis/stlink-org/stlink/master.svg?label=osx)](https://travis-ci.org/stlink-org/stlink) +[![Downloads](https://img.shields.io/github/downloads/stlink-org/stlink/total)](https://github.com/stlink-org/stlink/releases/latest) +![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.0/develop) +![GitHub activity](https://img.shields.io/github/commit-activity/m/stlink-org/stlink) +![GitHub contributors](https://img.shields.io/github/contributors/stlink-org/stlink) +[![Linux Status](https://img.shields.io/travis/stlink-org/stlink/master?env=BADGE=linux&label=linux)](https://travis-ci.org/stlink-org/stlink) +[![macOS Status](https://img.shields.io/travis/stlink-org/stlink/master?env=BADGE=osx&label=osx)](https://travis-ci.org/stlink-org/stlink) Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) of this software project. @@ -104,8 +106,10 @@ When there is no executable available for your platform or you need the latest ( * The semantic versioning scheme is used. Read more at [semver.org](http://semver.org) * Before creating a pull request, please _ALWAYS_ open a new issue for the discussion of the intended new features. Bugfixes don't require a discussion via a ticket-issue. However they should always be described in a few words as soon as they appear to help others as well. * Contributors and/or maintainers may submit comments or request changes to patch-proposals and/or pull-requests. -* **ATTENTION: _NEVER EVER_ use the '#' character to count-up single points within a listing as '#' is _exclusively_ reserved for referencing github issues and pull-requests. Otherwise you accidentally introduce false cross references within the project.** -* Please start new forks from the develop branch if possible as pull requests will go into this branch as well. +* **ATTENTION: _NEVER EVER_ use the '#' character to count-up single points within a listing as '#' is _exclusively_ reserved for referencing GitHub issues and pull-requests. Otherwise you accidentally introduce false cross references within the project.** +* Please start new forks from the develop branch, as pull requests will go into this branch as well. + +Please also refer to our [Contribution Guidelines](CONTRIBUTING.md). # Current state of the project diff --git a/cmake/packaging/debian/copyright b/cmake/packaging/debian/copyright index 4a7b110ae..4e58490f6 100644 --- a/cmake/packaging/debian/copyright +++ b/cmake/packaging/debian/copyright @@ -48,6 +48,7 @@ Copyright: 2011-2020 stlink-org Breton M. Saunders Bruno Dal Bo Burns Fisher + Cheng Guokai (Xim) [chenguokai] Chris Dew Chris Hiszpanski Chris Li @@ -153,5 +154,4 @@ Copyright: 2011-2020 stlink-org William Ransohoff [WRansohoff] Wojciech A. Koszek Woodrow Douglass - Xim [chenguokai] ... and others From 38a5c14877964e7ea272565b372576d61710790f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 27 Apr 2020 23:29:01 +0200 Subject: [PATCH 191/236] Updated CHANGELOG.md --- CHANGELOG.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad6b6497..f79cd846c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,9 +26,10 @@ Features: Updates & changes: +- Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION (#211, #782, #895) - Improved argument parsing for CLI tools (#378, #922) - [doc] Updated tutorial: macOS ST-Link-v1 detection (#574, #587) -- Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION (#211, #782, #895) +- Enhanced output for error msg "addr not a multiple of pagesize, not supported" (#663, #945) - [doc] Verify correct udev configuration for device access (#764) - Added more error info to WLOGs during probe (#883) - Added check for libssp during compilation (#885) @@ -41,9 +42,15 @@ Updates & changes: - [doc] Defined version compatibility and installation instructions for macOS (commit 23c071edea45f6e8852fef52d884a680973d6d8f) - Deprecated old appveyor-mingw script (commit 97484422008df0f75c978627054776f35842a075) - Enhanced error log with file path for map_file() (#650, #879, #921) -- Refactoring: Overall option code rework (#927) -- Refactoring: Build settings / GUI-Build on UNIX-based systems if GTK3 is detected (#929) -- Reconfiguration of package build process (#931, #936, #940, commit 9b19f9225460472af9d98959b7217d0a840ee972) +- [refactoring] Overall option code rework (#927) +- [refactoring] Build settings / GUI-Build on UNIX-based systems if GTK3 is detected (#929) +- [refactoring] Reconfiguration of package build process (#931, #936, #940, commit 9b19f9225460472af9d98959b7217d0a840ee972) +- [refactoring] st-util: Removed now useless v1/v2 STLink version stuff (#934) +- [refactoring] Cleanup for option bytes and flash settings (#941) +- Added compilation guideline for MSVC toolchain (#942) +- st-util: Removal of useless v1/v2 stlink version stuff (#934) +- libusb package extraction no longer requires 7zip as an external unarchiver (commit 5db2dc4c0410ace65308cddcc03d1c0cfa4855cf) +- [refactoring] Cleanup of cmake build process (#944, #946, #947) Fixes: @@ -60,7 +67,7 @@ Fixes: - Fixed formatting for options display in st-flash & st-info (commits c783d0e777ccc83a7a8be26a4f4d3414e0478560 and 562cd2496e696dbd22950925866aac662d81ee5f) - Fixed dead loop after an unexpected unplug (#780, #812, #913) - Fixed broken build on 32-bit systems (#919, #920) -- st-flash: minor usage fix and make cmdline parsing more user friendly (#925) +- st-flash: Minor usage fix and make cmdline parsing more user friendly (#925) - Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 (#378, #922) - Restored functionality of make test builds (Regression) (#926, #929) - Fixed compilation error due to uninitialized cpuid (#937, #938) From ce6ffe70303cc75b663b91b0f2905821f3235a17 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 29 Apr 2020 16:24:14 +0200 Subject: [PATCH 192/236] Refactoring for package distribution - New cpack package-config for DEB and RPM - Toolchain file for cross-building - Script to automate MinGW cross-building - Added file headers for .cmake files - Added dpkg and rpm to required pkgs --- .travis.yml | 20 ++-- Makefile | 2 +- cmake/modules/Findlibusb.cmake | 25 +++-- cmake/modules/c_flags.cmake | 3 + cmake/modules/get_version.cmake | 8 +- cmake/modules/set_toolchain.cmake | 20 ++++ cmake/packaging/cpack_config.cmake | 108 +++++++++++-------- cmake/packaging/windows/generate_binaries.sh | 26 +++++ debian/.gitignore | 10 -- doc/compiling.md | 2 + 10 files changed, 148 insertions(+), 76 deletions(-) create mode 100644 cmake/modules/set_toolchain.cmake create mode 100644 cmake/packaging/windows/generate_binaries.sh delete mode 100644 debian/.gitignore diff --git a/.travis.yml b/.travis.yml index 3e015dd07..a66777f5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x64 @@ -18,7 +18,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x64 @@ -26,7 +26,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x64 @@ -34,7 +34,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] - packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x64 @@ -42,7 +42,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] - packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] # - os: linux # arch: x64 # compiler: clang-6.0 @@ -60,7 +60,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x86 @@ -68,7 +68,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x86 @@ -76,7 +76,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x86 @@ -84,7 +84,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] - packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux env: BADGE=linux arch: x86 @@ -92,7 +92,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] - packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev'] + packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] ### macOS ### - os: osx diff --git a/Makefile b/Makefile index 74a4fece5..7f373ebcd 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ package: build/Release @$(MAKE) -C build/Release package test: debug - @echo "[TEST]" + @echo "[TEST] Debug" @$(MAKE) -C build/Debug test build/Debug: diff --git a/cmake/modules/Findlibusb.cmake b/cmake/modules/Findlibusb.cmake index 898820033..bc613779d 100644 --- a/cmake/modules/Findlibusb.cmake +++ b/cmake/modules/Findlibusb.cmake @@ -1,4 +1,6 @@ # Findlibusb.cmake +# Find and install external libusb library + # Once done this will define # # LIBUSB_FOUND libusb present on system @@ -8,7 +10,7 @@ include(FindPackageHandleStandardArgs) -if (APPLE) # macOS +if (APPLE) # macOS FIND_PATH( LIBUSB_INCLUDE_DIR NAMES libusb.h HINTS /usr /usr/local /opt @@ -25,7 +27,7 @@ if (APPLE) # macOS message(FATAL_ERROR "No libusb library found on your system! Install libusb-1.0 from Homebrew or MacPorts") endif () -elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system +elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated into the system FIND_PATH( LIBUSB_INCLUDE_DIR NAMES libusb.h HINTS /usr/include @@ -41,7 +43,7 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") # FreeBSD; libusb is integrated message(FATAL_ERROR "Expected libusb library not found on your system! Verify your system integrity.") endif () -elseif (WIN32) # Windows +elseif (WIN32 OR (EXISTS "/etc/debian_version" AND MINGW)) # Windows or MinGW-toolchain on Debian # for MinGW/MSYS/MSVC: 64-bit or 32-bit? if (CMAKE_SIZEOF_VOID_P EQUAL 8) set(ARCH 64) @@ -49,7 +51,7 @@ elseif (WIN32) # Windows set(ARCH 32) endif () - if (NOT EXISTS "/etc/debian_version") + if (WIN32 AND NOT EXISTS "/etc/debian_version") # Skip this for Debian... FIND_PATH( LIBUSB_INCLUDE_DIR NAMES libusb.h HINTS /usr /usr/local /opt @@ -71,12 +73,17 @@ elseif (WIN32) # Windows endif () endif () - if (NOT LIBUSB_FOUND OR EXISTS "/etc/debian_version") + if (NOT LIBUSB_FOUND) # Preparations for installing libusb library set(LIBUSB_WIN_VERSION 1.0.23) # set libusb version 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}/3rdparty/libusb-${LIBUSB_WIN_VERSION}) + if (WIN32 AND NOT EXISTS "/etc/debian_version") # ... on native Windows systems + set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_BINARY_DIR}/${LIBUSB_WIN_ARCHIVE}) + set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_BINARY_DIR}/3rdparty/libusb-${LIBUSB_WIN_VERSION}) + else (EXISTS "/etc/debian_version" AND MINGW) # ... only for cross-building on Debian + set(LIBUSB_WIN_ARCHIVE_PATH ${CMAKE_SOURCE_DIR}/build-mingw/${LIBUSB_WIN_ARCHIVE}) + set(LIBUSB_WIN_OUTPUT_FOLDER ${CMAKE_SOURCE_DIR}/build-mingw/3rdparty/libusb-${LIBUSB_WIN_VERSION}) + endif () # Get libusb package if (EXISTS ${LIBUSB_WIN_ARCHIVE_PATH}) # ... should the package be already there (for whatever reason) @@ -107,6 +114,7 @@ elseif (WIN32) # Windows ) if (MINGW OR MSYS) + set(LIBUSB_NAME usb-1.0) find_library( LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MinGW${ARCH}/static @@ -115,6 +123,7 @@ elseif (WIN32) # Windows ) else (MSVC) + set(LIBUSB_NAME libusb-1.0.lib) find_library( LIBUSB_LIBRARY NAMES ${LIBUSB_NAME} HINTS ${LIBUSB_WIN_OUTPUT_FOLDER}/MS${ARCH}/dll @@ -127,7 +136,7 @@ elseif (WIN32) # Windows FIND_PACKAGE_HANDLE_STANDARD_ARGS(libusb DEFAULT_MSG LIBUSB_LIBRARY LIBUSB_INCLUDE_DIR) mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARY) -else () # all other OS (unix-based) +else () # all other OS (unix-based) FIND_PATH( LIBUSB_INCLUDE_DIR NAMES libusb.h HINTS /usr /usr/local /opt diff --git a/cmake/modules/c_flags.cmake b/cmake/modules/c_flags.cmake index d6b12403b..520182e37 100644 --- a/cmake/modules/c_flags.cmake +++ b/cmake/modules/c_flags.cmake @@ -1,3 +1,6 @@ +# c_flags.cmake +# Configure C compiler flags + include(CheckCCompilerFlag) function(add_cflag_if_supported flag) diff --git a/cmake/modules/get_version.cmake b/cmake/modules/get_version.cmake index da9d76eba..b80f0c9db 100644 --- a/cmake/modules/get_version.cmake +++ b/cmake/modules/get_version.cmake @@ -1,6 +1,5 @@ -# Determine project version -# * Using Git -# * Local .version file +# get_version.cmake +# Determine project version by using Git or a local .version file set(__detect_version 0) @@ -77,13 +76,14 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") endif(GIT_DESCRIBE_RESULT EQUAL 0) endif () +## # Failure to read version via git # Possible cases: # -> git is not found or # -> /.git does not exist or # -> GIT_DESCRIBE failed or # -> version string is of invalid format - +## if (NOT GIT_FOUND OR NOT EXISTS "${PROJECT_SOURCE_DIR}/.git" OR ERROR_FLAG EQUAL 1) message(STATUS "Git and/or repository not found.") # e.g. when building from source package message(STATUS "Try to detect version from \"${PROJECT_SOURCE_DIR}/.version\" file instead...") diff --git a/cmake/modules/set_toolchain.cmake b/cmake/modules/set_toolchain.cmake new file mode 100644 index 000000000..3c40e917e --- /dev/null +++ b/cmake/modules/set_toolchain.cmake @@ -0,0 +1,20 @@ +# set_toolchain.cmake +# Toolchain file for cross-building on a Debian/Ubuntu Linux system + +### +# Set toolchain and configure target environment on the build host system +### + +# Set cross compilers to use for C and C++ +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) + +# Set path to directory with headers and libraries of the cross compiler +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) + +# Modify default behavior of FIND_XXX() commands to search for headers and libraries +# in the target environment and 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) diff --git a/cmake/packaging/cpack_config.cmake b/cmake/packaging/cpack_config.cmake index 522fb7f11..c81362896 100644 --- a/cmake/packaging/cpack_config.cmake +++ b/cmake/packaging/cpack_config.cmake @@ -1,67 +1,68 @@ +# cpack_config.cmake +# Configure and generate packages for distribution + ### # Configure package ### set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_PACKAGE_DESCRIPTION "Open source STM32 MCU programming toolset") +set(CPACK_PACKAGE_VENDOR "stlink-org") +set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/stlink-org/stlink") + set(CPACK_SET_DESTDIR "ON") set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist") -if (APPLE) +if (APPLE) # macOS set(CPACK_GENERATOR "ZIP") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-macosx-amd64") set(CPACK_INSTALL_PREFIX "") -elseif (WIN32) ### TODO: Binary build config for windows... + +elseif (WIN32 AND NOT EXISTS "/etc/debian_version") # Windows set(CPACK_GENERATOR "ZIP") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win32") set(CPACK_INSTALL_PREFIX "") - # Sample toolchain file for building for Windows from a Debian/Ubuntu Linux system. - # Typical usage: - # *) install cross compiler: `sudo apt-get install mingw-w64` - # *) cd build - # *) cmake -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake .. - # *) cmake -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake .. - - #set(CMAKE_SYSTEM_NAME Windows) - #set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) - #set(TOOLCHAIN_PREFIX i686-w64-mingw32) - - # cross compilers to use for C and C++ - #set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) - #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(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}) - - # modify default behavior of FIND_XXX() commands to - # search for headers/libs in the target environment and - # 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) - -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "/etc/debian_version") +elseif (WIN32) # Windows cross-build on Debian/Ubuntu + set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/build/Release/dist") + set(CPACK_GENERATOR "ZIP") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${TOOLCHAIN_PREFIX}") + set(CPACK_INSTALL_PREFIX "") + +elseif (EXISTS "/etc/debian_version") # Package-build is available on Debian/Ubuntu only message(STATUS "Debian-based Linux OS detected") - ### Debian-specific - set(CPACK_GENERATOR "DEB") - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Open source STM32 MCU programming toolset") - set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/stlink-org/stlink") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luca Boccassi") - set(CPACK_PACKAGE_CONTACT "bluca@debian.org") + set(CPACK_GENERATOR "DEB;RPM") # RPM requires package `rpm` - ## Set debian_revision number - # Convention: Restart the debian_revision at 1 each time the upstream_version is increased. - set(CPACK_DEBIAN_PACKAGE_RELEASE "0") + ### + # Debian (DEB) + ### + + # CPACK_DEB_PACKAGE_NAME --> Default: CPACK_PACKAGE_NAME - ## Debian package name + ## DEB package file name # CPack DEB generator generates package file name in deb format: # _-_.deb set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + # CPACK_DEBIAN_PACKAGE_VERSION --> Default: CPACK_PACKAGE_VERSION + + ## Set debian_revision number + # Convention: Restart the debian_revision at 1 each time the upstream_version is increased. + set(CPACK_DEBIAN_PACKAGE_RELEASE "1") + + # CPACK_DEBIAN_PACKAGE_ARCHITECTURE --> Default: Output of dpkg --print-architecture + set(CPACK_DEBIAN_PACKAGE_DEPENDS "pkg-config, build-essential, debhelper (>=9), cmake (>= 3.4.2), libusb-1.0-0-dev (>= 1.0.20)") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Luca Boccassi ") + # CPACK_DEBIAN_PACKAGE_DESCRIPTION --> Default: CPACK_DEBIAN_PACKAGE_DESCRIPTION (as it is set) + # CPACK_DEBIAN_PACKAGE_SECTION --> Default: “devel” + # CPACK_DEBIAN_ARCHIVE_TYPE --> Default: “gnutar” + # CPACK_DEBIAN_COMPRESSION_TYPE --> Default: “gzip” + # CPACK_DEBIAN_PACKAGE_PRIORITY --> Default: “optional” + # CPACK_DEBIAN_PACKAGE_HOMEPAGE --> Default: CMAKE_PROJECT_HOMEPAGE_URL + set(CPACK_DEBIAN_PACKAGE_SUGGESTS "libgtk-3-dev, pandoc") + ## Add CHANGELOG in Debian-specific format ### TODO @@ -71,15 +72,36 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND EXISTS "/etc/debian_version") # Include a postinst-script set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/packaging/debian/postinst") - ### rpm-specific ### TODO: Package config for opensuse should go here... + ### + # Slackware & Redhat (RPM) + ### + + # CPACK_RPM_PACKAGE_SUMMARY --> Default: CPACK_PACKAGE_DESCRIPTION_SUMMARY + # CPACK_RPM_PACKAGE_NAME --> Default: CPACK_PACKAGE_NAME + + ## RPM package file name + # Allow rpmbuild to generate package file name + set(CPACK_RPM_FILE_NAME RPM-DEFAULT) + + # CPACK_RPM_PACKAGE_VERSION --> Default: CPACK_PACKAGE_VERSION + # CPACK_RPM_PACKAGE_ARCHITECTURE --> Default: Native architecture output by uname -m + + ## Set rpm revision number + # Convention: Restart the debian_revision at 1 each time the upstream_version is increased. + set(CPACK_RPM_PACKAGE_RELEASE "1") + set(CPACK_RPM_PACKAGE_LICENSE "BSD-3") + # CPACK_RPM_PACKAGE_GROUP --> Default: “unknown” (RPM Groups are deprecated on Fedora) + # CPACK_RPM_PACKAGE_VENDOR --> Default: CPACK_PACKAGE_VENDOR (as it is set) + # CPACK_RPM_PACKAGE_URL --> Default: CMAKE_PROJECT_HOMEPAGE_URL + set(CPACK_RPM_PACKAGE_DESCRIPTION CPACK_DEBIAN_PACKAGE_DESCRIPTION) else () - ### TODO: Package config for fedora should go here... + # No package configuration on other platforms ... endif () ### -# Build package +# Build packages ### include(CPack) diff --git a/cmake/packaging/windows/generate_binaries.sh b/cmake/packaging/windows/generate_binaries.sh new file mode 100644 index 000000000..ba5b965f5 --- /dev/null +++ b/cmake/packaging/windows/generate_binaries.sh @@ -0,0 +1,26 @@ +### +# Build package with binaries for Windows +### + +# Install this cross-compiler toolchain: +#sudo apt-get install mingw-w64 + +# x86_64 +mkdir build-mingw +cd build-mingw +cmake -DCMAKE_SYSTEM_NAME=Windows \ + -DTOOLCHAIN_PREFIX=x86_64-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=./cmake/modules/set_toolchain.cmake .. +make package +cd .. +rm -rf build-mingw + +# i686 +mkdir build-mingw +cd build-mingw +cmake -DCMAKE_SYSTEM_NAME=Windows \ + -DTOOLCHAIN_PREFIX=i686-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=./cmake/modules/set_toolchain.cmake .. +make package +cd .. +rm -rf build-mingw diff --git a/debian/.gitignore b/debian/.gitignore deleted file mode 100644 index 7624d1c9b..000000000 --- a/debian/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.debhelper -files -debhelper-build-stamp -*.log -*.substvars -libstlink-dev -libstlink -stlink-gui -stlink-tools -tmp diff --git a/doc/compiling.md b/doc/compiling.md index 65d2510d0..3c8b78d73 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -87,6 +87,8 @@ 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) +* `dpkg` +* `rpm` * `pkg-config` * `libusb-1.0` * `libusb-1.0-0-dev` (development headers for building) From 06a5d716b82b2e897c1c54682866c1dbef55e848 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Wed, 29 Apr 2020 22:40:06 +0800 Subject: [PATCH 193/236] Remove all 'my' in tag name --- flashloaders/linker.ld | 2 +- flashloaders/stm32f0.s | 12 ++++++------ flashloaders/stm32f4.s | 10 +++++----- flashloaders/stm32f4lv.s | 10 +++++----- flashloaders/stm32f7.s | 10 +++++----- flashloaders/stm32f7lv.s | 10 +++++----- flashloaders/stm32l0x.s | 10 +++++----- flashloaders/stm32l4.s | 10 +++++----- flashloaders/stm32lx.s | 10 +++++----- src/flash_loader.c | 2 ++ 10 files changed, 44 insertions(+), 42 deletions(-) diff --git a/flashloaders/linker.ld b/flashloaders/linker.ld index 5bc738966..4d06433ea 100644 --- a/flashloaders/linker.ld +++ b/flashloaders/linker.ld @@ -1,5 +1,5 @@ /*. Entry Point *./ -ENTRY( mycopy ) +ENTRY( copy ) /*. Specify the memory areas .*/ diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index 3dd0ae6e8..6c4b8588f 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -1,8 +1,8 @@ .syntax unified .text - .global mycopy -mycopy: + .global copy +copy: ldr r7, =flash_base ldr r4, [r7] ldr r7, =flash_off_cr @@ -12,7 +12,7 @@ mycopy: ldr r5, [r7] adds r5, r5, r4 -myloop: +loop: # FLASH_CR ^= 1 ldr r7, =0x1 ldr r3, [r6] @@ -37,15 +37,15 @@ mywait: # exit if FLASH_SR != 4 ldr r7, =0x4 tst r3, r7 - bne myexit + bne exit # loop if r2 != 0 ldr r7, =0x1 subs r2, r2, r7 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: # FLASH_CR &= ~1 ldr r7, =0x1 ldr r3, [r6] diff --git a/flashloaders/stm32f4.s b/flashloaders/stm32f4.s index 836f6e1f2..b4e0f4913 100644 --- a/flashloaders/stm32f4.s +++ b/flashloaders/stm32f4.s @@ -1,13 +1,13 @@ .syntax unified .text - .global mycopy -mycopy: + .global copy +copy: ldr r12, flash_base ldr r10, flash_off_sr add r10, r10, r12 -myloop: +loop: # copy 4 bytes ldr r3, [r0] str r3, [r1] @@ -24,9 +24,9 @@ mywait: # loop if r2 != 0 sub r2, r2, #1 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt .align 2 diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index 4ba351faa..f5cc29841 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -1,8 +1,8 @@ .syntax unified .text - .global mycopy -mycopy: + .global copy +copy: ldr r12, flash_base ldr r10, flash_off_sr add r10, r10, r12 @@ -13,7 +13,7 @@ mycopy: # tip 2: r2 is always a power of 2 mov r2, r2, lsl#2 -myloop: +loop: # copy 1 byte ldrb r3, [r0] strb r3, [r1] @@ -30,9 +30,9 @@ mywait: # loop if r2 != 0 sub r2, r2, #1 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt .align 2 diff --git a/flashloaders/stm32f7.s b/flashloaders/stm32f7.s index 3f02e75f8..8694d864e 100644 --- a/flashloaders/stm32f7.s +++ b/flashloaders/stm32f7.s @@ -1,13 +1,13 @@ .syntax unified .text - .global mycopy -mycopy: + .global copy +copy: ldr r12, flash_base ldr r10, flash_off_sr add r10, r10, r12 -myloop: +loop: # copy 4 bytes ldr r3, [r0] str r3, [r1] @@ -27,9 +27,9 @@ mywait: # loop if r2 != 0 sub r2, r2, #1 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt .align 2 diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index d82726eeb..b48e40f0d 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -1,8 +1,8 @@ .syntax unified .text - .global mycopy -mycopy: + .global copy +copy: ldr r12, flash_base ldr r10, flash_off_sr add r10, r10, r12 @@ -13,7 +13,7 @@ mycopy: # tip 2: r2 is always a power of 2 mov r2, r2, lsl#2 -myloop: +loop: # copy 1 byte ldrb r3, [r0] strb r3, [r1] @@ -33,9 +33,9 @@ mywait: # loop if r2 != 0 sub r2, r2, #1 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt .align 2 diff --git a/flashloaders/stm32l0x.s b/flashloaders/stm32l0x.s index 893aa6f9b..f9c257e2e 100644 --- a/flashloaders/stm32l0x.s +++ b/flashloaders/stm32l0x.s @@ -1,9 +1,9 @@ .syntax unified .text - .global mycopy -mycopy: -myloop: + .global copy +copy: +loop: # copy 4 bytes ldr r3, [r0] str r3, [r1] @@ -16,7 +16,7 @@ myloop: ldr r7, =1 subs r2, r2, r7 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index 16c6d1063..c68198bfa 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -1,13 +1,13 @@ .syntax unified .text - .global mycopy -mycopy: + .global copy +copy: ldr r12, flash_base ldr r10, flash_off_bsy add r10, r10, r12 -myloop: +loop: # copy 8 bytes ldr r3, [r0] ldr r4, [r0, #4] @@ -26,9 +26,9 @@ mywait: # loop if r2 != 0 sub r2, r2, #1 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt .align 2 diff --git a/flashloaders/stm32lx.s b/flashloaders/stm32lx.s index 893aa6f9b..f9c257e2e 100644 --- a/flashloaders/stm32lx.s +++ b/flashloaders/stm32lx.s @@ -1,9 +1,9 @@ .syntax unified .text - .global mycopy -mycopy: -myloop: + .global copy +copy: +loop: # copy 4 bytes ldr r3, [r0] str r3, [r1] @@ -16,7 +16,7 @@ myloop: ldr r7, =1 subs r2, r2, r7 cmp r2, #0 - bne myloop + bne loop -myexit: +exit: bkpt diff --git a/src/flash_loader.c b/src/flash_loader.c index a3fd2cefd..80f5c262c 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -7,6 +7,8 @@ #define FLASH_REGS_BANK2_OFS 0x40 #define FLASH_BANK2_START_ADDR 0x08080000 +/* DO NOT MODIFY SOURCECODE DIRECTLY, EDIT ASSEMBLY FILES INSTEAD */ + /* flashloaders/stm32f0.s -- compiled with thumb2 */ static const uint8_t loader_code_stm32vl[] = { 0x16, 0x4f, 0x3c, 0x68, From 1f9724e8216ecc8205dffde900767f39659ce0db Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 29 Apr 2020 17:08:41 +0200 Subject: [PATCH 194/236] Removed deprecated debian pkg config settings --- {debian => cmake/packaging/debian}/rules | 0 debian/compat | 1 - debian/control | 53 ---------- debian/gbp.conf | 7 -- debian/libstlink-dev.install | 4 - debian/libstlink1.install | 1 - debian/libstlink1.symbols | 125 ----------------------- debian/source/format | 1 - debian/stlink-gui.install | 4 - debian/stlink-tools.install | 3 - debian/stlink-tools.manpages | 1 - debian/watch | 3 - 12 files changed, 203 deletions(-) rename {debian => cmake/packaging/debian}/rules (100%) delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/gbp.conf delete mode 100644 debian/libstlink-dev.install delete mode 100644 debian/libstlink1.install delete mode 100644 debian/libstlink1.symbols delete mode 100644 debian/source/format delete mode 100644 debian/stlink-gui.install delete mode 100644 debian/stlink-tools.install delete mode 100644 debian/stlink-tools.manpages delete mode 100644 debian/watch diff --git a/debian/rules b/cmake/packaging/debian/rules similarity index 100% rename from debian/rules rename to cmake/packaging/debian/rules diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec635144f..000000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index 3c1e9700f..000000000 --- a/debian/control +++ /dev/null @@ -1,53 +0,0 @@ -Source: stlink -Priority: optional -Maintainer: Luca Bocassi -Build-Depends: debhelper (>= 9), cmake, libusb-1.0-0-dev, libgtk-3-dev -Standards-Version: 4.1.3 -Section: electronics -Homepage: https://github.com/stlink-org/stlink -Vcs-Git: https://github.com/stlink-org/stlink.git -Vcs-Browser: https://github.com/stlink-org/stlink - -Package: libstlink-dev -Section: libdevel -Architecture: any -Depends: libstlink1 (= ${binary:Version}), ${misc:Depends} -Description: OpenSource ST-Link tools replacement. - Flashing tools for STMicroelectronics STM32VL and STM32L. The transport layers - STLINKv1 and STLINKv2 are supported. - . - This package contains the development files for stlink. - -Package: libstlink1 -Section: libs -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Breaks: libstlink -Replaces: libstlink -Description: OpenSource ST-Link tools replacement. - Flashing tools for STMicroelectronics STM32VL and STM32L. The transport layers - STLINKv1 and STLINKv2 are supported. - . - This package contains the shared library for stlink. - -Package: stlink-tools -Architecture: any -Depends: libstlink1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} -Breaks: libstlink -Replaces: libstlink -Description: OpenSource ST-Link tools replacement. - Flashing tools for STMicroelectronics STM32VL and STM32L. The transport layers - STLINKv1 and STLINKv2 are supported. - . - This package contains commandline utilities for stlink, and modprobe and - udev rules. - -Package: stlink-gui -Architecture: any -Depends: libstlink1 (= ${binary:Version}), stlink-tools (= ${binary:Version}), - ${shlibs:Depends}, ${misc:Depends} -Description: OpenSource ST-Link tools replacement. - Flashing tools for STMicroelectronics STM32VL and STM32L. The transport layers - STLINKv1 and STLINKv2 are supported. - . - This package contains a GUI tool for stlink. diff --git a/debian/gbp.conf b/debian/gbp.conf deleted file mode 100644 index 418e536e9..000000000 --- a/debian/gbp.conf +++ /dev/null @@ -1,7 +0,0 @@ -[buildpackage] -upstream-tag = %(version)s -debian-branch = debian - -[dch] -git-log = --first-parent -customizations = /usr/share/doc/git-buildpackage/examples/wrap_cl.py diff --git a/debian/libstlink-dev.install b/debian/libstlink-dev.install deleted file mode 100644 index 18fd98b03..000000000 --- a/debian/libstlink-dev.install +++ /dev/null @@ -1,4 +0,0 @@ -usr/include/* -usr/lib/*/lib*.a -usr/lib/*/pkg-config/* -usr/lib/*/lib*.so diff --git a/debian/libstlink1.install b/debian/libstlink1.install deleted file mode 100644 index 3ddde5841..000000000 --- a/debian/libstlink1.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/lib*.so.* diff --git a/debian/libstlink1.symbols b/debian/libstlink1.symbols deleted file mode 100644 index 51fa9bdb1..000000000 --- a/debian/libstlink1.symbols +++ /dev/null @@ -1,125 +0,0 @@ -libstlink.so.1 libstlink1 #MINVER# - _parse_version@Base 1.5.0 - _stlink_sg_close@Base 1.5.0 - _stlink_sg_core_id@Base 1.5.0 - _stlink_sg_current_mode@Base 1.5.0 - _stlink_sg_enter_jtag_mode@Base 1.5.0 - _stlink_sg_enter_swd_mode@Base 1.5.0 - _stlink_sg_exit_debug_mode@Base 1.5.0 - _stlink_sg_exit_dfu_mode@Base 1.5.0 - _stlink_sg_force_debug@Base 1.5.0 - _stlink_sg_jtag_reset@Base 1.5.0 - _stlink_sg_read_all_regs@Base 1.5.0 - _stlink_sg_read_debug32@Base 1.5.0 - _stlink_sg_read_mem32@Base 1.5.0 - _stlink_sg_read_reg@Base 1.5.0 - _stlink_sg_reset@Base 1.5.0 - _stlink_sg_run@Base 1.5.0 - _stlink_sg_status@Base 1.5.0 - _stlink_sg_step@Base 1.5.0 - _stlink_sg_version@Base 1.5.0 - _stlink_sg_write_debug32@Base 1.5.0 - _stlink_sg_write_mem32@Base 1.5.0 - _stlink_sg_write_mem8@Base 1.5.0 - _stlink_sg_write_reg@Base 1.5.0 - _stlink_usb_close@Base 1.5.0 - _stlink_usb_core_id@Base 1.5.0 - _stlink_usb_current_mode@Base 1.5.0 - _stlink_usb_enter_swd_mode@Base 1.5.0 - _stlink_usb_exit_debug_mode@Base 1.5.0 - _stlink_usb_exit_dfu_mode@Base 1.5.0 - _stlink_usb_force_debug@Base 1.5.0 - _stlink_usb_jtag_reset@Base 1.5.0 - _stlink_usb_read_all_regs@Base 1.5.0 - _stlink_usb_read_all_unsupported_regs@Base 1.5.0 - _stlink_usb_read_debug32@Base 1.5.0 - _stlink_usb_read_mem32@Base 1.5.0 - _stlink_usb_read_reg@Base 1.5.0 - _stlink_usb_read_unsupported_reg@Base 1.5.0 - _stlink_usb_reset@Base 1.5.0 - _stlink_usb_run@Base 1.5.0 - _stlink_usb_set_swdclk@Base 1.5.0 - _stlink_usb_status@Base 1.5.0 - _stlink_usb_step@Base 1.5.0 - _stlink_usb_target_voltage@Base 1.5.0 - _stlink_usb_version@Base 1.5.0 - _stlink_usb_write_debug32@Base 1.5.0 - _stlink_usb_write_mem32@Base 1.5.0 - _stlink_usb_write_mem8@Base 1.5.0 - _stlink_usb_write_reg@Base 1.5.0 - _stlink_usb_write_unsupported_reg@Base 1.5.0 - calculate_F4_sectornum@Base 1.5.0 - calculate_F7_sectornum@Base 1.5.0 - calculate_L4_page@Base 1.5.0 - is_bigendian@Base 1.5.0 - read_uint16@Base 1.5.0 - read_uint32@Base 1.5.0 - send_recv@Base 1.5.0 - send_usb_data_only@Base 1.5.0 - send_usb_mass_storage_command@Base 1.5.0 - stlink_calculate_pagesize@Base 1.5.0 - stlink_chip_id@Base 1.5.0 - stlink_chipid_get_params@Base 1.5.0 - stlink_close@Base 1.5.0 - stlink_clr_hw_bp@Base 1.5.0 - stlink_core_id@Base 1.5.0 - stlink_core_stat@Base 1.5.0 - stlink_cpu_id@Base 1.5.0 - stlink_current_mode@Base 1.5.0 - stlink_enter_swd_mode@Base 1.5.0 - stlink_erase_flash_mass@Base 1.5.0 - stlink_erase_flash_page@Base 1.5.0 - stlink_exit_debug_mode@Base 1.5.0 - stlink_exit_dfu_mode@Base 1.5.0 - stlink_fcheck_flash@Base 1.5.0 - stlink_flash_loader_init@Base 1.5.0 - stlink_flash_loader_run@Base 1.5.0 - stlink_flash_loader_write_to_sram@Base 1.5.0 - stlink_force_debug@Base 1.5.0 - stlink_fread@Base 1.5.0 - stlink_fwrite_flash@Base 1.5.0 - stlink_fwrite_sram@Base 1.5.0 - stlink_get_erased_pattern@Base 1.5.0 - stlink_is_core_halted@Base 1.5.0 - stlink_jtag_reset@Base 1.5.0 - stlink_load_device_params@Base 1.5.0 - stlink_mwrite_flash@Base 1.5.0 - stlink_mwrite_sram@Base 1.5.0 - stlink_open_usb@Base 1.5.0 - stlink_parse_ihex@Base 1.5.0 - stlink_print_data@Base 1.5.0 - stlink_probe_usb@Base 1.5.0 - stlink_probe_usb_free@Base 1.5.0 - stlink_q@Base 1.5.0 - stlink_read_all_regs@Base 1.5.0 - stlink_read_all_unsupported_regs@Base 1.5.0 - stlink_read_debug32@Base 1.5.0 - stlink_read_mem32@Base 1.5.0 - stlink_read_reg@Base 1.5.0 - stlink_read_unsupported_reg@Base 1.5.0 - stlink_reset@Base 1.5.0 - stlink_run@Base 1.5.0 - stlink_run_at@Base 1.5.0 - stlink_set_hw_bp@Base 1.5.0 - stlink_set_swdclk@Base 1.5.0 - stlink_stat@Base 1.5.0 - stlink_status@Base 1.5.0 - stlink_step@Base 1.5.0 - stlink_target_voltage@Base 1.5.0 - stlink_v1_open@Base 1.5.0 - stlink_v1_open_inner@Base 1.5.0 - stlink_verify_write_flash@Base 1.5.0 - stlink_version@Base 1.5.0 - stlink_write_debug32@Base 1.5.0 - stlink_write_dreg@Base 1.5.0 - stlink_write_flash@Base 1.5.0 - stlink_write_mem32@Base 1.5.0 - stlink_write_mem8@Base 1.5.0 - stlink_write_reg@Base 1.5.0 - stlink_write_unsupported_reg@Base 1.5.0 - stm32l1_write_half_pages@Base 1.5.0 - ugly_init@Base 1.5.0 - ugly_log@Base 1.5.0 - write_buffer_to_sram@Base 1.5.0 - write_uint16@Base 1.5.0 - write_uint32@Base 1.5.0 diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 89ae9db8f..000000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/debian/stlink-gui.install b/debian/stlink-gui.install deleted file mode 100644 index b419ac054..000000000 --- a/debian/stlink-gui.install +++ /dev/null @@ -1,4 +0,0 @@ -/usr/bin/stlink-gui* -/usr/share/stlink/stlink-gui.ui -/usr/share/applications/stlink-gui.desktop -/usr/share/icons/hicolor/scalable/apps/stlink-gui.svg diff --git a/debian/stlink-tools.install b/debian/stlink-tools.install deleted file mode 100644 index ca875a0e6..000000000 --- a/debian/stlink-tools.install +++ /dev/null @@ -1,3 +0,0 @@ -/usr/bin/st-* -lib/udev/rules.d/*.rules -etc/modprobe.d/*.conf diff --git a/debian/stlink-tools.manpages b/debian/stlink-tools.manpages deleted file mode 100644 index 6a461c09e..000000000 --- a/debian/stlink-tools.manpages +++ /dev/null @@ -1 +0,0 @@ -doc/man/st-*.1 diff --git a/debian/watch b/debian/watch deleted file mode 100644 index 20ad1260e..000000000 --- a/debian/watch +++ /dev/null @@ -1,3 +0,0 @@ -version=3 -opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/-$1\.tar\.gz/ \ - https://github.com/stlink-org/stlink/tags .*/v?(\d\S+)\.tar\.gz From 9b478a04e0d105f037cda2c29617409dc1f55a36 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 29 Apr 2020 19:20:47 +0200 Subject: [PATCH 195/236] Simplified subdir structure for packaging --- cmake/packaging/CMakeLists.txt | 5 ++--- cmake/packaging/{debian => deb}/CMakeLists.txt | 0 cmake/packaging/{debian => deb}/changelog | 0 cmake/packaging/{debian => deb}/copyright | 0 cmake/packaging/{debian => deb}/postinst | 0 cmake/packaging/{debian => deb}/rules | 0 cmake/packaging/opensuse/CMakeLists.txt | 0 cmake/packaging/{fedora => rpm}/CMakeLists.txt | 0 doc/compiling.md | 5 ++--- 9 files changed, 4 insertions(+), 6 deletions(-) rename cmake/packaging/{debian => deb}/CMakeLists.txt (100%) rename cmake/packaging/{debian => deb}/changelog (100%) rename cmake/packaging/{debian => deb}/copyright (100%) rename cmake/packaging/{debian => deb}/postinst (100%) rename cmake/packaging/{debian => deb}/rules (100%) delete mode 100644 cmake/packaging/opensuse/CMakeLists.txt rename cmake/packaging/{fedora => rpm}/CMakeLists.txt (100%) diff --git a/cmake/packaging/CMakeLists.txt b/cmake/packaging/CMakeLists.txt index 431c85d2d..1cf640552 100644 --- a/cmake/packaging/CMakeLists.txt +++ b/cmake/packaging/CMakeLists.txt @@ -1,6 +1,5 @@ -add_subdirectory(debian) -add_subdirectory(fedora) -add_subdirectory(opensuse) +add_subdirectory(deb) +add_subdirectory(rpm) add_subdirectory(windows) include(cpack_config.cmake) diff --git a/cmake/packaging/debian/CMakeLists.txt b/cmake/packaging/deb/CMakeLists.txt similarity index 100% rename from cmake/packaging/debian/CMakeLists.txt rename to cmake/packaging/deb/CMakeLists.txt diff --git a/cmake/packaging/debian/changelog b/cmake/packaging/deb/changelog similarity index 100% rename from cmake/packaging/debian/changelog rename to cmake/packaging/deb/changelog diff --git a/cmake/packaging/debian/copyright b/cmake/packaging/deb/copyright similarity index 100% rename from cmake/packaging/debian/copyright rename to cmake/packaging/deb/copyright diff --git a/cmake/packaging/debian/postinst b/cmake/packaging/deb/postinst similarity index 100% rename from cmake/packaging/debian/postinst rename to cmake/packaging/deb/postinst diff --git a/cmake/packaging/debian/rules b/cmake/packaging/deb/rules similarity index 100% rename from cmake/packaging/debian/rules rename to cmake/packaging/deb/rules diff --git a/cmake/packaging/opensuse/CMakeLists.txt b/cmake/packaging/opensuse/CMakeLists.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/cmake/packaging/fedora/CMakeLists.txt b/cmake/packaging/rpm/CMakeLists.txt similarity index 100% rename from cmake/packaging/fedora/CMakeLists.txt rename to cmake/packaging/rpm/CMakeLists.txt diff --git a/doc/compiling.md b/doc/compiling.md index 3c8b78d73..e20cbca83 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -85,10 +85,9 @@ Install the following packages from your package repository: * `git` * `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)) +* `build-essential` (on Debian based distros (Debian, Ubuntu)) * `cmake` (3.4.2 or later, use the latest version available from the repository) -* `dpkg` -* `rpm` +* `rpm` (on Debian based distros (Debian, Ubuntu), needed for package build with `make package`) * `pkg-config` * `libusb-1.0` * `libusb-1.0-0-dev` (development headers for building) From e952bcdb339cb0e65dc3af65d559a1a304152dab Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Wed, 29 Apr 2020 01:16:06 +0800 Subject: [PATCH 196/236] Add function to get number from char* like 0xff, 12, 1k, 1M, 0b1001 --- src/tools/flash_opts.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 544d4ad90..f635fa04c 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -11,6 +11,45 @@ static bool starts_with(const char * str, const char * prefix) { return (0 == strncmp(str, prefix, n)); } +// support positive integer from 0 to 0x7fffffff +// support decimal, hexadecimal, octal, binary format like 0xff 12 1k 1M, 0b1001 +// negative numbers are not supported +static int32_t get_integer_from_char_array (const char * const str) { + int32_t value; + char *tail; + + // hexadecimal + if ((strncmp ("0x", str, 2) == 0) || (strncmp ("0X", str, 2) == 0)) { + value = strtoul (str + 2, &tail, 16); + } + // binary + else if ((strncmp ("0b", str, 2) == 0) || (strncmp ("0B", str, 2) == 0)) { + value = strtoul (str + 2, &tail, 2); + } + // octal + else if ((strncmp ("0", str, 1) == 0) || (strncmp ("0", str, 1) == 0)) { + value = strtoul (str + 1, &tail, 8); + } + // decimal + else { + value = strtoul (str, &tail, 10); + } + + if (((tail[0] == 'k') || (tail[0] == 'K')) && (tail[1] == '\0')) { + return value * 1024; + } + else if (((tail[0] == 'm') || (tail[0] == 'M')) && (tail[1] == '\0')) { + return value * 1024 * 1024; + } + else if (tail[0] == '\0') { + return value; + } + else { + return -1; + } + return value; +} + static int invalid_args(const char *expected) { fprintf(stderr, "*** Error: Expected args for this command: %s\n", expected); return -1; @@ -22,6 +61,7 @@ static int bad_arg(const char *arg) { } int flash_get_opts(struct flash_opts* o, int ac, char** av) { + bool serial_specified = false; // defaults memset(o, 0, sizeof(*o)); From 9fdcc0cc3d1bc47734f28082496e1123409411d7 Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Wed, 29 Apr 2020 02:11:24 +0800 Subject: [PATCH 197/236] Modify strtoul with only one encoding to more user friendly interface --- src/tools/flash_opts.c | 49 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index f635fa04c..781188905 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -61,7 +61,6 @@ static int bad_arg(const char *arg) { } int flash_get_opts(struct flash_opts* o, int ac, char** av) { - bool serial_specified = false; // defaults memset(o, 0, sizeof(*o)); @@ -146,26 +145,10 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { } else if ( starts_with(av[0], "--flash=") ) { const char *arg = av[0] + strlen("--flash="); - char *ep = 0; - - o->flash_size = (uint32_t)strtoul(arg,&ep,0); - while ( *ep ) { - switch ( *ep++ ) { - case 0: - break; - case 'k': - case 'K': - o->flash_size *= 1024u; - break; - case 'm': - case 'M': - o->flash_size *= 1024u * 1024u; - break; - default: - fprintf(stderr,"Invalid --flash=%s\n",arg); - return -1; - } - } + + int32_t flash_size = get_integer_from_char_array(arg); + if (flash_size < 0) return bad_arg("--flash"); + else o->flash_size = (size_t) flash_size; } else { break; // non-option found @@ -201,7 +184,6 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { av++; } - char * tail; switch(o->cmd) { case FLASH_CMD_NONE: // no command found return -1; @@ -215,22 +197,31 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { if (ac != 3) return invalid_args("read "); if (ac != 3) return -1; o->filename = av[0]; - o->addr = (uint32_t) strtoul(av[1], &tail, 16); - if (tail[0] != '\0') return bad_arg("addr"); - o->size = strtoul(av[2], &tail, 16); - if (tail[0] != '\0') return bad_arg("size"); + int32_t address = get_integer_from_char_array(av[1]); + if(address < 0) return bad_arg("addr"); + else o->addr = (stm32_addr_t) address; + + int32_t size = get_integer_from_char_array(av[2]); + if(size < 0) return bad_arg("size"); + else o->size = (size_t) size; + break; case FLASH_CMD_WRITE: if (o->area == FLASH_OPTION_BYTES){ if (ac != 1) return -1; - o->val = (uint32_t)strtoul(av[0], &tail, 16); + + int32_t val = get_integer_from_char_array(av[0]); + if(val < 0) return bad_arg("val"); + else o->val = (uint32_t) val; + } else if (o->format == FLASH_FORMAT_BINARY) { // expect filename and addr if (ac != 2) return invalid_args("write "); o->filename = av[0]; - o->addr = (uint32_t) strtoul(av[1], &tail, 16); - if (tail[0] != '\0') return bad_arg("addr"); + int32_t addr = get_integer_from_char_array(av[1]); + if(addr < 0) return bad_arg("addr"); + else o->addr = (stm32_addr_t) addr; } else if (o->format == FLASH_FORMAT_IHEX) { // expect filename if (ac != 1) return invalid_args("write "); From af8807bc3dffb6e4f536fe942d33e65dddf2a55f Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Thu, 30 Apr 2020 01:37:12 +0800 Subject: [PATCH 198/236] Add range checking in converting string to integer --- src/tools/flash_opts.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 781188905..5baea2a9d 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -11,11 +11,12 @@ static bool starts_with(const char * str, const char * prefix) { return (0 == strncmp(str, prefix, n)); } -// support positive integer from 0 to 0x7fffffff +// support positive integer from 0 to INT64_MAX +// INT64_MAX+1 to UINT64_MAX are not supported // support decimal, hexadecimal, octal, binary format like 0xff 12 1k 1M, 0b1001 // negative numbers are not supported -static int32_t get_integer_from_char_array (const char * const str) { - int32_t value; +static int64_t get_long_integer_from_char_array (const char * const str) { + uint64_t value; char *tail; // hexadecimal @@ -36,18 +37,43 @@ static int32_t get_integer_from_char_array (const char * const str) { } if (((tail[0] == 'k') || (tail[0] == 'K')) && (tail[1] == '\0')) { - return value * 1024; + value = value * 1024; } else if (((tail[0] == 'm') || (tail[0] == 'M')) && (tail[1] == '\0')) { - return value * 1024 * 1024; + value = value * 1024 * 1024; } else if (tail[0] == '\0') { - return value; + // value not change } else { return -1; } - return value; + if (value >= INT64_MAX) { + fprintf (stderr, "*** Error: Integer greater than INT64_MAX\n"); + return -1l; + } + else { + return (int64_t)value; + } +} + +// support positive integer from 0 to INT32_MAX +// INT32_MAX+1 to UINT32_MAX are not supported +// support decimal, hexadecimal, octal, binary format like 0xff 12 1k 1M, 0b1001 +// negative numbers are not supported +static int32_t get_integer_from_char_array (const char * const str) { + int64_t v = get_long_integer_from_char_array (str); + if (v < 0) { + return (int32_t)v; + } + else if (v >= INT32_MAX) { + fprintf(stderr, "*** Error: Integer greater than INT32_MAX, \ +cannot convert to int32_t\n"); + return -1; + } + else { + return (int32_t)v; + } } static int invalid_args(const char *expected) { From 2f50899fb8bd03dece4b66382d46e84da613d6cc Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Fri, 1 May 2020 02:09:12 +0800 Subject: [PATCH 199/236] Modify get_integer_from_char_array to support unsigned integer --- src/tools/flash_opts.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 5baea2a9d..d3a39299b 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -11,11 +11,11 @@ static bool starts_with(const char * str, const char * prefix) { return (0 == strncmp(str, prefix, n)); } -// support positive integer from 0 to INT64_MAX -// INT64_MAX+1 to UINT64_MAX are not supported +// support positive integer from 0 to UINT64_MAX // support decimal, hexadecimal, octal, binary format like 0xff 12 1k 1M, 0b1001 // negative numbers are not supported -static int64_t get_long_integer_from_char_array (const char * const str) { +// return 0 if success else return -1 +static int get_long_integer_from_char_array (const char *const str, uint64_t *read_value) { uint64_t value; char *tail; @@ -48,31 +48,28 @@ static int64_t get_long_integer_from_char_array (const char * const str) { else { return -1; } - if (value >= INT64_MAX) { - fprintf (stderr, "*** Error: Integer greater than INT64_MAX\n"); - return -1l; - } - else { - return (int64_t)value; - } + *read_value = value; + return 0; } -// support positive integer from 0 to INT32_MAX -// INT32_MAX+1 to UINT32_MAX are not supported +// support positive integer from 0 to UINT32_MAX // support decimal, hexadecimal, octal, binary format like 0xff 12 1k 1M, 0b1001 // negative numbers are not supported -static int32_t get_integer_from_char_array (const char * const str) { - int64_t v = get_long_integer_from_char_array (str); - if (v < 0) { - return (int32_t)v; +// return 0 if success else return -1 +static int get_integer_from_char_array (const char *const str, uint32_t *read_value) { + uint64_t value; + int result = get_long_integer_from_char_array (str, &value); + if (result != 0) { + return result; } - else if (v >= INT32_MAX) { - fprintf(stderr, "*** Error: Integer greater than INT32_MAX, \ + else if (value > UINT32_MAX) { + fprintf (stderr, "*** Error: Integer greater than UINT32_MAX, \ cannot convert to int32_t\n"); return -1; } else { - return (int32_t)v; + *read_value = value; + return 0; } } From fc964c81d0b34a6cbc391251397162f0f43c6772 Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Fri, 1 May 2020 02:10:44 +0800 Subject: [PATCH 200/236] Modify function calls --- src/tools/flash_opts.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index d3a39299b..f83956e45 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -90,6 +90,7 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { o->log_level = STND_LOG_LEVEL; // options + int result; while (ac >= 1) { if (strcmp(av[0], "--version") == 0) { printf("v%s\n", STLINK_VERSION); @@ -169,8 +170,9 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { else if ( starts_with(av[0], "--flash=") ) { const char *arg = av[0] + strlen("--flash="); - int32_t flash_size = get_integer_from_char_array(arg); - if (flash_size < 0) return bad_arg("--flash"); + uint32_t flash_size; + result = get_integer_from_char_array(arg, &flash_size); + if (result != 0) return bad_arg ("--flash"); else o->flash_size = (size_t) flash_size; } else { @@ -220,12 +222,14 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { if (ac != 3) return invalid_args("read "); if (ac != 3) return -1; o->filename = av[0]; - int32_t address = get_integer_from_char_array(av[1]); - if(address < 0) return bad_arg("addr"); + uint32_t address; + result = get_integer_from_char_array(av[1], &address); + if (result != 0) return bad_arg ("addr"); else o->addr = (stm32_addr_t) address; - int32_t size = get_integer_from_char_array(av[2]); - if(size < 0) return bad_arg("size"); + uint32_t size; + result = get_integer_from_char_array(av[2], &size); + if (result != 0) return bad_arg ("size"); else o->size = (size_t) size; break; @@ -234,16 +238,18 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { if (o->area == FLASH_OPTION_BYTES){ if (ac != 1) return -1; - int32_t val = get_integer_from_char_array(av[0]); - if(val < 0) return bad_arg("val"); + uint32_t val; + result = get_integer_from_char_array(av[0], &val); + if (result != 0) return bad_arg ("val"); else o->val = (uint32_t) val; } else if (o->format == FLASH_FORMAT_BINARY) { // expect filename and addr if (ac != 2) return invalid_args("write "); o->filename = av[0]; - int32_t addr = get_integer_from_char_array(av[1]); - if(addr < 0) return bad_arg("addr"); + uint32_t addr; + result = get_integer_from_char_array(av[1], &addr); + if (result != 0) return bad_arg ("addr"); else o->addr = (stm32_addr_t) addr; } else if (o->format == FLASH_FORMAT_IHEX) { // expect filename From 0f1bf6e3410200a351aa5d9b000cbf7354b2ddd9 Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Fri, 1 May 2020 02:24:52 +0800 Subject: [PATCH 201/236] Add test cases for new syntax --- tests/flash.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/flash.c b/tests/flash.c index 903370cc3..96a43a2c3 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -95,16 +95,36 @@ static struct Test tests[] = { .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, - { "--debug --reset read test.bin 0x80000000 0x1000", 0, + { "--debug --reset read test.bin 0x80000000 1000", 0, { .cmd = FLASH_CMD_READ, .serial = { 0 }, .filename = "test.bin", .addr = 0x80000000, - .size = 0x1000, + .size = 1000, .reset = 1, .log_level = DEBUG_LOG_LEVEL, .format = FLASH_FORMAT_BINARY } }, + { "--debug --reset read test.bin 0x80000000 1k", 0, + { .cmd = FLASH_CMD_READ, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 1024, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, + { "--debug --reset read test.bin 0x80000000 1M", 0, + { .cmd = FLASH_CMD_READ, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 1048576, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .format = FLASH_FORMAT_BINARY } + }, { "--debug --reset write test.bin 0x80000000", 0, { .cmd = FLASH_CMD_WRITE, .serial = { 0 }, From f160c5ef3b74bdf5f6ad1a751dffaa68daad414a Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Fri, 1 May 2020 02:34:42 +0800 Subject: [PATCH 202/236] Modify strncmp to starts_with --- src/tools/flash_opts.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index f83956e45..147f56366 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -20,15 +20,15 @@ static int get_long_integer_from_char_array (const char *const str, uint64_t *re char *tail; // hexadecimal - if ((strncmp ("0x", str, 2) == 0) || (strncmp ("0X", str, 2) == 0)) { + if (starts_with (str, "0x") || starts_with (str, "0X")) { value = strtoul (str + 2, &tail, 16); } // binary - else if ((strncmp ("0b", str, 2) == 0) || (strncmp ("0B", str, 2) == 0)) { + else if (starts_with (str, "0b") || starts_with (str, "0B")) { value = strtoul (str + 2, &tail, 2); } // octal - else if ((strncmp ("0", str, 1) == 0) || (strncmp ("0", str, 1) == 0)) { + else if (starts_with (str, "0")) { value = strtoul (str + 1, &tail, 8); } // decimal From cb777ce57654f187f235c70a95d347d6c8b9c3b8 Mon Sep 17 00:00:00 2001 From: Rafael Lee Date: Fri, 1 May 2020 09:49:55 +0800 Subject: [PATCH 203/236] Fix CI, cast variable explicitly --- src/tools/flash_opts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 147f56366..044527a8b 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -68,7 +68,7 @@ cannot convert to int32_t\n"); return -1; } else { - *read_value = value; + *read_value = (uint32_t)value; return 0; } } From 2ad60ff0718b6886f4a2b59452ca5d7a84f2bbd5 Mon Sep 17 00:00:00 2001 From: Paul Gallagher Date: Sat, 2 May 2020 15:41:27 +0800 Subject: [PATCH 204/236] Fix: tutorial.md should be correctly linked from readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bf663e34..12052a7a8 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Supported operating systems are listed in [version_support.md](doc/version_suppo ## Tutorial & HOWTO -Our [tutorial.md](doc/tutorial.md may help you along with some advanced tasks and additional info. +Our [tutorial.md](doc/tutorial.md) may help you along with some advanced tasks and additional info. ## Installation From 5e0e29984c562bf42f1c7edb04bb0e4d1030950a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 6 May 2020 19:48:21 +0200 Subject: [PATCH 205/236] Updated travis CI test-builds - Added builds for clang -m32 on arch: AMD64 - Corrected invalid config settings - Added clang-9 builds for linux - Moved scripts to root directory - Added MinGW cross-test-build for linux --- .travis.sh | 95 ++++++++++++------- .travis.yml | 87 ++++++++++------- doc/version_support.md | 4 +- .../mingw64-build.bat => mingw64-build.bat | 4 +- ...n_clang_analyze.sh => run_clang_analyze.sh | 0 5 files changed, 117 insertions(+), 73 deletions(-) rename scripts/mingw64-build.bat => mingw64-build.bat (91%) rename scripts/run_clang_analyze.sh => run_clang_analyze.sh (100%) diff --git a/.travis.sh b/.travis.sh index 5291ec95b..e61098f89 100755 --- a/.travis.sh +++ b/.travis.sh @@ -8,39 +8,64 @@ echo "----" echo "WORK DIR:$DIR" DIR=$PWD -if [ "$TRAVIS_OS_NAME" == "linux" ]; then - sudo apt-get update -qq || true - sudo apt-get install -qq -y --no-install-recommends libgtk-3-dev - - echo "--> Building Debug..." - mkdir -p build/Debug && cd build/Debug - echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ - make && make package && cd - - - echo "--> Building Release..." - mkdir -p build/Release && cd build/Release - echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ - make && make package && cd - - -# echo "--> Building Binary..." -# mkdir -p build/Binary && cd build/Binary -# cho "-DCMAKE_BUILD_TYPE=Binary -DCMAKE_INSTALL_PREFIX=$PWD/_install" -# cmake -DCMAKE_BUILD_TYPE=Binary -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ -# make && make package && cd - -else [ "$TRAVIS_OS_NAME" == "osx" ]; - brew install libusb - - echo "--> Building Debug..." - mkdir -p build/Debug && cd build/Debug - echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ - make && make package && cd - - - echo "--> Building Release..." - mkdir -p build/Release && cd build/Release - echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ - make && make package && cd - +if [ "$TRAVIS_JOB_NAME" == "linux-mingw" ]; then + echo "--> Building Release for Windows (x86-64) ..." + mkdir -p build-mingw && cd build-mingw + echo "-DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=x86_64-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" + cmake -DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=x86_64-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + make && rm -rf build-mingw && cd - + + echo "--> Building Release for Windows (i686) ..." + mkdir -p build-mingw && cd build-mingw + echo "-DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=i686-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" + cmake -DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=i686-w64-mingw32 \ + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + make && rm -rf build-mingw && cd - + +elif [ "$TRAVIS_OS_NAME" == "linux" ]; then + sudo apt-get update -qq || true + sudo apt-get install -qq -y --no-install-recommends libgtk-3-dev + + echo "--> Building Debug..." + mkdir -p build/Debug && cd build/Debug + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + make && make package && cd - + + echo "--> Building Release..." + mkdir -p build/Release && cd build/Release + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + make && make package && cd - + +elif [ "$TRAVIS_OS_NAME" == "osx" ]; then + brew install libusb + + echo "--> Building Debug..." + mkdir -p build/Debug && cd build/Debug + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + make && make package && cd - + + echo "--> Building Release..." + mkdir -p build/Release && cd build/Release + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + make && make package && cd - + +else # local test-build + echo "--> Building Debug..." + mkdir -p build/Debug && cd build/Debug + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - + + echo "--> Building Release..." + mkdir -p build/Release && cd build/Release + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + make && make package && cd - fi diff --git a/.travis.yml b/.travis.yml index a66777f5f..17db35765 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,98 +1,111 @@ language: c -matrix: +jobs: include: - ### 64-bit builds ### + ### 64-bit builds on AMD64 ### - os: linux + dist: bionic env: BADGE=linux - arch: x64 compiler: gcc-5 addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux + dist: bionic env: BADGE=linux - arch: x64 - compiler: gcc-7 - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - - os: linux - env: BADGE=linux - arch: x64 compiler: gcc-9 addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux + dist: xenial env: BADGE=linux - arch: x64 compiler: clang-3.7 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] - os: linux + dist: bionic env: BADGE=linux - arch: x64 compiler: clang-6.0 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] -# - os: linux -# arch: x64 -# compiler: clang-6.0 -# addons: -# apt: -# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] -# packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev'] -# env: CFLAGS=-m32 LDFLAGS=-m32 - - ### 32-bit builds ### - os: linux + dist: bionic env: BADGE=linux - arch: x86 - compiler: gcc-5 + compiler: clang-9 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + packages: ['clang-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + + - os: linux + dist: bionic + env: BADGE=linux-mingw + name: linux-mingw + compiler: gcc-9 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm', 'mingw-w64'] + + ### 32-bit builds on AMD64 ### - os: linux + dist: bionic env: BADGE=linux - arch: x86 - compiler: gcc-7 + compiler: gcc-5 addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['gcc-7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + packages: ['gcc-5', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + before_install: + - CFLAGS="$CFLAGS -m32"; CXXFLAGS="$CXXFLAGS -m32"; LDFLAGS="$LDFLAGS -m32"; - os: linux + dist: bionic env: BADGE=linux - arch: x86 compiler: gcc-9 addons: apt: sources: ['ubuntu-toolchain-r-test'] packages: ['gcc-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + before_install: + - CFLAGS="$CFLAGS -m32"; CXXFLAGS="$CXXFLAGS -m32"; LDFLAGS="$LDFLAGS -m32"; - os: linux + dist: xenial env: BADGE=linux - arch: x86 compiler: clang-3.7 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-3.7'] packages: ['clang-3.7', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + before_install: + - CFLAGS="$CFLAGS -m32"; CXXFLAGS="$CXXFLAGS -m32"; LDFLAGS="$LDFLAGS -m32"; - os: linux + dist: bionic env: BADGE=linux - arch: x86 compiler: clang-6.0 addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-bionic-6.0'] packages: ['clang-6.0', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + before_install: + - CFLAGS="$CFLAGS -m32"; CXXFLAGS="$CXXFLAGS -m32"; LDFLAGS="$LDFLAGS -m32"; + - os: linux + dist: bionic + env: BADGE=linux + compiler: clang-9 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['clang-9', 'libusb-1.0.0-dev', 'libgtk-3-dev', 'rpm'] + before_install: + - CFLAGS="$CFLAGS -m32"; CXXFLAGS="$CXXFLAGS -m32"; LDFLAGS="$LDFLAGS -m32"; + ### macOS ### - os: osx @@ -114,8 +127,14 @@ matrix: - libusb - gtk+3 + ### Windows ### +# - os: windows +# env: BADGE=windows +# compiler: gcc + script: - git fetch --tags - printenv - cmake --version - - ./.travis.sh + - if [[ "$TRAVIS_OS_NAME" == "linux" ]] || [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis.sh; fi +# - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then cmd.exe /C 'mingw64-build.bat'; fi diff --git a/doc/version_support.md b/doc/version_support.md index 75def2e66..f889fbc32 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -68,10 +68,10 @@ Thus no user interaction regarding libusb is necessary. | Operating System | libusb
version | cmake
version | End of OS-Support | Notes | | --- | --- | --- | --- | --- | -| CentOS 7 | 1.0.21 | **2.8.12.2** | | named `libusbx`, but `libusb`-codebase is used | +| 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 | +| 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** | | diff --git a/scripts/mingw64-build.bat b/mingw64-build.bat similarity index 91% rename from scripts/mingw64-build.bat rename to mingw64-build.bat index 15ec21cd0..9d5cf4d06 100644 --- a/scripts/mingw64-build.bat +++ b/mingw64-build.bat @@ -1,5 +1,5 @@ -@echo off -cd .. +@echo on + 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% diff --git a/scripts/run_clang_analyze.sh b/run_clang_analyze.sh similarity index 100% rename from scripts/run_clang_analyze.sh rename to run_clang_analyze.sh From e11b077da3aba4470f0a66815d262100e2ff630c Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Thu, 7 May 2020 18:16:07 +0800 Subject: [PATCH 206/236] Fix https://github.com/stlink-org/stlink/issues/893 * Add --freq argument for st-flash --- include/stlink.h | 2 ++ include/stlink/tools/flash.h | 3 +- src/st-util/gdb-server.c | 4 +-- src/stlink-gui/gui.c | 2 +- src/tools/flash.c | 8 +++--- src/tools/flash_opts.c | 50 +++++++++++++++++++++++++++++++++ src/tools/info.c | 2 +- src/usb.c | 47 +++++++++++++++++++++++++++++-- src/usb.h | 2 +- tests/flash.c | 54 ++++++++++++++++++++++++++++++++++++ tests/usb.c | 2 +- 11 files changed, 162 insertions(+), 14 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index 74c366d1c..ffa65b332 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -159,6 +159,8 @@ typedef struct flash_loader { char serial[STLINK_SERIAL_MAX_SIZE]; int serial_size; + int freq; // set by stlink_open_usb(), values: STLINK_SWDCLK_xxx_DIVISOR + enum stlink_flash_type flash_type; // stlink_chipid_params.flash_type, set by stlink_load_device_params(), values: STLINK_FLASH_TYPE_xxx bool has_dual_bank; diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index 8c3f7d766..b8954af65 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -26,9 +26,10 @@ struct flash_opts uint32_t val; size_t flash_size; /* --flash=n[k][m] */ int opt; + int freq; }; -#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} int flash_get_opts(struct flash_opts* o, int ac, char** av); diff --git a/src/st-util/gdb-server.c b/src/st-util/gdb-server.c index a3839cfc8..20954821b 100644 --- a/src/st-util/gdb-server.c +++ b/src/st-util/gdb-server.c @@ -87,9 +87,9 @@ static void cleanup(int signum) { static stlink_t* do_connect(st_state_t *st) { stlink_t *sl = NULL; if (serial_specified) { - sl = stlink_open_usb(st->logging_level, st->reset, serialnumber); + sl = stlink_open_usb(st->logging_level, st->reset, serialnumber, 0); } else { - sl = stlink_open_usb(st->logging_level, st->reset, NULL); + sl = stlink_open_usb(st->logging_level, st->reset, NULL, 0); } return sl; } diff --git a/src/stlink-gui/gui.c b/src/stlink-gui/gui.c index 5d5a422d5..6e9d59b1e 100644 --- a/src/stlink-gui/gui.c +++ b/src/stlink-gui/gui.c @@ -490,7 +490,7 @@ static void connect_button_cb (GtkWidget *widget, gpointer data) { /* try version 1 then version 2 */ gui->sl = stlink_v1_open(0, 1); if (gui->sl == NULL) - gui->sl = stlink_open_usb(0, 1, NULL); + gui->sl = stlink_open_usb(0, 1, NULL, 0); if (gui->sl == NULL) { stlink_gui_set_info_error_message (gui, "Failed to connect to STLink."); return; diff --git a/src/tools/flash.c b/src/tools/flash.c index 841b93c3c..3a83daf8a 100644 --- a/src/tools/flash.c +++ b/src/tools/flash.c @@ -28,9 +28,9 @@ static void cleanup(int signum) { static void usage(void) { - puts("command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] {read|write} [addr] [size]"); - puts("command line: ./st-flash [--debug] [--serial ] erase"); - puts("command line: ./st-flash [--debug] [--serial ] reset"); + puts("command line: ./st-flash [--debug] [--reset] [--opt] [--serial ] [--format ] [--flash=] [--freq=] {read|write} [addr] [size]"); + puts("command line: ./st-flash [--debug] [--freq=] [--serial ] erase"); + puts("command line: ./st-flash [--debug] [--freq=] [--serial ] reset"); puts(" , and : Use hex format."); puts(" : Use decimal, octal or hex (prefix 0xXXX) format, optionally followed by k=KB, or m=MB (eg. --flash=128k)"); puts(" : Can be 'binary' (default) or 'ihex', although must be specified for binary format only."); @@ -56,7 +56,7 @@ int main(int ac, char** av) printf("st-flash %s\n", STLINK_VERSION); - sl = stlink_open_usb(o.log_level, 1, (char *)o.serial); + sl = stlink_open_usb(o.log_level, 1, (char *)o.serial, o.freq); if (sl == NULL) { return -1; diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index 044527a8b..a5c9d287f 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -149,6 +149,56 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { return -1; } + else if (strcmp(av[0], "--freq") == 0 || starts_with(av[0], "--freq=")) { + const char* freq; + if (strcmp(av[0], "--freq") == 0) { + ac--; + av++; + if (ac < 1) return -1; + freq = av[0]; + } + else { + freq = av[0] + strlen("--freq="); + } + if (strcmp(freq, "5K") == 0 || strcmp(freq, "5k") == 0) { + o->freq = 5; + } + else if (strcmp(freq, "15K") == 0 || strcmp(freq, "15k") == 0) { + o->freq = 15; + } + else if (strcmp(freq, "25K") == 0 || strcmp(freq, "25k") == 0) { + o->freq = 25; + } + else if (strcmp(freq, "50K") == 0 || strcmp(freq, "50k") == 0) { + o->freq = 50; + } + else if (strcmp(freq, "100K") == 0 || strcmp(freq, "100k") == 0) { + o->freq = 100; + } + else if (strcmp(freq, "125K") == 0 || strcmp(freq, "125k") == 0) { + o->freq = 125; + } + else if (strcmp(freq, "240K") == 0 || strcmp(freq, "240k") == 0) { + o->freq = 240; + } + else if (strcmp(freq, "480K") == 0 || strcmp(freq, "480k") == 0) { + o->freq = 480; + } + else if (strcmp(freq, "950K") == 0 || strcmp(freq, "950k") == 0) { + o->freq = 950; + } + else if (strcmp(freq, "1200K") == 0 || strcmp(freq, "1200k") == 0 || strcmp(freq, "1.2M") == 0 || strcmp(freq, "1.2m") == 0) { + o->freq = 1200; + } + else if (strcmp(freq, "1800K") == 0 || strcmp(freq, "1800k") == 0 || strcmp(freq, "1.8M") == 0 || strcmp(freq, "1.8m") == 0) { + o->freq = 1800; + } + else if (strcmp(freq, "4000K") == 0 || strcmp(freq, "4000k") == 0 || strcmp(freq, "4M") == 0 || strcmp(freq, "4m") == 0) { + o->freq = 4000; + } + else + return -1; + } else if (strcmp(av[0], "--format") == 0 || starts_with(av[0], "--format=")) { const char * format; if (strcmp(av[0], "--format") == 0) { diff --git a/src/tools/info.c b/src/tools/info.c index 3ebbba8de..45d484270 100644 --- a/src/tools/info.c +++ b/src/tools/info.c @@ -81,7 +81,7 @@ static stlink_t *stlink_open_first(void) stlink_t* sl = NULL; sl = stlink_v1_open(0, 1); if (sl == NULL) - sl = stlink_open_usb(0, 1, NULL); + sl = stlink_open_usb(0, 1, NULL, 0); return sl; } diff --git a/src/usb.c b/src/usb.c index 4e7a2983f..ef3743c78 100644 --- a/src/usb.c +++ b/src/usb.c @@ -873,7 +873,7 @@ static stlink_backend_t _stlink_usb_backend = { _stlink_usb_set_swdclk }; -stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE]) +stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq) { stlink_t* sl = NULL; struct stlink_libusb* slu = NULL; @@ -1041,10 +1041,51 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST stlink_exit_dfu_mode(sl); } + + sl->opt = freq; // set the speed before entering the mode // as the chip discovery phase should be done at this speed too // Set the stlink clock speed (default is 1800kHz) - stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); + DLOG("JTAG/SWD freq set to %d\n", freq); + switch (freq) { + case 5: + stlink_set_swdclk(sl, STLINK_SWDCLK_5KHZ_DIVISOR); + break; + case 15: + stlink_set_swdclk(sl, STLINK_SWDCLK_15KHZ_DIVISOR); + break; + case 25: + stlink_set_swdclk(sl, STLINK_SWDCLK_25KHZ_DIVISOR); + break; + case 50: + stlink_set_swdclk(sl, STLINK_SWDCLK_50KHZ_DIVISOR); + break; + case 100: + stlink_set_swdclk(sl, STLINK_SWDCLK_100KHZ_DIVISOR); + break; + case 125: + stlink_set_swdclk(sl, STLINK_SWDCLK_125KHZ_DIVISOR); + break; + case 240: + stlink_set_swdclk(sl, STLINK_SWDCLK_240KHZ_DIVISOR); + break; + case 480: + stlink_set_swdclk(sl, STLINK_SWDCLK_480KHZ_DIVISOR); + break; + case 950: + stlink_set_swdclk(sl, STLINK_SWDCLK_950KHZ_DIVISOR); + break; + case 1200: + stlink_set_swdclk(sl, STLINK_SWDCLK_1P2MHZ_DIVISOR); + break; + case 0: case 1800: + stlink_set_swdclk(sl, STLINK_SWDCLK_1P8MHZ_DIVISOR); + break; + case 4000: + stlink_set_swdclk(sl, STLINK_SWDCLK_4MHZ_DIVISOR); + break; + } + if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) { stlink_enter_swd_mode(sl); @@ -1147,7 +1188,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { continue; } - stlink_t *sl = stlink_open_usb(0, 1, serial); + stlink_t *sl = stlink_open_usb(0, 1, serial, 0); if (!sl) { ELOG("Failed to open USB device %#06x:%#06x\n", desc.idVendor, desc.idProduct); continue; diff --git a/src/usb.h b/src/usb.h index 968f38ba4..061042e8d 100644 --- a/src/usb.h +++ b/src/usb.h @@ -68,7 +68,7 @@ extern "C" { * @retval NULL Error while opening the stlink * @retval !NULL Stlink found and ready to use */ - stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE]); + stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq); size_t stlink_probe_usb(stlink_t **stdevs[]); void stlink_probe_usb_free(stlink_t **stdevs[], size_t size); diff --git a/tests/flash.c b/tests/flash.c index 96a43a2c3..3166e72b5 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -83,6 +83,7 @@ static struct Test tests[] = { .size = 0x1000, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "--debug --reset write test.bin 0x80000000", 0, @@ -93,6 +94,51 @@ static struct Test tests[] = { .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, + .format = FLASH_FORMAT_BINARY } + }, + { "--debug --freq 5k --reset write test.bin 0x80000000", 0, + { .cmd = FLASH_CMD_WRITE, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .freq = 5, + .format = FLASH_FORMAT_BINARY } + }, + { "--debug --freq 15K --reset write test.bin 0x80000000", 0, + { .cmd = FLASH_CMD_WRITE, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .freq = 15, + .format = FLASH_FORMAT_BINARY } + }, + { "--debug --freq=5k --reset write test.bin 0x80000000", 0, + { .cmd = FLASH_CMD_WRITE, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .freq = 0, + .format = FLASH_FORMAT_BINARY } + }, + { "--debug --freq=6k --reset write test.bin 0x80000000", -1, + { .cmd = FLASH_CMD_WRITE, + .serial = { 0 }, + .filename = "test.bin", + .addr = 0x80000000, + .size = 0, + .reset = 1, + .log_level = DEBUG_LOG_LEVEL, + .freq = 6, .format = FLASH_FORMAT_BINARY } }, { "--debug --reset read test.bin 0x80000000 1000", 0, @@ -103,6 +149,7 @@ static struct Test tests[] = { .size = 1000, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "--debug --reset read test.bin 0x80000000 1k", 0, @@ -113,6 +160,7 @@ static struct Test tests[] = { .size = 1024, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "--debug --reset read test.bin 0x80000000 1M", 0, @@ -123,6 +171,7 @@ static struct Test tests[] = { .size = 1048576, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "--debug --reset write test.bin 0x80000000", 0, @@ -133,6 +182,7 @@ static struct Test tests[] = { .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "erase", 0, @@ -143,6 +193,7 @@ static struct Test tests[] = { .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "--debug --reset --format=ihex write test.hex", 0, @@ -153,6 +204,7 @@ static struct Test tests[] = { .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_IHEX } }, { "--debug --reset --format=binary write test.hex", -1, FLASH_OPTS_INITIALIZER }, @@ -167,6 +219,7 @@ static struct Test tests[] = { .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, { "--serial=A1020304 erase", 0, @@ -177,6 +230,7 @@ static struct Test tests[] = { .size = 0, .reset = 0, .log_level = STND_LOG_LEVEL, + .freq = 0, .format = FLASH_FORMAT_BINARY } }, }; diff --git a/tests/usb.c b/tests/usb.c index d4098834d..5165ea563 100644 --- a/tests/usb.c +++ b/tests/usb.c @@ -9,7 +9,7 @@ int main(int ac, char** av) { stlink_t* sl; struct stlink_reg regs; - sl = stlink_open_usb(10, 1, NULL); + sl = stlink_open_usb(10, 1, NULL, 0); if (sl != NULL) { printf("-- version\n"); stlink_version(sl); From 931141869e17f72a01dc14ebd27cca8f86348c32 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Thu, 7 May 2020 18:52:34 +0800 Subject: [PATCH 207/236] Fix missing cmp and wrong expected value for freq --- tests/flash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/flash.c b/tests/flash.c index 3166e72b5..d47b3564d 100644 --- a/tests/flash.c +++ b/tests/flash.c @@ -66,6 +66,7 @@ static bool execute_test(const struct Test * test) { ret &= (opts.size == test->opts.size); ret &= (opts.reset == test->opts.reset); ret &= (opts.log_level == test->opts.log_level); + ret &= (opts.freq == test->opts.freq); ret &= (opts.format == test->opts.format); } @@ -127,7 +128,7 @@ static struct Test tests[] = { .size = 0, .reset = 1, .log_level = DEBUG_LOG_LEVEL, - .freq = 0, + .freq = 5, .format = FLASH_FORMAT_BINARY } }, { "--debug --freq=6k --reset write test.bin 0x80000000", -1, From 6c6f27b0f55fdd482ece7d223293ddc3e9a7a90b Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Fri, 8 May 2020 15:40:29 +0800 Subject: [PATCH 208/236] Add documentation of --freq and --opt --- doc/tutorial.md | 11 +++++++++++ include/stlink.h | 2 +- include/stlink/tools/flash.h | 4 ++-- src/usb.c | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 929aa3250..ad64a8db8 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -19,6 +19,17 @@ The size may be followed by an optional "k" or "m" to multiply the given value b When flashing a file, a checksum is calculated for the binary file, both in md5 and the sum algorithm. The latter is also used by the official ST-Link utility tool from STMicroelectronics as described in the document: [`UM0892 - User manual - STM32 ST-LINK utility software description`](https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf). +#### --freq=n[k][m] + +(since v1.6.1) + +You can specify the frequency of SWD/JTAG interface, to override the default 1800KHz configuration. This option accpets decimal only (5K or 1.8M). `Hz` is left out in this option. Valid frequencies are `5K, 15K, 25K, 50K, 100K, 125K, 240K, 480K, 950K, 1200K(1.2M), 1800K(1.8M), 4000K(4M)` + +#### --opt + +(since v1.6.1, optional; enabled by default from v1.0.0 to v1.6.0) + +You can enable the optimization to skip flashing empty (0x00 or 0xff) bytes at the end of binary file. May cause some garbage data left after a flash. ## Solutions to common problems ### a) STLINK/v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) diff --git a/include/stlink.h b/include/stlink.h index ffa65b332..b8080fd5e 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -151,7 +151,7 @@ typedef struct flash_loader { // transport layer verboseness: 0 for no debug info, 10 for lots int verbose; - int opt; + int opt; // set by main() in tools/flash.c, empty tail bytes drop optimization uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram int core_stat; // set by stlink_status(), values STLINK_CORE_xxxxx diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index b8954af65..a912a14aa 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -25,8 +25,8 @@ struct flash_opts enum flash_area area; uint32_t val; size_t flash_size; /* --flash=n[k][m] */ - int opt; - int freq; + int opt; /* enable empty tail data drop optimization */ + int freq; /* --freq=n[k][m] frequency of JTAG/SWD */ }; #define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} diff --git a/src/usb.c b/src/usb.c index ef3743c78..148ad7652 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1042,7 +1042,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } - sl->opt = freq; + sl->freq = freq; // set the speed before entering the mode // as the chip discovery phase should be done at this speed too // Set the stlink clock speed (default is 1800kHz) From f6e9cb1be385494a4dda45f03f58d7109ae971ea Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 9 May 2020 21:28:59 +0200 Subject: [PATCH 209/236] Additional fixes for #863 - Comment for selection of API-Version (#271) - Whitespace cleanup - Fixed casting (-Wshorten-64-to-32) --- include/stlink.h | 466 +++++++++++++++++++++++------------------------ src/usb.c | 22 +-- 2 files changed, 238 insertions(+), 250 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index 4e7fedc66..3aca9d8ee 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -1,9 +1,10 @@ /* - * File: stlink.h + * File: stlink.h * - * This should contain all the common top level stlink interfaces, regardless - * of how the backend does the work.... + * This should contain all the common top level stlink interfaces, + * regardless of how the backend does the work.... */ + #ifndef STLINK_H #define STLINK_H @@ -19,10 +20,10 @@ extern "C" { #define STLINK_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - // Max data transfer size. - // 6kB = max mem32_read block, 8kB sram - //#define Q_BUF_LEN 96 -#define Q_BUF_LEN (1024 * 100) +/* Max data transfer size */ +// 6kB = max mem32_read block, 8kB sram +//#define Q_BUF_LEN 96 +#define Q_BUF_LEN (1024 * 100) // STLINK_DEBUG_RESETSYS, etc: enum target_state { @@ -33,79 +34,76 @@ enum target_state { TARGET_DEBUG_RUNNING = 4, }; -#define STLINK_CORE_RUNNING 0x80 -#define STLINK_CORE_HALTED 0x81 +#define STLINK_CORE_RUNNING 0x80 +#define STLINK_CORE_HALTED 0x81 -#define STLINK_GET_VERSION 0xf1 -#define STLINK_GET_CURRENT_MODE 0xf5 -#define STLINK_GET_TARGET_VOLTAGE 0xF7 +#define STLINK_GET_VERSION 0xF1 +#define STLINK_GET_CURRENT_MODE 0xF5 +#define STLINK_GET_TARGET_VOLTAGE 0xF7 -#define STLINK_DEBUG_COMMAND 0xF2 -#define STLINK_DFU_COMMAND 0xF3 -#define STLINK_DFU_EXIT 0x07 +#define STLINK_DEBUG_COMMAND 0xF2 +#define STLINK_DFU_COMMAND 0xF3 +#define STLINK_DFU_EXIT 0x07 - // STLINK_GET_CURRENT_MODE -#define STLINK_DEV_DFU_MODE 0x00 -#define STLINK_DEV_MASS_MODE 0x01 -#define STLINK_DEV_DEBUG_MODE 0x02 -#define STLINK_DEV_UNKNOWN_MODE -1 +// STLINK_GET_CURRENT_MODE +#define STLINK_DEV_DFU_MODE 0x00 +#define STLINK_DEV_MASS_MODE 0x01 +#define STLINK_DEV_DEBUG_MODE 0x02 +#define STLINK_DEV_UNKNOWN_MODE -1 - // TODO - possible poor names... -#define STLINK_SWD_ENTER 0x30 -#define STLINK_SWD_READCOREID 0x32 // TBD -#define STLINK_JTAG_WRITEDEBUG_32BIT 0x35 -#define STLINK_JTAG_READDEBUG_32BIT 0x36 -#define STLINK_JTAG_DRIVE_NRST 0x3c +// TODO - possible poor names... +#define STLINK_SWD_ENTER 0x30 +#define STLINK_SWD_READCOREID 0x32 // TBD +#define STLINK_JTAG_WRITEDEBUG_32BIT 0x35 +#define STLINK_JTAG_READDEBUG_32BIT 0x36 +#define STLINK_JTAG_DRIVE_NRST 0x3C -#define STLINK_DEBUG_APIV2_SWD_SET_FREQ 0x43 +#define STLINK_DEBUG_APIV2_SWD_SET_FREQ 0x43 -#define STLINK_APIV3_SET_COM_FREQ 0x61 -#define STLINK_APIV3_GET_COM_FREQ 0x62 +#define STLINK_APIV3_SET_COM_FREQ 0x61 +#define STLINK_APIV3_GET_COM_FREQ 0x62 -#define STLINK_APIV3_GET_VERSION_EX 0xFB +#define STLINK_APIV3_GET_VERSION_EX 0xFB -// Baud rate divisors for SWDCLK -#define STLINK_SWDCLK_4MHZ_DIVISOR 0 -#define STLINK_SWDCLK_1P8MHZ_DIVISOR 1 -#define STLINK_SWDCLK_1P2MHZ_DIVISOR 2 -#define STLINK_SWDCLK_950KHZ_DIVISOR 3 -#define STLINK_SWDCLK_480KHZ_DIVISOR 7 -#define STLINK_SWDCLK_240KHZ_DIVISOR 15 -#define STLINK_SWDCLK_125KHZ_DIVISOR 31 -#define STLINK_SWDCLK_100KHZ_DIVISOR 40 -#define STLINK_SWDCLK_50KHZ_DIVISOR 79 -#define STLINK_SWDCLK_25KHZ_DIVISOR 158 -#define STLINK_SWDCLK_15KHZ_DIVISOR 265 -#define STLINK_SWDCLK_5KHZ_DIVISOR 798 +/* Baud rate divisors for SWDCLK */ +#define STLINK_SWDCLK_4MHZ_DIVISOR 0 +#define STLINK_SWDCLK_1P8MHZ_DIVISOR 1 +#define STLINK_SWDCLK_1P2MHZ_DIVISOR 2 +#define STLINK_SWDCLK_950KHZ_DIVISOR 3 +#define STLINK_SWDCLK_480KHZ_DIVISOR 7 +#define STLINK_SWDCLK_240KHZ_DIVISOR 15 +#define STLINK_SWDCLK_125KHZ_DIVISOR 31 +#define STLINK_SWDCLK_100KHZ_DIVISOR 40 +#define STLINK_SWDCLK_50KHZ_DIVISOR 79 +#define STLINK_SWDCLK_25KHZ_DIVISOR 158 +#define STLINK_SWDCLK_15KHZ_DIVISOR 265 +#define STLINK_SWDCLK_5KHZ_DIVISOR 798 -#define STLINK_SERIAL_MAX_SIZE 64 +#define STLINK_SERIAL_MAX_SIZE 64 -#define STLINK_V3_MAX_FREQ_NB 10 +#define STLINK_V3_MAX_FREQ_NB 10 /* Cortex Debug Control Block */ -#define DCB_DHCSR 0xE000EDF0 -#define DCB_DCRSR 0xE000EDF4 -#define DCB_DCRDR 0xE000EDF8 -#define DCB_DEMCR 0xE000EDFC +#define DCB_DHCSR 0xE000EDF0 +#define DCB_DCRSR 0xE000EDF4 +#define DCB_DCRDR 0xE000EDF8 +#define DCB_DEMCR 0xE000EDFC /* DCB_DHCSR bit and field definitions */ -#define DBGKEY (0xA05F << 16) -#define C_DEBUGEN (1 << 0) -#define C_HALT (1 << 1) -#define C_STEP (1 << 2) -#define C_MASKINTS (1 << 3) -#define S_REGRDY (1 << 16) -#define S_HALT (1 << 17) -#define S_SLEEP (1 << 18) -#define S_LOCKUP (1 << 19) -#define S_RETIRE_ST (1 << 24) -#define S_RESET_ST (1 << 25) - - -/* - * Map the relevant features, quirks and workaround for specific firmware - * version of stlink - */ +#define DBGKEY (0xA05F << 16) +#define C_DEBUGEN (1 << 0) +#define C_HALT (1 << 1) +#define C_STEP (1 << 2) +#define C_MASKINTS (1 << 3) +#define S_REGRDY (1 << 16) +#define S_HALT (1 << 17) +#define S_SLEEP (1 << 18) +#define S_LOCKUP (1 << 19) +#define S_RETIRE_ST (1 << 24) +#define S_RESET_ST (1 << 25) + + +/* Map the relevant features, quirks and workaround for specific firmware version of stlink */ #define STLINK_F_HAS_TRACE (1<<0) #define STLINK_F_HAS_SWD_SET_FREQ (1<<1) #define STLINK_F_HAS_JTAG_SET_FREQ (1<<2) @@ -120,181 +118,181 @@ enum target_state { #define C_BUF_LEN 32 - enum stlink_flash_type { - STLINK_FLASH_TYPE_UNKNOWN = 0, - STLINK_FLASH_TYPE_F0, /* used by f0, f1 (except f1xl),f3. */ - STLINK_FLASH_TYPE_F1_XL, /* f0 flash with dual bank, apparently */ - STLINK_FLASH_TYPE_F4, /* used by f2, f4, f7 */ - STLINK_FLASH_TYPE_L0, /* l0, l1 */ - STLINK_FLASH_TYPE_L4, /* l4, l4+ */ - STLINK_FLASH_TYPE_G0, - STLINK_FLASH_TYPE_G4, - STLINK_FLASH_TYPE_WB - }; - - struct stlink_reg { - uint32_t r[16]; - uint32_t s[32]; - uint32_t xpsr; - uint32_t main_sp; - uint32_t process_sp; - uint32_t rw; - uint32_t rw2; - uint8_t control; - uint8_t faultmask; - uint8_t basepri; - uint8_t primask; - uint32_t fpscr; - }; - - typedef uint32_t stm32_addr_t; +enum stlink_flash_type { + STLINK_FLASH_TYPE_UNKNOWN = 0, + STLINK_FLASH_TYPE_F0, // used by f0, f1 (except f1xl),f3. */ + STLINK_FLASH_TYPE_F1_XL, // f0 flash with dual bank, apparently */ + STLINK_FLASH_TYPE_F4, // used by f2, f4, f7 */ + STLINK_FLASH_TYPE_L0, // l0, l1 */ + STLINK_FLASH_TYPE_L4, // l4, l4+ */ + STLINK_FLASH_TYPE_G0, + STLINK_FLASH_TYPE_G4, + STLINK_FLASH_TYPE_WB +}; + +struct stlink_reg { + uint32_t r[16]; + uint32_t s[32]; + uint32_t xpsr; + uint32_t main_sp; + uint32_t process_sp; + uint32_t rw; + uint32_t rw2; + uint8_t control; + uint8_t faultmask; + uint8_t basepri; + uint8_t primask; + uint32_t fpscr; +}; + +typedef uint32_t stm32_addr_t; typedef struct flash_loader { - stm32_addr_t loader_addr; /* loader sram adddr */ - stm32_addr_t buf_addr; /* buffer sram address */ +stm32_addr_t loader_addr; // loader sram addr +stm32_addr_t buf_addr; // buffer sram address } flash_loader_t; - typedef struct _cortex_m3_cpuid_ { - uint16_t implementer_id; - uint16_t variant; - uint16_t part; - uint8_t revision; - } cortex_m3_cpuid_t; - - enum stlink_jtag_api_version { - STLINK_JTAG_API_V1 = 1, - STLINK_JTAG_API_V2, - STLINK_JTAG_API_V3, - }; - - typedef struct stlink_version_ { - uint32_t stlink_v; - uint32_t jtag_v; - uint32_t swim_v; - uint32_t st_vid; - uint32_t stlink_pid; - /** jtag api version supported */ - enum stlink_jtag_api_version jtag_api; - /** one bit for each feature supported. See macros STLINK_F_* */ - uint32_t flags; - } stlink_version_t; - - enum transport_type { - TRANSPORT_TYPE_ZERO = 0, - TRANSPORT_TYPE_LIBSG, - TRANSPORT_TYPE_LIBUSB, - TRANSPORT_TYPE_INVALID - }; - - typedef struct _stlink stlink_t; +typedef struct _cortex_m3_cpuid_ { + uint16_t implementer_id; + uint16_t variant; + uint16_t part; + uint8_t revision; +} cortex_m3_cpuid_t; + +enum stlink_jtag_api_version { + STLINK_JTAG_API_V1 = 1, + STLINK_JTAG_API_V2, + STLINK_JTAG_API_V3, +}; + +typedef struct stlink_version_ { + uint32_t stlink_v; + uint32_t jtag_v; + uint32_t swim_v; + uint32_t st_vid; + uint32_t stlink_pid; + // jtag api version supported + enum stlink_jtag_api_version jtag_api; + // one bit for each feature supported. See macros STLINK_F_* + uint32_t flags; +} stlink_version_t; + +enum transport_type { + TRANSPORT_TYPE_ZERO = 0, + TRANSPORT_TYPE_LIBSG, + TRANSPORT_TYPE_LIBUSB, + TRANSPORT_TYPE_INVALID +}; + +typedef struct _stlink stlink_t; #include - struct _stlink { - struct _stlink_backend *backend; - void *backend_data; - - // Room for the command header - unsigned char c_buf[C_BUF_LEN]; - // Data transferred from or to device - unsigned char q_buf[Q_BUF_LEN]; - int q_len; - - // transport layer verboseness: 0 for no debug info, 10 for lots - int verbose; - int opt; - uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID - uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram - enum target_state core_stat; // set by stlink_status() - - char serial[STLINK_SERIAL_MAX_SIZE]; - int serial_size; - - enum stlink_flash_type flash_type; // stlink_chipid_params.flash_type, set by stlink_load_device_params(), values: STLINK_FLASH_TYPE_xxx - bool has_dual_bank; - - stm32_addr_t flash_base; // STM32_FLASH_BASE, set by stlink_load_device_params() - size_t flash_size; // calculated by stlink_load_device_params() - size_t flash_pgsz; // stlink_chipid_params.flash_pagesize, set by stlink_load_device_params() - - /* sram settings */ - stm32_addr_t sram_base; // STM32_SRAM_BASE, set by stlink_load_device_params() - size_t sram_size; // stlink_chipid_params.sram_size, set by stlink_load_device_params() - - /* option settings */ - stm32_addr_t option_base; - size_t option_size; - - // 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) - 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() - - struct stlink_version_ version; - }; - - int stlink_enter_swd_mode(stlink_t *sl); - int stlink_enter_jtag_mode(stlink_t *sl); - int stlink_exit_debug_mode(stlink_t *sl); - int stlink_exit_dfu_mode(stlink_t *sl); - void stlink_close(stlink_t *sl); - int stlink_core_id(stlink_t *sl); - int stlink_reset(stlink_t *sl); - int stlink_jtag_reset(stlink_t *sl, int value); - int stlink_run(stlink_t *sl); - int stlink_status(stlink_t *sl); - int stlink_version(stlink_t *sl); - int stlink_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data); - int stlink_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len); - int stlink_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data); - int stlink_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len); - int stlink_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len); - int stlink_read_all_regs(stlink_t *sl, struct stlink_reg *regp); - int stlink_read_all_unsupported_regs(stlink_t *sl, struct stlink_reg *regp); - int stlink_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); - int stlink_read_unsupported_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); - int stlink_write_unsupported_reg(stlink_t *sl, uint32_t value, int r_idx, struct stlink_reg *regp); - int stlink_write_reg(stlink_t *sl, uint32_t reg, int idx); - int stlink_step(stlink_t *sl); - int stlink_current_mode(stlink_t *sl); - int stlink_force_debug(stlink_t *sl); - int stlink_target_voltage(stlink_t *sl); - int stlink_set_swdclk(stlink_t *sl, uint16_t divisor); - - int stlink_erase_flash_mass(stlink_t* sl); - int stlink_write_flash(stlink_t* sl, stm32_addr_t address, uint8_t* data, uint32_t length, uint8_t eraseonly); - int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, size_t * size, uint32_t * begin); - uint8_t stlink_get_erased_pattern(stlink_t *sl); - int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); - int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_mwrite_sram(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); - int stlink_fwrite_sram(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, uint32_t length); - - int stlink_chip_id(stlink_t *sl, uint32_t *chip_id); - int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid); - - int stlink_erase_flash_page(stlink_t* sl, stm32_addr_t flashaddr); - uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr); - uint16_t read_uint16(const unsigned char *c, const int pt); - void stlink_core_stat(stlink_t *sl); - void stlink_print_data(stlink_t *sl); - unsigned int is_bigendian(void); - uint32_t read_uint32(const unsigned char *c, const int pt); - void write_uint32(unsigned char* buf, uint32_t ui); - void write_uint16(unsigned char* buf, uint16_t ui); - bool stlink_is_core_halted(stlink_t *sl); - int write_buffer_to_sram(stlink_t *sl, flash_loader_t* fl, const uint8_t* buf, size_t size); - int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size); - int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); - int stlink_load_device_params(stlink_t *sl); - - int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte); - int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte); - - int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len); - int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); +struct _stlink { + struct _stlink_backend *backend; + void *backend_data; + + // Room for the command header + unsigned char c_buf[C_BUF_LEN]; + // Data transferred from or to device + unsigned char q_buf[Q_BUF_LEN]; + int q_len; + + // transport layer verboseness: 0 for no debug info, 10 for lots + int verbose; + int opt; + uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID + uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram + enum target_state core_stat; // set by stlink_status() + + char serial[STLINK_SERIAL_MAX_SIZE]; + int serial_size; + + enum stlink_flash_type flash_type; + // stlink_chipid_params.flash_type, set by stlink_load_device_params(), values: STLINK_FLASH_TYPE_xxx + bool has_dual_bank; + + stm32_addr_t flash_base; // STM32_FLASH_BASE, set by stlink_load_device_params() + size_t flash_size; // calculated by stlink_load_device_params() + size_t flash_pgsz; // stlink_chipid_params.flash_pagesize, set by stlink_load_device_params() + + /* sram settings */ + stm32_addr_t sram_base; // STM32_SRAM_BASE, set by stlink_load_device_params() + size_t sram_size; // stlink_chipid_params.sram_size, set by stlink_load_device_params() + + /* option settings */ + stm32_addr_t option_base; + size_t option_size; + + // 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) + 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() + + struct stlink_version_ version; +}; + +int stlink_enter_swd_mode(stlink_t *sl); +int stlink_enter_jtag_mode(stlink_t *sl); +int stlink_exit_debug_mode(stlink_t *sl); +int stlink_exit_dfu_mode(stlink_t *sl); +void stlink_close(stlink_t *sl); +int stlink_core_id(stlink_t *sl); +int stlink_reset(stlink_t *sl); +int stlink_jtag_reset(stlink_t *sl, int value); +int stlink_run(stlink_t *sl); +int stlink_status(stlink_t *sl); +int stlink_version(stlink_t *sl); +int stlink_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data); +int stlink_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len); +int stlink_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data); +int stlink_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len); +int stlink_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len); +int stlink_read_all_regs(stlink_t *sl, struct stlink_reg *regp); +int stlink_read_all_unsupported_regs(stlink_t *sl, struct stlink_reg *regp); +int stlink_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); +int stlink_read_unsupported_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); +int stlink_write_unsupported_reg(stlink_t *sl, uint32_t value, int r_idx, struct stlink_reg *regp); +int stlink_write_reg(stlink_t *sl, uint32_t reg, int idx); +int stlink_step(stlink_t *sl); +int stlink_current_mode(stlink_t *sl); +int stlink_force_debug(stlink_t *sl); +int stlink_target_voltage(stlink_t *sl); +int stlink_set_swdclk(stlink_t *sl, uint16_t divisor); + +int stlink_erase_flash_mass(stlink_t* sl); +int stlink_write_flash(stlink_t* sl, stm32_addr_t address, uint8_t* data, uint32_t length, uint8_t eraseonly); +int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, size_t * size, uint32_t * begin); +uint8_t stlink_get_erased_pattern(stlink_t *sl); +int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); +int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr); +int stlink_mwrite_sram(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); +int stlink_fwrite_sram(stlink_t *sl, const char* path, stm32_addr_t addr); +int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, uint32_t length); + +int stlink_chip_id(stlink_t *sl, uint32_t *chip_id); +int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid); + +int stlink_erase_flash_page(stlink_t* sl, stm32_addr_t flashaddr); +uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr); +uint16_t read_uint16(const unsigned char *c, const int pt); +void stlink_core_stat(stlink_t *sl); +void stlink_print_data(stlink_t *sl); +unsigned int is_bigendian(void); +uint32_t read_uint32(const unsigned char *c, const int pt); +void write_uint32(unsigned char* buf, uint32_t ui); +void write_uint16(unsigned char* buf, uint16_t ui); +bool stlink_is_core_halted(stlink_t *sl); +int write_buffer_to_sram(stlink_t *sl, flash_loader_t* fl, const uint8_t* buf, size_t size); +int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size); +int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); +int stlink_load_device_params(stlink_t *sl); + +int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte); +int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte); + +int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len); +int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); #include #include diff --git a/src/usb.c b/src/usb.c index 8db78016d..bd9f8e51e 100644 --- a/src/usb.c +++ b/src/usb.c @@ -87,11 +87,7 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate, int res = 0; int t; - t = libusb_bulk_transfer(handle->usb_handle, handle->ep_req, - txbuf, - (int) txsize, - &res, - 3000); + t = libusb_bulk_transfer(handle->usb_handle, handle->ep_req, txbuf, (int) txsize, &res, 3000); if (t) { printf("[!] send_recv send request failed: %s\n", libusb_error_name(t)); return -1; @@ -101,11 +97,7 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate, } if (rxsize != 0) { - t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, - rxbuf, - (int) rxsize, - &res, - 3000); + t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, rxbuf, (int) rxsize, &res, 3000); if (t) { printf("[!] send_recv read reply failed: %s\n", libusb_error_name(t)); @@ -116,11 +108,7 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate, if ((handle->protocoll == 1) && terminate) { /* Read the SG reply */ unsigned char sg_buf[13]; - t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, - sg_buf, - 13, - &res, - 3000); + t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, sg_buf, 13, &res, 3000); if (t) { printf("[!] send_recv read storage failed: %s\n", libusb_error_name(t)); @@ -270,7 +258,8 @@ int _stlink_usb_get_rw_status(stlink_t *sl) unsigned char* const rdata = sl->q_buf; struct stlink_libusb * const slu = sl->backend_data; unsigned char* const cmd = sl->c_buf; - int i, ret = 0; + int i; + int16_t ret = 0; i = fill_command(sl, SG_DXFER_FROM_DEV, 12); cmd[i++] = STLINK_DEBUG_COMMAND; @@ -456,6 +445,7 @@ int _stlink_usb_enter_swd_mode(stlink_t * sl) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; + // Select correct API-Version for entering SWD mode: V1 API (0x20) or V2 API (0x30) cmd[i++] = sl->version.jtag_api == STLINK_JTAG_API_V1 ? STLINK_DEBUG_APIV1_ENTER : STLINK_DEBUG_APIV2_ENTER; cmd[i++] = STLINK_DEBUG_ENTER_SWD; From 7a5b6ef2f707660e79d2ff7fde4aa84390da19be Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sat, 9 May 2020 22:20:17 +0200 Subject: [PATCH 210/236] Whitespace cleanup --- include/stlink.h | 331 ++++++++++++++++++++++++----------------------- 1 file changed, 166 insertions(+), 165 deletions(-) diff --git a/include/stlink.h b/include/stlink.h index b8080fd5e..68ca0ab39 100644 --- a/include/stlink.h +++ b/include/stlink.h @@ -1,9 +1,10 @@ /* * File: stlink.h * - * This should contain all the common top level stlink interfaces, regardless - * of how the backend does the work.... + * This should contain all the common top level stlink interfaces, + * regardless of how the backend does the work.... */ + #ifndef STLINK_H #define STLINK_H @@ -19,12 +20,12 @@ extern "C" { #define STLINK_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - // Max data transfer size. - // 6kB = max mem32_read block, 8kB sram - //#define Q_BUF_LEN 96 +// Max data transfer size. +// 6kB = max mem32_read block, 8kB sram +//#define Q_BUF_LEN 96 #define Q_BUF_LEN (1024 * 100) - // STLINK_DEBUG_RESETSYS, etc: +// STLINK_DEBUG_RESETSYS, etc: #define STLINK_CORE_RUNNING 0x80 #define STLINK_CORE_HALTED 0x81 #define STLINK_CORE_STAT_UNKNOWN -1 @@ -37,13 +38,13 @@ extern "C" { #define STLINK_DFU_COMMAND 0xF3 #define STLINK_DFU_EXIT 0x07 - // STLINK_GET_CURRENT_MODE +// STLINK_GET_CURRENT_MODE #define STLINK_DEV_DFU_MODE 0x00 #define STLINK_DEV_MASS_MODE 0x01 #define STLINK_DEV_DEBUG_MODE 0x02 #define STLINK_DEV_UNKNOWN_MODE -1 - // TODO - possible poor names... +// TODO - possible poor names... #define STLINK_SWD_ENTER 0x30 #define STLINK_SWD_READCOREID 0x32 // TBD #define STLINK_JTAG_WRITEDEBUG_32BIT 0x35 @@ -76,176 +77,176 @@ extern "C" { #define STLINK_V3_MAX_FREQ_NB 10 - /* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/ +/* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/ #define C_BUF_LEN 32 - enum stlink_flash_type { - STLINK_FLASH_TYPE_UNKNOWN = 0, - STLINK_FLASH_TYPE_F0, /* used by f0, f1 (except f1xl),f3. */ - STLINK_FLASH_TYPE_F1_XL, /* f0 flash with dual bank, apparently */ - STLINK_FLASH_TYPE_F4, /* used by f2, f4, f7 */ - STLINK_FLASH_TYPE_L0, /* l0, l1 */ - STLINK_FLASH_TYPE_L4, /* l4, l4+ */ - STLINK_FLASH_TYPE_G0, - STLINK_FLASH_TYPE_G4, - STLINK_FLASH_TYPE_WB - }; - - struct stlink_reg { - uint32_t r[16]; - uint32_t s[32]; - uint32_t xpsr; - uint32_t main_sp; - uint32_t process_sp; - uint32_t rw; - uint32_t rw2; - uint8_t control; - uint8_t faultmask; - uint8_t basepri; - uint8_t primask; - uint32_t fpscr; - }; - - typedef uint32_t stm32_addr_t; +enum stlink_flash_type { + STLINK_FLASH_TYPE_UNKNOWN = 0, + STLINK_FLASH_TYPE_F0, /* used by f0, f1 (except f1xl),f3. */ + STLINK_FLASH_TYPE_F1_XL, /* f0 flash with dual bank, apparently */ + STLINK_FLASH_TYPE_F4, /* used by f2, f4, f7 */ + STLINK_FLASH_TYPE_L0, /* l0, l1 */ + STLINK_FLASH_TYPE_L4, /* l4, l4+ */ + STLINK_FLASH_TYPE_G0, + STLINK_FLASH_TYPE_G4, + STLINK_FLASH_TYPE_WB +}; + +struct stlink_reg { + uint32_t r[16]; + uint32_t s[32]; + uint32_t xpsr; + uint32_t main_sp; + uint32_t process_sp; + uint32_t rw; + uint32_t rw2; + uint8_t control; + uint8_t faultmask; + uint8_t basepri; + uint8_t primask; + uint32_t fpscr; +}; + +typedef uint32_t stm32_addr_t; typedef struct flash_loader { stm32_addr_t loader_addr; /* loader sram adddr */ stm32_addr_t buf_addr; /* buffer sram address */ } flash_loader_t; - typedef struct _cortex_m3_cpuid_ { - uint16_t implementer_id; - uint16_t variant; - uint16_t part; - uint8_t revision; - } cortex_m3_cpuid_t; - - typedef struct stlink_version_ { - uint32_t stlink_v; - uint32_t jtag_v; - uint32_t swim_v; - uint32_t st_vid; - uint32_t stlink_pid; - } stlink_version_t; - - enum transport_type { - TRANSPORT_TYPE_ZERO = 0, - TRANSPORT_TYPE_LIBSG, - TRANSPORT_TYPE_LIBUSB, - TRANSPORT_TYPE_INVALID - }; +typedef struct _cortex_m3_cpuid_ { + uint16_t implementer_id; + uint16_t variant; + uint16_t part; + uint8_t revision; +} cortex_m3_cpuid_t; + +typedef struct stlink_version_ { + uint32_t stlink_v; + uint32_t jtag_v; + uint32_t swim_v; + uint32_t st_vid; + uint32_t stlink_pid; +} stlink_version_t; + +enum transport_type { + TRANSPORT_TYPE_ZERO = 0, + TRANSPORT_TYPE_LIBSG, + TRANSPORT_TYPE_LIBUSB, + TRANSPORT_TYPE_INVALID +}; typedef struct _stlink stlink_t; #include - struct _stlink { - struct _stlink_backend *backend; - void *backend_data; - - // Room for the command header - unsigned char c_buf[C_BUF_LEN]; - // Data transferred from or to device - unsigned char q_buf[Q_BUF_LEN]; - int q_len; - - // transport layer verboseness: 0 for no debug info, 10 for lots - int verbose; - int opt; // set by main() in tools/flash.c, empty tail bytes drop optimization - uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID - uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram - int core_stat; // set by stlink_status(), values STLINK_CORE_xxxxx - - char serial[STLINK_SERIAL_MAX_SIZE]; - int serial_size; - - int freq; // set by stlink_open_usb(), values: STLINK_SWDCLK_xxx_DIVISOR - - enum stlink_flash_type flash_type; // stlink_chipid_params.flash_type, set by stlink_load_device_params(), values: STLINK_FLASH_TYPE_xxx - bool has_dual_bank; - - stm32_addr_t flash_base; // STM32_FLASH_BASE, set by stlink_load_device_params() - size_t flash_size; // calculated by stlink_load_device_params() - size_t flash_pgsz; // stlink_chipid_params.flash_pagesize, set by stlink_load_device_params() - - /* sram settings */ - stm32_addr_t sram_base; // STM32_SRAM_BASE, set by stlink_load_device_params() - size_t sram_size; // stlink_chipid_params.sram_size, set by stlink_load_device_params() - - /* option settings */ - stm32_addr_t option_base; - size_t option_size; - - // 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) - 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() - - struct stlink_version_ version; - }; - - int stlink_enter_swd_mode(stlink_t *sl); - int stlink_enter_jtag_mode(stlink_t *sl); - int stlink_exit_debug_mode(stlink_t *sl); - int stlink_exit_dfu_mode(stlink_t *sl); - void stlink_close(stlink_t *sl); - int stlink_core_id(stlink_t *sl); - int stlink_reset(stlink_t *sl); - int stlink_jtag_reset(stlink_t *sl, int value); - int stlink_run(stlink_t *sl); - int stlink_status(stlink_t *sl); - int stlink_version(stlink_t *sl); - int stlink_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data); - int stlink_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len); - int stlink_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data); - int stlink_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len); - int stlink_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len); - int stlink_read_all_regs(stlink_t *sl, struct stlink_reg *regp); - int stlink_read_all_unsupported_regs(stlink_t *sl, struct stlink_reg *regp); - int stlink_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); - int stlink_read_unsupported_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); - int stlink_write_unsupported_reg(stlink_t *sl, uint32_t value, int r_idx, struct stlink_reg *regp); - int stlink_write_reg(stlink_t *sl, uint32_t reg, int idx); - int stlink_step(stlink_t *sl); - int stlink_current_mode(stlink_t *sl); - int stlink_force_debug(stlink_t *sl); - int stlink_target_voltage(stlink_t *sl); - int stlink_set_swdclk(stlink_t *sl, uint16_t divisor); - - int stlink_erase_flash_mass(stlink_t* sl); - int stlink_write_flash(stlink_t* sl, stm32_addr_t address, uint8_t* data, uint32_t length, uint8_t eraseonly); - int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, size_t * size, uint32_t * begin); - uint8_t stlink_get_erased_pattern(stlink_t *sl); - int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); - int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_mwrite_sram(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); - int stlink_fwrite_sram(stlink_t *sl, const char* path, stm32_addr_t addr); - int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, uint32_t length); - - int stlink_chip_id(stlink_t *sl, uint32_t *chip_id); - int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid); - - int stlink_erase_flash_page(stlink_t* sl, stm32_addr_t flashaddr); - uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr); - uint16_t read_uint16(const unsigned char *c, const int pt); - void stlink_core_stat(stlink_t *sl); - void stlink_print_data(stlink_t *sl); - unsigned int is_bigendian(void); - uint32_t read_uint32(const unsigned char *c, const int pt); - void write_uint32(unsigned char* buf, uint32_t ui); - void write_uint16(unsigned char* buf, uint16_t ui); - bool stlink_is_core_halted(stlink_t *sl); - int write_buffer_to_sram(stlink_t *sl, flash_loader_t* fl, const uint8_t* buf, size_t size); - int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size); - int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); - int stlink_load_device_params(stlink_t *sl); - - int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte); - int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte); - - int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len); - int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); +struct _stlink { + struct _stlink_backend *backend; + void *backend_data; + + // Room for the command header + unsigned char c_buf[C_BUF_LEN]; + // Data transferred from or to device + unsigned char q_buf[Q_BUF_LEN]; + int q_len; + + // transport layer verboseness: 0 for no debug info, 10 for lots + int verbose; + int opt; // set by main() in tools/flash.c, empty tail bytes drop optimization + uint32_t core_id; // set by stlink_core_id(), result from STLINK_DEBUGREADCOREID + uint32_t chip_id; // set by stlink_load_device_params(), used to identify flash and sram + int core_stat; // set by stlink_status(), values STLINK_CORE_xxxxx + + char serial[STLINK_SERIAL_MAX_SIZE]; + int serial_size; + + int freq; // set by stlink_open_usb(), values: STLINK_SWDCLK_xxx_DIVISOR + + enum stlink_flash_type flash_type; // stlink_chipid_params.flash_type, set by stlink_load_device_params(), values: STLINK_FLASH_TYPE_xxx + bool has_dual_bank; + + stm32_addr_t flash_base; // STM32_FLASH_BASE, set by stlink_load_device_params() + size_t flash_size; // calculated by stlink_load_device_params() + size_t flash_pgsz; // stlink_chipid_params.flash_pagesize, set by stlink_load_device_params() + + /* sram settings */ + stm32_addr_t sram_base; // STM32_SRAM_BASE, set by stlink_load_device_params() + size_t sram_size; // stlink_chipid_params.sram_size, set by stlink_load_device_params() + + /* option settings */ + stm32_addr_t option_base; + size_t option_size; + + // 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) + 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() + + struct stlink_version_ version; +}; + +int stlink_enter_swd_mode(stlink_t *sl); +int stlink_enter_jtag_mode(stlink_t *sl); +int stlink_exit_debug_mode(stlink_t *sl); +int stlink_exit_dfu_mode(stlink_t *sl); +void stlink_close(stlink_t *sl); +int stlink_core_id(stlink_t *sl); +int stlink_reset(stlink_t *sl); +int stlink_jtag_reset(stlink_t *sl, int value); +int stlink_run(stlink_t *sl); +int stlink_status(stlink_t *sl); +int stlink_version(stlink_t *sl); +int stlink_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data); +int stlink_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len); +int stlink_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data); +int stlink_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len); +int stlink_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len); +int stlink_read_all_regs(stlink_t *sl, struct stlink_reg *regp); +int stlink_read_all_unsupported_regs(stlink_t *sl, struct stlink_reg *regp); +int stlink_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); +int stlink_read_unsupported_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp); +int stlink_write_unsupported_reg(stlink_t *sl, uint32_t value, int r_idx, struct stlink_reg *regp); +int stlink_write_reg(stlink_t *sl, uint32_t reg, int idx); +int stlink_step(stlink_t *sl); +int stlink_current_mode(stlink_t *sl); +int stlink_force_debug(stlink_t *sl); +int stlink_target_voltage(stlink_t *sl); +int stlink_set_swdclk(stlink_t *sl, uint16_t divisor); + +int stlink_erase_flash_mass(stlink_t* sl); +int stlink_write_flash(stlink_t* sl, stm32_addr_t address, uint8_t* data, uint32_t length, uint8_t eraseonly); +int stlink_parse_ihex(const char* path, uint8_t erased_pattern, uint8_t * * mem, size_t * size, uint32_t * begin); +uint8_t stlink_get_erased_pattern(stlink_t *sl); +int stlink_mwrite_flash(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); +int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr); +int stlink_mwrite_sram(stlink_t *sl, uint8_t* data, uint32_t length, stm32_addr_t addr); +int stlink_fwrite_sram(stlink_t *sl, const char* path, stm32_addr_t addr); +int stlink_verify_write_flash(stlink_t *sl, stm32_addr_t address, uint8_t *data, uint32_t length); + +int stlink_chip_id(stlink_t *sl, uint32_t *chip_id); +int stlink_cpu_id(stlink_t *sl, cortex_m3_cpuid_t *cpuid); + +int stlink_erase_flash_page(stlink_t* sl, stm32_addr_t flashaddr); +uint32_t stlink_calculate_pagesize(stlink_t *sl, uint32_t flashaddr); +uint16_t read_uint16(const unsigned char *c, const int pt); +void stlink_core_stat(stlink_t *sl); +void stlink_print_data(stlink_t *sl); +unsigned int is_bigendian(void); +uint32_t read_uint32(const unsigned char *c, const int pt); +void write_uint32(unsigned char* buf, uint32_t ui); +void write_uint16(unsigned char* buf, uint16_t ui); +bool stlink_is_core_halted(stlink_t *sl); +int write_buffer_to_sram(stlink_t *sl, flash_loader_t* fl, const uint8_t* buf, size_t size); +int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size); +int stlink_fread(stlink_t* sl, const char* path, bool is_ihex, stm32_addr_t addr, size_t size); +int stlink_load_device_params(stlink_t *sl); + +int stlink_read_option_bytes32(stlink_t *sl, uint32_t* option_byte); +int stlink_write_option_bytes32(stlink_t *sl, uint32_t option_byte); + +int stlink_write_option_bytes(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t len); +int stlink_fwrite_option_bytes(stlink_t *sl, const char* path, stm32_addr_t addr); #include #include From 7bb34fcfb2a19c03c7daa2986aad4515f699f24b Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 10 May 2020 00:47:37 +0200 Subject: [PATCH 211/236] Update for windows binary packaging - Updated steps for release preparation - Changed destination for binary archives (Closes #798) --- cmake/packaging/cpack_config.cmake | 3 +-- cmake/packaging/windows/generate_binaries.sh | 2 ++ doc/release.md | 13 +++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmake/packaging/cpack_config.cmake b/cmake/packaging/cpack_config.cmake index c81362896..a0fddd71c 100644 --- a/cmake/packaging/cpack_config.cmake +++ b/cmake/packaging/cpack_config.cmake @@ -25,12 +25,11 @@ elseif (WIN32 AND NOT EXISTS "/etc/debian_version") set(CPACK_INSTALL_PREFIX "") elseif (WIN32) # Windows cross-build on Debian/Ubuntu - set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/build/Release/dist") set(CPACK_GENERATOR "ZIP") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-${TOOLCHAIN_PREFIX}") set(CPACK_INSTALL_PREFIX "") -elseif (EXISTS "/etc/debian_version") # Package-build is available on Debian/Ubuntu only +elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is available on Debian/Ubuntu only message(STATUS "Debian-based Linux OS detected") set(CPACK_GENERATOR "DEB;RPM") # RPM requires package `rpm` diff --git a/cmake/packaging/windows/generate_binaries.sh b/cmake/packaging/windows/generate_binaries.sh index ba5b965f5..d38f8d62f 100644 --- a/cmake/packaging/windows/generate_binaries.sh +++ b/cmake/packaging/windows/generate_binaries.sh @@ -12,6 +12,7 @@ cmake -DCMAKE_SYSTEM_NAME=Windows \ -DTOOLCHAIN_PREFIX=x86_64-w64-mingw32 \ -DCMAKE_TOOLCHAIN_FILE=./cmake/modules/set_toolchain.cmake .. make package +cp dist/*.zip ../build/Release/dist cd .. rm -rf build-mingw @@ -22,5 +23,6 @@ cmake -DCMAKE_SYSTEM_NAME=Windows \ -DTOOLCHAIN_PREFIX=i686-w64-mingw32 \ -DCMAKE_TOOLCHAIN_FILE=./cmake/modules/set_toolchain.cmake .. make package +cp dist/*.zip ../build/Release/dist cd .. rm -rf build-mingw diff --git a/doc/release.md b/doc/release.md index ae8b864ee..4b536d95a 100644 --- a/doc/release.md +++ b/doc/release.md @@ -1,10 +1,11 @@ Release ======= -This document describes the steps it takes for developers to create a release +This document describes the necessary steps 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` +1. Update `CHANGELOG.md` and `cmake/packaging/deb/changelog` +2. Update `.version` with semantic version: `x.x.x` +3. Update `README.md` with semantic version `x.x.x` in commits badge +4. Create and push git tag and commits `git tag x.x.x` +5. Create binary packages (.rpm / .deb / .zip) with `make package && sh ./cmake/packaging/windows/generate_binaries.sh` +6. Upload packages to the [release page](https://github.com/stlink-org/stlink/releases) of this project From d11e6f4c8affac671e42ed55d88d6b911418a215 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 10 May 2020 02:11:08 +0200 Subject: [PATCH 212/236] Updated tutorial - Added table for available tool options - Removed install instructions for OpenOCD - Removed outdated content - Fixed toolset description in desktop-file - Added documentation for the stlink-gui (Closes #884) --- doc/tutorial.md | 167 +++++------------------------- src/stlink-gui/stlink-gui.desktop | 2 +- 2 files changed, 25 insertions(+), 144 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index ad64a8db8..694142184 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1,35 +1,32 @@ stlink Tools Tutorial ===================== -## Useful tool options +## Available tools and options -### st-flash - -#### --flash=n[k][m] - -(since v1.4.0) - -You can specify `--flash=128k` for example, to override the STM32F103C8T6 to assume 128k of flash instead of the default of 64k. -This option accepts decimal (128k), octal 0200k, or hex 0x80k. -Obviously leaving the multiplier out is equally valid, for example: `--flash=0x20000`. -The size may be followed by an optional "k" or "m" to multiply the given value by 1k (1024) or 1M respectively. - -#### Checksum for binary files +| Option | Tool | Description | Available
since | +| --- | --- | --- | --- | +| --flash=n[k][m] | st-flash | One can specify `--flash=128k` for example, to override the default value of 64k
for the STM32F103C8T6 to assume 128k of flash being present. This option accepts
decimal (128k), octal 0200k, or hex 0x80k values. Leaving the multiplier out is
equally valid, e.g.: `--flash=0x20000`. The size may be followed by an optional "k"
or "m" to multiply the given value by 1k (1024) or 1M respectively. | v1.4.0 | +| --freq=n[k][m] | st-flash,
st-util | The frequency of the SWD/JTAG interface can be specified, to override the default
1800 kHz configuration. This option solely accepts decimal values (5K or 1.8M) with
the unit `Hz` being left out. Valid frequencies are `5K, 15K, 25K, 50K, 100K,`
`125K, 240K, 480K, 950K, 1200K(1.2M), 1800K(1.8M), 4000K(4M)`. | v1.6.1 | +| --opt | st-flash | Optimisation can be enabled in order to skip flashing empty (0x00 or 0xff) bytes at
the end of binary file. This may cause some garbage data left after a flash operation.
This option was enabled by default in earlier releases. | v1.6.1 | +| --version | st-info,
st-flash,
st-util | Print version information. | | +| --help | st-flash,
st-util | Print list of available commands. _(To be added to this table.)_ | | +### st-flash: Checksum for binary files When flashing a file, a checksum is calculated for the binary file, both in md5 and the sum algorithm. The latter is also used by the official ST-Link utility tool from STMicroelectronics as described in the document: [`UM0892 - User manual - STM32 ST-LINK utility software description`](https://www.st.com/resource/en/user_manual/cd00262073-stm32-stlink-utility-software-description-stmicroelectronics.pdf). -#### --freq=n[k][m] - -(since v1.6.1) +### stlink-gui +The `stlink` toolset also provides a GUI which is an optional feature. It is only installed if a gtk3 toolset has been detected during package installation or compilation from source. It is not available for Windows. If you prefer to have an user interface on the latter system, please use the official `ST-LINK Utility` instead. -You can specify the frequency of SWD/JTAG interface, to override the default 1800KHz configuration. This option accpets decimal only (5K or 1.8M). `Hz` is left out in this option. Valid frequencies are `5K, 15K, 25K, 50K, 100K, 125K, 240K, 480K, 950K, 1200K(1.2M), 1800K(1.8M), 4000K(4M)` +The stlink-gui offers the following features: +* Connect/disconnect to a present STlink programmer +* Display basic device information +* Select a binary file from the local filesystem to flash it to the detected device connected to the programmer +* Export the memory of the connected chip to a file which can be saved to the local filesystem +* Display of the memory address map in the main window for each, the device memory and a loaded binary file -#### --opt +Within the GUI main window tooltips explain the available user elements. -(since v1.6.1, optional; enabled by default from v1.0.0 to v1.6.0) - -You can enable the optimization to skip flashing empty (0x00 or 0xff) bytes at the end of binary file. May cause some garbage data left after a flash. ## Solutions to common problems ### a) STLINK/v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) @@ -153,22 +150,13 @@ This guide details the use of STMicroelectronics STM32 discovery kits in an open ## Installing a GNU toolchain -Any toolchain supporting the cortex m3 should do. You can find the -necessary to install such a toolchain here: - -``` -https://github.com/esden/summon-arm-toolchain -``` - -Details for the installation are provided in the topmost `README` file. -This documentation assumes the toolchains is installed in a -`$TOOLCHAIN_PATH`. +Any toolchain supporting the cortex m3 should do. ## Using the GDB server -This assumes you have got the libopencm3 project downloaded in `ocm3`. -The libopencm3 project has some good, reliable examples for each of the -Discovery boards. +This assumes you have got the [libopencm3](http://www.libopencm3.org) project downloaded in `ocm3`. +The libopencm3 project provides a firmware library, with solid examples for Cortex M3, M4 and M0 processors +from any vendor. It has some good, reliable examples for each of the Discovery boards. Even if you don’t plan on using libopencm3, the examples they provide will help you verify that: @@ -179,7 +167,7 @@ will help you verify that: - Your arm-none-eabi-gdb is functional - Your board is functional -A GDB server must be started to interact with the STM32 by running +A GDB server must be started to interact with the STM32 by running st-util tool : ``` @@ -283,7 +271,7 @@ There are a few options: Do not reset board on connection. ``` -The STLink device to use can be specified using the --serial parameter, or via +The STLink device to use can be specified using the --serial parameter, or via the environment variable STLINK_DEVICE on the format :. Then, in your project directory, someting like this... @@ -373,42 +361,6 @@ Example to read and write option bytes (currently writing only supported for STM ./st-flash --debug --reset --format binary --flash=128k write option_bytes_dump.bin 0x1FFF7800 ``` -## Installation of openOCD on Mac OS X with STlink-v2: - -`sudo port install openocd +jlink +stlink +ft2232` - -`/opt/local/bin/openocd --version` - -> Open On-Chip Debugger 0.7.0 (2014-08-11-22:12) - -`openocd -f /opt/local/share/openocd/scripts/interface/stlink-v2.cfg -f /opt/local/share/openocd/scripts/target/stm32f1x_stlink.cfg ` - -> Open On-Chip Debugger 0.8.0 (2014-08-11-15:36) -> -> Licensed under GNU GPL v2 -> -> For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html -> -> Info : This adapter doesn't support configurable speed -> -> Info : STLINK v2 JTAG v21 API v2 SWIM v4 VID 0x0483 PID 0x3748 -> -> Info : using stlink api v2 -> -> Info : Target voltage: 3.244269 -> -> Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints - -and connecting to the server through telnet yields a successful installation - -`telnet localhost 4444` - -> Connected to localhost. -> -> Escape character is '^]'. -> -> Open On-Chip Debugger - FAQ === @@ -424,74 +376,3 @@ A: Sometimes when you will try to use GDB `next` command to skip a loop, it will 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. - -Q: How can I install stlink and flash binaries on Mac OS X ? - -A: Installed on Mac OS X 10.9.4 with ports method, - however STlink v2 does not seem to work with libusb if you upgrade to the newest firmware !! - Only older firmware on STlink v2 works. - -[https://coderwall.com/p/oznj_q](https://coderwall.com/p/oznj_q) - -``` -sudo port install libusb automake autoconf pkgconfig -aclocal --force -I /opt/local/share/aclocal -git clone https://github.com/stlink-org/stlink.git stlink-utility -cd stlink-utility -./autogen.sh -./configure -make -``` - -Then trying to flash the image with STLINK v2 : - -`./st-flash write ~/Downloads/irq.bin 0x8000000` - -> libusb_handle_events() timeout -> -> [!] send_recv - -ST-Link/V2 debugger with downgraded V2.14.3 firmware: - -https://drive.google.com/folderview?id=0Bzv7UpKpOQhnbXJVVEg4VUo2M1k - -After downgrading the firmware, flashing works as described here: - -http://community.spark.io/t/how-to-flash-a-brand-new-freshly-soldered-stm32f103-chip/3906 - -`./st-flash write ~/Downloads/irq.bin 0x8000000` - -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Loading device parameters.... -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410 -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in -> pages of 1024 bytes -> -> 2014-08-11T23:14:52 INFO src/stlink-common.c: Attempting to write 24904 (0x6148) bytes to stm32 address: 134217728 -> (0x8000000) -> -> Flash page at addr: 0x08006000 erased -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Finished erasing 25 pages of 1024 (0x400) bytes -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id -> -> 2014-08-11T23:14:53 INFO src/stlink-common.c: Successfully loaded flash loader in sram 24/24 pages written -> -> 2014-08-11T23:14:54 INFO src/stlink-common.c: Starting verification of write complete -> -> 2014-08-11T23:14:54 INFO src/stlink-common.c: Flash written and verified! jolly good! - - -References -========== - -- - documentation related to the STM32L mcu - -- - documentation related to the STM32L discovery kit - -- - libopencm3, a project providing a firmware library, with solid examples for Cortex M3, M4 and M0 processors from any vendor. diff --git a/src/stlink-gui/stlink-gui.desktop b/src/stlink-gui/stlink-gui.desktop index 54cb40349..72bc26ac6 100644 --- a/src/stlink-gui/stlink-gui.desktop +++ b/src/stlink-gui/stlink-gui.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Name=stlink GenericName=Stlink Tools -Comment=STM32 discovery line Linux programmer +Comment=Open source STM32 MCU programming toolset Exec=stlink-gui Icon=stlink-gui Terminal=false From 06c66ed308d6e65ad70757c7177444257cb2ea1a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 10 May 2020 16:45:13 +0200 Subject: [PATCH 213/236] Updated documentation - Added note on windows binary installation - Contributors now listed in separate file (Closes #738) (Closes #795) --- README.md | 5 +- cmake/packaging/cpack_config.cmake | 7 +- cmake/packaging/deb/copyright | 122 +--------------------------- contributors.txt | 124 +++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 124 deletions(-) create mode 100644 contributors.txt diff --git a/README.md b/README.md index 4bf663e34..842284ff7 100644 --- a/README.md +++ b/README.md @@ -66,9 +66,10 @@ Our [tutorial.md](doc/tutorial.md may help you along with some advanced tasks an **Windows**: -Please compile and install from source as described in our [compiling manual](doc/compiling.md#Windows). +As of Release v1.6.1 stand-alone Windows binaries are made available (again) on the release page of the project. +Please ensure to select the correct version for your system (i686 or x86_64). The archive file can be unzipped to any desired location as it does not contain any hardcoded paths. However we suggest to move the unzipped application folder to `C:\Program Files\` on 32-bit systems and to `C:\Program Files (x86)\` on 64-bit systems (the toolset is a 32-bit). -Long awaited binaries will be available soon... +Alternatively one may compile and install from source as described in our [compiling manual](doc/compiling.md#Windows). **macOS**: diff --git a/cmake/packaging/cpack_config.cmake b/cmake/packaging/cpack_config.cmake index a0fddd71c..da03bb596 100644 --- a/cmake/packaging/cpack_config.cmake +++ b/cmake/packaging/cpack_config.cmake @@ -19,7 +19,7 @@ if (APPLE) set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-macosx-amd64") set(CPACK_INSTALL_PREFIX "") -elseif (WIN32 AND NOT EXISTS "/etc/debian_version") # Windows +elseif (WIN32 AND (NOT EXISTS "/etc/debian_version")) # Windows set(CPACK_GENERATOR "ZIP") set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win32") set(CPACK_INSTALL_PREFIX "") @@ -75,6 +75,8 @@ elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is av # Slackware & Redhat (RPM) ### + set(CPACK_SET_DESTDIR "OFF") + # CPACK_RPM_PACKAGE_SUMMARY --> Default: CPACK_PACKAGE_DESCRIPTION_SUMMARY # CPACK_RPM_PACKAGE_NAME --> Default: CPACK_PACKAGE_NAME @@ -94,6 +96,9 @@ elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is av # CPACK_RPM_PACKAGE_VENDOR --> Default: CPACK_PACKAGE_VENDOR (as it is set) # CPACK_RPM_PACKAGE_URL --> Default: CMAKE_PROJECT_HOMEPAGE_URL set(CPACK_RPM_PACKAGE_DESCRIPTION CPACK_DEBIAN_PACKAGE_DESCRIPTION) + + ## Add CHANGELOG in rpm-specific format + ### TODO else () # No package configuration on other platforms ... endif () diff --git a/cmake/packaging/deb/copyright b/cmake/packaging/deb/copyright index 4e58490f6..37a101b98 100644 --- a/cmake/packaging/deb/copyright +++ b/cmake/packaging/deb/copyright @@ -34,124 +34,4 @@ Copyright: 2011-2020 stlink-org Jerry Jacobs [xor-gate] [Nightwalker-87] . - Alexey Cherevatenko - Alexey Panarin - Anatoli Klassen [dev26th] - Andrea Mucignat - Andrew Andrianov [necromant] - Andrey Yurovsky - Andy Isaacson - Áron Radics - A. Sheaff - Björn Hauffe - Ihor Bobalo - Breton M. Saunders - Bruno Dal Bo - Burns Fisher - Cheng Guokai (Xim) [chenguokai] - Chris Dew - Chris Hiszpanski - Chris Li - Chris Samuelson - Christian Deussen [nullsub] - Christophe Levantis - Craig Lilley - Dan Dev - Dan Hepler - Daniel Campoverde [alx741] - Daniel O'Connor - Dave Flogeras - Dave Murphy [WinterMute] - Dave Vandervies [dj3vande] - Denis Fokin - Denis Osterland - Dmitry Bravikov [bravikov] - Efe Can İçöz - Ethan Zonca - Fabien Chouteau - Florian Hars - Friedrich Beckmann - Geoffrey Brown - George Talusan [gtalusan] - Georg von Zengen - Giuseppe Barba - Greg Alexander [galexander1] - Greg Meiste [meisteg] - Guillaume Revaillot [grevaillot] - Hakkavélin - Halt Hammerzeit - htk - Ian Griffiths - Jack Peel - Jakub Tyszkowski - Jan Sarenik - Jean-Luc Béchennec - Jean-Marie Lemetayer - Jeff Kent - Jeffrey Nelson - Jens Hoffmann - Jerome Lambourg - Jim Paris - Jiří Netolický - Jerry Nosky [jnosky] - Johannes Taelman - Jonas Danielsson - Jonas Norling - Josh Bialkowski - Karl Palsson [karlp] - Kevlar Harness - Kyle Manna - Lari Lehtomäki - Martin Nowak - Matteo Collina - Max Chen - Maxime Coquelin [mcoquelin-stm32] - Maxime Vincent - Michael Pratt [prattmic] - Michael Sparmann - Mike Szczys - Magnus Lundin [mlu] - mux - Ned Konz - Nic McDonald - Nicolas Schodet - Oleksiy Slyshyk [slyshykO] - Olivier Croquette - Olivier Gay - Onno Kortmann - orangeudav - Pavel Kirienko - Pekka Nikander - Pete Nelson - Peter Zotov - Petteri Aimonen - Piotr Haber - Rene Hopf [rene-dev] - Robin Kreis - Roger Wolff [rewolff] - Rob Spanton - Rytis Karpuska - Sean Simmons - Sergey Alirzaev - Simon Wright - Stany Marcel - Stefan Misik - Sven Wegener - Joel Bodenmann [Tectu] - Tuomo Kaikkonen - Theodore A. Roth - Thomas Gärtner - Tobias Badertscher - Tom de Boer - Tristan Gingold - Uli Köhler - Uwe Bonnes [UweBonnes] - Vadim Kaushan - Vasiliy Glazov [Vascom] - Vegard Storheil Eriksen - Viacheslav Dobromyslov - Victor Mayoral Vilches - William Ransohoff [WRansohoff] - Wojciech A. Koszek - Woodrow Douglass - ... and others + and many others... A list of contributors can be found in "contributors.txt". diff --git a/contributors.txt b/contributors.txt new file mode 100644 index 000000000..32c8e58e3 --- /dev/null +++ b/contributors.txt @@ -0,0 +1,124 @@ +List of contributors to the stlink project: + +Alexey Cherevatenko +Alexey Panarin +Anatoli Klassen [dev26th] +Andrea Mucignat +Andrew Andrianov [necromant] +Andrey Yurovsky +Andy Isaacson +Áron Radics +A. Sheaff +Björn Hauffe +Ihor Bobalo +Breton M. Saunders +Bruno Dal Bo +Burns Fisher +Cheng Guokai (Xim) [chenguokai] +Chris Dew +Chris Hiszpanski +Chris Li +Chris Samuelson +Christian Deussen [nullsub] +Christophe Levantis +Craig Lilley +Dan Dev +Dan Hepler +Daniel Campoverde [alx741] +Daniel O'Connor +Dave Flogeras +Dave Murphy [WinterMute] +Dave Vandervies [dj3vande] +Denis Fokin +Denis Osterland +Dmitry Bravikov [bravikov] +Efe Can İçöz +Ethan Zonca +Fabien Chouteau +Florian Hars +Friedrich Beckmann +Geoffrey Brown +George Talusan [gtalusan] +Georg von Zengen +Giuseppe Barba +Greg Alexander [galexander1] +Greg Meiste [meisteg] +Guillaume Revaillot [grevaillot] +Hakkavélin +Halt Hammerzeit +htk +Ian Griffiths +Jack Peel +Jakub Tyszkowski +Jan Sarenik +Jean-Luc Béchennec +Jean-Marie Lemetayer +Jeff Kent +Jeffrey Nelson +Jens Hoffmann +Jerome Lambourg +Jim Paris +Jiří Netolický +Jerry Nosky [jnosky] +Johannes Taelman +Jonas Danielsson +Jonas Norling +Josh Bialkowski +Karl Palsson [karlp] +Kevlar Harness +Kyle Manna +Lari Lehtomäki +Martin Nowak +Matteo Collina +Max Chen +Maxime Coquelin [mcoquelin-stm32] +Maxime Vincent +Michael Pratt [prattmic] +Michael Sparmann +Mike Szczys +Magnus Lundin [mlu] +mux +Ned Konz +Nic McDonald +Nicolas Schodet +Oleksiy Slyshyk [slyshykO] +Olivier Croquette +Olivier Gay +Onno Kortmann +orangeudav +Pavel Kirienko +Pekka Nikander +Pete Nelson +Peter Zotov +Petteri Aimonen +Piotr Haber +Rene Hopf [rene-dev] +Robin Kreis +Roger Wolff [rewolff] +Rob Spanton +Rytis Karpuska +Sean Simmons +Sergey Alirzaev +Simon Wright +Stany Marcel +Stefan Misik +Sven Wegener +Joel Bodenmann [Tectu] +Tuomo Kaikkonen +Theodore A. Roth +Thomas Gärtner +Tobias Badertscher +Tom de Boer +Tristan Gingold +Uli Köhler +Uwe Bonnes [UweBonnes] +Vadim Kaushan +Vasiliy Glazov [Vascom] +Vegard Storheil Eriksen +Viacheslav Dobromyslov +Victor Mayoral Vilches +William Ransohoff [WRansohoff] +Wojciech A. Koszek +Woodrow Douglass + +... and others From 4c1f5b9575a90178a9f8fd29b64ccbbb00953ec9 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 13 May 2020 12:38:43 +0200 Subject: [PATCH 214/236] Update issue templates Added reference to #906 in bug report template --- ...ort--only-valid-if-template-is-reused--.md | 38 +++++++++++++++++++ .github/ISSUE_TEMPLATE/bug-report.md | 6 +-- 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report--only-valid-if-template-is-reused--.md diff --git a/.github/ISSUE_TEMPLATE/bug-report--only-valid-if-template-is-reused--.md b/.github/ISSUE_TEMPLATE/bug-report--only-valid-if-template-is-reused--.md new file mode 100644 index 000000000..255596955 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report--only-valid-if-template-is-reused--.md @@ -0,0 +1,38 @@ +--- +name: Bug Report (only valid if template is reused!) +about: 'Please read #906 before submitting a ticket.' +title: "[STM32 device name]: [Title]" +labels: '' +assignees: '' + +--- + +Thank you for giving feedback to the stlink project. + +In order to allow developers and other contributors to isolate and target your respective issue, please take some time to fill out each of the following items appropriate to your specific problem: + +- Programmer/board type: [enter here] (e.g Stlink /v1, /v2, /v2-clone, /v2-1) +- Programmer firmware version: [enter here] (e.g STSW-LINK007 2.27.15) +- Operating system and version: [enter here] (e.g Linux, Mac OS X, Windows) +- **Stlink tools version** and/or git commit hash: [enter here] (e.g v1.1.0/git-c722056) +- Stlink commandline tool name: [enter here] (e.g `st-info`, `st-flash`, `st-util`) +- Target chip (and board if applicable): [enter here] (e.g STM32F402VG) + +Futher we kindly ask you to describe the detected problem as detailed as possible and to add debug output if available, by using the following template: + +Commandline-Output: + +``` +OUTPUT/ERROR of the commandline tool(s) +``` + +Expected/description: + +`short description of the expected value` + + +**NOTICE: This bug report may be closed without further notice, if not enough information is provided!** + +Thank you for your support. + +The stlink project maintainers diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 2d565a3f7..344a53ea6 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -1,8 +1,8 @@ --- name: Bug Report -about: Create a report to help us improve -title: "[Your device name]: [Title]" -labels: bug/needs-investigation +about: 'Please read #906 before submitting a ticket.' +title: "[STM32 device name]: [Title]" +labels: '' assignees: '' --- From def770b0c5ea841a69e7828a11baa4c306d2ce6a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Sun, 17 May 2020 12:40:45 +0200 Subject: [PATCH 215/236] Bugfix & cleanup - Fixed problem "libusb: warning [libusb_exit] application left some devices open" resulting from deprecated commands reintroduced in merge commit 0a91936b263f3fd09a42fb1ec32a72a06d9a39d6. - Whitespace cleanup --- src/mingw/mingw.h | 14 +- src/usb.c | 497 +++++++++++++++++++++------------------------- 2 files changed, 234 insertions(+), 277 deletions(-) diff --git a/src/mingw/mingw.h b/src/mingw/mingw.h index e3a7267a9..8f5b992fe 100644 --- a/src/mingw/mingw.h +++ b/src/mingw/mingw.h @@ -37,7 +37,7 @@ struct pollfd { short revents; /* returned events */ }; #endif -#define poll(x, y, z) win32_poll(x, y, z) +#define poll(x, y, z) win32_poll(x, y, z) /* These wrappers do nothing special except set the global errno variable if * an error occurs (winsock doesn't do this by default). They set errno @@ -45,12 +45,12 @@ struct pollfd { * outside of this file "shouldn't" have to worry about winsock specific error * handling. */ -#define socket(x, y, z) win32_socket(x, y, z) -#define connect(x, y, z) win32_connect(x, y, z) -#define accept(x, y, z) win32_accept(x, y, z) -#define shutdown(x, y) win32_shutdown(x, y) -#define read(x, y, z) win32_read_socket(x, y, z) -#define write(x, y, z) win32_write_socket(x, y, z) +#define socket(x, y, z) win32_socket(x, y, z) +#define connect(x, y, z) win32_connect(x, y, z) +#define accept(x, y, z) win32_accept(x, y, z) +#define shutdown(x, y) win32_shutdown(x, y) +#define read(x, y, z) win32_read_socket(x, y, z) +#define write(x, y, z) win32_write_socket(x, y, z) /* Winsock uses int instead of the usual socklen_t */ typedef int socklen_t; diff --git a/src/usb.c b/src/usb.c index 3445a7464..fcb2e1b30 100644 --- a/src/usb.c +++ b/src/usb.c @@ -17,13 +17,11 @@ enum SCSI_Generic_Direction {SG_DXFER_TO_DEV=0, SG_DXFER_FROM_DEV=0x80}; -static inline uint32_t le_to_h_u32(const uint8_t* buf) -{ +static inline uint32_t le_to_h_u32(const uint8_t* buf) { return (uint32_t)((uint32_t)buf[0] | (uint32_t)buf[1] << 8 | (uint32_t)buf[2] << 16 | (uint32_t)buf[3] << 24); } -static int _stlink_match_speed_map(const uint32_t *map, unsigned int map_size, uint32_t khz) -{ +static int _stlink_match_speed_map(const uint32_t *map, unsigned int map_size, uint32_t khz) { unsigned int i; int speed_index = -1; int speed_diff = INT_MAX; @@ -31,59 +29,51 @@ static int _stlink_match_speed_map(const uint32_t *map, unsigned int map_size, u bool match = true; for (i = 0; i < map_size; i++) { - if (!map[i]) - continue; - last_valid_speed = i; - if (khz == map[i]) { - speed_index = i; - break; - } else { - int current_diff = khz - map[i]; - /* get abs value for comparison */ - current_diff = (current_diff > 0) ? current_diff : -current_diff; - if ((current_diff < speed_diff) && khz >= map[i]) { - speed_diff = current_diff; - speed_index = i; - } - } + if (!map[i]) continue; + last_valid_speed = i; + if (khz == map[i]) { + speed_index = i; + break; + } else { + int current_diff = khz - map[i]; + // Get abs value for comparison + current_diff = (current_diff > 0) ? current_diff : -current_diff; + if ((current_diff < speed_diff) && khz >= map[i]) { + speed_diff = current_diff; + speed_index = i; + } + } } if (speed_index == -1) { - /* this will only be here if we cannot match the slow speed. - * use the slowest speed we support.*/ - speed_index = last_valid_speed; - match = false; - } else if (i == map_size) - match = false; - + // This will only be here if we cannot match the slow speed. Use the slowest speed we support. + speed_index = last_valid_speed; + match = false; + } else if (i == map_size) { + match = false; + } if (!match) { - ILOG("Unable to match requested speed %d kHz, using %d kHz\n", \ - khz, map[speed_index]); + ILOG("Unable to match requested speed %d kHz, using %d kHz\n", khz, map[speed_index]); } return speed_index; } void _stlink_usb_close(stlink_t* sl) { - if (!sl) - return; + if (!sl) return; struct stlink_libusb * const handle = sl->backend_data; - // maybe we couldn't even get the usb device? + // Maybe we couldn't even get the usb device? if (handle != NULL) { - if (handle->usb_handle != NULL) { - libusb_close(handle->usb_handle); - } - + if (handle->usb_handle != NULL) libusb_close(handle->usb_handle); libusb_exit(handle->libusb_ctx); free(handle); } } ssize_t send_recv(struct stlink_libusb* handle, int terminate, - unsigned char* txbuf, size_t txsize, - unsigned char* rxbuf, size_t rxsize) { - /* note: txbuf and rxbuf can point to the same area */ + unsigned char* txbuf, size_t txsize, unsigned char* rxbuf, size_t rxsize) { + /* Note: txbuf and rxbuf can point to the same area */ int res = 0; int t; @@ -93,43 +83,39 @@ 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) { t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, rxbuf, (int) rxsize, &res, 3000); if (t) { - printf("[!] send_recv read reply failed: %s\n", - libusb_error_name(t)); + printf("[!] send_recv read reply failed: %s\n", libusb_error_name(t)); return -1; } } if ((handle->protocoll == 1) && terminate) { - /* Read the SG reply */ + // Read the SG reply unsigned char sg_buf[13]; t = libusb_bulk_transfer(handle->usb_handle, handle->ep_rep, sg_buf, 13, &res, 3000); if (t) { - printf("[!] send_recv read storage failed: %s\n", - libusb_error_name(t)); + printf("[!] send_recv read storage failed: %s\n", libusb_error_name(t)); return -1; } - /* The STLink doesn't seem to evaluate the sequence number */ + // The STLink doesn't seem to evaluate the sequence number. handle->sg_transfer_idx++; } return res; } -static inline int send_only -(struct stlink_libusb* handle, int terminate, - unsigned char* txbuf, size_t txsize) { +static inline int send_only(struct stlink_libusb* handle, int terminate, + unsigned char* txbuf, size_t txsize) { return (int) send_recv(handle, terminate, txbuf, txsize, NULL, 0); } -static int fill_command -(stlink_t * sl, enum SCSI_Generic_Direction dir, uint32_t len) { +static int fill_command(stlink_t * sl, enum SCSI_Generic_Direction dir, uint32_t len) { struct stlink_libusb * const slu = sl->backend_data; unsigned char* const cmd = sl->c_buf; int i = 0; @@ -142,9 +128,9 @@ static int fill_command write_uint32(&cmd[i], slu->sg_transfer_idx); write_uint32(&cmd[i + 4], len); i += 8; - cmd[i++] = (dir == SG_DXFER_FROM_DEV)?0x80:0; - cmd[i++] = 0; /* Logical unit */ - cmd[i++] = 0xa; /* Command length */ + cmd[i++] = (dir == SG_DXFER_FROM_DEV) ? 0x80 : 0; + cmd[i++] = 0; // Logical unit + cmd[i++] = 0xa; // Command length } return i; } @@ -226,6 +212,7 @@ int _stlink_usb_read_debug32(stlink_t *sl, uint32_t addr, uint32_t *data) { return (int) size; } *data = read_uint32(rdata, 4); + return 0; } @@ -250,10 +237,8 @@ int _stlink_usb_write_debug32(stlink_t *sl, uint32_t addr, uint32_t data) { return 0; } -int _stlink_usb_get_rw_status(stlink_t *sl) -{ - if (sl->version.jtag_api == STLINK_JTAG_API_V1) - return -1; +int _stlink_usb_get_rw_status(stlink_t *sl) { + if (sl->version.jtag_api == STLINK_JTAG_API_V1) return -1; unsigned char* const rdata = sl->q_buf; struct stlink_libusb * const slu = sl->backend_data; @@ -270,8 +255,8 @@ int _stlink_usb_get_rw_status(stlink_t *sl) cmd[i++] = STLINK_DEBUG_APIV2_GETLASTRWSTATUS; ret = send_recv(slu, 1, cmd, slu->cmd_len, rdata, 2); } - if (ret < 0) - return -1; + if (ret < 0) return -1; + return 0; } @@ -287,11 +272,9 @@ int _stlink_usb_write_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { write_uint32(&cmd[i], addr); write_uint16(&cmd[i + 4], len); ret = send_only(slu, 0, cmd, slu->cmd_len); - if (ret == -1) - return ret; + if (ret == -1) return ret; ret = send_only(slu, 0, data, len); - if (ret == -1) - return ret; + if (ret == -1) return ret; return _stlink_usb_get_rw_status(sl); } @@ -308,12 +291,9 @@ int _stlink_usb_write_mem8(stlink_t *sl, uint32_t addr, uint16_t len) { write_uint32(&cmd[i], addr); write_uint16(&cmd[i + 4], len); ret = send_only(slu, 0, cmd, slu->cmd_len); - if (ret == -1) - return ret; - + if (ret == -1) return ret; ret = send_only(slu, 1, data, len); - if (ret == -1) - return ret; + if (ret == -1) return ret; return 0; } @@ -333,6 +313,7 @@ int _stlink_usb_current_mode(stlink_t * sl) { printf("[!] send_recv STLINK_GET_CURRENT_MODE\n"); return -1; } + return sl->q_buf[0]; } @@ -345,21 +326,22 @@ int _stlink_usb_core_id(stlink_t * sl) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - if (sl->version.jtag_api == STLINK_JTAG_API_V1) + if (sl->version.jtag_api == STLINK_JTAG_API_V1) { cmd[i++] = STLINK_DEBUG_READCOREID; - else + } else { cmd[i++] = STLINK_DEBUG_APIV2_READ_IDCODES; - + } size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_DEBUG_READCOREID\n"); return -1; } - if (sl->version.jtag_api == STLINK_JTAG_API_V1) + if (sl->version.jtag_api == STLINK_JTAG_API_V1) { sl->core_id = read_uint32(data, 0); - else + } else { sl->core_id = read_uint32(data, 4); + } return 0; } int _stlink_usb_status_v2(stlink_t *sl) @@ -385,9 +367,7 @@ int _stlink_usb_status_v2(stlink_t *sl) } int _stlink_usb_status(stlink_t * sl) { - if (sl->version.jtag_api != STLINK_JTAG_API_V1) { - return _stlink_usb_status_v2(sl); - } + if (sl->version.jtag_api != STLINK_JTAG_API_V1) return _stlink_usb_status_v2(sl); struct stlink_libusb * const slu = sl->backend_data; unsigned char* const data = sl->q_buf; @@ -398,7 +378,6 @@ int _stlink_usb_status(stlink_t * sl) { cmd[i++] = STLINK_DEBUG_COMMAND; cmd[i++] = STLINK_DEBUG_GETSTATUS; - size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_DEBUG_GETSTATUS\n"); @@ -445,7 +424,7 @@ int _stlink_usb_enter_swd_mode(stlink_t * sl) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - // Select correct API-Version for entering SWD mode: V1 API (0x20) or V2 API (0x30) + // Select correct API-Version for entering SWD mode: V1 API (0x20) or V2 API (0x30). cmd[i++] = sl->version.jtag_api == STLINK_JTAG_API_V1 ? STLINK_DEBUG_APIV1_ENTER : STLINK_DEBUG_APIV2_ENTER; cmd[i++] = STLINK_DEBUG_ENTER_SWD; @@ -455,8 +434,8 @@ int _stlink_usb_enter_swd_mode(stlink_t * sl) { size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); } if (size == -1) { - printf("[!] send_recv STLINK_DEBUG_ENTER\n"); - return (int) size; + printf("[!] send_recv STLINK_DEBUG_ENTER\n"); + return (int) size; } return 0; @@ -470,7 +449,6 @@ int _stlink_usb_exit_dfu_mode(stlink_t* sl) { cmd[i++] = STLINK_DFU_COMMAND; cmd[i++] = STLINK_DFU_EXIT; - size = send_only(slu, 1, cmd, slu->cmd_len); if (size == -1) { printf("[!] send_recv STLINK_DFU_EXIT\n"); @@ -490,10 +468,11 @@ int _stlink_usb_reset(stlink_t * sl) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - if (sl->version.jtag_api == STLINK_JTAG_API_V1) + if (sl->version.jtag_api == STLINK_JTAG_API_V1) { cmd[i++] = STLINK_DEBUG_APIV1_RESETSYS; - else + } else { cmd[i++] = STLINK_DEBUG_APIV2_RESETSYS; + } size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { @@ -501,12 +480,11 @@ int _stlink_usb_reset(stlink_t * sl) { return (int) size; } - // Reset through AIRCR so NRST does not need to be connected - return stlink_write_debug32(sl, STLINK_REG_AIRCR, - STLINK_REG_AIRCR_VECTKEY | STLINK_REG_AIRCR_SYSRESETREQ); + // Reset through AIRCR so that NRST does not need to be connected. + return stlink_write_debug32(sl, STLINK_REG_AIRCR, STLINK_REG_AIRCR_VECTKEY | + STLINK_REG_AIRCR_SYSRESETREQ); } - int _stlink_usb_jtag_reset(stlink_t * sl, int value) { struct stlink_libusb * const slu = sl->backend_data; unsigned char* const data = sl->q_buf; @@ -518,7 +496,6 @@ int _stlink_usb_jtag_reset(stlink_t * sl, int value) { cmd[i++] = STLINK_DEBUG_COMMAND; cmd[i++] = STLINK_JTAG_DRIVE_NRST; cmd[i++] = value; - size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_JTAG_DRIVE_NRST\n"); @@ -539,7 +516,6 @@ int _stlink_usb_step(stlink_t* sl) { cmd[i++] = STLINK_DEBUG_COMMAND; cmd[i++] = STLINK_DEBUG_STEPCORE; - size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_DEBUG_STEPCORE\n"); @@ -557,6 +533,7 @@ int _stlink_usb_run(stlink_t* sl) { struct stlink_libusb * const slu = sl->backend_data; int res; + if (sl->version.jtag_api != STLINK_JTAG_API_V1) { res = _stlink_usb_write_debug32(sl, DCB_DHCSR, DBGKEY|C_DEBUGEN); return res; @@ -571,7 +548,6 @@ int _stlink_usb_run(stlink_t* sl) { cmd[i++] = STLINK_DEBUG_COMMAND; cmd[i++] = STLINK_DEBUG_RUNCORE; - size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_DEBUG_RUNCORE\n"); @@ -589,6 +565,7 @@ int _stlink_usb_set_swdclk(stlink_t* sl, uint16_t clk_divisor) { ssize_t size; int rep_len = 2; int i; + // clock speed only supported by stlink/v2 and for firmware >= 22 if (sl->version.stlink_v == 2 && sl->version.jtag_v >= 22) { i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); @@ -597,7 +574,6 @@ int _stlink_usb_set_swdclk(stlink_t* sl, uint16_t clk_divisor) { cmd[i++] = STLINK_DEBUG_APIV2_SWD_SET_FREQ; cmd[i++] = clk_divisor & 0xFF; cmd[i++] = (clk_divisor >> 8) & 0xFF; - size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); if (size == -1) { printf("[!] send_recv STLINK_DEBUG_APIV2_SWD_SET_FREQ\n"); @@ -613,7 +589,6 @@ int _stlink_usb_set_swdclk(stlink_t* sl, uint16_t clk_divisor) { cmd[i++] = STLINK_DEBUG_COMMAND; cmd[i++] = STLINK_APIV3_GET_COM_FREQ; cmd[i++] = 0; // SWD mode - size = send_recv(slu, 1, cmd, slu->cmd_len, data, 52); if (size == -1) { printf("[!] send_recv STLINK_APIV3_GET_COM_FREQ\n"); @@ -622,15 +597,12 @@ int _stlink_usb_set_swdclk(stlink_t* sl, uint16_t clk_divisor) { int speeds_size = data[8]; - if (speeds_size > STLINK_V3_MAX_FREQ_NB) - speeds_size = STLINK_V3_MAX_FREQ_NB; + if (speeds_size > STLINK_V3_MAX_FREQ_NB) speeds_size = STLINK_V3_MAX_FREQ_NB; - for (i = 0; i < speeds_size; i++) - map[i] = le_to_h_u32(&data[12 + 4 * i]); + for (i = 0; i < speeds_size; i++) map[i] = le_to_h_u32(&data[12 + 4 * i]); - /* set to zero all the next entries */ - for (i = speeds_size; i < STLINK_V3_MAX_FREQ_NB; i++) - map[i] = 0; + // Set to zero all the next entries + for (i = speeds_size; i < STLINK_V3_MAX_FREQ_NB; i++) map[i] = 0; speed_index = _stlink_match_speed_map(map, STLINK_ARRAY_SIZE(map), 1800); @@ -685,16 +657,16 @@ int _stlink_usb_read_mem32(stlink_t *sl, uint32_t addr, uint16_t len) { cmd[i++] = STLINK_DEBUG_READMEM_32BIT; write_uint32(&cmd[i], addr); write_uint16(&cmd[i + 4], len); - size = send_recv(slu, 1, cmd, slu->cmd_len, data, len); + if (size == -1) { printf("[!] send_recv STLINK_DEBUG_READMEM_32BIT\n"); return (int) size; } sl->q_len = (int) size; - stlink_print_data(sl); + return 0; } @@ -707,11 +679,15 @@ int _stlink_usb_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - if (sl->version.jtag_api == STLINK_JTAG_API_V1) + + if (sl->version.jtag_api == STLINK_JTAG_API_V1) { cmd[i++] = STLINK_DEBUG_APIV1_READALLREGS; - else + } else { cmd[i++] = STLINK_DEBUG_APIV2_READALLREGS; + } + size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); + if (size == -1) { printf("[!] send_recv STLINK_DEBUG_READALLREGS\n"); return (int) size; @@ -722,15 +698,15 @@ int _stlink_usb_read_all_regs(stlink_t *sl, struct stlink_reg *regp) { int reg_offset = sl->version.jtag_api == STLINK_JTAG_API_V1 ? 0 : 4; sl->q_len = (int) size; stlink_print_data(sl); - for(i=reg_offset; i<16; i++) - regp->r[i]= read_uint32(sl->q_buf, i*4); + + for(i=reg_offset; i<16; i++) regp->r[i]= read_uint32(sl->q_buf, i*4); regp->xpsr = read_uint32(sl->q_buf, reg_offset + 64); regp->main_sp = read_uint32(sl->q_buf, reg_offset + 68); regp->process_sp = read_uint32(sl->q_buf, reg_offset + 72); regp->rw = read_uint32(sl->q_buf, reg_offset + 76); regp->rw2 = read_uint32(sl->q_buf, reg_offset + 80); - if (sl->verbose < 2) - return 0; + + if (sl->verbose < 2) return 0; DLOG("xpsr = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 64)); DLOG("main_sp = 0x%08x\n", read_uint32(sl->q_buf, reg_offset + 68)); @@ -752,16 +728,21 @@ int _stlink_usb_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - if (sl->version.jtag_api == STLINK_JTAG_API_V1) + + if (sl->version.jtag_api == STLINK_JTAG_API_V1) { cmd[i++] = STLINK_DEBUG_APIV1_READREG; - else + } else { cmd[i++] = STLINK_DEBUG_APIV2_READREG; + } + cmd[i++] = (uint8_t) r_idx; size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); + if (size == -1) { printf("[!] send_recv STLINK_DEBUG_READREG\n"); return (int) size; } + sl->q_len = (int) size; stlink_print_data(sl); r = read_uint32(sl->q_buf, reg_offset); @@ -778,10 +759,10 @@ int _stlink_usb_read_reg(stlink_t *sl, int r_idx, struct stlink_reg *regp) { regp->process_sp = r; break; case 19: - regp->rw = r; /* XXX ?(primask, basemask etc.) */ + regp->rw = r; // XXX ?(primask, basemask etc.) break; case 20: - regp->rw2 = r; /* XXX ?(primask, basemask etc.) */ + regp->rw2 = r; // XXX ?(primask, basemask etc.) break; default: regp->r[r_idx] = r; @@ -796,34 +777,30 @@ int _stlink_usb_read_unsupported_reg(stlink_t *sl, int r_idx, struct stlink_reg int ret; sl->q_buf[0] = (unsigned char) r_idx; - for (int i = 1; i < 4; i++) { - sl->q_buf[i] = 0; - } + for (int i = 1; i < 4; i++) sl->q_buf[i] = 0; ret = _stlink_usb_write_mem32(sl, STLINK_REG_DCRSR, 4); - if (ret == -1) - return ret; + if (ret == -1) return ret; ret = _stlink_usb_read_mem32(sl, STLINK_REG_DCRDR, 4); - if (ret == -1) - return ret; + if (ret == -1) return ret; r = read_uint32(sl->q_buf, 0); DLOG("r_idx (%2d) = 0x%08x\n", r_idx, r); switch (r_idx) { - case 0x14: - regp->primask = (uint8_t) (r & 0xFF); - regp->basepri = (uint8_t) ((r>>8) & 0xFF); - regp->faultmask = (uint8_t) ((r>>16) & 0xFF); - regp->control = (uint8_t) ((r>>24) & 0xFF); - break; - case 0x21: - regp->fpscr = r; - break; - default: - regp->s[r_idx - 0x40] = r; - break; + case 0x14: + regp->primask = (uint8_t) (r & 0xFF); + regp->basepri = (uint8_t) ((r>>8) & 0xFF); + regp->faultmask = (uint8_t) ((r>>16) & 0xFF); + regp->control = (uint8_t) ((r>>24) & 0xFF); + break; + case 0x21: + regp->fpscr = r; + break; + default: + regp->s[r_idx - 0x40] = r; + break; } return 0; @@ -833,17 +810,14 @@ int _stlink_usb_read_all_unsupported_regs(stlink_t *sl, struct stlink_reg *regp) int ret; ret = _stlink_usb_read_unsupported_reg(sl, 0x14, regp); - if (ret == -1) - return ret; + if (ret == -1) return ret; ret = _stlink_usb_read_unsupported_reg(sl, 0x21, regp); - if (ret == -1) - return ret; + if (ret == -1) return ret; for (int i = 0; i < 32; i++) { ret = _stlink_usb_read_unsupported_reg(sl, 0x40+i, regp); - if (ret == -1) - return ret; + if (ret == -1) return ret; } return 0; @@ -856,24 +830,35 @@ int _stlink_usb_write_unsupported_reg(stlink_t *sl, uint32_t val, int r_idx, str if (r_idx >= 0x1C && r_idx <= 0x1F) { /* primask, basepri, faultmask, or control */ /* These are held in the same register */ ret = _stlink_usb_read_unsupported_reg(sl, 0x14, regp); - if (ret == -1) - return ret; + if (ret == -1) return ret; val = (uint8_t) (val>>24); switch (r_idx) { - case 0x1C: /* control */ - val = (((uint32_t) val) << 24) | (((uint32_t) regp->faultmask) << 16) | (((uint32_t) regp->basepri) << 8) | ((uint32_t) regp->primask); - break; - case 0x1D: /* faultmask */ - val = (((uint32_t) regp->control) << 24) | (((uint32_t) val) << 16) | (((uint32_t) regp->basepri) << 8) | ((uint32_t) regp->primask); - break; - case 0x1E: /* basepri */ - val = (((uint32_t) regp->control) << 24) | (((uint32_t) regp->faultmask) << 16) | (((uint32_t) val) << 8) | ((uint32_t) regp->primask); - break; - case 0x1F: /* primask */ - val = (((uint32_t) regp->control) << 24) | (((uint32_t) regp->faultmask) << 16) | (((uint32_t) regp->basepri) << 8) | ((uint32_t) val); - break; + case 0x1C: /* control */ + val = (((uint32_t) val) << 24) | + (((uint32_t) regp->faultmask) << 16) | + (((uint32_t) regp->basepri) << 8) | + ((uint32_t) regp->primask); + break; + case 0x1D: /* faultmask */ + val = (((uint32_t) regp->control) << 24) | + (((uint32_t) val) << 16) | + (((uint32_t) regp->basepri) << 8) | + ((uint32_t) regp->primask); + break; + case 0x1E: /* basepri */ + val = (((uint32_t) regp->control) << 24) | + (((uint32_t) regp->faultmask) << 16) | + (((uint32_t) val) << 8) | + ((uint32_t) regp->primask); + break; + case 0x1F: /* primask */ + val = (((uint32_t) regp->control) << 24) | + (((uint32_t) regp->faultmask) << 16) | + (((uint32_t) regp->basepri) << 8) | + ((uint32_t) val); + break; } r_idx = 0x14; @@ -882,8 +867,7 @@ int _stlink_usb_write_unsupported_reg(stlink_t *sl, uint32_t val, int r_idx, str write_uint32(sl->q_buf, val); ret = _stlink_usb_write_mem32(sl, STLINK_REG_DCRDR, 4); - if (ret == -1) - return ret; + if (ret == -1) return ret; sl->q_buf[0] = (unsigned char) r_idx; sl->q_buf[1] = 0; @@ -902,13 +886,17 @@ int _stlink_usb_write_reg(stlink_t *sl, uint32_t reg, int idx) { int i = fill_command(sl, SG_DXFER_FROM_DEV, rep_len); cmd[i++] = STLINK_DEBUG_COMMAND; - if (sl->version.jtag_api == STLINK_JTAG_API_V1) + + if (sl->version.jtag_api == STLINK_JTAG_API_V1) { cmd[i++] = STLINK_DEBUG_APIV1_WRITEREG; - else + } else { cmd[i++] = STLINK_DEBUG_APIV2_WRITEREG; + } + cmd[i++] = idx; write_uint32(&cmd[i], reg); size = send_recv(slu, 1, cmd, slu->cmd_len, data, rep_len); + if (size == -1) { printf("[!] send_recv STLINK_DEBUG_WRITEREG\n"); return (int) size; @@ -949,8 +937,7 @@ static stlink_backend_t _stlink_usb_backend = { _stlink_usb_set_swdclk }; -stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq) -{ +stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq) { stlink_t* sl = NULL; struct stlink_libusb* slu = NULL; int ret = -1; @@ -958,10 +945,9 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST sl = calloc(1, sizeof (stlink_t)); slu = calloc(1, sizeof (struct stlink_libusb)); - if (sl == NULL) - goto on_malloc_error; - if (slu == NULL) - goto on_malloc_error; + + if (sl == NULL) goto on_malloc_error; + if (slu == NULL) goto on_malloc_error; ugly_init(verbose); sl->backend = &_stlink_usb_backend; @@ -980,81 +966,66 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST #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) */ + /* @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); struct libusb_device_descriptor desc; - int devBus =0; - int devAddr=0; - - /* @TODO: Reading a environment variable in a usb open function is not very nice, this - should be refactored and moved into the CLI tools, and instead of giving USB_BUS:USB_ADDR a real stlink - serial string should be passed to this function. Probably people are using this but this is very odd because - as programmer can change to multiple busses and it is better to detect them based on serial. */ + int devBus = 0; + int devAddr = 0; + + /* @TODO: Reading a environment variable in a usb open function is not very nice, this should be refactored + * and moved into the CLI tools, and instead of giving USB_BUS:USB_ADDR a real stlink serial string should + * be passed to this function. Probably people are using this but this is very odd because as programmer + * can change to multiple busses and it is better to detect them based on serial. + */ char *device = getenv("STLINK_DEVICE"); if (device) { char *c = strchr(device,':'); - if (c==NULL) { + if (c == NULL) { WLOG("STLINK_DEVICE must be : format\n"); goto on_error; } - devBus=atoi(device); - *c++=0; - devAddr=atoi(c); + devBus = atoi(device); + *c++ = 0; + devAddr = atoi(c); ILOG("bus %03d dev %03d\n",devBus, devAddr); } while (cnt--) { - struct libusb_device_handle *handle; + struct libusb_device_handle *handle; - libusb_get_device_descriptor( list[cnt], &desc ); - if (desc.idVendor != STLINK_USB_VID_ST) - continue; + libusb_get_device_descriptor(list[cnt], &desc); + if (desc.idVendor != STLINK_USB_VID_ST) continue; if (devBus && devAddr) { - if ((libusb_get_bus_number(list[cnt]) != devBus) - || (libusb_get_device_address(list[cnt]) != devAddr)) { + if ((libusb_get_bus_number(list[cnt]) != devBus) || (libusb_get_device_address(list[cnt]) != devAddr)) { continue; } } - ret = libusb_open(list[cnt], &handle); + ret = libusb_open(list[cnt], &handle); + if (ret) continue; // could not open device - /* could not open device, continue */ - if (ret) - continue; + sl->serial_size = libusb_get_string_descriptor_ascii( + handle, desc.iSerialNumber, (unsigned char *)sl->serial, sizeof(sl->serial)); + libusb_close(handle); - sl->serial_size = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, - (unsigned char *)sl->serial, sizeof(sl->serial)); - - if ((serial == NULL) || (*serial == 0)) - break; - - if (sl->serial_size < 0) - continue; + if (sl->serial_size < 0) continue; // could not read serial - if (memcmp(serial, &sl->serial, sl->serial_size) == 0) + // if no serial provided, or if serial match device, fixup version and protocol + if (((serial == NULL) || (*serial == 0)) || (memcmp(serial, &sl->serial, sl->serial_size) == 0)) { + if (STLINK_V1_USB_PID(desc.idProduct)) { + slu->protocoll = 1; + sl->version.stlink_v = 1; + } else if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct)) { + sl->version.stlink_v = 2; + } else if (STLINK_V3_USB_PID(desc.idProduct)) { + sl->version.stlink_v = 3; + } break; - - libusb_close(handle); - - /* could not read serial, continue */ - if (sl->serial_size < 0) - continue; - - /* if no serial provided, or if serial match device, fixup version and protocol */ - if (((serial == NULL) || (*serial == 0)) || (memcmp(serial, &sl->serial, sl->serial_size) == 0)) { - if (STLINK_V1_USB_PID(desc.idProduct)) { - slu->protocoll = 1; - sl->version.stlink_v = 1; - } else if (STLINK_V2_USB_PID(desc.idProduct) || STLINK_V2_1_USB_PID(desc.idProduct)) { - sl->version.stlink_v = 2; - } else if (STLINK_V3_USB_PID(desc.idProduct)) { - sl->version.stlink_v = 3; - } - - break; - } + } } if (cnt < 0) { @@ -1063,8 +1034,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST } else { ret = libusb_open(list[cnt], &slu->usb_handle); if (ret != 0) { - WLOG("Error %d (%s) opening ST-Link v%d device %03d:%03d\n", - ret, strerror (errno), sl->version.stlink_v, libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt])); + WLOG("Error %d (%s) opening ST-Link v%d device %03d:%03d\n", ret, strerror (errno), + sl->version.stlink_v, libusb_get_bus_number(list[cnt]), libusb_get_device_address(list[cnt])); libusb_free_device_list(list, 1); goto on_error; } @@ -1130,10 +1101,9 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST stlink_exit_dfu_mode(sl); } - sl->freq = freq; - // set the speed before entering the mode - // as the chip discovery phase should be done at this speed too + // set the speed before entering the mode as the chip discovery phase + // should be done at this speed too // Set the stlink clock speed (default is 1800kHz) DLOG("JTAG/SWD freq set to %d\n", freq); switch (freq) { @@ -1174,38 +1144,29 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST stlink_set_swdclk(sl, STLINK_SWDCLK_4MHZ_DIVISOR); break; } - - 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); if (reset) { - if ( sl->version.stlink_v > 1)stlink_jtag_reset(sl, 2); + if ( sl->version.stlink_v > 1) stlink_jtag_reset(sl, 2); stlink_reset(sl); usleep(10000); } stlink_load_device_params(sl); - return sl; -on_libusb_error: - stlink_close(sl); - return NULL; + on_libusb_error: + stlink_close(sl); + return NULL; + on_error: + if (slu->libusb_ctx) libusb_exit(slu->libusb_ctx); -on_error: - if (slu->libusb_ctx) - libusb_exit(slu->libusb_ctx); - -on_malloc_error: - if (sl != NULL) - free(sl); - if (slu != NULL) - free(slu); - - return NULL; + on_malloc_error: + if (sl != NULL) free(sl); + if (slu != NULL) free(slu); + return NULL; } static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { @@ -1219,18 +1180,19 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) { WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret); break; } - if (desc.idVendor != STLINK_USB_VID_ST) - continue; + if (desc.idVendor != STLINK_USB_VID_ST) continue; + + if (!STLINK_SUPPORTED_USB_PID(desc.idProduct)) { + WLOG("skipping ST device : %#04x:%#04x)\n", desc.idVendor, desc.idProduct); + continue; + } - if (!STLINK_SUPPORTED_USB_PID(desc.idProduct)) { - WLOG("skipping ST device : %#04x:%#04x)\n", desc.idVendor, desc.idProduct); - continue; - } slcnt++; } @@ -1246,45 +1208,44 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) { while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) { WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret); break; } - if (!STLINK_SUPPORTED_USB_PID(desc.idProduct)) { - continue; - } + if (!STLINK_SUPPORTED_USB_PID(desc.idProduct)) continue; - struct libusb_device_handle* handle; + struct libusb_device_handle* handle; char serial[STLINK_SERIAL_MAX_SIZE] = {0,}; - ret = libusb_open(dev, &handle); - if (ret < 0) { - if (ret == LIBUSB_ERROR_ACCESS) { - ELOG("Could not open USB device %#06x:%#06x, access error.\n", desc.idVendor, desc.idProduct, ret); - } else { - ELOG("Failed to open USB device %#06x:%#06x, libusb error: %d)\n", desc.idVendor, desc.idProduct, ret); - } - break; - } - ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)&serial, sizeof(serial)); + ret = libusb_open(dev, &handle); + + if (ret < 0) { + if (ret == LIBUSB_ERROR_ACCESS) { + ELOG("Could not open USB device %#06x:%#06x, access error.\n", desc.idVendor, desc.idProduct, ret); + } else { + ELOG("Failed to open USB device %#06x:%#06x, libusb error: %d)\n", desc.idVendor, desc.idProduct, ret); + } + break; + } + ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)&serial, sizeof(serial)); - libusb_close(handle); + libusb_close(handle); - if (ret < 0) { - continue; - } + if (ret < 0) continue; stlink_t *sl = stlink_open_usb(0, 1, serial, 0); if (!sl) { ELOG("Failed to open USB device %#06x:%#06x\n", desc.idVendor, desc.idProduct); continue; - } + } _sldevs[slcur++] = sl; } *sldevs = _sldevs; + return slcur; } @@ -1297,12 +1258,10 @@ size_t stlink_probe_usb(stlink_t **stdevs[]) { ssize_t cnt; r = libusb_init(NULL); - if (r < 0) - return 0; + if (r < 0) return 0; cnt = libusb_get_device_list(NULL, &devs); - if (cnt < 0) - return 0; + if (cnt < 0) return 0; slcnt = stlink_probe_usb_devs(devs, &sldevs); libusb_free_device_list(devs, 1); @@ -1310,15 +1269,13 @@ size_t stlink_probe_usb(stlink_t **stdevs[]) { libusb_exit(NULL); *stdevs = sldevs; + return slcnt; } void stlink_probe_usb_free(stlink_t ***stdevs, size_t size) { - if (stdevs == NULL || *stdevs == NULL || size == 0) - return; - - for (size_t n = 0; n < size; n++) - stlink_close((*stdevs)[n]); + if (stdevs == NULL || *stdevs == NULL || size == 0) return; + for (size_t n = 0; n < size; n++) stlink_close((*stdevs)[n]); free(*stdevs); *stdevs = NULL; } From e3aa887f7ffdfcfb3a0529ee3b94a7d3fe39b5d8 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 18 May 2020 00:49:08 +0200 Subject: [PATCH 216/236] Update for library linking - Simplified code - Added version info for static library --- CMakeLists.txt | 41 ++++++++++++++++++++++++----------------- Makefile | 3 ++- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5301fb0a..57a9161e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,11 @@ set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK T include(GNUInstallDirs) # Define GNU standard installation directories 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") - option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) + +set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory") option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) + option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) ## Determine project version @@ -186,16 +186,14 @@ set_target_properties( VERSION ${STLINK_SHARED_VERSION} ) -# Link shared library with Apple macOS libraries -if (APPLE) +# Link shared library +if (APPLE) # ... with Apple macOS libraries find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) - target_link_libraries(${STLINK_LIB_SHARED} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) -endif () - -if (WIN32 OR MINGW OR MSYS) - target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) + target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} ${ObjC} ${CoreFoundation} ${IOKit}) +elseif (WIN32) # ... with Windows libraries + target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32) else () target_link_libraries(${STLINK_LIB_SHARED} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif () @@ -207,6 +205,9 @@ install(TARGETS ${STLINK_LIB_SHARED} DESTINATION ${STLINK_LIBRARY_PATH}) # Static library ### +# Install static library per default +set(STLINK_STATIC_LIB ON CACHE BOOL "Install static lib") + set(STLINK_LIB_STATIC ${PROJECT_NAME}-static) add_library( @@ -215,21 +216,27 @@ add_library( ${STLINK_SOURCE} ) +set(STLINK_STATIC_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) + +message(STATUS "STLINK_LIB_STATIC: ${STLINK_LIB_STATIC}") +message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}") +message(STATUS "VERSION: ${STLINK_STATIC_VERSION}") + set_target_properties( ${STLINK_LIB_STATIC} PROPERTIES + SOVERSION ${PROJECT_VERSION_MAJOR} + VERSION ${STLINK_STATIC_VERSION} OUTPUT_NAME ${PROJECT_NAME} ) -# Link static library with Apple macOS libraries -if (APPLE) +# Link static library +if (APPLE) # ... with Apple macOS libraries find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) - target_link_libraries(${STLINK_LIB_STATIC} ${CoreFoundation} ${IOKit} ${ObjC} ${SSP_LIB}) -endif () - -if (WIN32 OR MINGW OR MSYS) - target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} wsock32 ws2_32 ${SSP_LIB}) + target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} ${ObjC} ${CoreFoundation} ${IOKit}) +elseif (WIN32) # ... with Windows libraries + target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB} wsock32 ws2_32) else () target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif () diff --git a/Makefile b/Makefile index 7f373ebcd..3f46d2943 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ ## -# This Makefile is used to drive building of Debug and Release targets of CMake +# This Makefile is used to drive building of CMake build targets ## + MAKEFLAGS += -s # additional flags for cmake, e.g. install path -DCMAKE_INSTALL_PREFIX=$(HOME)/.local From d73f864a375287ed93efaedd87a106a378c91d12 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 18 May 2020 11:53:58 +0800 Subject: [PATCH 217/236] Fix some uninitialized variables --- src/flash_loader.c | 2 +- src/usb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flash_loader.c b/src/flash_loader.c index 6862d493c..20a2bdc73 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -191,7 +191,7 @@ int stlink_flash_loader_init(stlink_t *sl, flash_loader_t *fl) { - size_t size; + size_t size = 0; /* allocate the loader in sram */ if (stlink_flash_loader_write_to_sram(sl, &fl->loader_addr, &size) == -1) { diff --git a/src/usb.c b/src/usb.c index fcb2e1b30..b986aed57 100644 --- a/src/usb.c +++ b/src/usb.c @@ -347,7 +347,7 @@ int _stlink_usb_core_id(stlink_t * sl) { int _stlink_usb_status_v2(stlink_t *sl) { int result; - uint32_t status; + uint32_t status = 0; result = _stlink_usb_read_debug32(sl, DCB_DHCSR, &status); DLOG("core status: %08X\n", status); From f8ef21cd130c2ad6460c375747be5987112c4703 Mon Sep 17 00:00:00 2001 From: Chen Guokai Date: Mon, 18 May 2020 11:58:31 +0800 Subject: [PATCH 218/236] Fix issue 958, move F0 flashloader nops to assembly --- flashloaders/stm32f0.s | 14 ++++++++++++++ src/flash_loader.c | 19 ++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index 6c4b8588f..cbb932b49 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -3,6 +3,20 @@ .global copy copy: + /* + * These two NOPs here are a safety precaution, added by Pekka Nikander + * while debugging the STM32F05x support. They may not be needed, but + * there were strange problems with simpler programs, like a program + * that had just a breakpoint or a program that first moved zero to register r2 + * and then had a breakpoint. So, it appears safest to have these two nops. + * + * Feel free to remove them, if you dare, but then please do test the result + * rigorously. Also, if you remove these, it may be a good idea first to + * #if 0 them out, with a comment when these were taken out, and to remove + * these only a few months later... But YMMV. + */ + nop + nop ldr r7, =flash_base ldr r4, [r7] ldr r7, =flash_off_cr diff --git a/src/flash_loader.c b/src/flash_loader.c index 20a2bdc73..a2c5879ce 100644 --- a/src/flash_loader.c +++ b/src/flash_loader.c @@ -41,22 +41,7 @@ /* flashloaders/stm32f0.s -- thumb1 only, same sequence as for STM32VL, bank ignored */ static const uint8_t loader_code_stm32f0[] = { -#if 1 - /* - * These two NOPs here are a safety precaution, added by Pekka Nikander - * while debugging the STM32F05x support. They may not be needed, but - * there were strange problems with simpler programs, like a program - * that had just a breakpoint or a program that first moved zero to register r2 - * and then had a breakpoint. So, it appears safest to have these two nops. - * - * Feel free to remove them, if you dare, but then please do test the result - * rigorously. Also, if you remove these, it may be a good idea first to - * #if 0 them out, with a comment when these were taken out, and to remove - * these only a few months later... But YMMV. - */ - 0x00, 0x30, // nop /* add r0,#0 */ - 0x00, 0x30, // nop /* add r0,#0 */ -#endif + 0xc0, 0x46, 0xc0, 0x46, 0x13, 0x4f, 0x3c, 0x68, 0x13, 0x4f, 0x3e, 0x68, 0x36, 0x19, 0x13, 0x4f, @@ -77,9 +62,9 @@ 0x00, 0x20, 0x02, 0x40, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x20, 0x48, 0x00, 0x00, 0x20, 0x4c, 0x00, 0x00, 0x20, + 0x50, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 From 97d3173f480db33c770ef2c66a002d708b139fa0 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 18 May 2020 15:13:36 +0200 Subject: [PATCH 219/236] Updated package & install configuration - Added package changelog files for deb & rpm - Added license file for deb pkg - Added rules file for deb pkg - Changed install subdirectory --- .travis.sh | 32 ++-- CMakeLists.txt | 6 +- cmake/packaging/cpack_config.cmake | 26 ++-- cmake/packaging/deb/changelog | 237 ++++------------------------- cmake/packaging/deb/control | 9 ++ cmake/packaging/deb/copyright | 16 +- cmake/packaging/deb/rules | 2 +- cmake/packaging/rpm/changelog | 2 + mingw64-build.bat | 2 +- 9 files changed, 85 insertions(+), 247 deletions(-) create mode 100644 cmake/packaging/deb/control create mode 100644 cmake/packaging/rpm/changelog diff --git a/.travis.sh b/.travis.sh index e61098f89..3bab4c5d0 100755 --- a/.travis.sh +++ b/.travis.sh @@ -12,17 +12,17 @@ if [ "$TRAVIS_JOB_NAME" == "linux-mingw" ]; then echo "--> Building Release for Windows (x86-64) ..." mkdir -p build-mingw && cd build-mingw echo "-DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=x86_64-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR" cmake -DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=x86_64-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && rm -rf build-mingw && cd - echo "--> Building Release for Windows (i686) ..." mkdir -p build-mingw && cd build-mingw echo "-DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=i686-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR" + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR" cmake -DCMAKE_SYSTEM_NAME=Windows -DTOOLCHAIN_PREFIX=i686-w64-mingw32 \ - -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/modules/set_toolchain.cmake -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && rm -rf build-mingw && cd - elif [ "$TRAVIS_OS_NAME" == "linux" ]; then @@ -31,14 +31,14 @@ elif [ "$TRAVIS_OS_NAME" == "linux" ]; then echo "--> Building Debug..." mkdir -p build/Debug && cd build/Debug - echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && make package && cd - echo "--> Building Release..." mkdir -p build/Release && cd build/Release - echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && make package && cd - elif [ "$TRAVIS_OS_NAME" == "osx" ]; then @@ -46,26 +46,26 @@ elif [ "$TRAVIS_OS_NAME" == "osx" ]; then echo "--> Building Debug..." mkdir -p build/Debug && cd build/Debug - echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && make package && cd - echo "--> Building Release..." mkdir -p build/Release && cd build/Release - echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install $DIR + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && make package && cd - else # local test-build echo "--> Building Debug..." mkdir -p build/Debug && cd build/Debug - echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install" + cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install ../../ make && make package && cd - echo "--> Building Release..." mkdir -p build/Release && cd build/Release - echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install" - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/_install ../../ + echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install" + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ../../ make && make package && cd - fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 57a9161e7..1526f3122 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ find_package(libusb REQUIRED) ## Package configuration (pkg-config) on unix-based systems if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING) - add_subdirectory(cmake/pkgconfig) + #add_subdirectory(cmake/pkgconfig) find_package(PkgConfig) pkg_check_modules(GTK3 gtk+-3.0) endif () @@ -187,7 +187,7 @@ set_target_properties( ) # Link shared library -if (APPLE) # ... with Apple macOS libraries +if (APPLE) # ... with Apple macOS libraries find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) @@ -230,7 +230,7 @@ set_target_properties( ) # Link static library -if (APPLE) # ... with Apple macOS libraries +if (APPLE) # ... with Apple macOS libraries find_library(ObjC objc) find_library(CoreFoundation CoreFoundation) find_library(IOKit IOKit) diff --git a/cmake/packaging/cpack_config.cmake b/cmake/packaging/cpack_config.cmake index da03bb596..f36a50b40 100644 --- a/cmake/packaging/cpack_config.cmake +++ b/cmake/packaging/cpack_config.cmake @@ -62,20 +62,23 @@ elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is av # CPACK_DEBIAN_PACKAGE_HOMEPAGE --> Default: CMAKE_PROJECT_HOMEPAGE_URL set(CPACK_DEBIAN_PACKAGE_SUGGESTS "libgtk-3-dev, pandoc") - ## Add CHANGELOG in Debian-specific format - ### TODO - - ## Add license file - ### TODO - - # Include a postinst-script - set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/packaging/debian/postinst") + ## Additional package files in Debian-specific format: + # * changelog (package changelog) + # * copyright (license file) + # * rules + # * postinst-script + set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + "${CMAKE_SOURCE_DIR}/cmake/packaging/deb/changelog" + "${CMAKE_SOURCE_DIR}/cmake/packaging/deb/copyright" + "${CMAKE_SOURCE_DIR}/cmake/packaging/deb/rules" + "${CMAKE_SOURCE_DIR}/cmake/packaging/deb/postinst" + ) ### # Slackware & Redhat (RPM) ### - set(CPACK_SET_DESTDIR "OFF") + set(CPACK_SET_DESTDIR "OFF") # Required for relocatable package # CPACK_RPM_PACKAGE_SUMMARY --> Default: CPACK_PACKAGE_DESCRIPTION_SUMMARY # CPACK_RPM_PACKAGE_NAME --> Default: CPACK_PACKAGE_NAME @@ -97,8 +100,9 @@ elseif (EXISTS "/etc/debian_version" AND NOT EXISTS WIN32) # Package-build is av # CPACK_RPM_PACKAGE_URL --> Default: CMAKE_PROJECT_HOMEPAGE_URL set(CPACK_RPM_PACKAGE_DESCRIPTION CPACK_DEBIAN_PACKAGE_DESCRIPTION) - ## Add CHANGELOG in rpm-specific format - ### TODO + ## Add package changelog in rpm-specific format + set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_SOURCE_DIR}/cmake/packaging/rpm/changelog") + else () # No package configuration on other platforms ... endif () diff --git a/cmake/packaging/deb/changelog b/cmake/packaging/deb/changelog index b4e942d7c..f4b644176 100644 --- a/cmake/packaging/deb/changelog +++ b/cmake/packaging/deb/changelog @@ -1,226 +1,49 @@ -stlink (1.6.0) unstable; urgency=medium - -Release date: 2020-02-20 - -Major changes and added features: - -* Initial support for STM32L41X -* Working support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 -* Added preliminary support for some STM32G0 chips -* Added support for mass erasing second bank on STM32F10x_XL -* Added call to clear PG bit after writing to flash -* Added support to write option bytes for the STM32G0 -* Added support for STM32WB55 chips -* Added STLink V3SET VID:PIDs to the udev rules -* Support for "STM32+Audio" v2-1 firmware -* Build for Windows under Debian/Ubuntu -* Allow for 64 bytes serials -* Added full support for STLINK CHIP ID L4RX -* Added support for the STLink-v2.1 when flashed with no mass storage (PID 0x3752) -* Added support for writing option bytes on STM32L0xx -* Added support to read and write option bytes for STM32F2 series -* Added support to read and write option bytes for STM32F446 - -Updates and fixes: - -* Fixed "unkown chip id", piped output and st-util -v -* Fixed an issue with versioning stuck at 1.4.0 for versions cloned with git -* Updated STM32F3xx chip ID that covers a few different devices -* Made udev rules and modprobe conf installation optional -* Fixed case when __FILE__ don't contain "/" nor "\\" -* Fixed double dash issue in doc/man -* Compiling documentation: package is called libusb-1.0-0-dev on Debian -* Only do bank calculation on STM32L4 devices with dual banked flash / Added chip-ID 0x464 for STM32L41xxx/L42xxx devices -* Added O_BINARY option to open file -* Fixed versioning when compiling from the checked out git-repo -* win32: move usleep definition to unistd.h -* Fixed relative path to the UI files needed by stlink-gui-local (GUI) -* Added howto for sending NRST signal through GDB -* Fixed package name "devscripts" in doc/compiling.md -* Fixed few potential memory/resource leaks -* Updated Linux source repositories in README.md: Debian and Ubuntu -* Do not issue JTAG reset on stlink-v1 -* Fixed flash size of STM32 Discovery vl -* Updated documentation on software structure - -General project updates: - -* Updated README.md, CHANGELOG.md and issue templates -* Fixed travis build config file -* Added CODE_OF_CONDUCT -* Archived page from github project wiki to doc/wiki_old.md - --- Luca Boccassi Tue, 25 Feb 2020 22:08:33 +0000 - - -stlink (1.5.1) unstable; urgency=medium - -Release date: 2018-09-13 - -Major changes and added features: - -* Added reset through AIRCR -* Added creation of icons for .desktop file -* Added desktop file for linux -* Added button to export STM32 flash memory to a file -* Updated libusb to 1.0.22 -* Added icons for STLink GUI -* Added support for STM32L4R9 target -* Added memory map for STM32F411RE target -* Implemented intel hex support for GTK GUI - -Updates and fixes: - -* Fixed missing flash_loader for STM32L0x -* Fix for stlink library calls exit() or _exit() -* Added semihosting parameter documentation in doc/man -* Fixed reference to non-exisiting st-term tool in doc/man -* Fixed serial number size mismatch with stlink_open_usb() -* Debian packaging, CMake and README.md fixes -* Disabled static library installation by default -* Fix for libusb deprecation -* Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX -* Regression: stlink installation under Linux (Debian 9) is broken since #695 -* Fixed flash memory map for STM32F72xxx target -* Proper flash page size calculation for STM32F412xx target -* Return correct value on EOF for Semihosting SYS_READ -* FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION - --- Luca Boccassi Fri, 28 Sep 2018 10:26:39 +0100 - - -stlink (1.5.0) unstable; urgency=medium - -Release date: 2018-02-16 - -Major changes and added features: - -* Added support of STM32L496xx/4A6xx devices -* Added unknown chip dummy to obtain the serial of the ST-link by a call to st-info --probe -* Added support for STM32F72xx (chip-ID: 0x452) devices - -Updates and fixes: - -* Fixed verification of flash error for STM32L496x device -* Updated Linux source repositories in README.md: Gentoo, Fedora and RedHat/CentOS -* Updated changelog in debian package -* Added LIB_INSTALL_DIR to correct libs install on 64-bit systems -* Fixed write for microcontroller with RAM size less or equal to 32K -* Fixed memory map for STM32L496xx boards -* Fixed __FILE__ base name extraction -* Added debian/triggers to run ldconfig -* Fixed build on Fedora with GCC 8 - --- Luca Boccassi Fri, 16 Mar 2018 16:56:17 +0000 +stlink (1.6.0+ds-1) unstable; urgency=medium + * Merge tag 'v1.6.0' into debian + * Bump Standards-Version to 4.5.0, no changes. + * Update libstlink1 symbols file for 1.6.0. -stlink (1.4.0) unstable; urgency=low + -- Luca Boccassi Tue, 25 Feb 2020 22:08:33 +0000 -Release date: 2017-07-01 +stlink (1.5.1+ds-2) unstable; urgency=medium -Major changes and added features: + * Mark library packages as Multi-Arch: same. + * Apply cross.patch to fix cross-compiling the GUI. Thanks Helmut for the patch! (Closes: #941320) + * Vcs-Git: add -b debian + * Set Rules-Requires-Root: no + * Bump Standards-Version to 4.4.0 -* Allow building of debian package with CPack -* Added support for STM32L011 target -* Added support for flashing second bank on STM32F10x_XL -* Initial support to compile with Microsoft Visual Studio 2017 -* Added support for STM32L452 target + -- Luca Boccassi Sun, 29 Sep 2019 12:50:58 +0100 -Updates and fixes: +stlink (1.5.1+ds-1) unstable; urgency=medium -* Fixed gdb-server: STM32L0xx has no FP_CTRL register for breakpoints -* Added --flash=n[k][m] command line option to override device model -* Updated libusb to 1.0.21 for Windows -* Fixed low-voltage flashing on STM32F7 devices -* Fixed building with mingw64 -* Fixed possible memory leak -* Fixed installation path for shared objects -* Fixed a few -Wformat warnings -* Removed unused defines in mimgw.h -* Skip GTK detection when cross-compiling -* Fixed compilation with GCC 7 -* Fixed flashing to 'f0 device' targets -* Fixed wrong counting when flashing + * Merge tag 'v1.5.1' into debian. See upstream changelog for info: + https://github.com/stlink-org/stlink/releases/tag/v1.5.1 + * Mark packages as linux-any, other systems not supported. --- Andrew 'Necromant' Andrianov Sat, 01 Jul 2017 00:00:00 +0000 + -- Luca Boccassi Fri, 28 Sep 2018 10:26:39 +0100 +stlink (1.5.0+ds-1) unstable; urgency=medium -stlink (1.3.1) unstable; urgency=low + * Upload to unstable. (Closes: #869421) -Release date: 2017-02-25 + -- Luca Boccassi Fri, 16 Mar 2018 16:56:17 +0000 -Major changes and added features: +stlink (1.4.0) unstable; urgency=low -* Added support for Semihosting `SYS_READC` -* Added support for STM32F413 -* Added preliminary support for STM32L011 to see it after probe (chip-ID 0x457) + -- Andrew 'Necromant' Andrianov Sat, 01 Jul 2017 00:00:00 +0000 -Updates and fixes: +stlink (1.3.1) unstable; urgency=low -* cmake/CPackConfig.cmake: Fixup OSX zip filename -* Updated source repositories in README.md: Windows, macOS, Alpine Linux -* Compilation fixes -* Stripped full paths to source files in log -* Fixed incorrect release folder name in docs -* Fixed compilation when path includes spaces + -- Andrew 'Necromant' Andrianov Sat, 25 Feb 2017 00:00:00 +0000 --- Andrew 'Necromant' Andrianov Sat, 25 Feb 2017 00:00:00 +0000 +stlink (1.3.0) unstable; urgency=low + -- Andrew 'Necromant' Andrianov Sat, 28 Jan 2017 00:00:00 +0000 -stlink (1.3.0) unstable; urgency=low +stlink (1.2.1) unstable; urgency=low + + * Initial Debian-Packaged Release. -Release date: 2017-01-28 - -Major changes and added features: - -* Deprecation of autotools (autoconf, automake) and fixed build with MinGW -* Added intel hex file reading for `st-flash` -* Added support for ARM semihosting to `st-util` -* Added manpages (generated with pandoc from Markdown) -* Removal of undocumented `st-term` utility, which is now replaced by `st-util` ARM semihosting feature -* Support serial numbers argument for `st-util` and `st-flash` to probe and control multiple connected programmers -* Merge st-probe tool into st-info -* Added support for native debian packaging -* Rewritten commandline parsing for `st-flash` -* Added `--reset` command to `st-flash` -* st-util should detect when USB commands fail - -Chip support added for: - -* STM32F401XE: Added memory map for device -* STM32F410RBTx -* STM32F412 -* STM32F7xx -* STM32F7x7x -* STM32L0xx Cat2 devices (chip-ID: 0x425) -* STM32L0xx Cat5 devices (chip-ID: 0x447) -* STM32L4xx -* STM32L432 - -Updates and fixes: - -* Fixed "unaligned addr or size" when trying to write a program in RAM -* Fixed flashing on STM32_F3_SMALL -* Fixed STM32L-problem with flash loader -* Don't read the target voltage on startup, because it crashes STM32F100 -* Added a useful error message instead of "[!] send_recv" -* Do a JTAG reset prior to reading CPU information when processor is in deep sleep -* Fixed STM32F030 erase error -* Fixed memory map for STM32F7xx -* Redesign of `st-flash` commandline options parsing -* Set SWDCLK and fixed jtag_reset bug -* doc/compiling.md: Add note about installation and ldconfig -* Fixed Release target to generate the man-pages with pandoc -* Fixed Cygwin build -* Reset flash mass erase (MER) bit after mass erase for safety -* Wrong extract command in FindLibUSB.cmake -* Fixed compilation error on Ubuntu 16.10 - --- Andrew 'Necromant' Andrianov Sat, 28 Jan 2017 00:00:00 +0000 - - -libstlink (1.2.1) unstable; urgency=low - -* Initial Debian-packaged release. - --- Andrew 'Necromant' Andrianov Sat, 09 Jul 2016 23:16:07 +0300 + -- Andrew 'Necromant' Andrianov Sat, 09 Jul 2016 23:16:07 +0300 diff --git a/cmake/packaging/deb/control b/cmake/packaging/deb/control new file mode 100644 index 000000000..d96746e65 --- /dev/null +++ b/cmake/packaging/deb/control @@ -0,0 +1,9 @@ +Source: stlink +Maintainer: Luca Bocassi +Build-Depends: cmake, dh-cmake, debhelper (>= 9), libusb-1.0-0-dev, libgtk-3-dev +Standards-Version: 4.1.3 +Section: electronics +Priority: optional +Homepage: https://github.com/stlink-org/stlink +Vcs-Git: https://github.com/stlink-org/stlink.git +Vcs-Browser: https://github.com/stlink-org/stlink diff --git a/cmake/packaging/deb/copyright b/cmake/packaging/deb/copyright index 37a101b98..a14d4eb6e 100644 --- a/cmake/packaging/deb/copyright +++ b/cmake/packaging/deb/copyright @@ -4,6 +4,14 @@ Upstream-Contact: Luca Bocassi Source: https://github.com/stlink-org/stlink Disclaimer: Comment: +Files: * +Copyright: 2011-2020 stlink-org + Martin Capitanio [capnm] + Fabien Le Mentec [texane] + Jerry Jacobs [xor-gate] + [Nightwalker-87] + and many others... + A list of contributors can be found in "contributors.txt". License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -27,11 +35,3 @@ License: BSD-3-clause 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. -Files: * -Copyright: 2011-2020 stlink-org - Martin Capitanio [capnm] - Fabien Le Mentec [texane] - Jerry Jacobs [xor-gate] - [Nightwalker-87] - . - and many others... A list of contributors can be found in "contributors.txt". diff --git a/cmake/packaging/deb/rules b/cmake/packaging/deb/rules index e183fffb7..2f80faeac 100755 --- a/cmake/packaging/deb/rules +++ b/cmake/packaging/deb/rules @@ -11,7 +11,7 @@ include /usr/share/dpkg/default.mk export DEB_BUILD_MAINT_OPTIONS = hardening=+all %: - dh $@ --buildsystem cmake + dh $@ --buildsystem cmake --with cpack override_dh_auto_configure: dh_auto_configure -- \ diff --git a/cmake/packaging/rpm/changelog b/cmake/packaging/rpm/changelog new file mode 100644 index 000000000..de2400d65 --- /dev/null +++ b/cmake/packaging/rpm/changelog @@ -0,0 +1,2 @@ +* Mon Jun 01 2020 Vasiliy Glazov - 1.6.1 +- Initial RPM-packaged release diff --git a/mingw64-build.bat b/mingw64-build.bat index 9d5cf4d06..eeaacddab 100644 --- a/mingw64-build.bat +++ b/mingw64-build.bat @@ -5,5 +5,5 @@ 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 +mingw32-make install DESTDIR=install mingw32-make package From 1b3200d5bc1d6c5b90a54f4c92aa8fbe3f8bb660 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 18 May 2020 18:34:16 +0200 Subject: [PATCH 220/236] Updated build settings - Removed unneeded commands in travis.sh - Removed -Wno-dev flag in Release target - cmake: Grouped udev and modprobe.d config - rpm package now relocatable (CPackRPM) --- .travis.sh | 6 +++--- CMakeLists.txt | 36 +++++++++++++++++++++--------------- Makefile | 2 +- doc/man/CMakeLists.txt | 2 +- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.travis.sh b/.travis.sh index 3bab4c5d0..2c98a6ef6 100755 --- a/.travis.sh +++ b/.travis.sh @@ -33,7 +33,7 @@ elif [ "$TRAVIS_OS_NAME" == "linux" ]; then mkdir -p build/Debug && cd build/Debug echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install" cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR - make && make package && cd - + make && cd - echo "--> Building Release..." mkdir -p build/Release && cd build/Release @@ -48,7 +48,7 @@ elif [ "$TRAVIS_OS_NAME" == "osx" ]; then mkdir -p build/Debug && cd build/Debug echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install" cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR - make && make package && cd - + make && cd - echo "--> Building Release..." mkdir -p build/Release && cd build/Release @@ -61,7 +61,7 @@ else # local test-build mkdir -p build/Debug && cd build/Debug echo "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install" cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install ../../ - make && make package && cd - + make && cd - echo "--> Building Release..." mkdir -p build/Release && cd build/Release diff --git a/CMakeLists.txt b/CMakeLists.txt index 1526f3122..8b3210dbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,14 +18,6 @@ project(stlink C) set(PROJECT_DESCRIPTION "Open source version of the STMicroelectronics ST-LINK Tools") include(GNUInstallDirs) # Define GNU standard installation directories -set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/udev/rules.d" CACHE PATH "udev rules directory") -option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) - -set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory") -option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) - -option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) - ## Determine project version include(${CMAKE_MODULE_PATH}/get_version.cmake) @@ -271,20 +263,32 @@ else () target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB}) endif () +install(TARGETS st-flash DESTINATION bin) +install(TARGETS st-info DESTINATION bin) +install(TARGETS st-util DESTINATION bin) + + +### +# udev and modprobe.d configuration +### + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + ## modprobe.d rules + set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory") + option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) if (STLINK_INSTALL_MODPROBE_CONF) - install(FILES etc/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}/) + install(FILES ${CMAKE_SOURCE_DIR}/etc/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}/) endif () + + ## udev rules + set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/udev/rules.d" CACHE PATH "udev rules directory") + option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) if (STLINK_INSTALL_UDEV_RULES) - file(GLOB RULES_FILES etc/udev/rules.d/*.rules) + file(GLOB RULES_FILES ${CMAKE_SOURCE_DIR}/etc/udev/rules.d/*.rules) install(FILES ${RULES_FILES} DESTINATION ${STLINK_UDEV_RULES_DIR}/) endif () endif () -install(TARGETS st-flash DESTINATION bin) -install(TARGETS st-info DESTINATION bin) -install(TARGETS st-util DESTINATION bin) - ### # Additional build tasks @@ -297,9 +301,11 @@ add_subdirectory(include) # contains subordinate CMakeLists for version config a add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI add_subdirectory(tests) # contains subordinate CMakeLists to build test executables -add_subdirectory(doc/man) # contains subordinate CMakeLists to generate manpages add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages +option(STLINK_GENERATE_MANPAGES "Generate manpages with pandoc" OFF) +add_subdirectory(doc/man) # contains subordinate CMakeLists to generate manpages + ### # Uninstall target diff --git a/Makefile b/Makefile index 3f46d2943..53b0ddcde 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ build/Debug: build/Release: @mkdir -p $@ - @cd $@ && cmake -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) -Wno-dev ../../ + @cd $@ && cmake -DCMAKE_BUILD_TYPE=Release $(CMAKEFLAGS) ../../ clean: @echo "[CLEAN]" diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 221c84d7b..3646654f4 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -30,7 +30,7 @@ foreach (manpage ${MANPAGES}) endif () if (f AND NOT WIN32) - install(FILES ${f} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1) + install(FILES ${f} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) unset(f) endif () endforeach () From 7ef06378aa16e210dc480ef5ae2bc12973becc0c Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 19 May 2020 11:28:35 +0200 Subject: [PATCH 221/236] Refactoring for build settings Tidy up install paths & directories: -> modprobe.d & udev rules (both are now ON per default on Linux) -> stlink-gui supplements -> man pages - Fixed paths according to GNUInstallDirs - cmake: Restructured library config - Test files & gui now use shared library --- .travis.sh | 12 +-- CMakeLists.txt | 88 +++++++------------ {etc => config}/modprobe.d/stlink_v1.conf | 0 .../udev/rules.d/49-stlinkv1.rules | 0 .../udev/rules.d/49-stlinkv2-1.rules | 0 .../udev/rules.d/49-stlinkv2.rules | 0 .../udev/rules.d/49-stlinkv3.rules | 0 doc/man/CMakeLists.txt | 2 +- src/stlink-gui/CMakeLists.txt | 29 +++--- tests/CMakeLists.txt | 6 +- 10 files changed, 56 insertions(+), 81 deletions(-) rename {etc => config}/modprobe.d/stlink_v1.conf (100%) rename {etc => config}/udev/rules.d/49-stlinkv1.rules (100%) rename {etc => config}/udev/rules.d/49-stlinkv2-1.rules (100%) rename {etc => config}/udev/rules.d/49-stlinkv2.rules (100%) rename {etc => config}/udev/rules.d/49-stlinkv3.rules (100%) diff --git a/.travis.sh b/.travis.sh index 2c98a6ef6..cc0958bf5 100755 --- a/.travis.sh +++ b/.travis.sh @@ -35,11 +35,11 @@ elif [ "$TRAVIS_OS_NAME" == "linux" ]; then cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && cd - - echo "--> Building Release..." + echo "--> Building Release with package..." mkdir -p build/Release && cd build/Release echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install" cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR - make && make package && cd - + make package && cd - elif [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install libusb @@ -50,11 +50,11 @@ elif [ "$TRAVIS_OS_NAME" == "osx" ]; then cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR make && cd - - echo "--> Building Release..." + echo "--> Building Release with package..." mkdir -p build/Release && cd build/Release echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install" cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install $DIR - make && make package && cd - + make package && cd - else # local test-build echo "--> Building Debug..." @@ -63,9 +63,9 @@ else # local test-build cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/install ../../ make && cd - - echo "--> Building Release..." + echo "--> Building Release with package..." mkdir -p build/Release && cd build/Release echo "-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install" cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ../../ - make && make package && cd - + make package && cd - fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b3210dbf..dcdaf2ad4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ 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) - ### # General project settings ### @@ -32,16 +31,7 @@ else () set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") endif () -## Set installation directories for libraries -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 () - set(LIB_INSTALL_DIR "lib" CACHE PATH "Main library directory") - set(STLINK_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}") -endif () - -## Set installation directories for header files +## Set installation directories for header files ### TODO: Clean this up... 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}") @@ -95,13 +85,14 @@ endif () include_directories(${LIBUSB_INCLUDE_DIR}) # ==== -include_directories(include) ### TODO: Clean this up... +include_directories(${PROJECT_SOURCE_DIR}/include) ### TODO: Clean this up... include_directories(${PROJECT_BINARY_DIR}/include/stlink) -include_directories(include/stlink) -include_directories(include/stlink/tools) +include_directories(${PROJECT_SOURCE_DIR}/include/stlink) +include_directories(${PROJECT_SOURCE_DIR}/include/stlink/tools) # ==== include_directories(src) +include_directories(src/tools) ### TODO: Clean this up... set(STLINK_HEADERS include/stlink.h @@ -145,29 +136,30 @@ if (${CMAKE_BUILD_TYPE} MATCHES "Debug") endif () +### +# Libraries +### + +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}"") + + ### # Shared library ### +# Set library name if (NOT WIN32) set(STLINK_LIB_SHARED ${PROJECT_NAME}) else (WIN32) 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} ${STLINK_SOURCE}) set(STLINK_SHARED_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) - message(STATUS "STLINK_LIB_SHARED: ${STLINK_LIB_SHARED}") message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}") message(STATUS "VERSION: ${STLINK_SHARED_VERSION}") @@ -176,6 +168,7 @@ set_target_properties( ${STLINK_LIB_SHARED} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${STLINK_SHARED_VERSION} + OUTPUT_NAME ${PROJECT_NAME} ) # Link shared library @@ -197,19 +190,12 @@ install(TARGETS ${STLINK_LIB_SHARED} DESTINATION ${STLINK_LIBRARY_PATH}) # Static library ### -# Install static library per default -set(STLINK_STATIC_LIB ON CACHE BOOL "Install static lib") - +# Set library name 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} ${STLINK_SOURCE}) set(STLINK_STATIC_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) - message(STATUS "STLINK_LIB_STATIC: ${STLINK_LIB_STATIC}") message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}") message(STATUS "VERSION: ${STLINK_STATIC_VERSION}") @@ -233,9 +219,7 @@ else () target_link_libraries(${STLINK_LIB_STATIC} ${LIBUSB_LIBRARY} ${SSP_LIB}) endif () -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}) ### @@ -263,30 +247,24 @@ else () target_link_libraries(st-util ${STLINK_LIB_SHARED} ${SSP_LIB}) endif () -install(TARGETS st-flash DESTINATION bin) -install(TARGETS st-info DESTINATION bin) -install(TARGETS st-util DESTINATION bin) +install(TARGETS st-flash DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS st-info DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS st-util DESTINATION ${CMAKE_INSTALL_BINDIR}) ### -# udev and modprobe.d configuration +# Device configuration (Linux only) ### if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - ## modprobe.d rules - set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/modprobe.d" CACHE PATH "modprobe.d directory") - option(STLINK_INSTALL_MODPROBE_CONF "Install modprobe conf files" ON) - if (STLINK_INSTALL_MODPROBE_CONF) - install(FILES ${CMAKE_SOURCE_DIR}/etc/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}/) - endif () - - ## udev rules - set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/udev/rules.d" CACHE PATH "udev rules directory") - option(STLINK_INSTALL_UDEV_RULES "Install udev rules files" ON) - if (STLINK_INSTALL_UDEV_RULES) - file(GLOB RULES_FILES ${CMAKE_SOURCE_DIR}/etc/udev/rules.d/*.rules) - install(FILES ${RULES_FILES} DESTINATION ${STLINK_UDEV_RULES_DIR}/) - endif () + ## Install modprobe.d conf files / rules to /usr/local/etc/stlink (default) + set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/modprobe.d" CACHE PATH "modprobe.d directory") + install(FILES ${CMAKE_SOURCE_DIR}/config/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}) + + ## Install udev rules files / rules to /usr/local/etc/stlink (default) + set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/udev/rules.d" CACHE PATH "udev rules directory") + file(GLOB RULES_FILES ${CMAKE_SOURCE_DIR}/config/udev/rules.d/*.rules) + install(FILES ${RULES_FILES} DESTINATION ${STLINK_UDEV_RULES_DIR}) endif () diff --git a/etc/modprobe.d/stlink_v1.conf b/config/modprobe.d/stlink_v1.conf similarity index 100% rename from etc/modprobe.d/stlink_v1.conf rename to config/modprobe.d/stlink_v1.conf diff --git a/etc/udev/rules.d/49-stlinkv1.rules b/config/udev/rules.d/49-stlinkv1.rules similarity index 100% rename from etc/udev/rules.d/49-stlinkv1.rules rename to config/udev/rules.d/49-stlinkv1.rules diff --git a/etc/udev/rules.d/49-stlinkv2-1.rules b/config/udev/rules.d/49-stlinkv2-1.rules similarity index 100% rename from etc/udev/rules.d/49-stlinkv2-1.rules rename to config/udev/rules.d/49-stlinkv2-1.rules diff --git a/etc/udev/rules.d/49-stlinkv2.rules b/config/udev/rules.d/49-stlinkv2.rules similarity index 100% rename from etc/udev/rules.d/49-stlinkv2.rules rename to config/udev/rules.d/49-stlinkv2.rules diff --git a/etc/udev/rules.d/49-stlinkv3.rules b/config/udev/rules.d/49-stlinkv3.rules similarity index 100% rename from etc/udev/rules.d/49-stlinkv3.rules rename to config/udev/rules.d/49-stlinkv3.rules diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 3646654f4..23da9e150 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -30,7 +30,7 @@ foreach (manpage ${MANPAGES}) endif () if (f AND NOT WIN32) - install(FILES ${f} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + install(FILES ${f} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/man/man1) unset(f) endif () endforeach () diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index b5ef99df9..c38fdadaa 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -16,26 +16,23 @@ set(GUI_SOURCES gui.c gui.h) ## stlink-gui-local add_executable(stlink-gui-local ${GUI_SOURCES}) -set_target_properties( - stlink-gui-local PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}" - # Note: ${CMAKE_CURRENT_SOURCE_DIR} is src/stlink-gui - ) -target_link_libraries(stlink-gui-local ${STLINK_LIB_STATIC} ${GTK3_LDFLAGS} ${SSP_LIB}) +set_target_properties(stlink-gui-local PROPERTIES + # Note: ${CMAKE_CURRENT_SOURCE_DIR} is src/stlink-gui + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}") +target_link_libraries(stlink-gui-local ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS}) ## stlink-gui add_executable(stlink-gui ${GUI_SOURCES}) -set_target_properties( - stlink-gui PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_PREFIX}/bin" - # Note: ${CMAKE_INSTALL_PREFIX} defaults to /usr/local - ) -target_link_libraries(stlink-gui ${STLINK_LIB_STATIC} ${GTK3_LDFLAGS} ${SSP_LIB}) +set_target_properties(stlink-gui PROPERTIES + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_BINDIR}") +target_link_libraries(stlink-gui ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS}) -install(TARGETS stlink-gui DESTINATION bin) -install(FILES stlink-gui.ui DESTINATION bin) +install(TARGETS stlink-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_BINDIR}) if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - install(FILES stlink-gui.desktop DESTINATION share/applications) # Install desktop application entry - install(FILES icons/stlink-gui.svg DESTINATION share/icons/hicolor/scalable/apps) # Install icon + # Install desktop application entry + install(FILES stlink-gui.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/applications) + # Install icons + install(FILES icons/stlink-gui.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/icons/hicolor/scalable/apps) endif () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 40d2203db..6e60fdd5a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,11 +6,11 @@ set(TESTEXEC usb sg) foreach (test ${TESTEXEC}) add_executable(test-${test} ${test}.c) - add_dependencies(test-${test} ${STLINK_LIB_STATIC}) - target_link_libraries(test-${test} ${STLINK_LIB_STATIC} ${SSP_LIB}) + add_dependencies(test-${test} ${STLINK_LIB_SHARED}) + target_link_libraries(test-${test} ${STLINK_LIB_SHARED} ${SSP_LIB}) 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") -target_link_libraries(test-flash ${STLINK_LIB_STATIC} ${SSP_LIB}) +target_link_libraries(test-flash ${STLINK_LIB_SHARED} ${SSP_LIB}) add_test(test-flash ${CMAKE_BINARY_DIR}/bin/test-flash) From 5fc02abf33722fbf27996e955b2cc3017368e45a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 19 May 2020 14:08:07 +0200 Subject: [PATCH 222/236] Improved cmake-config for GUI build --- src/stlink-gui/CMakeLists.txt | 57 ++++++++++++++++++----------------- src/stlink-gui/gui.c | 3 +- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/stlink-gui/CMakeLists.txt b/src/stlink-gui/CMakeLists.txt index c38fdadaa..8c36e5a1f 100644 --- a/src/stlink-gui/CMakeLists.txt +++ b/src/stlink-gui/CMakeLists.txt @@ -2,37 +2,40 @@ # Build GUI ### -## GUI-Building requires the presence of a GTK3 toolset -if (NOT GTK3_FOUND) - message(STATUS "GTK3 not found!") - return() # no GTK3 present => no GUI build -else (GTK3_FOUND) - message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}") -endif () +if (NOT WIN32) + ## GUI-Building requires the presence of a GTK3 toolset + if (NOT GTK3_FOUND) + message(STATUS "GTK3 not found!") + return() # no GTK3 present => no GUI build + else (GTK3_FOUND) + message(STATUS "Found GTK3: -I${GTK3_INCLUDE_DIRS}, ${GTK3_LIBRARIES}") + include_directories(SYSTEM ${GTK3_INCLUDE_DIRS}) + + # Install desktop application entry + install(FILES stlink-gui.desktop + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/applications) -include_directories(SYSTEM ${GTK3_INCLUDE_DIRS}) + # Install icons + install(FILES icons/stlink-gui.svg + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/icons/hicolor/scalable/apps) -set(GUI_SOURCES gui.c gui.h) + set(GUI_SOURCES gui.c gui.h) -## stlink-gui-local -add_executable(stlink-gui-local ${GUI_SOURCES}) -set_target_properties(stlink-gui-local PROPERTIES - # Note: ${CMAKE_CURRENT_SOURCE_DIR} is src/stlink-gui - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(stlink-gui-local ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS}) + ## stlink-gui-local + add_executable(stlink-gui-local ${GUI_SOURCES}) + file(COPY stlink-gui.ui DESTINATION ${CMAKE_BINARY_DIR}/bin) + set_target_properties(stlink-gui-local PROPERTIES + COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_BINARY_DIR}/bin") + target_link_libraries(stlink-gui-local ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS}) -## stlink-gui -add_executable(stlink-gui ${GUI_SOURCES}) -set_target_properties(stlink-gui PROPERTIES - COMPILE_DEFINITIONS STLINK_UI_DIR="${CMAKE_INSTALL_BINDIR}") -target_link_libraries(stlink-gui ${STLINK_LIB_SHARED} ${SSP_LIB} ${GTK3_LDFLAGS}) + ## stlink-gui + add_executable(stlink-gui ${GUI_SOURCES}) + install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_BINDIR}) + set_target_properties(stlink-gui PROPERTIES + 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}) -install(TARGETS stlink-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) -install(FILES stlink-gui.ui DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - # Install desktop application entry - install(FILES stlink-gui.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/applications) - # Install icons - install(FILES icons/stlink-gui.svg DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/icons/hicolor/scalable/apps) + endif () endif () diff --git a/src/stlink-gui/gui.c b/src/stlink-gui/gui.c index 5d5a422d5..0a95aee76 100644 --- a/src/stlink-gui/gui.c +++ b/src/stlink-gui/gui.c @@ -781,8 +781,7 @@ static void stlink_gui_build_ui (STlinkGUI *gui) { GtkListStore *filemem_store; gchar *ui_file = STLINK_UI_DIR "/stlink-gui.ui"; - if (!g_file_test (ui_file, G_FILE_TEST_EXISTS)) - ui_file = "stlink-gui.ui"; + if (!g_file_test (ui_file, G_FILE_TEST_EXISTS)) ui_file = "stlink-gui.ui"; builder = gtk_builder_new (); if (!gtk_builder_add_from_file (builder, ui_file, NULL)) { g_printerr ("Failed to load UI file: %s\n", ui_file); From 73dc5fed246317711f0ece4252064dbf3b63534b Mon Sep 17 00:00:00 2001 From: Oleksiy Slyshyk Date: Tue, 19 May 2020 17:50:10 +0300 Subject: [PATCH 223/236] link libssp statically --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dcdaf2ad4..c61b9b6bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ include(CheckLibraryExists) CHECK_LIBRARY_EXISTS(ssp __stack_chk_fail "" _stack_chk_fail_exists) if (_stack_chk_fail_exists) - set(SSP_LIB ssp) + set(SSP_LIB -static ssp) else () set(SSP_LIB "") endif () From af765a20228dd973d9933ed49228049bc121fcce Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 22 May 2020 15:11:43 +0200 Subject: [PATCH 224/236] Minor fixes for flashloader files --- flashloaders/stm32f0.s | 4 ++-- flashloaders/stm32f4.s | 4 ++-- flashloaders/stm32f4lv.s | 4 ++-- flashloaders/stm32f7.s | 4 ++-- flashloaders/stm32f7lv.s | 4 ++-- flashloaders/stm32l4.s | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flashloaders/stm32f0.s b/flashloaders/stm32f0.s index cbb932b49..f30e4bfc6 100644 --- a/flashloaders/stm32f0.s +++ b/flashloaders/stm32f0.s @@ -42,11 +42,11 @@ loop: adds r1, r1, r7 # wait if FLASH_SR == 1 -mywait: +wait: ldr r7, =0x1 ldr r3, [r5] tst r3, r7 - beq mywait + beq wait # exit if FLASH_SR != 4 ldr r7, =0x4 diff --git a/flashloaders/stm32f4.s b/flashloaders/stm32f4.s index b4e0f4913..a88ad9e02 100644 --- a/flashloaders/stm32f4.s +++ b/flashloaders/stm32f4.s @@ -16,10 +16,10 @@ loop: add r1, r1, #4 # wait if FLASH_SR == 1 -mywait: +wait: ldrh r3, [r10] tst r3, #0x1 - beq mywait + beq wait # loop if r2 != 0 sub r2, r2, #1 diff --git a/flashloaders/stm32f4lv.s b/flashloaders/stm32f4lv.s index f5cc29841..41467a9ef 100644 --- a/flashloaders/stm32f4lv.s +++ b/flashloaders/stm32f4lv.s @@ -22,10 +22,10 @@ loop: add r1, r1, #1 # wait if FLASH_SR == 1 -mywait: +wait: ldrh r3, [r10] tst r3, #0x1 - beq mywait + beq wait # loop if r2 != 0 sub r2, r2, #1 diff --git a/flashloaders/stm32f7.s b/flashloaders/stm32f7.s index 8694d864e..3779a5ea6 100644 --- a/flashloaders/stm32f7.s +++ b/flashloaders/stm32f7.s @@ -19,10 +19,10 @@ loop: dsb sy # wait if FLASH_SR == 1 -mywait: +wait: ldrh r3, [r10] tst r3, #0x1 - beq mywait + beq wait # loop if r2 != 0 sub r2, r2, #1 diff --git a/flashloaders/stm32f7lv.s b/flashloaders/stm32f7lv.s index b48e40f0d..e7b66cc2c 100644 --- a/flashloaders/stm32f7lv.s +++ b/flashloaders/stm32f7lv.s @@ -25,10 +25,10 @@ loop: dsb sy # wait if FLASH_SR == 1 -mywait: +wait: ldrh r3, [r10] tst r3, #0x1 - beq mywait + beq wait # loop if r2 != 0 sub r2, r2, #1 diff --git a/flashloaders/stm32l4.s b/flashloaders/stm32l4.s index c68198bfa..32c27a057 100644 --- a/flashloaders/stm32l4.s +++ b/flashloaders/stm32l4.s @@ -18,10 +18,10 @@ loop: add r1, r1, #8 # wait if FLASH_BSY[0b] == 1 -mywait: +wait: ldrh r3, [r10] tst r3, #0x1 - beq mywait + beq wait # loop if r2 != 0 sub r2, r2, #1 From 937f4d6aeaf7ddc50bc181a1448a40fc9389e8c2 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Fri, 22 May 2020 19:42:16 +0200 Subject: [PATCH 225/236] General Project Update - Updated CHANGELOG - Minor fixes --- CHANGELOG.md | 126 ++++++++++++++++++++++++++++--------------------- CMakeLists.txt | 6 +-- README.md | 2 +- 3 files changed, 74 insertions(+), 60 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f79cd846c..b6b63e156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,67 +10,83 @@ This release drops support for some older operating systems. Check project READM Features: -- Support for STM32L1, SM32L4 option bytes write (#596, #844, #847) -- CMake now creates an uninstall target (#619, #907) -- Added CMAKEFLAGS and install target (#804, #935) -- Support for STM32G4 (#822) -- Add aliased SRAM2 region in the L496 memory map (#824) -- Improved support for STM32G0 (#825, #850, #856, #857) -- Added postinst script with 'depmod -a' for 'make package' (#845, #931) -- Calculate checksums for flash operations (#862, #924) -- Added usb PID and udev rules for STlink v2.1 found on Nucleo-L432KC and Nucleo-L552ze boards (#900) -- STM32G0/G4 improvements (#910) +- Basic compatibility for STLink-v3 programmer ([#271](https://github.com/stlink-org/stlink/pull/271), [#863](https://github.com/stlink-org/stlink/pull/863), [#954](https://github.com/stlink-org/stlink/pull/954)) + - Added support for JTAG command API v2 & distinguish protocol versions v1 and v2 + - Compatibility with the STLink-v3 firmware which dropped support for the previous API v1 + - As of firmware version J11 the ST-LINK-V1 programmer supports API v2 commands as well +- Display programmer serial when no target is connected ([#432](https://github.com/stlink-org/stlink/pull/432), [#933](https://github.com/stlink-org/stlink/pull/933), [#943](https://github.com/stlink-org/stlink/pull/943)) +- Support for STM32L1, SM32L4 option bytes write ([#596](https://github.com/stlink-org/stlink/pull/596), [#844](https://github.com/stlink-org/stlink/pull/844), [#847](https://github.com/stlink-org/stlink/pull/847)) +- CMake now creates an uninstall target ([#619](https://github.com/stlink-org/stlink/pull/619), [#907](https://github.com/stlink-org/stlink/pull/907)) +- Added CMAKEFLAGS and install target ([#804](https://github.com/stlink-org/stlink/pull/804), [#935](https://github.com/stlink-org/stlink/pull/935)) +- Support for STM32G4 ([#822](https://github.com/stlink-org/stlink/pull/822)) +- Add aliased SRAM2 region in the L496 memory map ([#824](https://github.com/stlink-org/stlink/pull/824)) +- Improved support for STM32G0 ([#825](https://github.com/stlink-org/stlink/pull/825), [#850](https://github.com/stlink-org/stlink/pull/850), [#856](https://github.com/stlink-org/stlink/pull/856), [#857](https://github.com/stlink-org/stlink/pull/857)) +- Added postinst script with 'depmod -a' for 'make package' ([#845](https://github.com/stlink-org/stlink/pull/845), [#931](https://github.com/stlink-org/stlink/pull/931)) +- Calculate checksums for flash operations ([#862](https://github.com/stlink-org/stlink/pull/862), [#924](https://github.com/stlink-org/stlink/pull/924)) +- Adjust the JTAG/SWD frequency via cmdline option ([#893](https://github.com/stlink-org/stlink/pull/893), [#953](https://github.com/stlink-org/stlink/pull/953)) +- Added usb PID and udev rules for STlink v2.1 found on Nucleo-L432KC and Nucleo-L552ze boards ([#900](https://github.com/stlink-org/stlink/pull/900)) +- STM32G0/G4 improvements ([#910](https://github.com/stlink-org/stlink/pull/910)) - Enable mass erase with a flash programming check - Handle G4 Cat3 devices with configurable dual bank flash by using a helper -- Display programmer serial when no target is connected (#432, #933, #943) Updates & changes: -- Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION (#211, #782, #895) -- Improved argument parsing for CLI tools (#378, #922) -- [doc] Updated tutorial: macOS ST-Link-v1 detection (#574, #587) -- Enhanced output for error msg "addr not a multiple of pagesize, not supported" (#663, #945) -- [doc] Verify correct udev configuration for device access (#764) -- Added more error info to WLOGs during probe (#883) -- Added check for libssp during compilation (#885) -- Silence unnecessary messages (#886) -- Set up a libusb log level accordingly to verbosity (commit 49f887d5247fdd28f163b6317790c4f087e652cc) -- [doc] Define libusb & cmake version compatibility (#896, #897, #899, commit 27aa88821197d3ffe82baff4e971c3488ec39899) -- Update for STM32G471/473/474/483/484 devices (#901) -- [doc] st-flash --flash=n[k][m] command line option to override device model (#902) -- [doc] Update compiling instructions (#113, commit 10ae5294cd03aacfc07312010f026d3cb12ea56c) -- [doc] Defined version compatibility and installation instructions for macOS (commit 23c071edea45f6e8852fef52d884a680973d6d8f) -- Deprecated old appveyor-mingw script (commit 97484422008df0f75c978627054776f35842a075) -- Enhanced error log with file path for map_file() (#650, #879, #921) -- [refactoring] Overall option code rework (#927) -- [refactoring] Build settings / GUI-Build on UNIX-based systems if GTK3 is detected (#929) -- [refactoring] Reconfiguration of package build process (#931, #936, #940, commit 9b19f9225460472af9d98959b7217d0a840ee972) -- [refactoring] st-util: Removed now useless v1/v2 STLink version stuff (#934) -- [refactoring] Cleanup for option bytes and flash settings (#941) -- Added compilation guideline for MSVC toolchain (#942) -- st-util: Removal of useless v1/v2 stlink version stuff (#934) -- libusb package extraction no longer requires 7zip as an external unarchiver (commit 5db2dc4c0410ace65308cddcc03d1c0cfa4855cf) -- [refactoring] Cleanup of cmake build process (#944, #946, #947) +- [doc] Update compiling instructions ([#113](https://github.com/stlink-org/stlink/pull/113), commit [#10ae529](https://github.com/stlink-org/stlink/commit/10ae5294cd03aacfc07312010f026d3cb12ea56c)) +- Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION ([#211](https://github.com/stlink-org/stlink/pull/211), [#782](https://github.com/stlink-org/stlink/pull/782), [#895](https://github.com/stlink-org/stlink/pull/895)) +- Improved argument parsing for CLI tools ([#378](https://github.com/stlink-org/stlink/pull/378), [#922](https://github.com/stlink-org/stlink/pull/922)) +- [doc] Updated tutorial: macOS ST-Link-v1 detection ([#574](https://github.com/stlink-org/stlink/pull/574), [#587](https://github.com/stlink-org/stlink/pull/587)) +- Enhanced error log with file path for map_file() ([#650](https://github.com/stlink-org/stlink/pull/650), [#879](https://github.com/stlink-org/stlink/pull/879), [#921](https://github.com/stlink-org/stlink/pull/921)) +- Enhanced output for error msg "addr not a multiple of pagesize, not supported" ([#663](https://github.com/stlink-org/stlink/pull/663), [#945](https://github.com/stlink-org/stlink/pull/945)) +- [refactoring] Package distribution: Provide Windows binaries via Debian-based cross-build ([#738](https://github.com/stlink-org/stlink/pull/738), [#795](https://github.com/stlink-org/stlink/pull/795), [#798](https://github.com/stlink-org/stlink/pull/798), [#955](https://github.com/stlink-org/stlink/pull/955)) + - Update, corrections & cleanup for build settings (see #955 for details) + - New cpack package-config for DEB and RPM build + - Update for travis build configuration: builds for clang -m32, clang-9, MinGW-cross on linux + - Updated steps for release preparation + - Project contributors now listed in separate file + - Test files & gui now use shared stlink-library +- [doc] Verify correct udev configuration for device access ([#764](https://github.com/stlink-org/stlink/pull/764)) +- Added more error info to WLOGs during probe ([#883](https://github.com/stlink-org/stlink/pull/883)) +- [doc] Add missing documentation for stlink-gui ([#884](https://github.com/stlink-org/stlink/pull/884)) +- Added check for libssp during compilation ([#885](https://github.com/stlink-org/stlink/pull/885)) +- Silence unnecessary messages ([#886](https://github.com/stlink-org/stlink/pull/886)) +- [doc] Define libusb & cmake version compatibility ([#896](https://github.com/stlink-org/stlink/pull/896), [#897](https://github.com/stlink-org/stlink/pull/897), [#899](https://github.com/stlink-org/stlink/pull/899), commit [#27aa888](https://github.com/stlink-org/stlink/commit/27aa88821197d3ffe82baff4e971c3488ec39899)) +- Update for STM32G471/473/474/483/484 devices ([#901](https://github.com/stlink-org/stlink/pull/901)) +- [doc] st-flash --flash=n[k][m] command line option to override device model ([#902](https://github.com/stlink-org/stlink/pull/902)) +- [refactoring] BSD-License-compliant rewrite of flashloader source files ([#915](https://github.com/stlink-org/stlink/pull/915), [#932](https://github.com/stlink-org/stlink/pull/932)) +- [refactoring] Overall option code rework ([#927](https://github.com/stlink-org/stlink/pull/927)) +- [refactoring] Build settings / GUI-Build on UNIX-based systems if GTK3 is detected ([#929](https://github.com/stlink-org/stlink/pull/929)) +- [refactoring] Reconfiguration of package build process ([#931](https://github.com/stlink-org/stlink/pull/931), [#936](https://github.com/stlink-org/stlink/pull/936), [#940](https://github.com/stlink-org/stlink/pull/940), commit [#9b19f92](https://github.com/stlink-org/stlink/commit/9b19f9225460472af9d98959b7217d0a840ee972)) +- [refactoring] st-util: Removed now useless v1/v2 STLink version stuff ([#934](https://github.com/stlink-org/stlink/pull/934)) +- [refactoring] Cleanup for option bytes and flash settings ([#941](https://github.com/stlink-org/stlink/pull/941)) +- Added compilation guideline for MSVC toolchain ([#942](https://github.com/stlink-org/stlink/pull/942)) +- [refactoring] Cleanup of cmake build process ([#944](https://github.com/stlink-org/stlink/pull/944), [#946](https://github.com/stlink-org/stlink/pull/946), [#947](https://github.com/stlink-org/stlink/pull/947)) +- Set up a libusb log level accordingly to verbosity (commit [#49f887d](https://github.com/stlink-org/stlink/commit/49f887d5247fdd28f163b6317790c4f087e652cc)) +- [doc] Defined version compatibility and installation instructions for macOS (commit [#23c071e](https://github.com/stlink-org/stlink/commit/23c071edea45f6e8852fef52d884a680973d6d8f)) +- Deprecated old appveyor-mingw script (commit [#9748442](https://github.com/stlink-org/stlink/commit/97484422008df0f75c978627054776f35842a075)) +- libusb package extraction no longer requires 7zip as an external unarchiver (commit [#5db2dc4](https://github.com/stlink-org/stlink/commit/5db2dc4c0410ace65308cddcc03d1c0cfa4855cf)) + Fixes: -- Fixed wait-loop for flash_loader_run() (#290) -- Clear the PG bit before setting the PER bit (#579, #876) -- Fixed compilation issues with int length on 32-bit platforms (#629, #908) -- Fixed st-info --probe mechanism (#679, #918) -- Fixed sign-compare (size != rep_len) in usb.c (Regression) (#772, #869, #872, #891) -- Avoid re-define of O_BINARY on Windows (#788) -- Fixed st-flash manpage read example (#858) -- Fixed stlink support with no mass storage (#861) -- Make Version.cmake more error-resistant (#872) -- Error return in failed probe (#887, #890) -- Fixed formatting for options display in st-flash & st-info (commits c783d0e777ccc83a7a8be26a4f4d3414e0478560 and 562cd2496e696dbd22950925866aac662d81ee5f) -- Fixed dead loop after an unexpected unplug (#780, #812, #913) -- Fixed broken build on 32-bit systems (#919, #920) -- st-flash: Minor usage fix and make cmdline parsing more user friendly (#925) -- Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 (#378, #922) -- Restored functionality of make test builds (Regression) (#926, #929) -- Fixed compilation error due to uninitialized cpuid (#937, #938) +- Fixed wait-loop for flash_loader_run() ([#290](https://github.com/stlink-org/stlink/pull/290)) +- Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 ([#378](https://github.com/stlink-org/stlink/pull/378), [#922](https://github.com/stlink-org/stlink/pull/922)) +- Clear the PG bit before setting the PER bit ([#579](https://github.com/stlink-org/stlink/pull/579), [#876](https://github.com/stlink-org/stlink/pull/876)) +- Fixed compilation issues with int length on 32-bit platforms ([#629](https://github.com/stlink-org/stlink/pull/629), [#908](https://github.com/stlink-org/stlink/pull/908)) +- Fixed st-info --probe mechanism ([#679](https://github.com/stlink-org/stlink/pull/679), [#918](https://github.com/stlink-org/stlink/pull/918)) +- [regression] Fixed sign-compare (size != rep_len) in usb.c ([#772](https://github.com/stlink-org/stlink/pull/772), [#869](https://github.com/stlink-org/stlink/pull/869), [#872](https://github.com/stlink-org/stlink/pull/872), [#891](https://github.com/stlink-org/stlink/pull/891)) +- Fixed dead loop after an unexpected unplug ([#780](https://github.com/stlink-org/stlink/pull/780), [#812](https://github.com/stlink-org/stlink/pull/812), [#913](https://github.com/stlink-org/stlink/pull/913)) +- Avoid re-define of O_BINARY on Windows ([#788](https://github.com/stlink-org/stlink/pull/788)) +- Fixed st-flash manpage read example ([#858](https://github.com/stlink-org/stlink/pull/858)) +- Fixed stlink support with no mass storage ([#861](https://github.com/stlink-org/stlink/pull/861)) +- Make Version.cmake more error-resistant ([#872](https://github.com/stlink-org/stlink/pull/872)) +- Error return in failed probe ([#887](https://github.com/stlink-org/stlink/pull/887), [#890](https://github.com/stlink-org/stlink/pull/890)) +- Fixed broken build on 32-bit systems ([#919](https://github.com/stlink-org/stlink/pull/919), [#920](https://github.com/stlink-org/stlink/pull/920)) +- st-flash: Minor usage fix and make cmdline parsing more user friendly ([#925](https://github.com/stlink-org/stlink/pull/925)) +- [regression] Restored functionality of make test builds ([#926](https://github.com/stlink-org/stlink/pull/926), [#929](https://github.com/stlink-org/stlink/pull/929)) +- Fixed compilation error due to uninitialized cpuid ([#937](https://github.com/stlink-org/stlink/pull/937), [#938](https://github.com/stlink-org/stlink/pull/938)) +- Fixes for STM32F0 flashloader ([#958](https://github.com/stlink-org/stlink/pull/958), [#959](https://github.com/stlink-org/stlink/pull/959) +- Set static link for libssp (stack-smashing protection) ([#960](https://github.com/stlink-org/stlink/pull/960), [#961](https://github.com/stlink-org/stlink/pull/961)) +- Fixed formatting for options display in st-flash & st-info (commits [#c783d0e](https://github.com/stlink-org/stlink/commit/c783d0e777ccc83a7a8be26a4f4d3414e0478560) and [#562cd24](https://github.com/stlink-org/stlink/commit/562cd2496e696dbd22950925866aac662d81ee5f)) v1.6.0 @@ -81,7 +97,7 @@ Release date: 2020-02-20 Major changes and added features: * Initial support for STM32L41X ([#754](https://github.com/stlink-org/stlink/pull/754), [#799](https://github.com/stlink-org/stlink/pull/799)) -* Working support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 ([#756](https://github.com/stlink-org/stlink/pull/756), [#757](https://github.com/stlink-org/stlink/pull/757), [#805](https://github.com/stlink-org/stlink/pull/805), [#834](https://github.com/stlink-org/stlink/pull/834), Regression-Fixes: [#761](https://github.com/stlink-org/stlink/pull/761), [#766](https://github.com/stlink-org/stlink/pull/766)) +* Verified support for CKS32F103C8T6 and related CKS devices with Core-ID 0x2ba01477 ([#756](https://github.com/stlink-org/stlink/pull/756), [#757](https://github.com/stlink-org/stlink/pull/757), [#805](https://github.com/stlink-org/stlink/pull/805), [#834](https://github.com/stlink-org/stlink/pull/834), Regression-Fixes: [#761](https://github.com/stlink-org/stlink/pull/761), [#766](https://github.com/stlink-org/stlink/pull/766)) * Added preliminary support for some STM32G0 chips ([#759](https://github.com/stlink-org/stlink/pull/759), [#760](https://github.com/stlink-org/stlink/pull/760), [#797](https://github.com/stlink-org/stlink/pull/797)) * Added support for mass erasing second bank on STM32F10x_XL ([#767](https://github.com/stlink-org/stlink/pull/767), [#768](https://github.com/stlink-org/stlink/pull/768)) * Added call to clear PG bit after writing to flash ([#773](https://github.com/stlink-org/stlink/pull/773)) @@ -155,7 +171,7 @@ Updates and fixes: * Disabled static library installation by default ([#702](https://github.com/stlink-org/stlink/pull/702)) * Fix for libusb deprecation ([#703](https://github.com/stlink-org/stlink/pull/703), [#704](https://github.com/stlink-org/stlink/pull/704)) * Renamed STLINK_CHIPID_STM32_L4R9 to STLINK_CHIPID_STM32_L4RX ([#706](https://github.com/stlink-org/stlink/pull/706)) -* Regression: stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/stlink-org/stlink/pull/700), [#701](https://github.com/stlink-org/stlink/pull/701), [#707](https://github.com/stlink-org/stlink/pull/707)) +* [regression] stlink installation under Linux (Debian 9) is broken since #695 ([#700](https://github.com/stlink-org/stlink/pull/700), [#701](https://github.com/stlink-org/stlink/pull/701), [#707](https://github.com/stlink-org/stlink/pull/707)) * Fixed flash memory map for STM32F72xxx target ([#711](https://github.com/stlink-org/stlink/pull/711)) * Proper flash page size calculation for STM32F412xx target ([#721](https://github.com/stlink-org/stlink/pull/721)) * Return correct value on EOF for Semihosting SYS_READ ([#726](https://github.com/stlink-org/stlink/pull/726), [#727](https://github.com/stlink-org/stlink/pull/727), [#728](https://github.com/stlink-org/stlink/pull/728), [#729](https://github.com/stlink-org/stlink/pull/729), [#730](https://github.com/stlink-org/stlink/pull/730), [#731](https://github.com/stlink-org/stlink/pull/731), [#732](https://github.com/stlink-org/stlink/pull/732)) diff --git a/CMakeLists.txt b/CMakeLists.txt index c61b9b6bf..6b17fdc57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,8 +164,7 @@ 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 +set_target_properties(${STLINK_LIB_SHARED} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${STLINK_SHARED_VERSION} OUTPUT_NAME ${PROJECT_NAME} @@ -200,8 +199,7 @@ message(STATUS "STLINK_LIB_STATIC: ${STLINK_LIB_STATIC}") message(STATUS "PROJECT_VERSION_MAJOR: ${PROJECT_VERSION_MAJOR}") message(STATUS "VERSION: ${STLINK_STATIC_VERSION}") -set_target_properties( - ${STLINK_LIB_STATIC} PROPERTIES +set_target_properties(${STLINK_LIB_STATIC} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR} VERSION ${STLINK_STATIC_VERSION} OUTPUT_NAME ${PROJECT_NAME} diff --git a/README.md b/README.md index 42ee63aa2..b2495840d 100644 --- a/README.md +++ b/README.md @@ -125,4 +125,4 @@ Here we would appreciate any help and would love to welcome new contributors who * Writing external memory connected to an STM32 controller (e.g Quad SPI NOR flash) ([#412](https://github.com/stlink-org/stlink/issues/412)) * MCU hotplug ([#449](https://github.com/stlink-org/stlink/issues/449)) * Writing options bytes (region) ([#458](https://github.com/stlink-org/stlink/issues/458)) -* Support for STLINKv3 programmer ([#820](https://github.com/stlink-org/stlink/issues/820)) +* Enhanced support for STLINKv3 programmer ([#820](https://github.com/stlink-org/stlink/issues/820)) From ea17f9ac77064e3c47b58fd014834f06bd763724 Mon Sep 17 00:00:00 2001 From: Geoffrey Brown Date: Fri, 22 May 2020 14:40:26 -0400 Subject: [PATCH 226/236] added connect under reset code --- .vscode/settings.json | 3 +++ src/usb.c | 5 +++-- src/usb.h | 2 +- tests/usb.c | 23 ++++++++++++++++++++--- 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..cad7657df --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/src/usb.c b/src/usb.c index b986aed57..26243daa3 100644 --- a/src/usb.c +++ b/src/usb.c @@ -937,7 +937,7 @@ static stlink_backend_t _stlink_usb_backend = { _stlink_usb_set_swdclk }; -stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq) { +stlink_t *stlink_open_usb(enum ugly_loglevel verbose, int reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq) { stlink_t* sl = NULL; struct stlink_libusb* slu = NULL; int ret = -1; @@ -1145,9 +1145,10 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[ST break; } + if (reset == 2) stlink_jtag_reset(sl,0); if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl); - if (reset) { + if (reset == 1) { if ( sl->version.stlink_v > 1) stlink_jtag_reset(sl, 2); stlink_reset(sl); usleep(10000); diff --git a/src/usb.h b/src/usb.h index 061042e8d..5c1f5b7ca 100644 --- a/src/usb.h +++ b/src/usb.h @@ -68,7 +68,7 @@ extern "C" { * @retval NULL Error while opening the stlink * @retval !NULL Stlink found and ready to use */ - stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq); + stlink_t *stlink_open_usb(enum ugly_loglevel verbose, int reset, char serial[STLINK_SERIAL_MAX_SIZE], int freq); size_t stlink_probe_usb(stlink_t **stdevs[]); void stlink_probe_usb_free(stlink_t **stdevs[], size_t size); diff --git a/tests/usb.c b/tests/usb.c index 5165ea563..ce72e24a5 100644 --- a/tests/usb.c +++ b/tests/usb.c @@ -1,15 +1,32 @@ #include #include +#include + +static void usage(void) +{ + puts("test-usb --reset"); + puts("test-usb --no-reset"); +} int main(int ac, char** av) { - (void)ac; - (void)av; stlink_t* sl; struct stlink_reg regs; + int reset = 0; + + if (ac == 2) { + if (strcmp(av[1], "--reset") == 0) + reset = 2; + if (strcmp(av[1], "--no-reset") == 0) + reset = 1; + } + if (reset == 0) { + usage(); + return 0; + } - sl = stlink_open_usb(10, 1, NULL, 0); + sl = stlink_open_usb(10, reset, NULL, 0); if (sl != NULL) { printf("-- version\n"); stlink_version(sl); From ce0df3ba3c3ea211f343b1b83800d7a8161792e4 Mon Sep 17 00:00:00 2001 From: Geoffrey Brown Date: Fri, 22 May 2020 17:51:17 -0400 Subject: [PATCH 227/236] removed .vscode --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index cad7657df..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "cmake.configureOnOpen": false -} \ No newline at end of file From 25d0e56161d02014f77b9efd1a3fc66ef30f27b5 Mon Sep 17 00:00:00 2001 From: Geoffrey Brown Date: Sat, 23 May 2020 16:01:12 -0400 Subject: [PATCH 228/236] Added --connect-under-reset to st-flash and st-info --- include/stlink/tools/flash.h | 3 ++- src/tools/flash_opts.c | 3 +++ src/tools/info.c | 39 +++++++++++++++++++++++++----------- src/usb.c | 10 ++++++++- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/include/stlink/tools/flash.h b/include/stlink/tools/flash.h index a912a14aa..3a4dc3ec4 100644 --- a/include/stlink/tools/flash.h +++ b/include/stlink/tools/flash.h @@ -27,9 +27,10 @@ struct flash_opts size_t flash_size; /* --flash=n[k][m] */ int opt; /* enable empty tail data drop optimization */ int freq; /* --freq=n[k][m] frequency of JTAG/SWD */ + bool connect_under_reset; }; -#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} int flash_get_opts(struct flash_opts* o, int ac, char** av); diff --git a/src/tools/flash_opts.c b/src/tools/flash_opts.c index a5c9d287f..c8d7841de 100644 --- a/src/tools/flash_opts.c +++ b/src/tools/flash_opts.c @@ -225,6 +225,9 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av) { if (result != 0) return bad_arg ("--flash"); else o->flash_size = (size_t) flash_size; } + else if (strcmp(av[0],"--connect-under-reset")== 0){ + o->connect_under_reset = true; + } else { break; // non-option found } diff --git a/src/tools/info.c b/src/tools/info.c index 45d484270..8464d8632 100644 --- a/src/tools/info.c +++ b/src/tools/info.c @@ -11,11 +11,11 @@ static void usage(void) puts("st-info --probe"); puts("st-info --serial"); puts("st-info --hla-serial"); - puts("st-info --flash"); - puts("st-info --pagesize"); - puts("st-info --sram"); - puts("st-info --chipid"); - puts("st-info --descr"); + puts("st-info --flash [--connect-under-reset]"); + puts("st-info --pagesize [--connect-under-reset]"); + puts("st-info --sram [--connect-under-reset]"); + puts("st-info --chipid [--connect-under-reset]"); + puts("st-info --descr [--connect-under-reset]"); } /* Print normal or OpenOCD hla_serial with newline */ @@ -76,19 +76,25 @@ static void stlink_probe(void) stlink_probe_usb_free(&stdevs, size); } -static stlink_t *stlink_open_first(void) +static stlink_t *stlink_open_first(bool under_reset) { stlink_t* sl = NULL; sl = stlink_v1_open(0, 1); - if (sl == NULL) - sl = stlink_open_usb(0, 1, NULL, 0); - + if (sl == NULL) { + if (under_reset) { + sl = stlink_open_usb(0, 2, NULL, 0); + } else { + sl = stlink_open_usb(0, 1, NULL, 0); + } + } + return sl; } -static int print_data(char **av) +static int print_data(int ac, char **av) { stlink_t* sl = NULL; + bool under_reset = false; // Probe needs all devices unclaimed if (strcmp(av[1], "--probe") == 0) { @@ -99,7 +105,16 @@ static int print_data(char **av) return 0; } - sl = stlink_open_first(); + if (ac == 3) { + if (strcmp(av[2],"--connect-under-reset") == 0) { + under_reset = true; + } else { + usage(); + return -1; + } + } + + sl = stlink_open_first(under_reset); if (sl == NULL) { return -1; @@ -149,7 +164,7 @@ int main(int ac, char** av) return -1; } - err = print_data(av); + err = print_data(ac,av); return err; } diff --git a/src/usb.c b/src/usb.c index 26243daa3..a711749da 100644 --- a/src/usb.c +++ b/src/usb.c @@ -1145,7 +1145,15 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, int reset, char serial[STL break; } - if (reset == 2) stlink_jtag_reset(sl,0); + if (reset == 2) { + stlink_jtag_reset(sl,0); + 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); + } + + if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE) stlink_enter_swd_mode(sl); if (reset == 1) { From fd2a5c37d4e5b7886bef1157717ea64a611b7b5a Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Mon, 25 May 2020 00:40:56 +0200 Subject: [PATCH 229/236] Minor formatting fixes & corrections --- README.md | 9 +++------ contributors.txt | 6 ++++++ doc/app-example/CMakeLists.txt | 7 ++++--- doc/app-example/README.md | 2 +- doc/app-example/main.c | 7 +++---- doc/devices_boards.md | 2 +- doc/release.md | 2 +- doc/version_support.md | 2 ++ run_clang_analyze.sh | 5 +++-- 9 files changed, 24 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b2495840d..7dc634c9c 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,13 @@ Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) o #### License -The stlink library and tools are licensed under the **[BSD-3 License](LICENSE.md)**.
-The source files **stm32l0x.s** and **stm32lx.s** found in the subdirectory `/flashloaders/` -are licensed under the **General Public License (GPL v2+)**. +The stlink library and tools are licensed under the **[BSD-3 License](LICENSE.md)**. ## Introduction STLink is an open source toolset to program and debug STM32 devices and boards manufactured by STMicroelectronics. -It supports several so called STLINK programmer boards (and clones thereof) which use a microcontroller chip -to translate commands from USB to JTAG/SWD. There are four generations available on the market: +It supports several so called STLINK programmer boards (and clones thereof) which use a microcontroller chip to translate commands from USB to JTAG/SWD. There are four generations available on the market which are _all_ supported by this toolset: * **STLINK/v1** _(obsolete as of 21-11-2019)_ - transport layer: SCSI passthru commands over USB @@ -59,7 +56,7 @@ Supported operating systems are listed in [version_support.md](doc/version_suppo ## Tutorial & HOWTO -Our [tutorial.md](doc/tutorial.md) may help you along with some advanced tasks and additional info. +Our [tutorial](doc/tutorial.md) may help you along with some advanced tasks and additional info. ## Installation diff --git a/contributors.txt b/contributors.txt index 32c8e58e3..8811da855 100644 --- a/contributors.txt +++ b/contributors.txt @@ -37,6 +37,7 @@ Ethan Zonca Fabien Chouteau Florian Hars Friedrich Beckmann +Gabriel Górski [Glaeqen] Geoffrey Brown George Talusan [gtalusan] Georg von Zengen @@ -60,6 +61,7 @@ Jerome Lambourg Jim Paris Jiří Netolický Jerry Nosky [jnosky] +Jochen Wilhelmy [Jochen0x90h] Johannes Taelman Jonas Danielsson Jonas Norling @@ -68,6 +70,7 @@ Karl Palsson [karlp] Kevlar Harness Kyle Manna Lari Lehtomäki +Lutz Freitag [nerdmaennchen] Martin Nowak Matteo Collina Max Chen @@ -76,6 +79,7 @@ Maxime Vincent Michael Pratt [prattmic] Michael Sparmann Mike Szczys +Miklós Márton [martonmiklos] Magnus Lundin [mlu] mux Ned Konz @@ -89,6 +93,7 @@ orangeudav Pavel Kirienko Pekka Nikander Pete Nelson +Peter Torelli [petertorelli] Peter Zotov Petteri Aimonen Piotr Haber @@ -99,6 +104,7 @@ Rob Spanton Rytis Karpuska Sean Simmons Sergey Alirzaev +Simon Derr [sderr] Simon Wright Stany Marcel Stefan Misik diff --git a/doc/app-example/CMakeLists.txt b/doc/app-example/CMakeLists.txt index a7697720c..5f71a5d4f 100644 --- a/doc/app-example/CMakeLists.txt +++ b/doc/app-example/CMakeLists.txt @@ -6,17 +6,18 @@ cmake_minimum_required(VERSION 3.4.2) project(st-hello) set(PROJECT_VERSION 0.1) + set(SRCS main.c) +include_directories(${STLINK_INCLUDE_DIRS}) + find_package(PkgConfig) pkg_check_modules(STLINK REQUIRED stlink) set(CMAKE_C_FLAGS " ${STLINK_CFLAGS_OTHER} -Wall -Werror") -include_directories(${STLINK_INCLUDE_DIRS}) - add_executable(${PROJECT_NAME} ${SRCS}) target_link_libraries(${PROJECT_NAME} ${STLINK_LIBRARIES}) -install(TARGETS ${PROJECT_NAME} DESTINATION bin) +install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/doc/app-example/README.md b/doc/app-example/README.md index 683056171..f3a0bf9bb 100644 --- a/doc/app-example/README.md +++ b/doc/app-example/README.md @@ -1,2 +1,2 @@ This is a simple standalone application example that uses libstlink. -You can use this as a boilerplate for your own app development +It can be used as a boilerplate for app development. diff --git a/doc/app-example/main.c b/doc/app-example/main.c index 12621434a..b8e64b259 100644 --- a/doc/app-example/main.c +++ b/doc/app-example/main.c @@ -2,8 +2,7 @@ #include #include -static stlink_t *stlink_open_first(void) -{ +static stlink_t *stlink_open_first(void) { stlink_t* sl = NULL; sl = stlink_v1_open(0, 1); if (sl == NULL) @@ -13,8 +12,7 @@ static stlink_t *stlink_open_first(void) } -int main() -{ +int main() { stlink_t* sl = NULL; sl = stlink_open_first(); @@ -25,5 +23,6 @@ int main() fprintf(stderr, "STlink device opened, that's cool!\n"); stlink_close(sl); + return 0; } diff --git a/doc/devices_boards.md b/doc/devices_boards.md index 00acdd2cf..8291f7532 100644 --- a/doc/devices_boards.md +++ b/doc/devices_boards.md @@ -53,7 +53,7 @@ Tested boards [incl. STLink programmers]: | 0x430 | XL-Density | xF XG | | F101 | | F103 | | Tested boards [incl. STLink programmers]: -* 32VL-Discovery (STM32F100RBT6) with STLink-v1 [v1, v2] +* STM32VL-Discovery (STM32F100RBT6) with STLink-v1 [v1, v2] * STM32F103-Bluepill: C8Tx & R8xx [v2] * Nucleo-F103RB [v2-1] * HY-STM32 (STM32F103VETx) [v1, v2] diff --git a/doc/release.md b/doc/release.md index 4b536d95a..b44183b80 100644 --- a/doc/release.md +++ b/doc/release.md @@ -3,7 +3,7 @@ Release This document describes the necessary steps for developers to create a release: -1. Update `CHANGELOG.md` and `cmake/packaging/deb/changelog` +1. Update `CHANGELOG.md` 2. Update `.version` with semantic version: `x.x.x` 3. Update `README.md` with semantic version `x.x.x` in commits badge 4. Create and push git tag and commits `git tag x.x.x` diff --git a/doc/version_support.md b/doc/version_support.md index f889fbc32..4d1f724f7 100644 --- a/doc/version_support.md +++ b/doc/version_support.md @@ -21,6 +21,8 @@ Thus no user interaction regarding libusb is necessary. | homebrew | 1.0.23 | 3.17.0 | 3.24.18
gtk+3 | 10.12 (Sierra)- 10.15 (Catalina) | | MacPorts | 1.0.23 | 3.17.0 | 3.24.18
gtk3 | 10.6 (Snow Leopard) - 10.15 (Catalina) | +NOTE: In order to use a STLINK/v1 programmer on macOS, versions 10.13, 10.14 or 10.15 are required. + ### Linux-/Unix-based: diff --git a/run_clang_analyze.sh b/run_clang_analyze.sh index 8d5c5a988..fd1b78b55 100755 --- a/run_clang_analyze.sh +++ b/run_clang_analyze.sh @@ -1,6 +1,7 @@ #!/bin/bash -# Run this hacky script in project root directory to start -# clang static analysis. Adjust ccc-analyzer path if nesesary +# Run this hacky script in project root directory to start clang static analysis. +# Adjust ccc-analyzer path if necessary + CCC_ANALYZER=/usr/share/clang/scan-build-3.5/ccc-analyzer mkdir -p build-clang-analyze/reports cd build-clang-analyze From 252ac0b3cc0690d8d2e26c117ca178f481e9fdb2 Mon Sep 17 00:00:00 2001 From: matthew sherwood Date: Mon, 25 May 2020 15:33:44 -0400 Subject: [PATCH 230/236] Update compiling.md neither `make release` nor `make debug` would execute properly on a fresh clone of the directory until i ran `make clean`. system is linux mint - 5.3.0-53-generic #47~18.04.1-Ubuntu SMP Thu May 7 13:10:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux --- doc/compiling.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/compiling.md b/doc/compiling.md index e20cbca83..2da79f071 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -110,8 +110,9 @@ or execute (Debian-based systems only): `apt-get install gcc build-essential cma ### 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_)
+2. Run `make clean` -- required by some linux variants. +3. Run `make release` to create the _Release_ target +4. Run `make debug` to create the _Debug_ target (_optional_)
The debug target is only necessary in order to modify the sources and to run under a debugger. The top level Makefile is just a handy wrapper for: From 230497c1a457673be20b18e6e3453a4104075133 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Tue, 26 May 2020 13:58:56 +0200 Subject: [PATCH 231/236] Updated stlink-v1 driver for macOS - Updated xcode project settings v11.3.1 - Removed support for 10.6-10.12 - Compiled new kexts for macOS 10.13-10.15 - Moved instructions to separate README - Updated installation instructions --- doc/tutorial.md | 65 +- .../Makefile | 25 +- stlinkv1_macos_driver/README.md | 50 ++ stlinkv1_macos_driver/install.sh | 22 + .../Contents/Info.plist | 82 +++ .../Contents/MacOS/stlink_shield_10_13 | Bin 0 -> 33840 bytes .../stlink_shield_10_13.kext/Contents/PkgInfo | 1 + .../Contents/_CodeSignature/CodeResources | 115 ++++ .../Contents/Info.plist | 82 +++ .../Contents/MacOS/stlink_shield_10_14 | Bin 0 -> 33840 bytes .../stlink_shield_10_14.kext/Contents/PkgInfo | 1 + .../Contents/_CodeSignature/CodeResources | 115 ++++ .../Contents/Info.plist | 82 +++ .../Contents/MacOS/stlink_shield_10_15 | Bin 0 -> 33840 bytes .../stlink_shield_10_15.kext/Contents/PkgInfo | 1 + .../Contents/_CodeSignature/CodeResources | 115 ++++ .../stlink_shield_xcode/Info.plist | 60 ++ .../stlink_shield.xcodeproj/project.pbxproj | 613 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../UserInterfaceState.xcuserstate | Bin 0 -> 185319 bytes .../WorkspaceSettings.xcsettings | 22 + .../xcschemes/stlink_shield_10.13.xcscheme | 67 ++ .../xcschemes/stlink_shield_10.14.xcscheme | 67 ++ .../xcschemes/stlink_shield_10.15.xcscheme | 67 ++ .../xcschemes/xcschememanagement.plist | 67 ++ stlinkv1_macosx_driver/README.md | 47 -- stlinkv1_macosx_driver/osx.tar.gz | Bin 23580 -> 0 bytes 29 files changed, 1666 insertions(+), 123 deletions(-) rename {stlinkv1_macosx_driver => stlinkv1_macos_driver}/Makefile (74%) create mode 100644 stlinkv1_macos_driver/README.md create mode 100644 stlinkv1_macos_driver/install.sh create mode 100644 stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/Info.plist create mode 100644 stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/MacOS/stlink_shield_10_13 create mode 100644 stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/PkgInfo create mode 100644 stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/_CodeSignature/CodeResources create mode 100644 stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/Info.plist create mode 100644 stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/MacOS/stlink_shield_10_14 create mode 100644 stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/PkgInfo create mode 100644 stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/_CodeSignature/CodeResources create mode 100644 stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/Info.plist create mode 100644 stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/MacOS/stlink_shield_10_15 create mode 100644 stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/PkgInfo create mode 100644 stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/_CodeSignature/CodeResources create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/Info.plist create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.pbxproj create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/UserInterfaceState.xcuserstate create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/WorkspaceSettings.xcsettings create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.13.xcscheme create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.14.xcscheme create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.15.xcscheme create mode 100644 stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcuserdata/vm-user.xcuserdatad/xcschemes/xcschememanagement.plist delete mode 100644 stlinkv1_macosx_driver/README.md delete mode 100644 stlinkv1_macosx_driver/osx.tar.gz diff --git a/doc/tutorial.md b/doc/tutorial.md index 694142184..81315dbef 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -29,70 +29,7 @@ Within the GUI main window tooltips explain the available user elements. ## Solutions to common problems -### a) STLINK/v1 driver: Issue with Kernel Extension (kext) (macOS 10.11 and later only) -#### Problem: - -st-util fails to detect a STLINK/v1 device: - -``` -st-util -1 -st-util $VERSION-STRING$ -WARN src/sg.c: Failed to find an stlink v1 by VID:PID -ERROR src/sg.c: Could not open stlink device -``` - -#### Solution (clean setup): - -1) Configure System Integrity Protection (SIP) - -The root of this problem is a system security setting introduced by Apple with OS X El Capitan (10.11) in 2015. -The so called System Integrity Protection (SIP) is active per default -and prevents the operating system amongst other things to load unsigned Kernel Extension Modules (kext). -Thus the STLINK/v1 driver supplied with the tools, which installs as a kext, remains not functional, -while SIP is fully activated (as is per default). - -Action needs to be taken here by booting into the recovery mode where a terminal console window needs to be opened. - -For macOS 10.11 - 10.13 it is not recommended to disable SIP completely as with the command `csrutil disable`, -because this leaves the system more vulnerable to common threats. -Instead there is a more adequate and reasonable option implemented by Apple. -Running `csrutil enable --without kext`, allows to load unsigned kernel extensions -while leaving SIP active with all other security features. -Unfortunately this option has been removed in macOS 10.14, which leaves the only option to disable SIP completely. - -So who ever intends to run the STLINK/v1 programmer on macOS please take this into account. - -Further details can be found here: https://forums.developer.apple.com/thread/17452 - -2) Install the ST-Link-v1 driver from the subdirectory `/stlinkv1_macosx_driver` - by referring to the instructions in the README file available there. - -3) Move the $OS_VERSION$.kext file to `/System/Library/Extensions`. - -4) Load the Kernel Extension (kext): `$ sudo kextload -v /System/Library/Extensions/stlink_shield10_x.kext` - -``` -Requesting load of /System/Library/Extensions/stlink_shield10_x.kext. -/System/Library/Extensions/stlink_shield10_x.kext loaded successfully (or already loaded). -``` - -5) Enter the command `$ sudo touch /System/Library/Extensions` - - -7) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` - -You should then see a similar output like in this example: - -``` -INFO common.c: Loading device parameters.... -INFO common.c: Device connected is: F1 High-density device, id 0x10036414 -INFO common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 2048 bytes -INFO sg.c: Successfully opened a stlink v1 debugger -INFO gdb-server.c: Chip ID is 00000414, Core ID is 1ba01477. -INFO gdb-server.c: Listening at *:4242... -``` - -### b) Verify if udev rules are set correctly (by Dave Hylands) +### a) Verify if udev rules are set correctly (by Dave Hylands) To investigate, start by plugging your STLINK device into the usb port. Then run `lsusb`. You should see an entry something like the following: diff --git a/stlinkv1_macosx_driver/Makefile b/stlinkv1_macos_driver/Makefile similarity index 74% rename from stlinkv1_macosx_driver/Makefile rename to stlinkv1_macos_driver/Makefile index 9947ff672..e6ba6309b 100644 --- a/stlinkv1_macosx_driver/Makefile +++ b/stlinkv1_macos_driver/Makefile @@ -1,15 +1,17 @@ -# make ... for both stlink v1 and stlink v2 support -## +### +# Makefile for STlink-v1 support +### + VPATH=src -SOURCES_LIB=stlink-common.c stlink-usb.c stlink-sg.c uglylogging.c +SOURCES_LIB=common.c usb.c sg.c logging.c OBJS_LIB=$(SOURCES_LIB:.c=.o) -TEST_PROGRAMS=test_usb test_sg +TEST_PROGRAMS=test-flash test-sg test-usb LDFLAGS=-L. -lstlink -lusb-1.0 CFLAGS+=-g CFLAGS+=-DDEBUG=1 -CFLAGS+=-std=gnu99 +CFLAGS+=-std=gnu11 CFLAGS+=-Wall -Wextra @@ -20,8 +22,8 @@ all: $(LIBRARY) flash gdbserver $(TEST_PROGRAMS) $(LIBRARY): $(OBJS_LIB) @echo "objs are $(OBJS_LIB)" $(AR) -cr $@ $^ - @echo "done making library" - + @echo "Compilation of library completed." + test_sg: test_sg.o $(LIBRARY) @echo "building test_sg" @@ -40,18 +42,17 @@ test_usb: test_usb.o $(LIBRARY) clean: rm -rf $(OBJS_LIB) rm -rf $(LIBRARY) - rm -rf test_usb* - rm -rf test_sg* + rm -rf test-flash* test-sg* test-usb* $(MAKE) -C flash clean $(MAKE) -C gdbserver clean - + flash: $(MAKE) -C flash gdbserver: $(MAKE) -C gdbserver CONFIG_USE_LIBSG="$(CONFIG_USE_LIBSG)" -osx_stlink_shield: - ./osx/install.sh +macos_stlink_shield: + ./install.sh .PHONY: clean all flash gdbserver diff --git a/stlinkv1_macos_driver/README.md b/stlinkv1_macos_driver/README.md new file mode 100644 index 000000000..ca4a3da30 --- /dev/null +++ b/stlinkv1_macos_driver/README.md @@ -0,0 +1,50 @@ +### +# Installation instructions for STLINK/v1 driver +### + +When connecting to the STLINK/v1 on macOS via USB, the system claims the programmer as a SCSI device. Thus libusb is not able to initialise and establish a connection to it. To solve this issue Marco Cassinerio (marco.cassinerio@gmail.com) has created a so called "codeless driver" which claims the device. It is of higher priority then the default apple mass storage driver, what allows the device to be accessed through libusb. + +To make use of this alternative approach one needs to go through the following steps: + +1) Install the macOS Kernel Extension (kext): + - Open a terminal console and navigate to this subdirectory `/stlinkv1_macos_driver` + - Use the command ```sudo sh ./install.sh``` to install the appropiate kext for your system version. + +2) Install the ST-Link-v1 driver from this subdirectory `/stlinkv1_macos_driver` by executing: ```sudo make osx_stlink_shield```. This should result in the following output: + +``` +Requesting load of /System/Library/Extensions/stlink_shield.kext. +/System/Library/Extensions/stlink_shield.kext loaded successfully (or already loaded). +``` + +3) Configure System Integrity Protection (SIP) + +The above system security setting introduced by Apple with OS X El Capitan (10.11) in 2015 is active per default +and prevents the operating system amongst other things to load unsigned Kernel Extension Modules (kext). +Thus the STLINK/v1 driver supplied with the tools, which installs as a kext, remains not functional, +until SIP is fully deactivated. + +Without SIP-deactivation, st-util fails to detect a STLINK/v1 device: + +``` +st-util -1 +st-util $VERSION-STRING$ +WARN src/sg.c: Failed to find an stlink v1 by VID:PID +ERROR src/sg.c: Could not open stlink device +``` + +In order to deactivate SIP, boot into the recovery mode and run ```csrutil disable``` in a terminal console window. + +4) Reboot the system. + +5) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` +You should then see a similar output like in this example: + +``` +INFO common.c: Loading device parameters.... +INFO common.c: Device connected is: F1 High-density device, id 0x10036414 +INFO common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 2048 bytes +INFO sg.c: Successfully opened a stlink v1 debugger +INFO gdb-server.c: Chip ID is 00000414, Core ID is 1ba01477. +INFO gdb-server.c: Listening at *:4242... +``` diff --git a/stlinkv1_macos_driver/install.sh b/stlinkv1_macos_driver/install.sh new file mode 100644 index 000000000..9e5f8d813 --- /dev/null +++ b/stlinkv1_macos_driver/install.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +ISMACOS=$(sw_vers -productVersion) +case $ISMACOS in +10.13*) + KEXT="stlink_shield_10_13.kext" + ;; +10.14*) + KEXT="stlink_shield_10_14.kext" + ;; +10.15*) + KEXT="stlink_shield_10_15.kext" + ;; +*) + echo "OS X version not supported." + exit 1 + ;; +esac +chown -R root:wheel $KEXT/ +cp -R $KEXT /System/Library/Extensions/stlink_shield.kext +kextload -v /System/Library/Extensions/stlink_shield.kext +touch /System/Library/Extensions diff --git a/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/Info.plist b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/Info.plist new file mode 100644 index 000000000..fc759b362 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/Info.plist @@ -0,0 +1,82 @@ + + + + + BuildMachineOSBuild + 18G4032 + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.libusb.stlink-shield + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + KEXT + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0.0 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 11C504 + DTPlatformVersion + GM + DTSDKBuild + 19B90 + DTSDKName + macosx10.15 + DTXcode + 1130 + DTXcodeBuild + 11C504 + IOKitPersonalities + + DeviceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBDevice + bcdDevice + 256 + idProduct + 14148 + idVendor + 1155 + + InterfaceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBInterface + bConfigurationValue + 1 + bInterfaceNumber + 0 + idProduct + 14148 + idVendor + 1155 + + + LSMinimumSystemVersion + 10.13 + OSBundleLibraries + + com.apple.iokit.IOUSBFamily + 1.8 + com.apple.kpi.libkern + 11.2.0 + + + diff --git a/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/MacOS/stlink_shield_10_13 b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/MacOS/stlink_shield_10_13 new file mode 100644 index 0000000000000000000000000000000000000000..161c0a829359293dc1189621a2d41dbdc31ab5ad GIT binary patch literal 33840 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 literal 0 HcmV?d00001 diff --git a/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/PkgInfo b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/PkgInfo new file mode 100644 index 000000000..bdab95bcc --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/PkgInfo @@ -0,0 +1 @@ +KEXT???? \ No newline at end of file diff --git a/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/_CodeSignature/CodeResources b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/_CodeSignature/CodeResources new file mode 100644 index 000000000..d5d0fd744 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_10_13.kext/Contents/_CodeSignature/CodeResources @@ -0,0 +1,115 @@ + + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/Info.plist b/stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/Info.plist new file mode 100644 index 000000000..d43deca2b --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/Info.plist @@ -0,0 +1,82 @@ + + + + + BuildMachineOSBuild + 18G4032 + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.libusb.stlink-shield + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + KEXT + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0.0 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 11C504 + DTPlatformVersion + GM + DTSDKBuild + 19B90 + DTSDKName + macosx10.15 + DTXcode + 1130 + DTXcodeBuild + 11C504 + IOKitPersonalities + + DeviceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBDevice + bcdDevice + 256 + idProduct + 14148 + idVendor + 1155 + + InterfaceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBInterface + bConfigurationValue + 1 + bInterfaceNumber + 0 + idProduct + 14148 + idVendor + 1155 + + + LSMinimumSystemVersion + 10.14 + OSBundleLibraries + + com.apple.iokit.IOUSBFamily + 1.8 + com.apple.kpi.libkern + 11.2.0 + + + diff --git a/stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/MacOS/stlink_shield_10_14 b/stlinkv1_macos_driver/stlink_shield_10_14.kext/Contents/MacOS/stlink_shield_10_14 new file mode 100644 index 0000000000000000000000000000000000000000..a49757ef1fc67fcaeb819c141550efa3f275928a GIT binary patch literal 33840 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 + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/Info.plist b/stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/Info.plist new file mode 100644 index 000000000..a2a5f8ac2 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/Info.plist @@ -0,0 +1,82 @@ + + + + + BuildMachineOSBuild + 18G4032 + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.libusb.stlink-shield + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + KEXT + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1.0.0 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 11C504 + DTPlatformVersion + GM + DTSDKBuild + 19B90 + DTSDKName + macosx10.15 + DTXcode + 1130 + DTXcodeBuild + 11C504 + IOKitPersonalities + + DeviceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBDevice + bcdDevice + 256 + idProduct + 14148 + idVendor + 1155 + + InterfaceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBInterface + bConfigurationValue + 1 + bInterfaceNumber + 0 + idProduct + 14148 + idVendor + 1155 + + + LSMinimumSystemVersion + 10.15 + OSBundleLibraries + + com.apple.iokit.IOUSBFamily + 1.8 + com.apple.kpi.libkern + 11.2.0 + + + diff --git a/stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/MacOS/stlink_shield_10_15 b/stlinkv1_macos_driver/stlink_shield_10_15.kext/Contents/MacOS/stlink_shield_10_15 new file mode 100644 index 0000000000000000000000000000000000000000..4e64961ae1a6cb922efe525978510783165de57f GIT binary patch literal 33840 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 + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/Info.plist b/stlinkv1_macos_driver/stlink_shield_xcode/Info.plist new file mode 100644 index 000000000..b0a0228d8 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/Info.plist @@ -0,0 +1,60 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + KEXT + CFBundleSignature + ???? + CFBundleVersion + 1.0.0 + IOKitPersonalities + + DeviceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBDevice + bcdDevice + 256 + idProduct + 14148 + idVendor + 1155 + + InterfaceDriver + + CFBundleIdentifier + com.apple.kpi.iokit + IOClass + IOService + IOProviderClass + IOUSBInterface + bConfigurationValue + 1 + bInterfaceNumber + 0 + idProduct + 14148 + idVendor + 1155 + + + OSBundleLibraries + + com.apple.iokit.IOUSBFamily + 1.8 + com.apple.kpi.libkern + 11.2.0 + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.pbxproj b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.pbxproj new file mode 100644 index 000000000..23dc192d8 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.pbxproj @@ -0,0 +1,613 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXFileReference section */ + 8CD33C31149BB80D0033D618 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 8F9084F124786F0B009109AD /* stlink_shield_10_13.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = stlink_shield_10_13.kext; sourceTree = BUILT_PRODUCTS_DIR; }; + 8F9084FD24786F0F009109AD /* stlink_shield_10_14.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = stlink_shield_10_14.kext; sourceTree = BUILT_PRODUCTS_DIR; }; + 8F90850924786F39009109AD /* stlink_shield_10_15.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = stlink_shield_10_15.kext; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* NanosMouse */ = { + isa = PBXGroup; + children = ( + 089C167CFE841241C02AAC07 /* Resources */, + 19C28FB6FE9D52B211CA2CBB /* Products */, + ); + name = NanosMouse; + sourceTree = ""; + usesTabs = 0; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 8CD33C31149BB80D0033D618 /* Info.plist */, + ); + name = Resources; + sourceTree = ""; + }; + 19C28FB6FE9D52B211CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8F9084F124786F0B009109AD /* stlink_shield_10_13.kext */, + 8F9084FD24786F0F009109AD /* stlink_shield_10_14.kext */, + 8F90850924786F39009109AD /* stlink_shield_10_15.kext */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8F9084E924786F0B009109AD /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F9084F524786F0F009109AD /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F90850124786F39009109AD /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8F9084E724786F0B009109AD /* stlink_shield_10_13 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8F9084EE24786F0B009109AD /* Build configuration list for PBXNativeTarget "stlink_shield_10_13" */; + buildPhases = ( + 8F9084E824786F0B009109AD /* ShellScript */, + 8F9084E924786F0B009109AD /* Headers */, + 8F9084EA24786F0B009109AD /* Resources */, + 8F9084EC24786F0B009109AD /* Sources */, + 8F9084ED24786F0B009109AD /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = stlink_shield_10_13; + productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Extensions"; + productName = NanosMouse; + productReference = 8F9084F124786F0B009109AD /* stlink_shield_10_13.kext */; + productType = "com.apple.product-type.kernel-extension.iokit"; + }; + 8F9084F324786F0F009109AD /* stlink_shield_10_14 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8F9084FA24786F0F009109AD /* Build configuration list for PBXNativeTarget "stlink_shield_10_14" */; + buildPhases = ( + 8F9084F424786F0F009109AD /* ShellScript */, + 8F9084F524786F0F009109AD /* Headers */, + 8F9084F624786F0F009109AD /* Resources */, + 8F9084F824786F0F009109AD /* Sources */, + 8F9084F924786F0F009109AD /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = stlink_shield_10_14; + productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Extensions"; + productName = NanosMouse; + productReference = 8F9084FD24786F0F009109AD /* stlink_shield_10_14.kext */; + productType = "com.apple.product-type.kernel-extension.iokit"; + }; + 8F9084FF24786F39009109AD /* stlink_shield_10_15 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8F90850624786F39009109AD /* Build configuration list for PBXNativeTarget "stlink_shield_10_15" */; + buildPhases = ( + 8F90850024786F39009109AD /* ShellScript */, + 8F90850124786F39009109AD /* Headers */, + 8F90850224786F39009109AD /* Resources */, + 8F90850424786F39009109AD /* Sources */, + 8F90850524786F39009109AD /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = stlink_shield_10_15; + productInstallPath = "$(SYSTEM_LIBRARY_DIR)/Extensions"; + productName = NanosMouse; + productReference = 8F90850924786F39009109AD /* stlink_shield_10_15.kext */; + productType = "com.apple.product-type.kernel-extension.iokit"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = "stlink-org"; + }; + buildConfigurationList = 3EEA308708D71E4B002CBB49 /* Build configuration list for PBXProject "stlink_shield" */; + compatibilityVersion = "Xcode 11.0"; + developmentRegion = en; + hasScannedForEncodings = 1; + knownRegions = ( + en, + ); + mainGroup = 089C166AFE841209C02AAC07 /* NanosMouse */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8F9084E724786F0B009109AD /* stlink_shield_10_13 */, + 8F9084F324786F0F009109AD /* stlink_shield_10_14 */, + 8F9084FF24786F39009109AD /* stlink_shield_10_15 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8F9084EA24786F0B009109AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F9084F624786F0F009109AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F90850224786F39009109AD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 8F9084E824786F0B009109AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPreprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi\n"; + }; + 8F9084ED24786F0B009109AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPostprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi\n"; + }; + 8F9084F424786F0F009109AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPreprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; + }; + 8F9084F924786F0F009109AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPostprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; + }; + 8F90850024786F39009109AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPreprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; + }; + 8F90850524786F39009109AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "script=\"${SYSTEM_DEVELOPER_DIR}/ProjectBuilder Extras/Kernel Extension Support/KEXTPostprocess\";\nif [ -x \"$script\" ]; then\n . \"$script\"\nfi"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8F9084EC24786F0B009109AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F9084F824786F0F009109AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F90850424786F39009109AD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 3EEA308808D71E4B002CBB49 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + APPLY_RULES_IN_COPY_FILES = YES; + APPLY_RULES_IN_COPY_HEADERS = YES; + CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; + CLANG_ANALYZER_GCD_PERFORMANCE = YES; + CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_STATIC_ANALYZER_MODE = deep; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_ATOMIC_IMPLICIT_SEQ_CST = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_CXX0X_EXTENSIONS = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_FLOAT_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_INTERFACE_IVARS = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + COPY_HEADERS_RUN_UNIFDEF = YES; + CREATE_INFOPLIST_SECTION_IN_BINARY = YES; + DEAD_CODE_STRIPPING = YES; + DEFINES_MODULE = YES; + DEPLOYMENT_LOCATION = YES; + DEPLOYMENT_POSTPROCESSING = YES; + DONT_GENERATE_INFOPLIST_FILE = NO; + DRIVERKIT_DEPLOYMENT_TARGET = 19.0; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_PREVIEWS = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = YES; + GCC_ENABLE_KERNEL_DEVELOPMENT = YES; + GCC_ENABLE_TRIGRAPHS = YES; + GCC_FAST_MATH = YES; + GCC_INCREASE_PRECOMPILED_HEADER_SHARING = YES; + GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_SHORT_ENUMS = YES; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_UNROLL_LOOPS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + GENERATE_MASTER_OBJECT_FILE = YES; + GENERATE_PKGINFO_FILE = YES; + GENERATE_PROFILING_CODE = YES; + GENERATE_TEXT_BASED_STUBS = YES; + INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; + INFOPLIST_OUTPUT_FORMAT = XML; + INFOPLIST_PREPROCESS = YES; + INLINE_PRIVATE_FRAMEWORKS = YES; + KEEP_PRIVATE_EXTERNS = YES; + LD_GENERATE_MAP_FILE = YES; + LINKER_DISPLAYS_MANGLED_NAMES = YES; + MODULE_NAME = com.libusb.stlink_shield; + MODULE_VERSION = 1.0; + PLIST_FILE_OUTPUT_FORMAT = XML; + PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.libusb.stlink-shield"; + RUN_CLANG_STATIC_ANALYZER = YES; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + SEPARATE_SYMBOL_EDIT = YES; + SUPPORTS_TEXT_BASED_API = YES; + TAPI_VERIFY_MODE = Pedantic; + VALIDATE_PRODUCT = YES; + VALIDATE_WORKSPACE = YES; + VERSIONING_SYSTEM = "apple-generic"; + WRAPPER_EXTENSION = kext; + }; + name = Debug; + }; + 3EEA308908D71E4B002CBB49 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + APPLICATION_EXTENSION_API_ONLY = YES; + APPLY_RULES_IN_COPY_FILES = YES; + APPLY_RULES_IN_COPY_HEADERS = YES; + CLANG_ADDRESS_SANITIZER_CONTAINER_OVERFLOW = YES; + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; + CLANG_ANALYZER_GCD_PERFORMANCE = YES; + CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = YES; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_STATIC_ANALYZER_MODE = deep; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES; + CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_ATOMIC_IMPLICIT_SEQ_CST = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_CXX0X_EXTENSIONS = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_FLOAT_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_INTERFACE_IVARS = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; + CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SEMICOLON_BEFORE_METHOD_BODY = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; + CODE_SIGN_IDENTITY = "-"; + COMBINE_HIDPI_IMAGES = YES; + COPY_HEADERS_RUN_UNIFDEF = YES; + CREATE_INFOPLIST_SECTION_IN_BINARY = YES; + DEAD_CODE_STRIPPING = YES; + DEFINES_MODULE = YES; + DEPLOYMENT_LOCATION = YES; + DEPLOYMENT_POSTPROCESSING = YES; + DONT_GENERATE_INFOPLIST_FILE = NO; + DRIVERKIT_DEPLOYMENT_TARGET = 19.0; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_PREVIEWS = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_CHAR_IS_UNSIGNED_CHAR = YES; + GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = YES; + GCC_ENABLE_KERNEL_DEVELOPMENT = YES; + GCC_ENABLE_TRIGRAPHS = YES; + GCC_FAST_MATH = YES; + GCC_INCREASE_PRECOMPILED_HEADER_SHARING = YES; + GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_SHORT_ENUMS = YES; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_UNROLL_LOOPS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; + GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNKNOWN_PRAGMAS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_LABEL = YES; + GCC_WARN_UNUSED_PARAMETER = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + GENERATE_MASTER_OBJECT_FILE = YES; + GENERATE_PKGINFO_FILE = YES; + GENERATE_PROFILING_CODE = YES; + GENERATE_TEXT_BASED_STUBS = YES; + INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; + INFOPLIST_OUTPUT_FORMAT = XML; + INFOPLIST_PREPROCESS = YES; + INLINE_PRIVATE_FRAMEWORKS = YES; + KEEP_PRIVATE_EXTERNS = YES; + LD_GENERATE_MAP_FILE = YES; + LINKER_DISPLAYS_MANGLED_NAMES = YES; + MODULE_NAME = com.libusb.stlink_shield; + MODULE_VERSION = 1.0; + PLIST_FILE_OUTPUT_FORMAT = XML; + PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES; + PRODUCT_BUNDLE_IDENTIFIER = "com.libusb.stlink-shield"; + RUN_CLANG_STATIC_ANALYZER = YES; + SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES; + SEPARATE_SYMBOL_EDIT = YES; + SUPPORTS_TEXT_BASED_API = YES; + TAPI_VERIFY_MODE = Pedantic; + VALIDATE_PRODUCT = YES; + VALIDATE_WORKSPACE = YES; + VERSIONING_SYSTEM = "apple-generic"; + WRAPPER_EXTENSION = kext; + }; + name = Release; + }; + 8F9084EF24786F0B009109AD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + MACOSX_DEPLOYMENT_TARGET = 10.13; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 8F9084F024786F0B009109AD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + MACOSX_DEPLOYMENT_TARGET = 10.13; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 8F9084FB24786F0F009109AD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 8F9084FC24786F0F009109AD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 8F90850724786F39009109AD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 8F90850824786F39009109AD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_IDENTITY = "-"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3EEA308708D71E4B002CBB49 /* Build configuration list for PBXProject "stlink_shield" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3EEA308808D71E4B002CBB49 /* Debug */, + 3EEA308908D71E4B002CBB49 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8F9084EE24786F0B009109AD /* Build configuration list for PBXNativeTarget "stlink_shield_10_13" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8F9084EF24786F0B009109AD /* Debug */, + 8F9084F024786F0B009109AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8F9084FA24786F0F009109AD /* Build configuration list for PBXNativeTarget "stlink_shield_10_14" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8F9084FB24786F0F009109AD /* Debug */, + 8F9084FC24786F0F009109AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8F90850624786F39009109AD /* Build configuration list for PBXNativeTarget "stlink_shield_10_15" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8F90850724786F39009109AD /* Debug */, + 8F90850824786F39009109AD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..f9b0d7c5e --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/UserInterfaceState.xcuserstate b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000000000000000000000000000000000000..b06818d2f7b3b1cd51b2e0589a4382c7af8c7b30 GIT binary patch literal 185319 zcmeEv2Y3@l)9~%8oKBKuHB@X#Rxu?MW78o(kZlm4&LxN�S327Hl5@)y@&Lk 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

Lua8Nv+ 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 literal 0 HcmV?d00001 diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/WorkspaceSettings.xcsettings b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 000000000..e097e4fe6 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/project.xcworkspace/xcuserdata/vm-user.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,22 @@ + + + + + BuildLocationStyle + UseAppPreferences + CustomBuildIntermediatesPath + Build/Intermediates.noindex + CustomBuildLocationType + RelativeToDerivedData + CustomBuildProductsPath + Build/Products + DerivedDataLocationStyle + Default + IssueFilterStyle + ShowActiveSchemeOnly + LiveSourceIssuesEnabled + + SharedBuildFolderName + Build + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.13.xcscheme b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.13.xcscheme new file mode 100644 index 000000000..d98dd9b97 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.13.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.14.xcscheme b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.14.xcscheme new file mode 100644 index 000000000..79299d7a5 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.14.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.15.xcscheme b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.15.xcscheme new file mode 100644 index 000000000..e72a90366 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcshareddata/xcschemes/stlink_shield_10.15.xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcuserdata/vm-user.xcuserdatad/xcschemes/xcschememanagement.plist b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcuserdata/vm-user.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 000000000..d23112ec9 --- /dev/null +++ b/stlinkv1_macos_driver/stlink_shield_xcode/stlink_shield.xcodeproj/xcuserdata/vm-user.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,67 @@ + + + + + SchemeUserState + + stlink_shield 10.7.xcscheme_^#shared#^_ + + orderHint + 2 + + stlink_shield copy copy.xcscheme_^#shared#^_ + + orderHint + 3 + + stlink_shield copy.xcscheme_^#shared#^_ + + orderHint + 2 + + stlink_shield.xcscheme_^#shared#^_ + + orderHint + 1 + + stlink_shield_10.13.xcscheme_^#shared#^_ + + orderHint + 0 + + stlink_shield_10.14 copy.xcscheme_^#shared#^_ + + orderHint + 4 + + stlink_shield_10.14.xcscheme_^#shared#^_ + + orderHint + 1 + + stlink_shield_10.15.xcscheme_^#shared#^_ + + orderHint + 2 + + + SuppressBuildableAutocreation + + 8F9084E724786F0B009109AD + + primary + + + 8F9084F324786F0F009109AD + + primary + + + 8F9084FF24786F39009109AD + + primary + + + + + diff --git a/stlinkv1_macosx_driver/README.md b/stlinkv1_macosx_driver/README.md deleted file mode 100644 index b2a68442c..000000000 --- a/stlinkv1_macosx_driver/README.md +++ /dev/null @@ -1,47 +0,0 @@ -from: marco.cassinerio@gmail.com - -to: texane@gmail.com - -Hi, - -i managed to get the stlink v1 working under os x and i would like to share the solution so maybe you can add it in your package. -The problem is that os x claims the device as scsi and libusb won't be able to connect to it. -I've created what is called a codeless driver which claims the device and has a higher priority then the default apple mass storage driver, so the device can be accessed through libusb. - -I tested this codeless driver under OS X 10.6.8 and 10.7.2. -I assume it works with any 10.6.x and 10.7.x version as well. - -Attached to this mail you'll find the osx folder with the source code of the driver, both drivers (for 10.6.x and 10.7.x), an install.sh script and the modified Makefile, i only added a line at the end which invoke the `install.sh`. - -First, unpack the `osx.tar.gz` contents: -```bash -tar xzvf osx.tar.gz -``` - -Then, install the driver using: -```bash -sudo make osx_stlink_shield -``` - -no reboot required. - -P.S. If error `OS X version not supported` occurs. For the latest versions of Mac OS X you may need to change the `osx/install.sh` as follows: -```bash -< ISOSXLION=$(sw_vers -productVersion) ---- -> ISOSXLION=$(sw_vers -productVersion | sed -e 's:.[[:digit:]]*$::') -``` - -### OS X 10.10 Yosemite - -For OS X 10.10 Yosemite you must force the system to load unsigned kernelextensions - -```bash -sudo nvram boot-args="kext-dev-mode=1" -``` - -reboot the system! - -### OS X 10.11 El Capitan - -For OS X 10.11 El Capitan: the Yosemite kext seems to work (tested on 10.11.04). diff --git a/stlinkv1_macosx_driver/osx.tar.gz b/stlinkv1_macosx_driver/osx.tar.gz deleted file mode 100644 index 57bc314668c66f849b8fdcd50a5e38a430cac624..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23580 zcmZ^~V|1o5`z>DEwx-6^wr$&(+HRk^Q`@%fsohR(d#b7J=Q;Df=l93?aK2p0o$QsJ zmE2itCu?7%F>qjVE`l0hkXOB1$rQ5bWHQUkk6N!XQ>#Cx6*{J;bkKR#({N$C2{kON zsBjiN@W5@{0Dwt<6aJ5F9AjSFQ)jOH{o6Zjr-{7(jCu_VQppgxx;)l)U^OJx%+G}$b~H7vx@ zsC1JaV+)CYnb9(xB2I-@KLXtCy|R&DO-dFB1X_uK4@s1;W5R1wn*6=9LoQdLso-Bl zHMaM!@?*B2nzA8x+Lq{J#sV@96z71T(eARwFPRNX_jLL5ME=>F6R1CleF2j8>L^wLX3#<968KIOZoH!jE zHL(48y8sNsd|`jZlo`*T_DjFA{p3_&zhUp47H~_$zv=%ia5sXf{4Xq#EMnfjYKCl| zM$zO89fZAxiWKZEoElF&zz2X3-#;zM<{Hk`3+Ham9+>~Ug$;d$2mxdZ`itj`mn!}T znZi~_v;68UCLbuqluENKdMEJ@-fqjLED)duzi|yf#`&ON2hS0->EF7Ya^@jbc#mfn zEd-<>r6;jbe1-sL2Ko8jQgju*m(31zL1g?MDh}o`#IS5*!{H-uDZDSAh3~thy=Vr-7aOy{a!Mvk%Zm`&;N$ z2FT<0JK^Q?9u+8W(|EnwS31!C)-JOW}LFS*}<-q|<$ z4>c(%dKDW!`VE|fd;ZVeZ{xeLTX~2T>}&YnVPn>AEiV;>h4FRV^k1i8vB#D$Wv9;z z3IqZy`>q00@|dZQ&OdfPZS9pKlGm5qZh~uDXnxiR0OC#J=I(I0I?*ASYay9O24XG- zVpyGJ4Pa5h29eJ8QkZ36{G5;Bbf?*c6Z_E1XT>s^t=Y#7*N2HFE%st@L;hgf%+(FT zTYU0hD{X~b@Wku^dYZ4IZt>}b0c@E?dw00xdtG_Vmlys4+g?mBTu!@;mvr>j`KX$h zYqwBe>@KxM&hMsExro-hoq8#!fBH^ol_TYUf+9~wz?C2!+<=jnpjArE<5NI9zu%y&c z!z4xp$eeQZmGFfV7(x5DIAYv5`R$eTThmzoE!r4p{j(qeFe3Bo^zQV1PjxZ-u7O9L z1swMwk4CKeuHwC)@h`+@$cV0(s1M6>DZ5 z3;j`;1p+A$2;!lO1A#yjXbE4S3>3=&P=f2H(=9I5F-^@L=;(I`fZaL5vp)Pp_r)_J zp+wsFP&PA%dHdL;$^B}nNRU8zJf?|#CeAcDf7d5Du$T_{>qhE}@Z2~_;+q_(dG-q= zEo%%qIPpE?ZS0?v<7H)7cZa{uxs-glY)$+c?w~OSm2cL%@3kp_&p{S>sMfF1i#>A` zFq8kCKCRiQp08fxGX!`3^I-Lj!J+{tX5;4JErC>6jR3}0D(Jy~%EPL?yR#0mS$!gr z@Oy+VZG;J`CTt*aJZy}Ua(>{~Zr@kCtCo>cBxbiQppj6}j%t12He z<-VhK(C=bViikNIu?~{b@*-kyno3vXX#-{URKsZ;hs!hpc9jhl({>uj z#YYB(B4sAfSabb4T+OUamgD>NqjGPO!$+9#bZqwHjzXoZ!l;ZM(@rSiw4Rf{J%)bh zH{{aQu(wTjln*nXR+nB8dex}&)qkoVH}$~!iUqswmoCs9L|iRGcE zy+VB4(lUvIDfQ^WzY=73J4UQ497=wxKZFOJC{=QIyx4}8*V|4lzv?X$n}7A8LpXKO zH}lu@P6*cJ3Ea}wbAmR>vQr{k9~q0Jl<2yT{lZtE%P_8Ac{|($Aa!374CDAh5@sw= zfpLu3T3;BRO4ecR}jq43yA&I=yPjUZcEG-B6WX|$GiHS|D zvd*0*Gd~zc1N>gkBL92_&v&#!>F3F!6M*)P-`^wfCmcLAu!=ZXAV&ZvP3as}F$SB( zd~HbPol0ew4#F20Il(Wgr(%zf#Y|e z5<}zc>NA)-kXz>fg>8oCFTnGFAeQo3-qH%NFXRSLwP4Pq_?;Zv-E5|Y{p zL69Gy&wran0=nb*k#V=z4Voha`~k85BaR*U`VX-eXt<9k2pmXCk%R_9-35`w3_!eo zp^nQ`jRB-#O@crzW5%qpXRpIhJX|1<#5ic-4fK2J&cfRfxqeKYFl*BMPiBmF%W|^X z{D-U%%Qde+>uKX=9nV_JUD%E|P-6h?VcX*VfR8&3P@`I+<% z1U+tyF8Q>63J_kn17!eCuKSgFM{htgPp&IU4K2^$Cd9doHMp^w$~m&$NDQE7!fvh?X*g3$-DmtQspD!HUK8NDCNz?mChsaTL#%H zDd^=HuRhP#qtgJ1Eer78ac^wOp>K|N{nOMF+kO-z5IFbnA3?Tb>?=mn|IYoQkDTv) zcn(fILJIZ%87~A9%U3@8_$TFIAPe}?_11tj2NQ;!dJup(SDQI;QwY6RbgK7`ff~m#k0$MqRbLScLbcXy}(TU3`R1zeXPRkF7`kOllG zAXOp|bmX#F!VhX|P&YV<6V&-$3#9ZUpt);Z9mvX$>j(m{oQ~*Jq>^l9v6006#T4Ef zDNzmJlg{<#s5UQCd?)Sm2#}U1YXc@6317VYJIa_VAg);9c$mH##YYaoUeOVK&QVeRwKW=(v%Ct;OO zEW@ZXQ1!?SKuF2g{oNRTxe%304a$lOIHBeU_LcB#g1$m7mlE}`K#~thlLzIUb^HrQ zUP^WMRA)H7tutCas?&g{!_ihflWr+^CXrrU3dSIf$EN19-OZsZ2DiQ?*TZn@8LR{@ zq|VrKeB&g9lNdq9JP&b(s@PWFTd-X?V*N(WTe!5HyB76G-tM5Yll+Ii1Ijoe-n^)lb3f*R43Z-&BS6sQtm3ex`9WTb!sf>H?;BJ-D|6h*0SHZO>mwwXG{XqYImx z&;Go+(;ap~KdJ<=SP+5_y#<&mh+gakh#l9QvsG#JV+PZL?hy^gvjje6uiMsL8tR~% zVX0L*n51{?1Vkxbbx5G|O5Uz{Zh{T=oHp!*w@UDAZD_bKr|KVE9J{wTu}`sVR>$WT z*Yd6i)(4Y{O#Y%Q2rq?SD3DB5YFz>En=dz4Ke8a(Z&!&3T@iyX6N)#;a`OiL{yanZ z%Y>pZC|nRsPv4?#!HI9>ZY=fd$HU&xbZo`Z|E8VKec>+Lnluu?h?+E z+_U}VEbh)-+ZT-ck5h9Gfda)^eZS0k?F;RypIcV#_wCbe?2D*fVSNG}f$rO9L-D6S zv{DP#vIY_=CU4Dzrt%ZiXkz#V?9q>3%<$G3Wyv z<0@P}a?$PyQm^sgWvG=dN}hJhFL$G>&cgU-uy}uzQ?dq@?xJz) zhEezjqGfVAjSY`t$GG;eDGxIk!1qg6qvfU(RyDgGPhZhta0N^uKlF=~4lFW@H@0>8W-{a(K?P-Y$2rX5xhM_>go{boXwaRw1G}DL2gS;>o=Z6)SM?7Q9 z)%EGpp)C}HCw?Uc-@Uj#qFq8!GGHZ6+56ttuO0q5@{ z8~k^*uEl_IdKepDU2!TxsBN-XGAJZ8nR4Do8(9O6GNkdC7(9STH)k&-Fp7dMg0Yin$E7bFzv zE=Jil+2OM0Nq#C)y*eb$gZ^eCVJ|Qiy{4)}`)EmQEs4}IIHiatl5NG!$|NjU+~$bK#@fsn#4S zq^~Viw>1u}hdc;ELr~NWg|I1sDffFi*xlD@1pNpResg|KIFlAy&fzoaWXSK)V_3*UwVaxI2v7gQO4d-{e3_gExzd&)4i5;Pu$9Ld|L&K zJHPD#RQK&10H+^gq@WK2i1g<^%|vEVS$LEe->%&=Z$m0871h#Lze*7{<#--Nmx**d zW>AyINyX7umtPyFT73=NBX=@M%NMy%gYM;!F_&t&TqVUBp4mR}0P)2WaU-^uYWi2L zuO<%mnP%6-nWjNCx3A%!dPPQl*^!1L9($6BWVtKLey45;Sb4`3S{XCZL=8=>dCR~v z;mB|8ipL^+owLw0WsLW#Q6PfHPz1 zvn{UwxIpY1Wp-mYs1NHM0ZqN;jeeC=5p|tUmMmmQt5~a9q^6k~T}_r@-u089j#kr< zo>D7jl|G(@zNFZ4g6;e8y!^%QpB8E|4@%^!r^i^HdSj3-H#$d~$?imfrQSydYGth;@&!KuWaCVlr=kXp^8U>x90JquO}JF_Q8(81N!OWpQ?t`Rz|^z@T6hBpiYHc3ppDH=bw6+T21keu46M zIUbekyhvMC>E}*j*Th4WqQPA~;Ws2Q70mVd;l_Us~NA={3sAn*`Trkk7(Tp~v78kmg7C~;o z+xyxiu?ys*eQ}Xn2iI=kXVG0RIMN(cghWpvPb|_ zY8>M#H=1+$K_l4(-}qaRv*3fVxm00gb`cJ;;T-nBHdLJEGw;ar7}ZoOl3CG*hH8r0 zmPpw;mx`10dW7eKgVvGo#*aI;q5LrJ+HeK{D`9;*ofNxggMF}P)GbUL&!#_BY{k%_ zt-uQkFXF7sfSF7tAL#*Ada#>mUoJTeH6zghLaTv48^#GxdcqD-+?DZucpXUld3}Vf z(8*x;{n5dX-un{PGHegc{h6pV%`F;VOABvtnnl*o zv@z^+3A*IO&95oQGs$gKe%n<8iQXKd;Ivj?UT>Uu^E*UOYft-3ccnlPrflZ z8ucnR*KcUB;3EWg+>F~T(C3bmIl0x(*mn{=+;v_8{6HqI&t=6RdIhEZ1)`d(Cjd zoBfPnEJjT75Z@X`5QB)0>~AfLx|K~w;BVlrWLsx#27A5T3pLmX@e~?Kt6TOvyW!#% zr`f~2?X81~xk;XR6J)WcUbQD7bTyuhaoyH4h(W(fQ68h7bg>^Vh11p2;wU;p&8OxH zlhm0>S9C8r`!I@DZ#%qZaG7NHvOD@Ni56v(m)!Q*X|e5DWnYqv86p*9thPDYz`^GD zvBdAk!P^9Z!NnO$fN>?>=#dzJK3;|64o>)Sd1)$nh0=#CQFwtP;&R=oc?jS*Fq+=HS>1o@6{vm?^I0H_h#O@z8AxGLobPf%+!few2`!Y zkM2ObV|WBvHhb?nL%Hq)`whP5Hw@=I8=#dOq>i)9!88qYoK>k9lNX44v>1QUi8r9G zCi&!3s-WqcTEstFt@*J56h(5in&h&B81H5l;bTL>QZ2{I$w*hI>rBG6GDLglp$6zG z3Fp8mIkU?M!b*2xZa!gFOu`YW@n0myRg!4rE;SB+yyyrCVT zvmMFtXaHI3T;X!ycbMuV-Sak;7i*te=zBzw&D-=1;WdFJwIn@(aPAB%H1g#r_n@ znbIe*rv1FnlhBG*>g6_`-;VM1x4&x!4!mWf%~s)04!a9_CG-1tA0b{88#s*$*^GH{ zmB{hW?`3DT4dOEV5EIo}aE&SapfWN$Sl2B_4^*&y&4NR=g?a)9v>a{ zA+@p1jY=Lk%lGuT{=24n@@%QTx~7Oe#0(2s1lGT(QHhp@^8t=Oo;#e!$KML)9v15u zl82Z-?Lk~mOGA3E2UdrnJhO~&0Z#}c>~QBl!Yl9*dOt$)Lq@cy07KFAjn&d*1` zs#bZ?#tj-}@L6vZNf=`N#hO1)07Q9U!(gIe{mY(G_J4-Nu>RrnL8Z4@2D5h%$viEJ;=EbprRH9v#x{v5R1T zO7l%H?u+h=S5`|z0{6sx|648xlWb1^K*28RCJe4Q%I^31fK~KquMe7+B<6Rn}Cb3wi__B!^cUI?_6-bE#Er0obJkRdOmIwtePK3#I+AZCK%{vvSd}x)$CS-{6vJ6%tgGPMhVsvJC#+ z2C>G7Q}b1t8a~>)eeft%A7I7k*bW^c@2&(epirY3W3Fj7ie3(7ItY#Fd=Es#IMvM= z33AX$EXK$#GqJrxLa!P9cuB;_?{T(%x4R!=bBMAokmkM*M!yjE#U7(5mc3>K+>oLs^dpBmvan>9zjU{zyZACRJV`Tn&@H|Z zeRMMV2xJ>?YWhR?v6$w&Fkd^rVgzL4f(ZwvH$HdCgxiAAZ9Mm?fx{S z!mLOq$sMi9N)-Apy_N)iUI0hfCvM1TqidrqlYbI!A3E8TI-)!pQ9d^%Dq0G7V!L2d zUDwxk?2pkyvw{OFpPkBIi#OR)nS0=#wlp zthi=_6;WXf#Av!SITs1zKm8#{1>YoWY`reew}m>&arj7M7{U&ZwTkat(en|0m72%z z|B$q5k8u*jKblcZ_ml5FqEk~0{Ynfao&PRUD^*cH#Y>)^AUnW9G`Wu}qV zczr)N;=QGE+2up4k1P&CXUKU`gF4#6+XXqMifbO*Z&sb$>HOgba^SL+ z6cEzB_Z6qI>?sy{rlw!dZaK->+&k{9U)wz|boj(+MpMMbkb87YBA|0-+~;rEy-B(o z&4%=bzn-6v3_r!&^Yuv4zH@+X9W-nQX?=A+?SfaufLQy>tznx(effUu*+0q9_h1bf zf0r|d2%L|2hf9#hMg+9nuA)>)6s}XUq7xor4@Gb+K^dsA)xXvtcTU?l2WmxN12y)+ zKbvEryNWW@4wPX@MjBYyM%_GoF$>fmhL<~(QbKsm0 zgubp^-Bv)L9&*b>$o=X{MG^Sf-$?x5(df_TDSlN6LId6Rg~W5zvqBr>5~><3)8FNw zd1u6v$n{Y!u840OxrcC6$%&AV?7+_2v#FE zvHtewqMX`D3oXJx@J~^RzauF49#s_l3=wg4zm(m|Hrm8nA259jZ7@zatywz*s}VKw zAg`}70PH`H*T-llLxRXy2`=^CH zXf7hSzpxDVW(F2P$|#^P$gDE%Ttc=pd@v*U8T~;Pn>$;X_fovbfmk<1c8{Q^!KW8@ zL?FNap5TFmII~P|;dD@Gb9~0TQ%qJ+Kh;u_)k1XvG20ezz#rk@y8@M{4{rU%P%9tw z&5$N8LD6@GIM(B)&e}hrs`!w9~s-22(RO@dIh_lyZY_*v>#U*yJoJxFPA9vuN9eVi?nz2%K z!dQcNuKL7sJUHPTu(_a5dXg|OcSkNbT`U)mMwFy-XtC{*+IjmC$%K5q20EWaZ-oR4 z*e;HJx&Sp7;ptg?8Dk=+HGoLJjjnlgm2)l7(Ho9;!unkB<{z7-e*Hk!|aaFSrg|=HGH@p>(`|A0|18$}qQVYTm z@4jhe4dV-tUN|g-g%Y}!=*Iyo2>N)#BlSog&-iq|J+IEm77xyQy8;Qt)@Aso>29Ga ziL(h0-N4Jo4p)}nct&H2NBnhzpe3PV*OE^m(u`YkPlsYz#NP$E2NkGSA?KhMyKHcU z%<_zli%Y8atjZb2zOIGc zm2VpSm2+5{zoPln9z>Cwd6lj2b_w(Df2&hma-fqwMd?k?e-@kBi|-%TztQw{JJSAx z{Vf+wx3{&9+(uZ3sH47?SHF#}@vmY_GapL?wsvPiUpmXPn;nou#8Q@XIi$E|o&6O{ z))K%#`J=Ntm#ZR0ztOk)+5T|bXlqGwDvMdFr1stlSsii2 zd=O{tz^wYJj>DCYk%u_iOEs*R)(>Lz@_x(G-}H#wVt8Tpx(ajO#^c(^2pe=)w}R$h z{DyBV8j@gY_WwQXWVyp!d*e{`C}Q$J>01nr=?aH`XSW-Qs4J~~I;}bB$Y`R2@vKEQ z^X9{o-t(@q!JLZ*U3%qt<<Cu6HX;P`D%taEaz35kv8^RaSCn$nI)-2<(}V;vM7? zit0uSG0UccR*4C(CeO0f#YzfNjp4@_(jzETWN6ABD-L#7V1?2*9US`+B$hLs-DoWM<;UJDTy^c{;i8wsYrRzRBI24C%$c_-o_L&JW1{pWqg>D@ zJw`ldyRtpH1*MgSge(ULLF)=nz*Sq4@AgPZvwz^t-UHGJdB} zc@;$L6Rj=$eaKp|UC7=Q7TbJfVt(5~p?kjdk#`2B*S(}NentuAg#XO9yXzC;8-V-C z^P88DMvK=y-EP}P&5ssSy|8i>ky86i2|D*l9ROPs>7b1_pER_(-rURhl7OZ5gGfLU z%unHfhw)2mK>2;0Z6DXgO!|ft#&v~2nTUbU7PiQK*Qx*rVG3su7a(TMD=zKv&@kPx zlWw6ve^8+xA0J=5MG1yoVR)Uu4+OH9Y;5MeSK7TUZeW*Ou z=G^SMSYk-%xp?6}Ut$>OIepKH2R$wwJ$f{%JxP3-itP)bUv$w zC5JV=iCM>FZD#s3qbI`>ccYp|f*GS4t*9Oj!ZO#L%e~)_O+f~1v7^%8Dh~3_Kt%mG6$E%)a$mRNtvlaB4d)@sdy`$QV|Cp3$3mvIz*HtH! zIy4$y^vbTM9%sWV8m2uV>0ws7Da+ZP(Bk z5QbVet-4k#lPASa7p#(Lg`kpo)Ly+4rN>Z(q@p&GJFh-2)- z>f*e;C7722fEfxx50X+7%j`;4iA`)N(>xCqv3dAIPNe(iRwuVHDOp46L8oxQy1@=~ z|5-~byuf_jfrcCKcO3Bma31CTez_Ay^;t%6UpQyaa`4xN13HVo;C{y0$a`gSC)7T} zL2JT5{Gskse5HJ88JG8QHcDk)*FaKBvR`Yh7VpxJ6qC*6zq8BFML@|#C9e&eLI``Q zLN4#h1fWLD_)pI@Hnlk6V^DJ?1SrE&_RkR@wsq!pFO8;@1mF);7r!@NvJ?W2%WTC0 zMp*ay2P1R1l_Rgljn_Ey5Slj)gXCpyvX?<&r@>Z!6S&SLU0~LeczAx zWmi0V4#Jb2aDE4+E|Hv(-stRv1F60#fszORwV&@xor-WTrQp25R$uky7m_jJI4eYYTu0S>

    j8Y(F{;Oc1p&o2`rjEgTlTet!n|}EG9(XKHIrH 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 M^A0x(5eCYC0W6&Nj{pDw From 3e49becc2f20f2b62cff266f12f4f99d6101446f Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 27 May 2020 12:35:05 +0200 Subject: [PATCH 232/236] Corrected udev & modprobe install directories (Fixes #966) --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b17fdc57..b660e0f23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,12 +255,12 @@ install(TARGETS st-util DESTINATION ${CMAKE_INSTALL_BINDIR}) ### if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - ## Install modprobe.d conf files / rules to /usr/local/etc/stlink (default) - set(STLINK_MODPROBED_DIR "${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/modprobe.d" CACHE PATH "modprobe.d directory") + ## Install modprobe.d conf files to /etc/modprobe.d/ (explicitly hardcoded) + set(STLINK_MODPROBED_DIR "/etc/modprobe.d" CACHE PATH "modprobe.d directory") install(FILES ${CMAKE_SOURCE_DIR}/config/modprobe.d/stlink_v1.conf DESTINATION ${STLINK_MODPROBED_DIR}) - ## Install udev rules files / rules to /usr/local/etc/stlink (default) - set(STLINK_UDEV_RULES_DIR "${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}/udev/rules.d" CACHE PATH "udev rules directory") + ## Install udev rules files to /etc/udev/rules.d/ (explicitly hardcoded) + set(STLINK_UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "udev rules directory") file(GLOB RULES_FILES ${CMAKE_SOURCE_DIR}/config/udev/rules.d/*.rules) install(FILES ${RULES_FILES} DESTINATION ${STLINK_UDEV_RULES_DIR}) endif () From 71011a3e7dec751f193556881507eb213f1da6b2 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Wed, 27 May 2020 21:50:45 +0200 Subject: [PATCH 233/236] Updated README for STLink-v1 setup on macOS --- stlinkv1_macos_driver/README.md | 38 +++++++++++---------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/stlinkv1_macos_driver/README.md b/stlinkv1_macos_driver/README.md index ca4a3da30..7221732c0 100644 --- a/stlinkv1_macos_driver/README.md +++ b/stlinkv1_macos_driver/README.md @@ -1,43 +1,31 @@ -### # Installation instructions for STLINK/v1 driver -### When connecting to the STLINK/v1 on macOS via USB, the system claims the programmer as a SCSI device. Thus libusb is not able to initialise and establish a connection to it. To solve this issue Marco Cassinerio (marco.cassinerio@gmail.com) has created a so called "codeless driver" which claims the device. It is of higher priority then the default apple mass storage driver, what allows the device to be accessed through libusb. To make use of this alternative approach one needs to go through the following steps: -1) Install the macOS Kernel Extension (kext): - - Open a terminal console and navigate to this subdirectory `/stlinkv1_macos_driver` - - Use the command ```sudo sh ./install.sh``` to install the appropiate kext for your system version. - -2) Install the ST-Link-v1 driver from this subdirectory `/stlinkv1_macos_driver` by executing: ```sudo make osx_stlink_shield```. This should result in the following output: - -``` -Requesting load of /System/Library/Extensions/stlink_shield.kext. -/System/Library/Extensions/stlink_shield.kext loaded successfully (or already loaded). -``` - -3) Configure System Integrity Protection (SIP) +1) Configure System Integrity Protection (SIP) The above system security setting introduced by Apple with OS X El Capitan (10.11) in 2015 is active per default and prevents the operating system amongst other things to load unsigned Kernel Extension Modules (kext). Thus the STLINK/v1 driver supplied with the tools, which installs as a kext, remains not functional, -until SIP is fully deactivated. +until SIP is fully deactivated. Without SIP-deactivation, st-util would fail to detect a STLINK/v1 device later on. -Without SIP-deactivation, st-util fails to detect a STLINK/v1 device: +In order to deactivate SIP, boot into the recovery mode and run ```csrutil disable``` in a terminal console window. -``` -st-util -1 -st-util $VERSION-STRING$ -WARN src/sg.c: Failed to find an stlink v1 by VID:PID -ERROR src/sg.c: Could not open stlink device -``` +2) Reboot the system. -In order to deactivate SIP, boot into the recovery mode and run ```csrutil disable``` in a terminal console window. +3) Install the macOS Kernel Extension (kext) (ST-Link-v1 driver): + - Open a terminal console and navigate to this subdirectory `/stlinkv1_macos_driver` + - Use the command ```sudo sh ./install.sh``` to install the appropiate kext for your system version. + This should result in the following output: -4) Reboot the system. +``` +Requesting load of /System/Library/Extensions/stlink_shield.kext. +/System/Library/Extensions/stlink_shield.kext loaded successfully (or already loaded). +``` -5) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` +4) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` You should then see a similar output like in this example: ``` From 9b6cd7f99ba33fe7f783cbdc49bddafeee017ca8 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 28 May 2020 11:09:32 +0200 Subject: [PATCH 234/236] General Project Update - Updated CHANGELOG - Corrected instructions for udev & STLink-v1 --- CHANGELOG.md | 134 +++++++++++++++++++++++++---------------------- doc/compiling.md | 22 ++++---- 2 files changed, 81 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b63e156..94c47e8fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,89 +4,98 @@ stlink ChangeLog v1.6.1 ====== -Release date: (TBD) +Release date: 2020-06-xx This release drops support for some older operating systems. Check project README for details. Features: -- Basic compatibility for STLink-v3 programmer ([#271](https://github.com/stlink-org/stlink/pull/271), [#863](https://github.com/stlink-org/stlink/pull/863), [#954](https://github.com/stlink-org/stlink/pull/954)) +* Basic compatibility for STLink-v3 programmer ([#271](https://github.com/stlink-org/stlink/pull/271), [#863](https://github.com/stlink-org/stlink/pull/863), [#954](https://github.com/stlink-org/stlink/pull/954)) - Added support for JTAG command API v2 & distinguish protocol versions v1 and v2 - Compatibility with the STLink-v3 firmware which dropped support for the previous API v1 - As of firmware version J11 the ST-LINK-V1 programmer supports API v2 commands as well -- Display programmer serial when no target is connected ([#432](https://github.com/stlink-org/stlink/pull/432), [#933](https://github.com/stlink-org/stlink/pull/933), [#943](https://github.com/stlink-org/stlink/pull/943)) -- Support for STM32L1, SM32L4 option bytes write ([#596](https://github.com/stlink-org/stlink/pull/596), [#844](https://github.com/stlink-org/stlink/pull/844), [#847](https://github.com/stlink-org/stlink/pull/847)) -- CMake now creates an uninstall target ([#619](https://github.com/stlink-org/stlink/pull/619), [#907](https://github.com/stlink-org/stlink/pull/907)) -- Added CMAKEFLAGS and install target ([#804](https://github.com/stlink-org/stlink/pull/804), [#935](https://github.com/stlink-org/stlink/pull/935)) -- Support for STM32G4 ([#822](https://github.com/stlink-org/stlink/pull/822)) -- Add aliased SRAM2 region in the L496 memory map ([#824](https://github.com/stlink-org/stlink/pull/824)) -- Improved support for STM32G0 ([#825](https://github.com/stlink-org/stlink/pull/825), [#850](https://github.com/stlink-org/stlink/pull/850), [#856](https://github.com/stlink-org/stlink/pull/856), [#857](https://github.com/stlink-org/stlink/pull/857)) -- Added postinst script with 'depmod -a' for 'make package' ([#845](https://github.com/stlink-org/stlink/pull/845), [#931](https://github.com/stlink-org/stlink/pull/931)) -- Calculate checksums for flash operations ([#862](https://github.com/stlink-org/stlink/pull/862), [#924](https://github.com/stlink-org/stlink/pull/924)) -- Adjust the JTAG/SWD frequency via cmdline option ([#893](https://github.com/stlink-org/stlink/pull/893), [#953](https://github.com/stlink-org/stlink/pull/953)) -- Added usb PID and udev rules for STlink v2.1 found on Nucleo-L432KC and Nucleo-L552ze boards ([#900](https://github.com/stlink-org/stlink/pull/900)) -- STM32G0/G4 improvements ([#910](https://github.com/stlink-org/stlink/pull/910)) +* Display programmer serial when no target is connected ([#432](https://github.com/stlink-org/stlink/pull/432), [#933](https://github.com/stlink-org/stlink/pull/933), [#943](https://github.com/stlink-org/stlink/pull/943)) +* Added connect under reset to stlink_open_usb( ) ([#577](https://github.com/stlink-org/stlink/pull/577), [#963](https://github.com/stlink-org/stlink/pull/963)) +* Support for STM32L1, SM32L4 option bytes write ([#596](https://github.com/stlink-org/stlink/pull/596), [#844](https://github.com/stlink-org/stlink/pull/844), [#847](https://github.com/stlink-org/stlink/pull/847)) +* Added CMAKEFLAGS and install target ([#804](https://github.com/stlink-org/stlink/pull/804), [#935](https://github.com/stlink-org/stlink/pull/935)) +* Support for STM32G4 ([#822](https://github.com/stlink-org/stlink/pull/822)) +* Add aliased SRAM2 region in the L496 memory map ([#824](https://github.com/stlink-org/stlink/pull/824)) +* Improved support for STM32G0 ([#825](https://github.com/stlink-org/stlink/pull/825), [#850](https://github.com/stlink-org/stlink/pull/850), [#856](https://github.com/stlink-org/stlink/pull/856), [#857](https://github.com/stlink-org/stlink/pull/857)) +* Added postinst script with 'depmod -a' for 'make package' ([#845](https://github.com/stlink-org/stlink/pull/845), [#931](https://github.com/stlink-org/stlink/pull/931)) +* Calculate checksums for flash operations ([#862](https://github.com/stlink-org/stlink/pull/862), [#924](https://github.com/stlink-org/stlink/pull/924)) +* Adjust the JTAG/SWD frequency via cmdline option ([#893](https://github.com/stlink-org/stlink/pull/893), [#953](https://github.com/stlink-org/stlink/pull/953)) +* Added usb PID and udev rules for STlink v2.1 found on Nucleo-L432KC and Nucleo-L552ze boards ([#900](https://github.com/stlink-org/stlink/pull/900)) +* STM32G0/G4 improvements ([#910](https://github.com/stlink-org/stlink/pull/910)) - Enable mass erase with a flash programming check - Handle G4 Cat3 devices with configurable dual bank flash by using a helper Updates & changes: -- [doc] Update compiling instructions ([#113](https://github.com/stlink-org/stlink/pull/113), commit [#10ae529](https://github.com/stlink-org/stlink/commit/10ae5294cd03aacfc07312010f026d3cb12ea56c)) -- Define libusb version compatibility for supported operating systems via LIBUSB_API_VERSION ([#211](https://github.com/stlink-org/stlink/pull/211), [#782](https://github.com/stlink-org/stlink/pull/782), [#895](https://github.com/stlink-org/stlink/pull/895)) -- Improved argument parsing for CLI tools ([#378](https://github.com/stlink-org/stlink/pull/378), [#922](https://github.com/stlink-org/stlink/pull/922)) -- [doc] Updated tutorial: macOS ST-Link-v1 detection ([#574](https://github.com/stlink-org/stlink/pull/574), [#587](https://github.com/stlink-org/stlink/pull/587)) -- Enhanced error log with file path for map_file() ([#650](https://github.com/stlink-org/stlink/pull/650), [#879](https://github.com/stlink-org/stlink/pull/879), [#921](https://github.com/stlink-org/stlink/pull/921)) -- Enhanced output for error msg "addr not a multiple of pagesize, not supported" ([#663](https://github.com/stlink-org/stlink/pull/663), [#945](https://github.com/stlink-org/stlink/pull/945)) -- [refactoring] Package distribution: Provide Windows binaries via Debian-based cross-build ([#738](https://github.com/stlink-org/stlink/pull/738), [#795](https://github.com/stlink-org/stlink/pull/795), [#798](https://github.com/stlink-org/stlink/pull/798), [#955](https://github.com/stlink-org/stlink/pull/955)) - - Update, corrections & cleanup for build settings (see #955 for details) +* [doc] Updated compiling instructions ([#113](https://github.com/stlink-org/stlink/pull/113), commit [#10ae529](https://github.com/stlink-org/stlink/commit/10ae5294cd03aacfc07312010f026d3cb12ea56c)) +* Defined libusb version compatibility for supported systems via LIBUSB_API_VERSION ([#211](https://github.com/stlink-org/stlink/pull/211), [#782](https://github.com/stlink-org/stlink/pull/782), [#895](https://github.com/stlink-org/stlink/pull/895)) +* Improved argument parsing for CLI tools ([#378](https://github.com/stlink-org/stlink/pull/378), [#922](https://github.com/stlink-org/stlink/pull/922)) +* [doc] Updated tutorial: macOS ST-Link-v1 detection ([#574](https://github.com/stlink-org/stlink/pull/574), [#587](https://github.com/stlink-org/stlink/pull/587)) +* Enhanced error log with file path for map_file() ([#650](https://github.com/stlink-org/stlink/pull/650), [#879](https://github.com/stlink-org/stlink/pull/879), [#921](https://github.com/stlink-org/stlink/pull/921)) +* Enhanced output for error msg "addr not a multiple of pagesize, not supported" ([#663](https://github.com/stlink-org/stlink/pull/663), [#945](https://github.com/stlink-org/stlink/pull/945)) +* Package distribution: Provide Windows binaries via Debian-based cross-build ([#738](https://github.com/stlink-org/stlink/pull/738), [#795](https://github.com/stlink-org/stlink/pull/795), [#798](https://github.com/stlink-org/stlink/pull/798), [#870](https://github.com/stlink-org/stlink/pull/870), [#955](https://github.com/stlink-org/stlink/pull/955)) + - [refactoring] Update, corrections & cleanup for build settings (see #955 for details) - New cpack package-config for DEB and RPM build - Update for travis build configuration: builds for clang -m32, clang-9, MinGW-cross on linux - Updated steps for release preparation - Project contributors now listed in separate file - Test files & gui now use shared stlink-library -- [doc] Verify correct udev configuration for device access ([#764](https://github.com/stlink-org/stlink/pull/764)) -- Added more error info to WLOGs during probe ([#883](https://github.com/stlink-org/stlink/pull/883)) -- [doc] Add missing documentation for stlink-gui ([#884](https://github.com/stlink-org/stlink/pull/884)) -- Added check for libssp during compilation ([#885](https://github.com/stlink-org/stlink/pull/885)) -- Silence unnecessary messages ([#886](https://github.com/stlink-org/stlink/pull/886)) -- [doc] Define libusb & cmake version compatibility ([#896](https://github.com/stlink-org/stlink/pull/896), [#897](https://github.com/stlink-org/stlink/pull/897), [#899](https://github.com/stlink-org/stlink/pull/899), commit [#27aa888](https://github.com/stlink-org/stlink/commit/27aa88821197d3ffe82baff4e971c3488ec39899)) -- Update for STM32G471/473/474/483/484 devices ([#901](https://github.com/stlink-org/stlink/pull/901)) -- [doc] st-flash --flash=n[k][m] command line option to override device model ([#902](https://github.com/stlink-org/stlink/pull/902)) -- [refactoring] BSD-License-compliant rewrite of flashloader source files ([#915](https://github.com/stlink-org/stlink/pull/915), [#932](https://github.com/stlink-org/stlink/pull/932)) -- [refactoring] Overall option code rework ([#927](https://github.com/stlink-org/stlink/pull/927)) -- [refactoring] Build settings / GUI-Build on UNIX-based systems if GTK3 is detected ([#929](https://github.com/stlink-org/stlink/pull/929)) -- [refactoring] Reconfiguration of package build process ([#931](https://github.com/stlink-org/stlink/pull/931), [#936](https://github.com/stlink-org/stlink/pull/936), [#940](https://github.com/stlink-org/stlink/pull/940), commit [#9b19f92](https://github.com/stlink-org/stlink/commit/9b19f9225460472af9d98959b7217d0a840ee972)) -- [refactoring] st-util: Removed now useless v1/v2 STLink version stuff ([#934](https://github.com/stlink-org/stlink/pull/934)) -- [refactoring] Cleanup for option bytes and flash settings ([#941](https://github.com/stlink-org/stlink/pull/941)) -- Added compilation guideline for MSVC toolchain ([#942](https://github.com/stlink-org/stlink/pull/942)) -- [refactoring] Cleanup of cmake build process ([#944](https://github.com/stlink-org/stlink/pull/944), [#946](https://github.com/stlink-org/stlink/pull/946), [#947](https://github.com/stlink-org/stlink/pull/947)) -- Set up a libusb log level accordingly to verbosity (commit [#49f887d](https://github.com/stlink-org/stlink/commit/49f887d5247fdd28f163b6317790c4f087e652cc)) -- [doc] Defined version compatibility and installation instructions for macOS (commit [#23c071e](https://github.com/stlink-org/stlink/commit/23c071edea45f6e8852fef52d884a680973d6d8f)) -- Deprecated old appveyor-mingw script (commit [#9748442](https://github.com/stlink-org/stlink/commit/97484422008df0f75c978627054776f35842a075)) -- libusb package extraction no longer requires 7zip as an external unarchiver (commit [#5db2dc4](https://github.com/stlink-org/stlink/commit/5db2dc4c0410ace65308cddcc03d1c0cfa4855cf)) - +* [doc] Verify correct udev configuration for device access ([#764](https://github.com/stlink-org/stlink/pull/764)) +* Added more error info to WLOGs during probe ([#883](https://github.com/stlink-org/stlink/pull/883)) +* [doc] Added missing documentation for stlink-gui ([#884](https://github.com/stlink-org/stlink/pull/884)) +* Added check for libssp during compilation ([#885](https://github.com/stlink-org/stlink/pull/885)) +* Silenced unnecessary messages ([#886](https://github.com/stlink-org/stlink/pull/886)) +* [doc] Defined libusb & cmake version compatibility ([#896](https://github.com/stlink-org/stlink/pull/896), [#897](https://github.com/stlink-org/stlink/pull/897), [#899](https://github.com/stlink-org/stlink/pull/899), commit [#27aa888](https://github.com/stlink-org/stlink/commit/27aa88821197d3ffe82baff4e971c3488ec39899)) +* Update for STM32G471/473/474/483/484 devices ([#901](https://github.com/stlink-org/stlink/pull/901)) +* [doc] st-flash --flash=n[k][m] command line option to override device model ([#902](https://github.com/stlink-org/stlink/pull/902)) +* [refactoring] Improved cmake build process ([#912](https://github.com/stlink-org/stlink/pull/912)) + - Set up a libusb log level accordingly to verbosity ([#894](https://github.com/stlink-org/stlink/pull/894) + - [compatibility] Updated libusb to v1.0.23 ([#895](https://github.com/stlink-org/stlink/pull/895) + - Updated compiling doc & version support ([#896](https://github.com/stlink-org/stlink/pull/896), [#897](https://github.com/stlink-org/stlink/pull/897), [#899](https://github.com/stlink-org/stlink/pull/899)) + - Version requirements & pkg-maintainer + - Fixed install paths in build script + - Updated C-flag -std=gnu99 to gnu11) + - Added cmake uninstall target ([#619](https://github.com/stlink-org/stlink/pull/619), [#907](https://github.com/stlink-org/stlink/pull/907)) + - Integrated module GNUInstallDirs.cmake ([#557](https://github.com/stlink-org/stlink/pull/557)) + - [doc] Defined version compatibility and installation instructions for macOS + - [refactoring] libusb detection + - Deprecated old appveyor-mingw script +* [refactoring] BSD-License-compliant rewrite of flashloader source files ([#915](https://github.com/stlink-org/stlink/pull/915), [#932](https://github.com/stlink-org/stlink/pull/932)) +* [refactoring] Overall option code rework ([#927](https://github.com/stlink-org/stlink/pull/927)) +* [refactoring] Build settings / GUI-Build on UNIX-based systems if GTK3 is detected ([#929](https://github.com/stlink-org/stlink/pull/929)) +* [refactoring] Reconfiguration of package build process ([#931](https://github.com/stlink-org/stlink/pull/931), [#936](https://github.com/stlink-org/stlink/pull/936), [#940](https://github.com/stlink-org/stlink/pull/940), commit [#9b19f92](https://github.com/stlink-org/stlink/commit/9b19f9225460472af9d98959b7217d0a840ee972)) +* [refactoring] st-util: Removed now useless v1/v2 STLink version stuff ([#934](https://github.com/stlink-org/stlink/pull/934)) +* [refactoring] Cleanup for option bytes and flash settings ([#941](https://github.com/stlink-org/stlink/pull/941)) +* Added compilation guideline for MSVC toolchain ([#942](https://github.com/stlink-org/stlink/pull/942)) +* [refactoring] Cleanup of cmake build process ([#944](https://github.com/stlink-org/stlink/pull/944), [#946](https://github.com/stlink-org/stlink/pull/946), [#947](https://github.com/stlink-org/stlink/pull/947)) + - libusb package extraction no longer requires 7zip as an external unarchiver Fixes: -- Fixed wait-loop for flash_loader_run() ([#290](https://github.com/stlink-org/stlink/pull/290)) -- Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 ([#378](https://github.com/stlink-org/stlink/pull/378), [#922](https://github.com/stlink-org/stlink/pull/922)) -- Clear the PG bit before setting the PER bit ([#579](https://github.com/stlink-org/stlink/pull/579), [#876](https://github.com/stlink-org/stlink/pull/876)) -- Fixed compilation issues with int length on 32-bit platforms ([#629](https://github.com/stlink-org/stlink/pull/629), [#908](https://github.com/stlink-org/stlink/pull/908)) -- Fixed st-info --probe mechanism ([#679](https://github.com/stlink-org/stlink/pull/679), [#918](https://github.com/stlink-org/stlink/pull/918)) -- [regression] Fixed sign-compare (size != rep_len) in usb.c ([#772](https://github.com/stlink-org/stlink/pull/772), [#869](https://github.com/stlink-org/stlink/pull/869), [#872](https://github.com/stlink-org/stlink/pull/872), [#891](https://github.com/stlink-org/stlink/pull/891)) -- Fixed dead loop after an unexpected unplug ([#780](https://github.com/stlink-org/stlink/pull/780), [#812](https://github.com/stlink-org/stlink/pull/812), [#913](https://github.com/stlink-org/stlink/pull/913)) -- Avoid re-define of O_BINARY on Windows ([#788](https://github.com/stlink-org/stlink/pull/788)) -- Fixed st-flash manpage read example ([#858](https://github.com/stlink-org/stlink/pull/858)) -- Fixed stlink support with no mass storage ([#861](https://github.com/stlink-org/stlink/pull/861)) -- Make Version.cmake more error-resistant ([#872](https://github.com/stlink-org/stlink/pull/872)) -- Error return in failed probe ([#887](https://github.com/stlink-org/stlink/pull/887), [#890](https://github.com/stlink-org/stlink/pull/890)) -- Fixed broken build on 32-bit systems ([#919](https://github.com/stlink-org/stlink/pull/919), [#920](https://github.com/stlink-org/stlink/pull/920)) -- st-flash: Minor usage fix and make cmdline parsing more user friendly ([#925](https://github.com/stlink-org/stlink/pull/925)) -- [regression] Restored functionality of make test builds ([#926](https://github.com/stlink-org/stlink/pull/926), [#929](https://github.com/stlink-org/stlink/pull/929)) -- Fixed compilation error due to uninitialized cpuid ([#937](https://github.com/stlink-org/stlink/pull/937), [#938](https://github.com/stlink-org/stlink/pull/938)) -- Fixes for STM32F0 flashloader ([#958](https://github.com/stlink-org/stlink/pull/958), [#959](https://github.com/stlink-org/stlink/pull/959) -- Set static link for libssp (stack-smashing protection) ([#960](https://github.com/stlink-org/stlink/pull/960), [#961](https://github.com/stlink-org/stlink/pull/961)) -- Fixed formatting for options display in st-flash & st-info (commits [#c783d0e](https://github.com/stlink-org/stlink/commit/c783d0e777ccc83a7a8be26a4f4d3414e0478560) and [#562cd24](https://github.com/stlink-org/stlink/commit/562cd2496e696dbd22950925866aac662d81ee5f)) +* Fixed wait-loop for flash_loader_run() ([#290](https://github.com/stlink-org/stlink/pull/290)) +* Better argument parsing for CLI tools: stlink_open_usb can address v1, v2, v3 ([#378](https://github.com/stlink-org/stlink/pull/378), [#922](https://github.com/stlink-org/stlink/pull/922)) +* Clear the PG bit before setting the PER bit ([#579](https://github.com/stlink-org/stlink/pull/579), [#876](https://github.com/stlink-org/stlink/pull/876)) +* Fixed compilation issues with int length on 32-bit platforms ([#629](https://github.com/stlink-org/stlink/pull/629), [#908](https://github.com/stlink-org/stlink/pull/908)) +* Fixed st-info --probe mechanism ([#679](https://github.com/stlink-org/stlink/pull/679), [#918](https://github.com/stlink-org/stlink/pull/918)) +* [regression] Fixed sign-compare (size != rep_len) in usb.c ([#772](https://github.com/stlink-org/stlink/pull/772), [#869](https://github.com/stlink-org/stlink/pull/869), [#872](https://github.com/stlink-org/stlink/pull/872), [#891](https://github.com/stlink-org/stlink/pull/891)) +* Fixed dead loop after an unexpected unplug ([#780](https://github.com/stlink-org/stlink/pull/780), [#812](https://github.com/stlink-org/stlink/pull/812), [#913](https://github.com/stlink-org/stlink/pull/913)) +* Avoid re-define of O_BINARY on Windows ([#788](https://github.com/stlink-org/stlink/pull/788)) +* Fixed st-flash manpage read example ([#858](https://github.com/stlink-org/stlink/pull/858)) +* Fixed stlink support with no mass storage ([#861](https://github.com/stlink-org/stlink/pull/861)) +* Make Version.cmake more error-resistant ([#872](https://github.com/stlink-org/stlink/pull/872)) +* Error return in failed probe ([#887](https://github.com/stlink-org/stlink/pull/887), [#890](https://github.com/stlink-org/stlink/pull/890)) +* Fixed broken build on 32-bit systems ([#919](https://github.com/stlink-org/stlink/pull/919), [#920](https://github.com/stlink-org/stlink/pull/920)) +* st-flash: Minor usage fix and make cmdline parsing more user friendly ([#925](https://github.com/stlink-org/stlink/pull/925)) +* [regression] Restored functionality of make test builds ([#926](https://github.com/stlink-org/stlink/pull/926), [#929](https://github.com/stlink-org/stlink/pull/929)) +* Fixed compilation error due to uninitialized cpuid ([#937](https://github.com/stlink-org/stlink/pull/937), [#938](https://github.com/stlink-org/stlink/pull/938)) +* Fixes for STM32F0 flashloader ([#958](https://github.com/stlink-org/stlink/pull/958), [#959](https://github.com/stlink-org/stlink/pull/959)) +* Set static link for libssp (stack-smashing protection) ([#960](https://github.com/stlink-org/stlink/pull/960), [#961](https://github.com/stlink-org/stlink/pull/961)) +* Fixed udev rules installing to wrong directory ([#966](https://github.com/stlink-org/stlink/pull/966)) +* Fixed formatting for options display in st-flash & st-info (commits [#c783d0e](https://github.com/stlink-org/stlink/commit/c783d0e777ccc83a7a8be26a4f4d3414e0478560) and [#562cd24](https://github.com/stlink-org/stlink/commit/562cd2496e696dbd22950925866aac662d81ee5f)) v1.6.0 @@ -333,6 +342,7 @@ Updates and fixes: * Fixed STM32F2xx memory map (Nicolas Schodet) * Memory map for STM32F42xxx and STM32F43xxx devices (Craig Lilley) * Stm32l0x flash loader (Robin Kreis) +* Fixed segfault when programmer is already busy and NULL pointers are in the list ([#256](https://github.com/stlink-org/stlink/pull/256), [#394](https://github.com/stlink-org/stlink/pull/394)) * Send F4 memory-map and features for STM32F429 ([#188](https://github.com/stlink-org/stlink/pull/188), [#196](https://github.com/stlink-org/stlink/pull/196), [#250](https://github.com/stlink-org/stlink/pull/250), [#251](https://github.com/stlink-org/stlink/pull/251)) (Release v1.1.0) * Added AHB3 Peripherals definition for STM32F4 ([#218](https://github.com/stlink-org/stlink/pull/218), [#288](https://github.com/stlink-org/stlink/pull/288)) (Release v1.1.0) * Corrected flash size register address for STM32F2 devices ([#278](https://github.com/stlink-org/stlink/pull/278)) (Release v1.0.0) diff --git a/doc/compiling.md b/doc/compiling.md index 2da79f071..428d9cc3c 100644 --- a/doc/compiling.md +++ b/doc/compiling.md @@ -153,11 +153,11 @@ $ debuild -uc -us ### Set permissions with udev 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. +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`. -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: +The rules are located in the subdirectory `config/udev/rules.d` within the sourcefolder and are automatically installed along with `sudo make install` on linux. +Afterwards it may be necessary to reload the udev rules: ```sh $ cp etc/udev/rules.d /etc/udev/rules.d @@ -165,18 +165,14 @@ $ udevadm control --reload-rules $ udevadm trigger ``` -Udev will now create device node files `/dev/stlinkv2_XX`, `/dev/stlinkv1_XX`. +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: +### Note on the use of STLink-v1 programmers (legacy): -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: +As the STLINKv1's SCSI emulation is somehow broken, the best advice possibly is to tell your operating system to completely ignore it.
    +Choose one of the following options _before_ connecting the device to your computer: * `modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i` * _OR_ @@ -208,8 +204,8 @@ To do this with only one simple command, type: - with gcc: `sudo brew install git gcc cmake libusb gtk+3` or - with clang: `sudo brew install git llvm cmake libusb gtk+3` or * for MacPorts: - - with gcc: `sudo port install git llvm-9.0 cmake libusb gtk3` or - - with clang: `sudo port install git gcc9 cmake libusb gtk3` + - with gcc: `sudo port install git gcc10 cmake libusb gtk3` or + - with clang: `sudo port install git llvm-10 cmake libusb gtk3` ### Installation From a5dc016b42ab1faf872c8fce49521f1bacf28256 Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 28 May 2020 11:42:26 +0200 Subject: [PATCH 235/236] Changed kext-path to /Library/Extensions --- CMakeLists.txt | 2 +- stlinkv1_macos_driver/README.md | 7 ++++--- stlinkv1_macos_driver/install.sh | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b17fdc57..7e54b3fa2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,7 +143,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}" ") ### diff --git a/stlinkv1_macos_driver/README.md b/stlinkv1_macos_driver/README.md index 7221732c0..e0f9256e8 100644 --- a/stlinkv1_macos_driver/README.md +++ b/stlinkv1_macos_driver/README.md @@ -21,11 +21,12 @@ In order to deactivate SIP, boot into the recovery mode and run ```csrutil disab This should result in the following output: ``` -Requesting load of /System/Library/Extensions/stlink_shield.kext. -/System/Library/Extensions/stlink_shield.kext loaded successfully (or already loaded). +Requesting load of /Library/Extensions/stlink_shield.kext. +/Library/Extensions/stlink_shield.kext loaded successfully (or already loaded). ``` +4) Reboot the system. -4) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` +5) Verify correct detection of the STLINK/v1 device with the following input: `st-util -1` You should then see a similar output like in this example: ``` diff --git a/stlinkv1_macos_driver/install.sh b/stlinkv1_macos_driver/install.sh index 9e5f8d813..19e9f141d 100644 --- a/stlinkv1_macos_driver/install.sh +++ b/stlinkv1_macos_driver/install.sh @@ -10,13 +10,13 @@ case $ISMACOS in ;; 10.15*) KEXT="stlink_shield_10_15.kext" - ;; + ;; *) echo "OS X version not supported." exit 1 ;; esac chown -R root:wheel $KEXT/ -cp -R $KEXT /System/Library/Extensions/stlink_shield.kext -kextload -v /System/Library/Extensions/stlink_shield.kext -touch /System/Library/Extensions +cp -R $KEXT /Library/Extensions/stlink_shield.kext +kextload -v /Library/Extensions/stlink_shield.kext +touch /Library/Extensions From 7829600c9af2cd354f61fc9ed2165b58733d54de Mon Sep 17 00:00:00 2001 From: nightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com> Date: Thu, 28 May 2020 21:57:56 +0200 Subject: [PATCH 236/236] Preparation for Release v1.6.1 --- .version | 2 +- CHANGELOG.md | 3 ++- README.md | 4 +++- contributors.txt | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.version b/.version index ce6a70b9d..9c6d6293b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -1.6.0 \ No newline at end of file +1.6.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 94c47e8fb..3195bae3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ stlink ChangeLog v1.6.1 ====== -Release date: 2020-06-xx +Release date: 2020-06-01 This release drops support for some older operating systems. Check project README for details. @@ -37,6 +37,7 @@ Updates & changes: * [doc] Updated tutorial: macOS ST-Link-v1 detection ([#574](https://github.com/stlink-org/stlink/pull/574), [#587](https://github.com/stlink-org/stlink/pull/587)) * Enhanced error log with file path for map_file() ([#650](https://github.com/stlink-org/stlink/pull/650), [#879](https://github.com/stlink-org/stlink/pull/879), [#921](https://github.com/stlink-org/stlink/pull/921)) * Enhanced output for error msg "addr not a multiple of pagesize, not supported" ([#663](https://github.com/stlink-org/stlink/pull/663), [#945](https://github.com/stlink-org/stlink/pull/945)) +* Updated STLink-v1 driver for macOS ([#735](https://github.com/stlink-org/stlink/pull/735), [#964](https://github.com/stlink-org/stlink/pull/964)) * Package distribution: Provide Windows binaries via Debian-based cross-build ([#738](https://github.com/stlink-org/stlink/pull/738), [#795](https://github.com/stlink-org/stlink/pull/795), [#798](https://github.com/stlink-org/stlink/pull/798), [#870](https://github.com/stlink-org/stlink/pull/870), [#955](https://github.com/stlink-org/stlink/pull/955)) - [refactoring] Update, corrections & cleanup for build settings (see #955 for details) - New cpack package-config for DEB and RPM build diff --git a/README.md b/README.md index 7dc634c9c..21ab9f48b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Open source version of the STMicroelectronics STlink Tools [![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/stlink-org/stlink.svg)](https://github.com/stlink-org/stlink/releases/latest) [![Downloads](https://img.shields.io/github/downloads/stlink-org/stlink/total)](https://github.com/stlink-org/stlink/releases/latest) -![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.0/develop) +![GitHub commits](https://img.shields.io/github/commits-since/stlink-org/stlink/v1.6.1/develop) ![GitHub activity](https://img.shields.io/github/commit-activity/m/stlink-org/stlink) ![GitHub contributors](https://img.shields.io/github/contributors/stlink-org/stlink) [![Linux Status](https://img.shields.io/travis/stlink-org/stlink/master?env=BADGE=linux&label=linux)](https://travis-ci.org/stlink-org/stlink) @@ -53,6 +53,8 @@ Currently known working combinations of programmers and targets are listed in [d Supported operating systems are listed in [version_support.md](doc/version_support.md). +The `stlink` toolset continues to maintain backwards compatibility with the **STLINK/v1** programmer.
    +Please note that on macOS this support is limited to versions 10.13 - 10.15. ## Tutorial & HOWTO diff --git a/contributors.txt b/contributors.txt index 8811da855..fec7510c3 100644 --- a/contributors.txt +++ b/contributors.txt @@ -13,6 +13,7 @@ Björn Hauffe Ihor Bobalo Breton M. Saunders Bruno Dal Bo +Brian Team [dot4qu] Burns Fisher Cheng Guokai (Xim) [chenguokai] Chris Dew