diff options
author | Pooya Moradi <pvonmoradi@gmail.com> | 2021-08-14 19:08:34 +0430 |
---|---|---|
committer | Pooya Moradi <pvonmoradi@gmail.com> | 2021-08-16 15:29:57 +0430 |
commit | 1b76de8268ece6622d8bf19c634b456c0a2ca79a (patch) | |
tree | 96cc89f8c346319364db5b19331b2d17bcbecf3e /pkgs/development/embedded/blackmagic | |
parent | 08d9ac46db3304a6f10b015d04839c3b1d13aa36 (diff) | |
download | nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.tar nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.tar.gz nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.tar.bz2 nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.tar.lz nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.tar.xz nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.tar.zst nixpkgs-1b76de8268ece6622d8bf19c634b456c0a2ca79a.zip |
blackmagic: move the directory to pkgs/development/embedded/
Diffstat (limited to 'pkgs/development/embedded/blackmagic')
-rw-r--r-- | pkgs/development/embedded/blackmagic/default.nix | 78 | ||||
-rwxr-xr-x | pkgs/development/embedded/blackmagic/helper.sh | 52 |
2 files changed, 130 insertions, 0 deletions
diff --git a/pkgs/development/embedded/blackmagic/default.nix b/pkgs/development/embedded/blackmagic/default.nix new file mode 100644 index 00000000000..f3b3b0b2d04 --- /dev/null +++ b/pkgs/development/embedded/blackmagic/default.nix @@ -0,0 +1,78 @@ +{ stdenv, lib, fetchFromGitHub, fetchpatch +, gcc-arm-embedded, libftdi1, libusb-compat-0_1, pkg-config +, python3 +}: + +with lib; + +stdenv.mkDerivation rec { + pname = "blackmagic"; + version = "unstable-2020-08-05"; + # `git describe --always` + firmwareVersion = "v1.6.1-539-gdd74ec8"; + + src = fetchFromGitHub { + owner = "blacksphere"; + repo = "blackmagic"; + rev = "dd74ec8e6f734302daa1ee361af88dfb5043f166"; + sha256 = "18w8y64fs7wfdypa4vm3migk5w095z8nbd8qp795f322mf2bz281"; + fetchSubmodules = true; + }; + + patches = [ + # Fix deprecation warning with libftdi 1.5 + (fetchpatch { + url = "https://github.com/blacksphere/blackmagic/commit/dea4be2539c5ea63836ec78dca08b52fa8b26ab5.patch"; + sha256 = "0f81simij1wdhifsxaavalc6yxzagfbgwry969dbjmxqzvrsrds5"; + }) + ]; + + nativeBuildInputs = [ + gcc-arm-embedded pkg-config + python3 + ]; + + buildInputs = [ + libftdi1 + libusb-compat-0_1 + ]; + + 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 = "${stdenv.shell} ${./helper.sh}"; + dontInstall = true; + + enableParallelBuilding = true; + + 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 emily sorki ]; + # fails on darwin with + # arm-none-eabi-gcc: error: unrecognized command line option '-iframework' + platforms = platforms.linux; + }; +} diff --git a/pkgs/development/embedded/blackmagic/helper.sh b/pkgs/development/embedded/blackmagic/helper.sh new file mode 100755 index 00000000000..bae57f633cf --- /dev/null +++ b/pkgs/development/embedded/blackmagic/helper.sh @@ -0,0 +1,52 @@ +################################################################################ +# 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 +export MAKEFLAGS="\ + ${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}" + +################################################################################ +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" = "hosted" ]; then + 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 + +mkdir -p "$out/bin" + +for platform in platforms/*/Makefile.inc; do + probe=$(basename "$(dirname "$platform")") + make_platform "$probe" +done |