blackmagic: 1.8.2 -> 2.0.0 (bmputil: 0.1.3 -> 1.0.0) (#427095)

This commit is contained in:
Aleksana 2025-07-26 11:50:54 +08:00 committed by GitHub
commit 2aeb783f4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 102 additions and 79 deletions

View File

@ -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

View File

@ -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;
};

View File

@ -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
install -Dm 444 ${blackmagic.src}/driver/99-blackmagic-plugdev.rules $out/lib/udev/rules.d/99-blackmagic-plugdev.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
];
};
}