about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/embedded/blackmagic/default.nix
blob: 893a0c889fadad878276397a36f3d681751fcac2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ stdenv, lib
, fetchFromGitHub
, gcc-arm-embedded
, pkg-config
, python3
, hidapi
, libftdi1
, libusb1
}:

stdenv.mkDerivation rec {
  pname = "blackmagic";
  version = "1.8.2";
  # `git describe --always`
  firmwareVersion = "v${version}";

  src = fetchFromGitHub {
    owner = "blacksphere";
    repo = "blackmagic";
    rev = firmwareVersion;
    hash = "sha256-NGzoohmpVwGOncr9AvHYANMf/oEskjmTXYj/Kdx2RwM=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    gcc-arm-embedded
    pkg-config
    python3
  ];

  buildInputs = [
    hidapi
    libftdi1
    libusb1
  ];

  strictDeps = true;

  postPatch = ''
    # Prevent calling out to `git' to generate a version number:
    substituteInPlace src/Makefile \
      --replace '$(shell git describe --always --dirty)' '${firmwareVersion}'

    # Fix scripts that generate headers:
    for f in $(find scripts libopencm3/scripts -type f); do
      patchShebangs "$f"
    done
  '';

  buildPhase = ''
    runHook preBuild
    ${stdenv.shell} ${./helper.sh}
    runHook postBuild
  '';

  dontInstall = true;

  enableParallelBuilding = true;

  meta = with lib; {
    description = "In-application debugger for ARM Cortex microcontrollers";
    mainProgram = "blackmagic";
    longDescription = ''
      The Black Magic Probe is a modern, in-application debugging tool
      for embedded microprocessors. It allows you to see what is going
      on "inside" an application running on an embedded microprocessor
      while it executes.

      This package builds the firmware for all supported platforms,
      placing them in separate directories under the firmware
      directory.  It also places the FTDI version of the blackmagic
      executable in the bin directory.
    '';
    homepage = "https://github.com/blacksphere/blackmagic";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ pjones emily sorki ];
    platforms = platforms.unix;
  };
}