1{ stdenv, lib
2, fetchFromGitHub
3, gcc-arm-embedded
4, pkg-config
5, python3
6, hidapi
7, libftdi1
8, libusb1
9}:
10
11stdenv.mkDerivation rec {
12 pname = "blackmagic";
13 version = "1.8.2";
14 # `git describe --always`
15 firmwareVersion = "v${version}";
16
17 src = fetchFromGitHub {
18 owner = "blacksphere";
19 repo = "blackmagic";
20 rev = firmwareVersion;
21 hash = "sha256-NGzoohmpVwGOncr9AvHYANMf/oEskjmTXYj/Kdx2RwM=";
22 fetchSubmodules = true;
23 };
24
25 nativeBuildInputs = [
26 gcc-arm-embedded
27 pkg-config
28 python3
29 ];
30
31 buildInputs = [
32 hidapi
33 libftdi1
34 libusb1
35 ];
36
37 strictDeps = true;
38
39 postPatch = ''
40 # Prevent calling out to `git' to generate a version number:
41 substituteInPlace src/Makefile \
42 --replace '$(shell git describe --always --dirty)' '${firmwareVersion}'
43
44 # Fix scripts that generate headers:
45 for f in $(find scripts libopencm3/scripts -type f); do
46 patchShebangs "$f"
47 done
48 '';
49
50 buildPhase = ''
51 runHook preBuild
52 ${stdenv.shell} ${./helper.sh}
53 runHook postBuild
54 '';
55
56 dontInstall = true;
57
58 enableParallelBuilding = true;
59
60 meta = with lib; {
61 description = "In-application debugger for ARM Cortex microcontrollers";
62 longDescription = ''
63 The Black Magic Probe is a modern, in-application debugging tool
64 for embedded microprocessors. It allows you to see what is going
65 on "inside" an application running on an embedded microprocessor
66 while it executes.
67
68 This package builds the firmware for all supported platforms,
69 placing them in separate directories under the firmware
70 directory. It also places the FTDI version of the blackmagic
71 executable in the bin directory.
72 '';
73 homepage = "https://github.com/blacksphere/blackmagic";
74 license = licenses.gpl3Plus;
75 maintainers = with maintainers; [ pjones emily sorki ];
76 # fails on darwin with
77 # arm-none-eabi-gcc: error: unrecognized command line option '-iframework'
78 platforms = platforms.linux;
79 };
80}