diff --git a/pkgs/by-name/gc/gcc-arm-embedded-12-2-rel1/package.nix b/pkgs/by-name/gc/gcc-arm-embedded-12-2-rel1/package.nix new file mode 100644 index 00000000000000..445ce1a4c6afcb --- /dev/null +++ b/pkgs/by-name/gc/gcc-arm-embedded-12-2-rel1/package.nix @@ -0,0 +1,97 @@ +{ + 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 = { + 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 lib.licenses; [ + bsd2 + gpl2 + gpl3 + lgpl21 + lgpl3 + mit + ]; + maintainers = with lib.maintainers; [ + prusnak + prtzl + carlossless + ]; + platforms = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +} diff --git a/pkgs/development/embedded/blackmagic/default.nix b/pkgs/development/embedded/blackmagic/default.nix index bb09ade35f2ffc..c353051f085aa2 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 - } ################################################################################