11 , enableFtdi ? true, libftdi1
13 # Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters)
14 , extraHardwareSupport ? []
17 stdenv.mkDerivation rec {
21 url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2";
22 sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo=";
25 nativeBuildInputs = [ pkg-config ];
27 buildInputs = [ hidapi jimtcl libftdi1 libjaylink libusb1 ]
29 # tracking issue for v2 api changes https://sourceforge.net/p/openocd/tickets/306/
30 lib.optional stdenv.isLinux libgpiod_1;
34 "--disable-internal-jimtcl"
35 "--disable-internal-libjaylink"
38 "--enable-remote-bitbang"
39 (lib.enableFeature enableFtdi "ftdi")
40 (lib.enableFeature stdenv.isLinux "linuxgpiod")
41 (lib.enableFeature stdenv.isLinux "sysfsgpio")
43 map (hardware: "--enable-${hardware}") extraHardwareSupport
46 enableParallelBuilding = true;
48 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [
50 "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0
53 postInstall = lib.optionalString stdenv.isLinux ''
54 mkdir -p "$out/etc/udev/rules.d"
55 rules="$out/share/openocd/contrib/60-openocd.rules"
56 if [ ! -f "$rules" ]; then
57 echo "$rules is missing, must update the Nix file."
60 ln -s "$rules" "$out/etc/udev/rules.d/"
64 description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing";
65 mainProgram = "openocd";
67 OpenOCD provides on-chip programming and debugging support with a layered
68 architecture of JTAG interface and TAP support, debug target support
69 (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several
70 network interfaces are available for interactiving with OpenOCD: HTTP,
71 telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a
72 "remote target" for source-level debugging of embedded systems using the
75 homepage = "https://openocd.sourceforge.net/";
76 license = licenses.gpl2Plus;
77 maintainers = with maintainers; [ bjornfor prusnak ];
78 platforms = platforms.unix;