summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2017-07-05 23:35:16 +0200
committerGitHub <noreply@github.com>2017-07-05 23:35:16 +0200
commit8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc (patch)
tree7ebe92c2a9f8f8908cac8722c3a4dcf88758d394 /pkgs/development
parente52455baffe329dbe388cc551144ccddec7cd699 (diff)
parente33c7fa4c1261f3963d8aa478334d896f2ef9a86 (diff)
downloadnixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.tar
nixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.tar.gz
nixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.tar.bz2
nixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.tar.lz
nixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.tar.xz
nixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.tar.zst
nixlib-8dee8d5f5c04b4b9fe39d1e6cdffcd0c881bf0fc.zip
Merge pull request #26584 from pjones/pjones/blackmagic
blackmagic init at 1.6.1
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/tools/misc/blackmagic/default.nix59
-rwxr-xr-xpkgs/development/tools/misc/blackmagic/helper.sh49
2 files changed, 108 insertions, 0 deletions
diff --git a/pkgs/development/tools/misc/blackmagic/default.nix b/pkgs/development/tools/misc/blackmagic/default.nix
new file mode 100644
index 000000000000..ab84cb37656e
--- /dev/null
+++ b/pkgs/development/tools/misc/blackmagic/default.nix
@@ -0,0 +1,59 @@
+{ stdenv, lib, fetchFromGitHub
+, gcc-arm-embedded, bash, libftdi
+, python, pythonPackages
+}:
+
+with lib;
+
+stdenv.mkDerivation rec {
+  name = "blackmagic-${version}";
+  version = "1.6.1";
+
+  src = fetchFromGitHub {
+    owner = "blacksphere";
+    repo = "blackmagic";
+    rev = "d3a8f27fdbf952194e8fc5ce9b2fc9bcef7c545c";
+    sha256 = "0c3l7cfqag3g7zrfn4mmikkx7076hb1r856ybhhdh0f6zji2j6jx";
+    fetchSubmodules = true;
+  };
+
+  buildInputs = [
+    gcc-arm-embedded
+    libftdi
+    python
+    pythonPackages.intelhex
+  ];
+
+  postPatch = ''
+    # Prevent calling out to `git' to generate a version number:
+    substituteInPlace src/Makefile \
+      --replace '`git describe --always --dirty`' '${version}'
+
+    # Fix scripts that generate headers:
+    for f in $(find scripts libopencm3/scripts -type f); do
+      patchShebangs "$f"
+    done
+  '';
+
+  buildPhase = "${stdenv.shell} ${./helper.sh}";
+  installPhase = ":"; # buildPhase does this.
+
+  meta = {
+    description = "In-application debugger for ARM Cortex microcontrollers";
+    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 ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/development/tools/misc/blackmagic/helper.sh b/pkgs/development/tools/misc/blackmagic/helper.sh
new file mode 100755
index 000000000000..b4c7558885bb
--- /dev/null
+++ b/pkgs/development/tools/misc/blackmagic/helper.sh
@@ -0,0 +1,49 @@
+################################################################################
+# Build all of the platforms manually since the `all_platforms' target
+# doesn't preserve all of the build outputs and overrides CFLAGS.
+set -e
+set -u
+
+################################################################################
+# Prevent a warning from shellcheck:
+out=${out:-/tmp}
+
+################################################################################
+export CFLAGS=$NIX_CFLAGS_COMPILE
+
+################################################################################
+PRODUCTS="blackmagic.bin blackmagic.hex blackmagic_dfu.bin blackmagic_dfu.hex"
+
+################################################################################
+make_platform() {
+  echo "Building for hardware platform $1"
+
+  make clean
+  make PROBE_HOST="$1"
+
+  if [ "$1" = libftdi ]; then
+    mkdir -p "$out/bin"
+    install -m 0555 blackmagic "$out/bin"
+  fi
+
+  for f in $PRODUCTS; do
+    if [ -r "$f" ]; then
+      mkdir -p "$out/firmware/$1"
+      install -m 0444 "$f" "$out/firmware/$1"
+    fi
+  done
+
+}
+
+################################################################################
+# Start by building libopencm3:
+make -C libopencm3
+
+################################################################################
+# And now all of the platforms:
+cd src
+
+for platform in platforms/*/Makefile.inc; do
+  probe=$(basename "$(dirname "$platform")")
+  make_platform "$probe"
+done