Skip to content

Commit

Permalink
Merge branch 'martonmiklos-add_stlink_v3_support' into develop
Browse files Browse the repository at this point in the history
Resolved conflicts with develop branch.
  • Loading branch information
Nightwalker-87 committed Feb 24, 2020
2 parents e06daed + 5020ba7 commit aad5cf1
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 191 deletions.
2 changes: 1 addition & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
36 changes: 23 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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), [#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))
Expand All @@ -26,7 +26,7 @@ Major changes and added features:

Updates and fixes:

* Make udev rules and modprobe conf installation optional ([#741](https://github.com/texane/stlink/pull/741))
* 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)
Expand All @@ -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)
Expand All @@ -59,19 +59,29 @@ Release date: 2018-09-13

Major changes and added features:

* Implemented intel hex support for GTK GUI
* Updated libusb to 1.0.22
* Added memory map for STM32F411RE target
* Add support for STM32L4R9 target
* 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))

Fixes:

* FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION
* Proper flash page size calculation for F412 target
* Fixed flash memory map for F72xxx target
* Return correct value on EOF for Semihosting SYS_READ

For a complete list of changes see [the milestone](https://github.com/texane/stlink/milestone/6?closed=1)
* 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))
* 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))
* FreeBSD defines LIBUSB_API_VERSION instead of LIBUSBX_API_VERSION ([#733](https://github.com/texane/stlink/pull/733))

v1.5.0
======
Expand Down
205 changes: 105 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
Open source version of the STMicroelectronics Stlink Tools
==========================================================

[![GitHub release](https://img.shields.io/github/release/texane/stlink.svg)](https://github.com/texane/stlink/releases/latest)
[![BSD licensed](https://img.shields.io/badge/license-BSD-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE)
[![GitHub commits](https://img.shields.io/github/commits-since/texane/stlink/v1.6.0.svg)](https://github.com/texane/stlink/releases/develop)
[![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)

Recent new features and bugfixes can be found in the [Changelog](CHANGELOG.md) of this software project.


## Introduction

## HOWTO
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.

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. These programmer boards are available in four versions:
These programmer boards are available in four versions:

* **STLINKv1:**
- transport layer: SCSI passthru commands over USB
Expand All @@ -24,39 +27,122 @@ This stlink toolset supports several so called stlink programmer boards (and clo
* transport layer: raw USB commands
* present on some STM32 nucleo boards
* **STLINKv3:**
* _currently not supported by this toolset_
* _not yet supported by this toolset (but planned)_


## Supported hardware combinations

Currently known working combinations of programmers and targets are listed in [doc/tested-boards.md](doc/tested-boards.md).


## Installation

Windows users can [download v1.3.0](https://github.com/texane/stlink/releases/tag/1.3.0) from the releases page.
**Windows**: download [v1.6.0](https://github.com/texane/stlink/releases/tag/v1.6.0) from the releases page.

**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.

Mac OS X users can install from [homebrew](http://brewformulas.org/Stlink) or [download v1.3.0](https://github.com/texane/stlink/releases/tag/1.3.0) from the releases page.
**Linux**:

Debian Linux users can install it via the ```stlink-tools``` package [repository](https://packages.debian.org/buster/stlink-tools)
We recommend to install `stlink-tools` from the package repository of the used distribution:

Ubuntu Linux users can install it via the ```stlink-tools``` package [repository](https://packages.ubuntu.com/stlink-tools)
* Debian Linux: [(Link)](https://packages.debian.org/buster/stlink-tools)
* Ubuntu Linux: [(Link)](https://packages.ubuntu.com/stlink-tools)
* Arch Linux: [(Link)](https://www.archlinux.org/packages/community/x86_64/stlink)
* Alpine Linux: [(Link)](https://pkgs.alpinelinux.org/packages?name=stlink)
* Fedora: [(Link)](https://src.fedoraproject.org/rpms/stlink)
* Gentoo Linux: [(Link)](https://packages.gentoo.org/packages/dev-embedded/stlink)

Arch Linux users can install from the [repository](https://www.archlinux.org/packages/community/x86_64/stlink)
**Other Operating Systems**:

Alpine Linux users can install from the [repository](https://pkgs.alpinelinux.org/packages?name=stlink)
* RedHat/CentOS 7: Users can install [from EPEL repository](https://src.fedoraproject.org/rpms/stlink/branch/epel7)
* FreeBSD: Users can install [from freshports](https://www.freshports.org/devel/stlink)
* OpenBSD: Users need to install [from source](doc/compiling.md).

Fedora users can install from [repository](https://src.fedoraproject.org/rpms/stlink)

RedHat/CentOS 7 users can install from EPEL [repository](https://src.fedoraproject.org/rpms/stlink/branch/epel7)
## Installation from source (advanced users)

Gentoo Linux users can install from the official portage [repository](https://packages.gentoo.org/packages/dev-embedded/stlink)
When there is no executable available for your platform or you need the latest (possible unstable) version you need to compile the toolset yourself. This procedure is explained in the [compiling manual](doc/compiling.md).

FreeBSD users can install from [freshports](https://www.freshports.org/devel/stlink)

OpenBSD users need to install [from source](doc/compiling.md).
## Contributing and versioning

* 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.

## Installation from source (advanced users)

When there is no executable available for your platform or you need the latest (possible unstable) version you need to compile yourself. This is explained in the [compiling manual](doc/compiling.md).
## License

The stlink library and tools are licensed under the [BSD 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

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))
* 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)


# HOWTO
## Using the gdb server

To run the gdb server:
Expand Down Expand Up @@ -177,84 +263,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.


## Currently known working combinations of programmer and target

See [doc/tested-boards.md](doc/tested-boards.md)

## Changelog

The [Changelog](CHANGELOG.md) for the StLink Tools.


## Known missing features

Some features are missing from the `texane/stlink` project and we would like you to help us out if you want to get involved:

* Control programming speed (See [#462](https://github.com/texane/stlink/issues/462))
* OTP area programming (See [#202](https://github.com/texane/stlink/issues/202))
* EEPROM area programming (See [#318](https://github.com/texane/stlink/issues/218))
* Protection bits area reading (See [#346](https://github.com/texane/stlink/issues/346))
* MCU hotplug (See [#449](https://github.com/texane/stlink/issues/449))
* Writing options bytes (region) (See [#458](https://github.com/texane/stlink/issues/458))
* Instrumentation Trace Macro (ITM) Cell (See [#136](https://github.com/texane/stlink/issues/136))
* Writing external memory connected to an STM32 controller (e.g Quad SPI NOR flash) (See [#412](https://github.com/texane/stlink/issues/412))


## 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)


## Contributing and versioning

* The semantic versioning scheme is used. Read more at [semver.org](http://semver.org)
* When creating a pull request, please open first a issue for discussion of new features. Bugfixes don't need a discussion.

## License

The stlink library and tools are licensed under the [BSD license](LICENSE.md).

The flashloaders/stm32l0x.s and flashloaders/stm32lx.s source files are licensed under the GPLv2+.
8 changes: 8 additions & 0 deletions include/stlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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
Expand All @@ -68,6 +73,9 @@ extern "C" {

#define STLINK_SERIAL_MAX_SIZE 64

#define STLINK_V3_MAX_FREQ_NB 10


/* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/
#define C_BUF_LEN 32

Expand Down
1 change: 1 addition & 0 deletions include/stlink/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enum stlink_debug_commands {
STLINK_DEBUG_ENTER = 0x20,
STLINK_DEBUG_EXIT = 0x21,
STLINK_DEBUG_READCOREID = 0x22,
STLINK_DEBUG_APIV2_ENTER = 0x30,
STLINK_DEBUG_ENTER_SWD = 0xa3
};

Expand Down
Loading

0 comments on commit aad5cf1

Please sign in to comment.