at 23.11-beta 79 lines 2.5 kB view raw
1{ stdenv 2, lib 3, fetchurl 4, pkg-config 5, hidapi 6, jimtcl 7, libjaylink 8, libusb1 9, libgpiod_1 10 11, enableFtdi ? true, libftdi1 12 13# Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters) 14, extraHardwareSupport ? [] 15}: 16 17stdenv.mkDerivation rec { 18 pname = "openocd"; 19 version = "0.12.0"; 20 src = fetchurl { 21 url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2"; 22 sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo="; 23 }; 24 25 nativeBuildInputs = [ pkg-config ]; 26 27 buildInputs = [ hidapi jimtcl libftdi1 libjaylink libusb1 ] 28 ++ 29 # tracking issue for v2 api changes https://sourceforge.net/p/openocd/tickets/306/ 30 lib.optional stdenv.isLinux libgpiod_1; 31 32 configureFlags = [ 33 "--disable-werror" 34 "--disable-internal-jimtcl" 35 "--disable-internal-libjaylink" 36 "--enable-jtag_vpi" 37 "--enable-buspirate" 38 "--enable-remote-bitbang" 39 (lib.enableFeature enableFtdi "ftdi") 40 (lib.enableFeature stdenv.isLinux "linuxgpiod") 41 (lib.enableFeature stdenv.isLinux "sysfsgpio") 42 ] ++ 43 map (hardware: "--enable-${hardware}") extraHardwareSupport 44 ; 45 46 enableParallelBuilding = true; 47 48 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ 49 "-Wno-error=cpp" 50 "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0 51 ]); 52 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." 58 exit 1 59 fi 60 ln -s "$rules" "$out/etc/udev/rules.d/" 61 ''; 62 63 meta = with lib; { 64 description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing"; 65 longDescription = '' 66 OpenOCD provides on-chip programming and debugging support with a layered 67 architecture of JTAG interface and TAP support, debug target support 68 (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several 69 network interfaces are available for interactiving with OpenOCD: HTTP, 70 telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a 71 "remote target" for source-level debugging of embedded systems using the 72 GNU GDB program. 73 ''; 74 homepage = "https://openocd.sourceforge.net/"; 75 license = licenses.gpl2Plus; 76 maintainers = with maintainers; [ bjornfor prusnak ]; 77 platforms = platforms.unix; 78 }; 79}