From 7a6e22ba26c379c346d30577c8978d4e61e40be9 Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Mon, 28 Oct 2024 22:54:05 +0100 Subject: [PATCH] blackmagic: 1.8.2 -> 1.10.2 --- .../gcc-arm-embedded/12-2-rel1/default.nix | 68 +++++++++++++++++++ .../embedded/blackmagic/default.nix | 46 ++++++++----- .../development/embedded/blackmagic/helper.sh | 5 +- pkgs/top-level/all-packages.nix | 2 + 4 files changed, 102 insertions(+), 19 deletions(-) create mode 100644 pkgs/development/compilers/gcc-arm-embedded/12-2-rel1/default.nix diff --git a/pkgs/development/compilers/gcc-arm-embedded/12-2-rel1/default.nix b/pkgs/development/compilers/gcc-arm-embedded/12-2-rel1/default.nix new file mode 100644 index 00000000000000..529c0d0114c813 --- /dev/null +++ b/pkgs/development/compilers/gcc-arm-embedded/12-2-rel1/default.nix @@ -0,0 +1,68 @@ +{ lib +, stdenv +, fetchurl +, ncurses5 +, python39 +, libxcrypt-legacy +, runtimeShell +}: + +stdenv.mkDerivation rec { + pname = "gcc-arm-embedded"; + version = "12.2.rel1"; + + platform = { + aarch64-darwin = "darwin-arm64"; + aarch64-linux = "aarch64"; + x86_64-darwin = "darwin-x86_64"; + x86_64-linux = "x86_64"; + }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + + src = fetchurl { + url = "https://developer.arm.com/-/media/Files/downloads/gnu/${version}/binrel/arm-gnu-toolchain-${version}-${platform}-arm-none-eabi.tar.xz"; + sha256 = { + aarch64-darwin = "0j12n631bmbfvnfbmv4q7cfhmh4l7ka3vcjcvyw0vjqb4msyia91"; + aarch64-linux = "131ydgndff7dyhkivfchbk43lv3cv2p172knkqilx64aapvk5qvy"; + x86_64-darwin = "00i9gd1ny00681pwinh6ng9x45xsyrnwc6hm2vr348z9gasyxh00"; + x86_64-linux = "0rv8r5zh0a5621v0xygxi8f6932qgwinw2s9vnniasp9z7897gl4"; + }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + }; + + dontConfigure = true; + dontBuild = true; + dontPatchELF = true; + dontStrip = true; + + installPhase = '' + mkdir -p $out + cp -r * $out + ''; + + preFixup = '' + find $out -type f | while read f; do + patchelf "$f" > /dev/null 2>&1 || continue + patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true + patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python39 libxcrypt-legacy ]} "$f" || true + done + ''; + + postFixup = '' + mv $out/bin/arm-none-eabi-gdb $out/bin/arm-none-eabi-gdb-unwrapped + cat < $out/bin/arm-none-eabi-gdb + #!${runtimeShell} + export PYTHONPATH=${python39}/lib/python3.9 + export PYTHONHOME=${python39.interpreter} + exec $out/bin/arm-none-eabi-gdb-unwrapped "\$@" + EOF + chmod +x $out/bin/arm-none-eabi-gdb + ''; + + meta = with lib; { + description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors"; + homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm"; + license = with licenses; [ bsd2 gpl2 gpl3 lgpl21 lgpl3 mit ]; + maintainers = with maintainers; [ prusnak prtzl carlossless ]; + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + }; +} diff --git a/pkgs/development/embedded/blackmagic/default.nix b/pkgs/development/embedded/blackmagic/default.nix index bb09ade35f2ffc..051688e2fafce9 100644 --- a/pkgs/development/embedded/blackmagic/default.nix +++ b/pkgs/development/embedded/blackmagic/default.nix @@ -1,31 +1,37 @@ -{ stdenv, lib -, fetchFromGitHub -, gcc-arm-embedded -, pkg-config -, python3 -, hidapi -, libftdi1 -, libusb1 +{ + stdenv, + lib, + fetchFromGitHub, + gnumake, + pkg-config, + python3, + hidapi, + libftdi1, + libusb1, + gcc-arm-embedded-12-2-rel1 }: stdenv.mkDerivation rec { pname = "blackmagic"; - version = "1.8.2"; + version = "1.10.2"; # `git describe --always` firmwareVersion = "v${version}"; src = fetchFromGitHub { - owner = "blacksphere"; + owner = "blackmagic-debug"; repo = "blackmagic"; - rev = firmwareVersion; - hash = "sha256-NGzoohmpVwGOncr9AvHYANMf/oEskjmTXYj/Kdx2RwM="; + rev = "refs/tags/${firmwareVersion}"; + hash = "sha256-ZhcVGSES+RPSjS7Pdk1EGWF8MfIW19HmHbvYtzMECME="; fetchSubmodules = true; }; nativeBuildInputs = [ - gcc-arm-embedded + gnumake pkg-config python3 + # only this or previous versions of gcc-arm-embedded builds 1.10.2 in a way that fits into rom for the native platform + # https://github.com/blackmagic-debug/blackmagic/issues/1978 + gcc-arm-embedded-12-2-rel1 ]; buildInputs = [ @@ -39,7 +45,7 @@ stdenv.mkDerivation rec { postPatch = '' # Prevent calling out to `git' to generate a version number: substituteInPlace src/Makefile \ - --replace '$(shell git describe --always --dirty)' '${firmwareVersion}' + --replace-fail '$(shell if [ -e "../.git" ]; then git describe --always --dirty --tags; fi)' '${firmwareVersion}' # Fix scripts that generate headers: for f in $(find scripts libopencm3/scripts -type f); do @@ -57,7 +63,7 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - meta = with lib; { + meta = { description = "In-application debugger for ARM Cortex microcontrollers"; mainProgram = "blackmagic"; longDescription = '' @@ -72,8 +78,12 @@ stdenv.mkDerivation rec { executable in the bin directory. ''; homepage = "https://github.com/blacksphere/blackmagic"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ pjones sorki ]; - platforms = platforms.unix; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ + pjones + sorki + carlossless + ]; + platforms = lib.platforms.unix; }; } diff --git a/pkgs/development/embedded/blackmagic/helper.sh b/pkgs/development/embedded/blackmagic/helper.sh index 77f84ef890d41e..9ab05553d9c5f2 100755 --- a/pkgs/development/embedded/blackmagic/helper.sh +++ b/pkgs/development/embedded/blackmagic/helper.sh @@ -17,6 +17,10 @@ PRODUCTS="blackmagic.bin blackmagic.hex blackmagic_dfu.bin blackmagic_dfu.hex" ################################################################################ make_platform() { + if [ "$1" = "common" ]; then + return; + fi + echo "Building for hardware platform $1" make clean @@ -32,7 +36,6 @@ make_platform() { install -m 0444 "$f" "$out/firmware/$1" fi done - } ################################################################################ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e9c67d18a97c3e..2526a7b170ebbe 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14860,6 +14860,8 @@ with pkgs; gcc-arm-embedded-13 = callPackage ../development/compilers/gcc-arm-embedded/13 { }; gcc-arm-embedded = gcc-arm-embedded-12; + gcc-arm-embedded-12-2-rel1 = callPackage ../development/compilers/gcc-arm-embedded/12-2-rel1 { }; + # It would be better to match the default gcc so that there are no linking errors # when using C/C++ libraries in D packages, but right now versions >= 12 are broken. gdc = gdc11;