Skip to content

Commit

Permalink
Update and correction for compiling instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightwalker-87 committed Mar 10, 2021
1 parent 70f68e1 commit 8429ac0
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions doc/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,54 +108,50 @@ or execute (Debian-based systems only): `apt-get install gcc build-essential cma

### Building

#### Installation:

1. Change into the project source directory: `cd stlink`
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_)<br />
4. Run `make install` to full install the package with complete system integration
5. Run `make debug` to create the _Debug_ target (_optional_)<br />
The debug target is only necessary in order to modify the sources and to run under a debugger.
6. Run `make package`to build a Debian Package. The generated packages can be found in the subdirectory `./build/dist`.

The top level Makefile is just a handy wrapper for:
As an option you may also install to an individual user-defined folder e.g `$HOME` with `make install DESTDIR=$HOME`.

##### MinGW64:

```sh
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw64.cmake -S ..
$ make
```
#### Removal:

##### MinGW32:
1. Run `make uninstall` to perform a clean uninstall of the package from the system.
2. Run `make clean` to clean the build-folder within the project source and remove all compiled and linked files and libraries.

```sh
$ mkdir build && cd build
$ cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE=./cmake/linux-mingw32.cmake -S ..
$ make
```

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

When installing system-wide, the dynamic library cache needs to be updated with the command `ldconfig`.
### Cross-Building for Windows

Install the following packages from your package repository:

### Build a Debian Package
* `mingw-w64`
* `mingw-w64-common`
* `mingw-w64-i686-dev`
* `mingw-w64-x86-64-dev`

To build the debian package you need the following extra packages: `devscripts debhelper`.
After following the steps for installation above, proceed with from the build dircetory itself:

```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
$ sudo sh ./cmake/packaging/windows/generate_binaries.sh
```

The generated zip-packages can be found in the subdirectory `./build/dist`.


### Set permissions with udev
### Set device access permissions and the role of 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.<br />
udev rules create devices nodes and set the group of these to `stlink`.
In this context udev rules, which create devices nodes, are necessary to run the tools without root permissions.
To achieve this you need to ensure that the group `plugdev` exists and the user who is trying to access these devices is a member of this group.

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.
Within the sourcefolder of the project, these rules are located in the subdirectory `config/udev/rules.d` and are automatically installed along with `sudo make install` on linux.
Afterwards it may be necessary to reload the udev rules:

```sh
Expand All @@ -164,13 +160,12 @@ $ sudo udevadm control --reload-rules
$ sudo udevadm trigger
```

Udev will now create device node files `/dev/stlinkv2_XX`, `/dev/stlinkv1_XX`.<br />
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.
udev will now create device node files, e.g. `/dev/stlinkv3_XX`, `/dev/stlinkv2_XX`, `/dev/stlinkv1_XX`.


### Note on the use of STLink-v1 programmers (legacy):
### Special note on the use of STLink/V1 programmers (legacy):

As the STLINKv1's SCSI emulation is somehow broken, the best advice possibly is to tell your operating system to completely ignore it.<br />
As the STLINKV1's SCSI emulation is somehow broken, the best advice possibly is to tell your operating system to completely ignore it.<br />
Choose one of the following options _before_ connecting the device to your computer:

* `modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i`
Expand Down

0 comments on commit 8429ac0

Please sign in to comment.