From b1299b356e479fc0518887ccd7234f9abc26602a Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Mon, 21 Jul 2025 11:47:26 +0300 Subject: [PATCH 1/2] bmputil: 0.1.3 -> 1.0.0 --- pkgs/by-name/bm/bmputil/package.nix | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/bm/bmputil/package.nix b/pkgs/by-name/bm/bmputil/package.nix index be962985b51b..25d13da5692c 100644 --- a/pkgs/by-name/bm/bmputil/package.nix +++ b/pkgs/by-name/bm/bmputil/package.nix @@ -5,27 +5,39 @@ rustPlatform, versionCheckHook, udevCheckHook, + pkg-config, + openssl, }: rustPlatform.buildRustPackage rec { pname = "bmputil"; - version = "0.1.3"; + version = "1.0.0"; src = fetchFromGitHub { owner = "blackmagic-debug"; repo = "bmputil"; tag = "v${version}"; - hash = "sha256-LKtdwQbsPNEu3EDTowOXeFmi5OHOU3kq5f5xxevBjtM="; + hash = "sha256-5BHnh1/6DqjvT0ptOoGqDqVGU0coVPdnZPDQPT9fVFk="; }; useFetchCargoVendor = true; - cargoHash = "sha256-32dTB5gOMgy6Fn62p68tAZB8AYwh1BAW+kwwuZPGJyM="; + cargoHash = "sha256-JoqNEesozr4ahyenZeeAMf0m8M+sxvbF+A6t23Gcz+4="; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ + openssl # can be removed once https://github.com/blackmagic-debug/bmputil/commit/5fa01c20902a3f2570fed58ee66f2241546dd6d7 is released + ]; postInstall = '' install -Dm 444 ${blackmagic.src}/driver/99-blackmagic.rules $out/lib/udev/rules.d/99-blackmagic.rules ''; - nativeInstallCheckInputs = [ versionCheckHook ]; - nativeBuildInputs = [ udevCheckHook ]; + doCheck = false; # fails at least 1 test + + nativeInstallCheckInputs = [ + versionCheckHook + udevCheckHook + ]; versionCheckProgramArg = "--version"; doInstallCheck = true; @@ -36,7 +48,10 @@ rustPlatform.buildRustPackage rec { mit asl20 ]; - mainProgram = "bmputil"; - maintainers = [ lib.maintainers.shimun ]; + mainProgram = "bmputil-cli"; + maintainers = [ + lib.maintainers.shimun + lib.maintainers.carlossless + ]; }; } From f9c48a919ef8fb99c2b3441b57ccfe913218be8b Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Mon, 21 Jul 2025 11:49:35 +0300 Subject: [PATCH 2/2] blackmagic: 1.8.2 -> 2.0.0 --- pkgs/by-name/bl/blackmagic/helper.sh | 51 ------------- pkgs/by-name/bl/blackmagic/package.nix | 99 ++++++++++++++++++++------ pkgs/by-name/bm/bmputil/package.nix | 2 +- 3 files changed, 80 insertions(+), 72 deletions(-) delete mode 100755 pkgs/by-name/bl/blackmagic/helper.sh diff --git a/pkgs/by-name/bl/blackmagic/helper.sh b/pkgs/by-name/bl/blackmagic/helper.sh deleted file mode 100755 index 77f84ef890d4..000000000000 --- a/pkgs/by-name/bl/blackmagic/helper.sh +++ /dev/null @@ -1,51 +0,0 @@ -################################################################################ -# 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 MAKEFLAGS="\ - ${enableParallelBuilding:+-j${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 diff --git a/pkgs/by-name/bl/blackmagic/package.nix b/pkgs/by-name/bl/blackmagic/package.nix index de9749036fea..5755cd4f63e2 100644 --- a/pkgs/by-name/bl/blackmagic/package.nix +++ b/pkgs/by-name/bl/blackmagic/package.nix @@ -2,62 +2,120 @@ stdenv, lib, fetchFromGitHub, - gcc-arm-embedded, + gcc-arm-embedded-13, pkg-config, - python3, + meson, + ninja, hidapi, libftdi1, libusb1, + libgpiod_1, + versionCheckHook, + udevCheckHook, }: +let + libopencm3Src = fetchFromGitHub { + owner = "libopencm3"; + repo = "libopencm3"; + rev = "8a96a9d95a8e5c187a53652540b25a8f4d73a432"; + hash = "sha256-PylP95hpPeg3rqfelHW9qz+pi/qOP60RfvkurxbkWDs="; + }; + ctxlinkWinc1500Src = fetchFromGitHub { + owner = "sidprice"; + repo = "ctxlink_winc1500"; + rev = "debeab9516e33622439f727a68bddabcdf52c528"; + hash = "sha256-IWLIJu2XuwsnP8/2C9uj09EBU2VtwTke3XXbc3NyZt4="; + }; +in stdenv.mkDerivation rec { pname = "blackmagic"; - version = "1.8.2"; + version = "2.0.0"; # `git describe --always` firmwareVersion = "v${version}"; src = fetchFromGitHub { - owner = "blacksphere"; + owner = "blackmagic-debug"; repo = "blackmagic"; rev = firmwareVersion; - hash = "sha256-NGzoohmpVwGOncr9AvHYANMf/oEskjmTXYj/Kdx2RwM="; - fetchSubmodules = true; + hash = "sha256-JbPeN0seSkxV2uZ8BvsvjDUBMOyJu2BxqMgNkhLOiFI="; }; nativeBuildInputs = [ - gcc-arm-embedded + gcc-arm-embedded-13 # fails to build with 14 pkg-config - python3 + meson + ninja + udevCheckHook ]; buildInputs = [ hidapi libftdi1 libusb1 - ]; + ] + ++ lib.optional stdenv.hostPlatform.isLinux libgpiod_1; strictDeps = true; - postPatch = '' - # Prevent calling out to `git' to generate a version number: - substituteInPlace src/Makefile \ - --replace '$(shell git describe --always --dirty)' '${firmwareVersion}' + postUnpack = '' + mkdir -p $sourceRoot/deps/libopencm3 + cp -r ${libopencm3Src}/* $sourceRoot/deps/libopencm3/ - # Fix scripts that generate headers: - for f in $(find scripts libopencm3/scripts -type f); do - patchShebangs "$f" - done + mkdir -p $sourceRoot/deps/winc1500 + cp -r ${ctxlinkWinc1500Src}/* $sourceRoot/deps/winc1500/ ''; buildPhase = '' runHook preBuild - ${stdenv.shell} ${./helper.sh} + + echo "Building host cli" + meson compile -C . + + echo "Building probe firmware" + pushd .. + for cf in cross-file/*.ini; do + target=$(basename "''${cf%.ini}") + + if [ "$target" = "arm-none-eabi" ]; then + echo "Skipping arm-none-eabi target" + continue + fi + + echo "Building target: $target" + mkdir -p "build/firmware/$target" + meson setup "build/firmware/$target" --cross-file "$cf" + meson compile -C "build/firmware/$target" + done + popd + runHook postBuild ''; - dontInstall = true; + installPhase = '' + runHook preInstall - enableParallelBuilding = true; + echo "Installing host cli" + install -Dm555 blackmagic $out/bin/blackmagic + + echo "Installing probe firmware" + for targetDir in firmware/*; do + target=$(basename "$targetDir") + echo "Installing firmware for target: $target" + for f in $targetDir/*.{bin,elf}; do + install -Dm444 $f $out/firmware/$target/$(basename "$f") + done + done + + echo "Installing udev rules" + install -Dm444 ../driver/99-blackmagic-plugdev.rules $out/lib/udev/rules.d/99-blackmagic-plugdev.rules + + runHook postInstall + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "--help"; + doInstallCheck = true; meta = with lib; { description = "In-application debugger for ARM Cortex microcontrollers"; @@ -78,6 +136,7 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ pjones sorki + carlossless ]; platforms = platforms.unix; }; diff --git a/pkgs/by-name/bm/bmputil/package.nix b/pkgs/by-name/bm/bmputil/package.nix index 25d13da5692c..4ad081c193d5 100644 --- a/pkgs/by-name/bm/bmputil/package.nix +++ b/pkgs/by-name/bm/bmputil/package.nix @@ -29,7 +29,7 @@ rustPlatform.buildRustPackage rec { ]; postInstall = '' - install -Dm 444 ${blackmagic.src}/driver/99-blackmagic.rules $out/lib/udev/rules.d/99-blackmagic.rules + install -Dm 444 ${blackmagic.src}/driver/99-blackmagic-plugdev.rules $out/lib/udev/rules.d/99-blackmagic-plugdev.rules ''; doCheck = false; # fails at least 1 test