@@ -0,0 +1,59 @@
1+{ stdenv, lib, fetchFromGitHub
2+, gcc-arm-embedded, bash, libftdi
3+, python, pythonPackages
4+}:
5+
6+with lib;
7+
8+stdenv.mkDerivation rec {
9+ name = "blackmagic-${version}";
10+ version = "1.6.1";
11+
12+ src = fetchFromGitHub {
13+ owner = "blacksphere";
14+ repo = "blackmagic";
15+ rev = "d3a8f27fdbf952194e8fc5ce9b2fc9bcef7c545c";
16+ sha256 = "0c3l7cfqag3g7zrfn4mmikkx7076hb1r856ybhhdh0f6zji2j6jx";
17+ fetchSubmodules = true;
18+ };
19+
20+ buildInputs = [
21+ gcc-arm-embedded
22+ libftdi
23+ python
24+ pythonPackages.intelhex
25+ ];
26+
27+ postPatch = ''
28+ # Prevent calling out to `git' to generate a version number:
29+ substituteInPlace src/Makefile \
30+ --replace '`git describe --always --dirty`' '${version}'
31+
32+ # Fix scripts that generate headers:
33+ for f in $(find scripts libopencm3/scripts -type f); do
34+ patchShebangs "$f"
35+ done
36+ '';
37+
38+ buildPhase = "${stdenv.shell} ${./helper.sh}";
39+ installPhase = ":"; # buildPhase does this.
40+
41+ meta = {
42+ description = "In-application debugger for ARM Cortex microcontrollers";
43+ longDescription = ''
44+ The Black Magic Probe is a modern, in-application debugging tool
45+ for embedded microprocessors. It allows you to see what is going
46+ on "inside" an application running on an embedded microprocessor
47+ while it executes.
48+
49+ This package builds the firmware for all supported platforms,
50+ placing them in separate directories under the firmware
51+ directory. It also places the FTDI version of the blackmagic
52+ executable in the bin directory.
53+ '';
54+ homepage = https://github.com/blacksphere/blackmagic;
55+ license = licenses.gpl3Plus;
56+ maintainers = with maintainers; [ pjones ];
57+ platforms = platforms.unix;
58+ };
59+}