1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 pkg-config,
7 libusb1,
8 pico-sdk,
9 mbedtls_2,
10 versionCheckHook,
11 gitUpdater,
12}:
13
14stdenv.mkDerivation (finalAttrs: {
15 pname = "picotool";
16 version = "2.1.1";
17
18 src = fetchFromGitHub {
19 owner = "raspberrypi";
20 repo = "picotool";
21 tag = finalAttrs.version;
22 hash = "sha256-WA17FXSUGylzUcbvzgAGCeds+XeuSvDlgFBJD10ERVY=";
23 };
24
25 postPatch = ''
26 # necessary for signing/hashing support. our pico-sdk does not come with
27 # it by default, and it shouldn't due to submodule size. pico-sdk uses
28 # an upstream version of mbedtls 2.x so we patch ours in directly.
29 substituteInPlace lib/CMakeLists.txt \
30 --replace-fail "''$"'{PICO_SDK_PATH}/lib/mbedtls' '${mbedtls_2.src}'
31 '';
32
33 buildInputs = [
34 libusb1
35 pico-sdk
36 ];
37 nativeBuildInputs = [
38 cmake
39 pkg-config
40 ];
41 cmakeFlags = [ "-DPICO_SDK_PATH=${pico-sdk}/lib/pico-sdk" ];
42
43 postInstall = ''
44 install -Dm444 ../udev/99-picotool.rules -t $out/etc/udev/rules.d
45 '';
46
47 nativeInstallCheckInputs = [
48 versionCheckHook
49 ];
50 versionCheckProgramArg = "version";
51 doInstallCheck = true;
52
53 passthru = {
54 updateScript = gitUpdater { };
55 };
56
57 meta = {
58 description = "Tool for interacting with RP2040/RP2350 device(s) in BOOTSEL mode, or with an RP2040/RP2350 binary";
59 homepage = "https://github.com/raspberrypi/picotool";
60 changelog = "https://github.com/raspberrypi/picotool/releases/tag/${finalAttrs.version}";
61 mainProgram = "picotool";
62 license = lib.licenses.bsd3;
63 maintainers = with lib.maintainers; [ muscaln ];
64 platforms = lib.platforms.unix;
65 };
66})