diff options
Diffstat (limited to 'nixpkgs/pkgs/development/embedded')
51 files changed, 2765 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-ci/default.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-ci/default.nix new file mode 100644 index 000000000000..fe28a962e102 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-ci/default.nix @@ -0,0 +1,45 @@ +{ lib, stdenv, fetchFromGitHub, makeWrapper, arduino-cli, ruby, python3 }: + +let + + runtimePath = lib.makeBinPath [ + arduino-cli + python3 # required by the esp8266 core + ]; + +in +stdenv.mkDerivation rec { + pname = "arduino-ci"; + version = "0.2.0"; + + src = fetchFromGitHub { + owner = "pololu"; + repo = "arduino-ci"; + rev = "v${version}"; + sha256 = "sha256-9RbBxgwsSQ7oGGKr1Vsn9Ug9AsacoRgvQgd9jbRQ034="; + }; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + install $src/ci.rb $out/bin/arduino-ci + + runHook postInstall + ''; + + fixupPhase = '' + substituteInPlace $out/bin/arduino-ci --replace "/usr/bin/env nix-shell" "${ruby}/bin/ruby" + wrapProgram $out/bin/arduino-ci --prefix PATH ":" "${runtimePath}" + ''; + + meta = with lib; { + description = "CI for Arduino Libraries"; + homepage = src.meta.homepage; + license = licenses.mit; + maintainers = with maintainers; [ ryantm ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-cli/default.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-cli/default.nix new file mode 100644 index 000000000000..c41f884d4fe1 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-cli/default.nix @@ -0,0 +1,97 @@ +{ lib, stdenv, buildGoModule, fetchFromGitHub, buildFHSEnv, installShellFiles, go-task }: + +let + + pkg = buildGoModule rec { + pname = "arduino-cli"; + version = "0.34.2"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = pname; + rev = version; + hash = "sha256-X7vrcaJkVqzZoaIFLWJhhdlgRpckLG69uVmUUZd/XXY="; + }; + + nativeBuildInputs = [ + installShellFiles + ]; + + nativeCheckInputs = [ + go-task + ]; + + subPackages = [ "." ]; + + vendorHash = "sha256-cr5D7QDh65xWZJ4gq32ehklwrHWyQEWW/FZZ4gPTJBk="; + + postPatch = let + skipTests = [ + # tries to "go install" + "TestDummyMonitor" + # try to Get "https://downloads.arduino.cc/libraries/library_index.tar.bz2" + "TestDownloadAndChecksums" + "TestParseArgs" + "TestParseReferenceCores" + "TestPlatformSearch" + "TestPlatformSearchSorting" + ]; + in '' + substituteInPlace Taskfile.yml \ + --replace "go test" "go test -p $NIX_BUILD_CORES -skip '(${lib.concatStringsSep "|" skipTests})'" + ''; + + doCheck = stdenv.isLinux; + + checkPhase = '' + runHook preCheck + task go:test + runHook postCheck + ''; + + ldflags = [ + "-s" "-w" "-X github.com/arduino/arduino-cli/version.versionString=${version}" "-X github.com/arduino/arduino-cli/version.commit=unknown" + ] ++ lib.optionals stdenv.isLinux [ "-extldflags '-static'" ]; + + postInstall = '' + export HOME="$(mktemp -d)" + for s in {bash,zsh,fish}; do + $out/bin/arduino-cli completion $s > completion.$s + installShellCompletion --cmd arduino-cli --$s completion.$s + done + unset HOME + ''; + + meta = with lib; { + inherit (src.meta) homepage; + description = "Arduino from the command line"; + changelog = "https://github.com/arduino/arduino-cli/releases/tag/${version}"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ ryantm ]; + }; + + }; + +in +if stdenv.isLinux then +# buildFHSEnv is needed because the arduino-cli downloads compiler +# toolchains from the internet that have their interpreters pointed at +# /lib64/ld-linux-x86-64.so.2 + buildFHSEnv + { + inherit (pkg) name meta; + + runScript = "${pkg.outPath}/bin/arduino-cli"; + + extraInstallCommands = '' + mv $out/bin/$name $out/bin/arduino-cli + cp -r ${pkg.outPath}/share $out/share + ''; + passthru.pureGoPkg = pkg; + + targetPkgs = pkgs: with pkgs; [ + zlib + ]; + } +else + pkg diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix new file mode 100644 index 000000000000..a97fa50aebf2 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-core/chrootenv.nix @@ -0,0 +1,36 @@ +{ lib, buildFHSEnv, arduino-core-unwrapped, withGui ? false, withTeensyduino ? false }: +let + arduino-unwrapped = arduino-core-unwrapped.override { inherit withGui withTeensyduino; }; +in +buildFHSEnv { + name = "arduino"; + + targetPkgs = + pkgs: (with pkgs; [ + ncurses + arduino-unwrapped + zlib + (python3.withPackages (p: with p; [ + pyserial + ])) + ]); + multiArch = false; + + extraInstallCommands = '' + ${lib.optionalString withGui '' + # desktop file + mkdir -p $out/share/applications + cp ${arduino-core-unwrapped.src}/build/linux/dist/desktop.template $out/share/applications/arduino.desktop + substituteInPlace $out/share/applications/arduino.desktop \ + --replace '<BINARY_LOCATION>' "$out/bin/arduino" \ + --replace '<ICON_NAME>' "$out/share/arduino/icons/128x128/apps/arduino.png" + # icon file + mkdir -p $out/share/arduino + cp -r ${arduino-core-unwrapped.src}/build/shared/icons $out/share/arduino + ''} + ''; + + runScript = "arduino"; + + meta = arduino-core-unwrapped.meta; +} diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-core/default.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-core/default.nix new file mode 100644 index 000000000000..91c2792f9be1 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-core/default.nix @@ -0,0 +1,254 @@ +{ stdenv +, lib +, fetchFromGitHub +, fetchurl +, jdk +, ant +, libusb-compat-0_1 +, libusb1 +, unzip +, zlib +, ncurses +, readline +, withGui ? false +, gtk3 +, wrapGAppsHook +, withTeensyduino ? false + /* Packages needed for Teensyduino */ +, upx +, fontconfig +, xorg +, gcc +, atk +, glib +, pango +, gdk-pixbuf +, gtk2 +, libpng12 +, expat +, freetype +, cairo +, udev +}: + +assert withTeensyduino -> withGui; +let + externalDownloads = import ./downloads.nix { + inherit fetchurl; + inherit (lib) optionalAttrs; + inherit (stdenv.hostPlatform) system; + }; + # Some .so-files are later copied from .jar-s to $HOME, so patch them beforehand + patchelfInJars = + lib.optional (stdenv.hostPlatform.system == "aarch64-linux") { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_aarch64.so"; } + ++ lib.optional (builtins.match "armv[67]l-linux" stdenv.hostPlatform.system != null) { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_armhf.so"; } + ++ lib.optional (stdenv.hostPlatform.system == "x86_64-linux") { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_x86_64.so"; } + ++ lib.optional (stdenv.hostPlatform.system == "i686-linux") { jar = "share/arduino/lib/jssc-2.8.0-arduino4.jar"; file = "libs/linux/libjSSC-2.8_x86.so"; } + ; + # abiVersion 6 is default, but we need 5 for `avrdude_bin` executable + ncurses5 = ncurses.override { abiVersion = "5"; }; + teensy_libpath = lib.makeLibraryPath [ + atk + cairo + expat + fontconfig + freetype + gcc.cc.lib + gdk-pixbuf + glib + gtk2 + libpng12 + libusb-compat-0_1 + pango + udev + xorg.libSM + xorg.libX11 + xorg.libXext + xorg.libXft + xorg.libXinerama + xorg.libXxf86vm + zlib + ]; + teensy_architecture = + if stdenv.hostPlatform.isx86_32 then "linux32" + else if stdenv.hostPlatform.isx86_64 then "linux64" + else if stdenv.hostPlatform.isAarch64 then "linuxaarch64" + else if stdenv.hostPlatform.isAarch32 then "linuxarm" + else throw "${stdenv.hostPlatform.system} is not supported in teensy"; + +in +stdenv.mkDerivation rec { + pname = (if withTeensyduino then "teensyduino" else "arduino") + lib.optionalString (!withGui) "-core"; + version = "1.8.19"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = "Arduino"; + rev = version; + sha256 = "sha256-I+PvfGc5F8H/NJOGRa18z7dKyKcO8I8Cg7Tj5yxkYAQ="; + }; + + teensyduino_version = "156"; + teensyduino_src = fetchurl { + url = "https://www.pjrc.com/teensy/td_${teensyduino_version}/TeensyduinoInstall.${teensy_architecture}"; + sha256 = { + linux64 = "sha256-4DbhmmYrx+rCBpDrYFaC0A88Qv9UEeNlQAkFi3zAstk="; + linux32 = "sha256-DlRPOtDxmMPv2Qzhib7vNZdKNZCxmm9YmVNnwUKXK/E="; + linuxarm = "sha256-d+DbpER/4lFPcPDFeMG5f3WaUGn8pFchdIDo7Hm0XWs="; + linuxaarch64 = "sha256-8keQzhWq7QlAGIbfHEe3lfxpJleMMvBORuPaNrLmM6Y="; + }.${teensy_architecture} or (throw "No arduino binaries for ${teensy_architecture}"); + }; + # Used because teensyduino requires jars be a specific size + arduino_dist_src = fetchurl { + url = "https://downloads.arduino.cc/arduino-${version}-${teensy_architecture}.tar.xz"; + sha256 = { + linux64 = "sha256-62i93B0cASC+L8oTUKA+40Uxzzf1GEeyEhC25wVFvJs="; + linux32 = "sha256-wSxtx3BqXMQCeWQDK8PHkWLlQqQM1Csao8bIk98FrFg="; + linuxarm = "sha256-lJ/R1ePq7YtDk3bvloFcn8jswrJH+L63tvH5QpTqfXs="; + linuxaarch64 = "sha256-gm8cDjLKNfpcaeO7fw6Kyv1TnWV/ZmH4u++nun9X6jo="; + }.${teensy_architecture} or (throw "No arduino binaries for ${teensy_architecture}"); + }; + + # the glib setup hook will populate GSETTINGS_SCHEMAS_PATH, + # wrapGAppHooks (among other things) adds it to XDG_DATA_DIRS + # so 'save as...' works: + nativeBuildInputs = [ glib wrapGAppsHook unzip ]; + buildInputs = [ + jdk + ant + libusb-compat-0_1 + libusb1 + zlib + ncurses5 + readline + ] ++ lib.optionals withTeensyduino [ upx ]; + downloadSrcList = builtins.attrValues externalDownloads; + downloadDstList = builtins.attrNames externalDownloads; + + buildPhase = '' + # Copy pre-downloaded files to proper locations + download_src=($downloadSrcList) + download_dst=($downloadDstList) + while [[ "''${#download_src[@]}" -ne 0 ]]; do + file_src=''${download_src[0]} + file_dst=''${download_dst[0]} + mkdir -p $(dirname $file_dst) + download_src=(''${download_src[@]:1}) + download_dst=(''${download_dst[@]:1}) + cp -v $file_src $file_dst + done + + # Deliberately break build.xml's download statement in order to cause + # an error if anything needed is missing from download.nix. + substituteInPlace build/build.xml \ + --replace 'ignoreerrors="true"' 'ignoreerrors="false"' + + cd ./arduino-core && ant + cd ../build && ant + cd .. + ''; + + # This will be patched into `arduino` wrapper script + # Java loads gtk dynamically, so we need to provide it using LD_LIBRARY_PATH + dynamicLibraryPath = lib.makeLibraryPath [ gtk3 ]; + javaPath = lib.makeBinPath [ jdk ]; + + # Everything else will be patched into rpath + rpath = lib.makeLibraryPath [ zlib libusb-compat-0_1 libusb1 readline ncurses5 stdenv.cc.cc ]; + + installPhase = '' + mkdir -p $out/share/arduino + cp -r ./build/linux/work/* "$out/share/arduino/" + echo -n ${version} > $out/share/arduino/lib/version.txt + + ${lib.optionalString withGui '' + mkdir -p $out/bin + substituteInPlace $out/share/arduino/arduino \ + --replace "JAVA=java" "JAVA=$javaPath/java" \ + --replace "LD_LIBRARY_PATH=" "LD_LIBRARY_PATH=$dynamicLibraryPath:" + ln -sr "$out/share/arduino/arduino" "$out/bin/arduino" + + cp -r build/shared/icons $out/share/arduino + mkdir -p $out/share/applications + cp build/linux/dist/desktop.template $out/share/applications/arduino.desktop + substituteInPlace $out/share/applications/arduino.desktop \ + --replace '<BINARY_LOCATION>' "$out/bin/arduino" \ + --replace '<ICON_NAME>' "$out/share/arduino/icons/128x128/apps/arduino.png" + ''} + + ${lib.optionalString withTeensyduino '' + # Back up the original jars + mv $out/share/arduino/lib/arduino-core.jar $out/share/arduino/lib/arduino-core.jar.bak + mv $out/share/arduino/lib/pde.jar $out/share/arduino/lib/pde.jar.bak + # Extract jars from the arduino distributable package + mkdir arduino_dist + cd arduino_dist + tar xfJ ${arduino_dist_src} arduino-${version}/lib/arduino-core.jar arduino-${version}/lib/pde.jar + cd .. + # Replace the built jars with the official arduino jars + mv arduino_dist/arduino-${version}/lib/{arduino-core,pde}.jar $out/share/arduino/lib/ + # Delete the directory now that the jars are copied out + rm -r arduino_dist + # Extract and patch the Teensyduino installer + cp ${teensyduino_src} ./TeensyduinoInstall.${teensy_architecture} + chmod +w ./TeensyduinoInstall.${teensy_architecture} + upx -d ./TeensyduinoInstall.${teensy_architecture} + patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + --set-rpath "${teensy_libpath}" \ + ./TeensyduinoInstall.${teensy_architecture} + chmod +x ./TeensyduinoInstall.${teensy_architecture} + ./TeensyduinoInstall.${teensy_architecture} --dir=$out/share/arduino + # Check for successful installation + [ -d $out/share/arduino/hardware/teensy ] || exit 1 + # After the install, copy the built jars back + mv $out/share/arduino/lib/arduino-core.jar.bak $out/share/arduino/lib/arduino-core.jar + mv $out/share/arduino/lib/pde.jar.bak $out/share/arduino/lib/pde.jar + ''} + ''; + + # So we don't accidentally mess with firmware files + dontStrip = true; + dontPatchELF = true; + + preFixup = '' + for file in $(find $out -type f \( -perm /0111 -o -name \*.so\* \) ); do + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$file" || true + patchelf --set-rpath ${rpath}:$out/lib $file || true + done + + ${lib.concatMapStringsSep "\n" + ({ jar, file }: + '' + jar xvf $out/${jar} ${file} + patchelf --set-rpath $rpath ${file} + jar uvf $out/${jar} ${file} + rm -f ${file} + '' + ) + patchelfInJars} + + # avrdude_bin is linked against libtinfo.so.5 + mkdir $out/lib/ + ln -s ${lib.makeLibraryPath [ ncurses5 ]}/libtinfo.so.5 $out/lib/libtinfo.so.5 + + ${lib.optionalString withTeensyduino '' + # Patch the Teensy loader binary + patchelf --debug \ + --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \ + --set-rpath "${teensy_libpath}" \ + $out/share/arduino/hardware/tools/teensy{,_ports,_reboot,_restart,_serialmon} + ''} + ''; + + meta = with lib; { + description = "Open-source electronics prototyping platform"; + homepage = "https://www.arduino.cc/"; + license = if withTeensyduino then licenses.unfreeRedistributable else licenses.gpl2; + sourceProvenance = with sourceTypes; [ + binaryBytecode + binaryNativeCode + ]; + platforms = platforms.linux; + maintainers = with maintainers; [ antono auntie robberer bjornfor bergey ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-core/downloads.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-core/downloads.nix new file mode 100644 index 000000000000..14ce93d2c50a --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-core/downloads.nix @@ -0,0 +1,217 @@ +{ fetchurl +, optionalAttrs +, system +}: +# This file preloads all the archives which Arduino's build/build.xml +# would otherwise try to download itself. When updating this for a new +# version of Arduino, check build.xml for version numbers and new +# urls. +{ + "build/shared/reference-1.6.6-3.zip" = fetchurl { + url = "https://downloads.arduino.cc/reference-1.6.6-3.zip"; + sha256 = "119nj1idz85l71fy6a6wwsx0mcd8y0ib1wy0l6j9kz88nkwvggy3"; + }; + "build/shared/Galileo_help_files-1.6.2.zip" = fetchurl { + url = "https://downloads.arduino.cc/Galileo_help_files-1.6.2.zip"; + sha256 = "0qda0xml353sfhjmx9my4mlcyzbf531k40dcr1cnsa438xp2fw0w"; + }; + "build/shared/Edison_help_files-1.6.2.zip" = fetchurl { + url = "https://downloads.arduino.cc/Edison_help_files-1.6.2.zip"; + sha256 = "1x25rivmh0zpa6lr8dafyxvim34wl3wnz3r9msfxg45hnbjqqwan"; + }; + "build/Ethernet-2.0.0.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Ethernet/archive/2.0.0.zip"; + sha256 = "0had46c1n1wx9fa7ki5dwidvchiy00pv7qj9msp6wgv199vm19m8"; + }; + "build/GSM-1.0.6.zip" = fetchurl { + url = "https://github.com/arduino-libraries/GSM/archive/1.0.6.zip"; + sha256 = "1kmikxr07cyzsnhhymvgj9m4dxi671ni120l33gfmmm6079qfwbk"; + }; + "build/Stepper-1.1.3.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Stepper/archive/1.1.3.zip"; + sha256 = "1kyv6bmhmbjh7z8x77v04aywd2s54nm80g0j07gay2sa3f6k1p4v"; + }; + "build/TFT-1.0.6.zip" = fetchurl { + url = "https://github.com/arduino-libraries/TFT/archive/1.0.6.zip"; + sha256 = "1d69xp3hrva58nrx0vy4skrr1h63649q1jnc2g55bpbaxjhf5j5w"; + }; + "build/WiFi-1.2.7.zip" = fetchurl { + url = "https://github.com/arduino-libraries/WiFi/archive/1.2.7.zip"; + sha256 = "1fmj2q2672hivp5jn05xhc875ii3w54nfja3b1yrp8s2fwinh7f6"; + }; + "build/Firmata-2.5.8.zip" = fetchurl { + url = "https://github.com/firmata/arduino/archive/2.5.8.zip"; + sha256 = "0jmlqrnw5fksyqkjhcsl6j1q7c0clnvfr8yknanqqssc19pxp722"; + }; + "build/Bridge-1.7.0.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Bridge/archive/1.7.0.zip"; + sha256 = "1qpnb2mj77jm4qczk1ndgjc9j2kqxnyahxdvlp0120x6w2jcq8s8"; + }; + "build/Robot_Control-1.0.4.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Robot_Control/archive/1.0.4.zip"; + sha256 = "1pkabrghx3h8l60x571vwkbhfm02nhyn5x2vqz4vhx9cczr70zq7"; + }; + "build/Robot_Motor-1.0.3.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Robot_Motor/archive/1.0.3.zip"; + sha256 = "1pkvrimg77jrhdsz4l81y59hv50h6cl7hvhk9w8ac7ckg70lvxkw"; + }; + "build/RobotIRremote-2.0.0.zip" = fetchurl { + url = "https://github.com/arduino-libraries/RobotIRremote/archive/2.0.0.zip"; + sha256 = "0j5smap74j8p3wc6k0h73b1skj4gkr7r25jbjh1j1cg052dxri86"; + }; + "build/SpacebrewYun-1.0.2.zip" = fetchurl { + url = "https://github.com/arduino-libraries/SpacebrewYun/archive/1.0.2.zip"; + sha256 = "1d8smmsx12qhf2ldvmi93h48cvdyz4id5gd68cvf076wfyv6dks8"; + }; + "build/Temboo-1.2.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Temboo/archive/1.2.1.zip"; + sha256 = "1fyzfihsbcjpjasqbmbbfcall2zl48nzrp4xk9pslppal31mvl8x"; + }; + "build/Esplora-1.0.4.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Esplora/archive/1.0.4.zip"; + sha256 = "1dflfrg38f0312nxn6wkkgq1ql4hx3y9kplalix6mkqmzwrdvna4"; + }; + "build/Mouse-1.0.1.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Mouse/archive/1.0.1.zip"; + sha256 = "106jjqxzpf5lrs9akwvamqsblj5w2fb7vd0wafm9ihsikingiypr"; + }; + "build/Keyboard-1.0.2.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Keyboard/archive/1.0.2.zip"; + sha256 = "17yfj95r1i7fb87q4krmxmaq07b4x2xf8cjngrj5imj68wgjck53"; + }; + "build/SD-1.2.4.zip" = fetchurl { + url = "https://github.com/arduino-libraries/SD/archive/1.2.4.zip"; + sha256 = "123g9px9nqcrsx696wqwzjd5s4hr55nxgfz95b7ws3v007i1f3fz"; + }; + "build/Servo-1.1.8.zip" = fetchurl { + url = "https://github.com/arduino-libraries/Servo/archive/1.1.8.zip"; + sha256 = "sha256-8mfRQG/HIRVvdiRApjMib6n1ENqAB63vGsxe6vwndeU="; + }; + "build/LiquidCrystal-1.0.7.zip" = fetchurl { + url = "https://github.com/arduino-libraries/LiquidCrystal/archive/1.0.7.zip"; + sha256 = "1wrxrqz3n4yrj9j1a2b7pdd7a1rlyi974ra7crv5amjng8817x9n"; + }; + "build/Adafruit_Circuit_Playground-1.11.3.zip" = fetchurl { + url = "https://github.com/adafruit/Adafruit_CircuitPlayground/archive/1.11.3.zip"; + sha256 = "sha256-YL4ZAi9Fno+rG/bAdjxnXIglfZnbN6KpXFpj23Bf3LQ="; + }; + "build/libastylej-2.05.1-5.zip" = fetchurl { + url = "https://downloads.arduino.cc/libastylej-2.05.1-5.zip"; + sha256 = "11mlprwvqfq3nvmz6hdf1fcg02a7xi2a9qhffa1d8a4w15s2iwny"; + }; + "build/liblistSerials-1.4.2-2.zip" = fetchurl { + url = "https://downloads.arduino.cc/liblistSerials/liblistSerials-1.4.2-2.zip"; + sha256 = "0sqzwp1lfjy452z3d4ma5c4blwsj7za72ymxf7crpq9dh9qd8f53"; + }; + "build/shared/WiFi101-Updater-ArduinoIDE-Plugin-0.12.0.zip" = fetchurl { + url = "https://github.com/arduino-libraries/WiFi101-FirmwareUpdater-Plugin/releases/download/v0.12.0/WiFi101-Updater-ArduinoIDE-Plugin-0.12.0.zip"; + sha256 = "sha256-6RM7Sr/tk5PVeonhzaa6WvRaz+7av+MhSYKPAinaOkg="; + }; + "build/avr-1.8.3.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/cores/avr-1.8.3.tar.bz2"; + sha256 = "051wnc0nmsmxvvs4c79zvjag33yx5il2pz2j7qyjsxkp4jc9p2ny"; + }; + "build/arduino-examples-1.9.1.zip" = fetchurl { + url = "https://github.com/arduino/arduino-examples/archive/refs/tags/1.9.1.zip"; + sha256 = "sha256-kAxIhYQ8P2ULTzQwi6bUXXEXJ53mKNgQxuwX3QYhNoQ="; + }; +} + +// optionalAttrs (system == "x86_64-linux") { + "build/arduino-builder-linux64-1.6.1.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linux64-1.6.1.tar.bz2"; + sha256 = "sha256-QUHuC+rE5vrMX8+Bkfuw+59UQdJAekeoaZd1Mch7UXE="; + }; + "build/linux/avr-gcc-7.3.0-atmel3.6.1-arduino7-x86_64-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino7-x86_64-pc-linux-gnu.tar.bz2"; + sha256 = "07nrzv7gsq7bi7ichlw3xsdvgzk0lvv56b73ksn3089ajpv3g35x"; + }; + "build/linux/avrdude-6.3.0-arduino17-x86_64-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-x86_64-pc-linux-gnu.tar.bz2"; + sha256 = "0gfic26af9vlcpkw8v914psn05vmq1rsrlk1fi7vzapj1a9gpkdc"; + }; + "build/linux/arduinoOTA-1.3.0-linux_amd64.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_amd64.tar.bz2"; + sha256 = "1ylz4pfa9np0nn0w9igmmm3sr8hz3na04n7cv8ia3hzz84jfwida"; + }; +} + +// optionalAttrs (system == "i686-linux") { + "build/arduino-builder-linux32-1.6.1.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linux32-1.6.1.tar.bz2"; + sha256 = "sha256-GX2oGUGYYyatLroASBCBOGjsdCws06907O+O5Rz7Kls="; + }; + "build/linux/avr-gcc-7.3.0-atmel3.6.1-arduino5-i686-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-i686-pc-linux-gnu.tar.bz2"; + sha256 = "078f3rbpdrghk63mbaq73bd5p6znimp14b1wdf6nh2gdswwjgw9g"; + }; + "build/linux/avrdude-6.3.0-arduino17-i686-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-i686-pc-linux-gnu.tar.bz2"; + sha256 = "0py0jvpim0frmv0dnvzfj122ni5hg1qwshgya4a0wc5rgp0wd32w"; + }; + "build/linux/arduinoOTA-1.3.0-linux_386.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_386.tar.bz2"; + sha256 = "1cl79019ldsq0sc3fd4pm0vx2kqcklld7w03hdcj99y7zgb5jzry"; + }; +} + +// optionalAttrs (system == "x86_64-darwin") { + "build/arduino-builder-macosx-1.6.1-signed.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-macosx-1.6.1-signed.tar.bz2"; + sha256 = "sha256-icMXwovzT2UQAKry9sWyRvcNxPXaFdltAPyW/DDVEFA="; + }; + "build/macosx/avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-apple-darwin14-signed.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-x86_64-apple-darwin14-signed.tar.bz2"; + sha256 = "0lcnp525glnc2chcynnz2nllm4q6ar4n9nrjqd1jbj4m706zbv67"; + }; + "build/macosx/avrdude-6.3.0-arduino17-x86_64-apple-darwin12-signed.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-x86_64-apple-darwin12-signed.tar.bz2"; + sha256 = "1m24dci8mjf70yrf033mp1834pbp870m8sns2jxs3iy2i4qviiki"; + }; + "build/linux/arduinoOTA-1.3.0-darwin_amd64-signed.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.3.0-darwin_amd64-signed.tar.bz2"; + sha256 = "12pwfnikq3z3ji5wgjhzx1mfyaha5cym7mr63r8kfl5a85fhk8nz"; + }; + "build/macosx/appbundler/appbundler-1.0ea-arduino5.jar.zip" = fetchurl { + url = "https://downloads.arduino.cc/appbundler-1.0ea-arduino5.jar.zip"; + sha256 = "1ims951z7ajprqms7yd8ll83c79n7krhd9ljw30yn61f6jk46x82"; + }; +} + +// optionalAttrs (system == "aarch64-linux") { + "build/arduino-builder-linuxaarch64-1.6.1.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linuxaarch64-1.6.1.tar.bz2"; + sha256 = "sha256-BLcAIvGt0OQfjN87W1aLpLAQchhdFHoBqJPCcIWyHxQ="; + }; + "build/linux/avr-gcc-7.3.0-atmel3.6.1-arduino7-aarch64-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino7-aarch64-pc-linux-gnu.tar.bz2"; + sha256 = "sha256-A9Miud9toXKJ6efGIzw0qFNdnGRcGe/HcroZ5WkU8zk="; + }; + "build/linux/avrdude-6.3.0-arduino17-aarch64-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-aarch64-pc-linux-gnu.tar.bz2"; + sha256 = "1z59dx2j2j4675awjzag9fswhvkn3hlz4ds5d2b7pzmca7vliybc"; + }; + "build/linux/arduinoOTA-1.3.0-linux_aarch64.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_aarch64.tar.bz2"; + sha256 = "04s1is2w8xhvc7lg0lmyk0yjsnar2l2gdc6ig7lkgb7zgkrxhpl3"; + }; +} + +// optionalAttrs (builtins.match "armv[67]l-linux" system != null) { + "build/arduino-builder-linuxarm-1.6.1.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduino-builder-linuxarm-1.6.1.tar.bz2"; + sha256 = "sha256-VtJxhRaOOKdBxmTWjTYnSPAXl728hMksBKSKS49qiMU="; + }; + "build/linux/avr-gcc-7.3.0-atmel3.6.1-arduino5-arm-linux-gnueabihf.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avr-gcc-7.3.0-atmel3.6.1-arduino5-arm-linux-gnueabihf.tar.bz2"; + sha256 = "0fcn0s0fdgbz3yma2gjv16s1idrzn6nhmypdw8awg0kb3i9xbb7l"; + }; + "build/linux/avrdude-6.3.0-arduino17-armhf-pc-linux-gnu.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/avrdude-6.3.0-arduino17-armhf-pc-linux-gnu.tar.bz2"; + sha256 = "1lah9wvwvliajrrf5jw5blkjhk1sxivz26gj5s86zah3v32ni3ia"; + }; + "build/linux/arduinoOTA-1.3.0-linux_arm.tar.bz2" = fetchurl { + url = "https://downloads.arduino.cc/tools/arduinoOTA-1.3.0-linux_arm.tar.bz2"; + sha256 = "0mm6spjlg0lhkfx5c9q27b6agjywnc1nf3mbl15yysmm15s5i20q"; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-language-server/default.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-language-server/default.nix new file mode 100644 index 000000000000..1a0c3665ea27 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-language-server/default.nix @@ -0,0 +1,40 @@ +{ lib +, stdenv +, buildGoModule +, fetchFromGitHub +}: + +buildGoModule rec { + pname = "arduino-language-server"; + version = "0.7.5"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = "arduino-language-server"; + rev = "refs/tags/${version}"; + hash = "sha256-RBoDT/KnbQHeuE5WpoL4QWu3gojiNdsi+/NEY2e/sHs="; + }; + + subPackages = [ "." ]; + + vendorHash = "sha256-tS6OmH757VDdViPHJAJAftQu+Y1YozE7gXkt5anDlT0="; + + doCheck = false; + + ldflags = [ + "-s" + "-w" + "-X github.com/arduino/arduino-language-server/version.versionString=${version}" + "-X github.com/arduino/arduino-language-server/version.commit=unknown" + ] ++ lib.optionals stdenv.isLinux [ + "-extldflags '-static'" + ]; + + meta = with lib; { + description = "An Arduino Language Server based on Clangd to Arduino code autocompletion"; + homepage = "https://github.com/arduino/arduino-language-server"; + changelog = "https://github.com/arduino/arduino-language-server/releases/tag/${version}"; + license = licenses.asl20; + maintainers = with maintainers; [ BattleCh1cken ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduino-mk/default.nix b/nixpkgs/pkgs/development/embedded/arduino/arduino-mk/default.nix new file mode 100644 index 000000000000..d5f506038ca6 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduino-mk/default.nix @@ -0,0 +1,32 @@ +{ stdenv, lib, fetchFromGitHub, python3Packages, installShellFiles }: + +stdenv.mkDerivation rec { + version = "1.6.0"; + pname = "arduino-mk"; + + src = fetchFromGitHub { + owner = "sudar"; + repo = "Arduino-Makefile"; + rev = version; + sha256 = "0flpl97d2231gp51n3y4qvf3y1l8xzafi1sgpwc305vwc2h4dl2x"; + }; + + nativeBuildInputs = [ python3Packages.wrapPython installShellFiles ]; + propagatedBuildInputs = with python3Packages; [ pyserial ]; + installPhase = '' + mkdir $out + cp -rT $src $out + installManPage *.1 + ''; + postFixupPhase = '' + wrapPythonPrograms + ''; + + meta = with lib; { + description = "Makefile for Arduino sketches"; + homepage = "https://github.com/sudar/Arduino-Makefile"; + license = licenses.lgpl21; + maintainers = [ maintainers.eyjhb ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/arduino/arduinoOTA/default.nix b/nixpkgs/pkgs/development/embedded/arduino/arduinoOTA/default.nix new file mode 100644 index 000000000000..92da1a77f18e --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/arduino/arduinoOTA/default.nix @@ -0,0 +1,33 @@ +{ lib +, buildGoModule +, fetchFromGitHub +, nix-update-script +}: +buildGoModule rec { + pname = "arduinoOTA"; + version = "1.4.1"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = pname; + rev = version; + hash = "sha256-HaNMkeV/PDEotYp8+rUKFaBxGbZO8qA99Yp2sa6glz8="; + }; + + vendorHash = null; + + postPatch = '' + substituteInPlace version/version.go \ + --replace 'versionString = ""' 'versionString = "${version}"' + ''; + + passthru.updateScript = nix-update-script { }; + + meta = with lib; { + homepage = "https://github.com/arduino/arduinoOTA"; + description = "A tool for uploading programs to Arduino boards over a network"; + license = licenses.gpl3; + maintainers = with maintainers; [ poelzi ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/avrdude/default.nix b/nixpkgs/pkgs/development/embedded/avrdude/default.nix new file mode 100644 index 000000000000..0f6bd8b6befc --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/avrdude/default.nix @@ -0,0 +1,47 @@ +{ lib, stdenv, fetchFromGitHub, cmake, bison, flex, libusb-compat-0_1, libelf +, libftdi1, readline +# documentation building is broken on darwin +, docSupport ? (!stdenv.isDarwin), texliveMedium, texinfo, texi2html, unixtools }: + +stdenv.mkDerivation rec { + pname = "avrdude"; + version = "7.2"; + + src = fetchFromGitHub { + owner = "avrdudes"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-/JyhMBcjNklyyXZEFZGTjrTNyafXEdHEhcLz6ZQx9aU="; + }; + + nativeBuildInputs = [ cmake bison flex ] ++ lib.optionals docSupport [ + unixtools.more + texliveMedium + texinfo + texi2html + ]; + + buildInputs = [ libusb-compat-0_1 libelf libftdi1 readline ]; + + cmakeFlags = lib.optionals docSupport [ + "-DBUILD_DOC=ON" + ]; + + # dvips output references texlive in comments, resulting in a huge closure + postInstall = lib.optionalString docSupport '' + rm $out/share/doc/${pname}/*.ps + ''; + + meta = with lib; { + description = "Command-line tool for programming Atmel AVR microcontrollers"; + longDescription = '' + AVRDUDE (AVR Downloader/UploaDEr) is an utility to + download/upload/manipulate the ROM and EEPROM contents of AVR + microcontrollers using the in-system programming technique (ISP). + ''; + homepage = "https://www.nongnu.org/avrdude/"; + license = licenses.gpl2Plus; + platforms = with platforms; linux ++ darwin; + maintainers = [ maintainers.bjornfor ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/blackmagic/default.nix b/nixpkgs/pkgs/development/embedded/blackmagic/default.nix new file mode 100644 index 000000000000..a422cdc54fc3 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/blackmagic/default.nix @@ -0,0 +1,78 @@ +{ stdenv, lib +, fetchFromGitHub +, gcc-arm-embedded +, pkg-config +, python3 +, hidapi +, libftdi1 +, libusb1 +}: + +stdenv.mkDerivation rec { + pname = "blackmagic"; + version = "1.8.2"; + # `git describe --always` + firmwareVersion = "v${version}"; + + src = fetchFromGitHub { + owner = "blacksphere"; + repo = "blackmagic"; + rev = firmwareVersion; + hash = "sha256-NGzoohmpVwGOncr9AvHYANMf/oEskjmTXYj/Kdx2RwM="; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ + gcc-arm-embedded + pkg-config + python3 + ]; + + buildInputs = [ + hidapi + libftdi1 + libusb1 + ]; + + strictDeps = true; + + postPatch = '' + # Prevent calling out to `git' to generate a version number: + substituteInPlace src/Makefile \ + --replace '$(shell git describe --always --dirty)' '${firmwareVersion}' + + # Fix scripts that generate headers: + for f in $(find scripts libopencm3/scripts -type f); do + patchShebangs "$f" + done + ''; + + buildPhase = '' + runHook preBuild + ${stdenv.shell} ${./helper.sh} + runHook postBuild + ''; + + dontInstall = true; + + enableParallelBuilding = true; + + meta = with lib; { + description = "In-application debugger for ARM Cortex microcontrollers"; + longDescription = '' + The Black Magic Probe is a modern, in-application debugging tool + for embedded microprocessors. It allows you to see what is going + on "inside" an application running on an embedded microprocessor + while it executes. + + This package builds the firmware for all supported platforms, + placing them in separate directories under the firmware + directory. It also places the FTDI version of the blackmagic + executable in the bin directory. + ''; + homepage = "https://github.com/blacksphere/blackmagic"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ pjones emily sorki ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/blackmagic/helper.sh b/nixpkgs/pkgs/development/embedded/blackmagic/helper.sh new file mode 100755 index 000000000000..77f84ef890d4 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/blackmagic/helper.sh @@ -0,0 +1,51 @@ +################################################################################ +# 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/nixpkgs/pkgs/development/embedded/blisp/default.nix b/nixpkgs/pkgs/development/embedded/blisp/default.nix new file mode 100644 index 000000000000..027ca82324f8 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/blisp/default.nix @@ -0,0 +1,50 @@ +{ lib +, stdenv +, fetchFromGitHub +, argtable +, cmake +, libserialport +, pkg-config +, testers +, IOKit +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "blisp"; + version = "0.0.4"; + + src = fetchFromGitHub { + owner = "pine64"; + repo = "blisp"; + rev = "v${finalAttrs.version}"; + hash = "sha256-cN35VLbdQFA3KTZ8PxgpbsLGXqfFhw5eh3nEBRZqAm4="; + }; + + nativeBuildInputs = [ cmake pkg-config ]; + + buildInputs = [ + argtable + libserialport + ] ++ lib.optional stdenv.isDarwin IOKit; + + cmakeFlags = [ + "-DBLISP_BUILD_CLI=ON" + "-DBLISP_USE_SYSTEM_LIBRARIES=ON" + ]; + + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-Wno-error=implicit-function-declaration"; + + passthru.tests.version = testers.testVersion { + package = finalAttrs.finalPackage; + version = "v${finalAttrs.version}"; + }; + + meta = with lib; { + description = "An In-System-Programming (ISP) tool & library for Bouffalo Labs RISC-V Microcontrollers and SoCs"; + license = licenses.mit; + mainProgram = "blisp"; + homepage = "https://github.com/pine64/blisp"; + platforms = platforms.unix; + maintainers = [ maintainers.bdd ]; + }; +}) diff --git a/nixpkgs/pkgs/development/embedded/bossa/arduino.nix b/nixpkgs/pkgs/development/embedded/bossa/arduino.nix new file mode 100644 index 000000000000..04e483ff38b5 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/bossa/arduino.nix @@ -0,0 +1,13 @@ +{ bossa, git, fetchFromGitHub }: + +bossa.overrideAttrs (attrs: rec { + pname = "bossa-arduino"; + version = "1.9.1-arduino2"; + + src = fetchFromGitHub { + owner = "arduino"; + repo = "BOSSA"; + rev = version; + sha256 = "sha256-sBJ6QMd7cTClDnGCeOU0FT6IczEjqqRxCD7kef5GuY8="; + }; +}) diff --git a/nixpkgs/pkgs/development/embedded/bossa/bin2c.c b/nixpkgs/pkgs/development/embedded/bossa/bin2c.c new file mode 100644 index 000000000000..f0b915de540a --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/bossa/bin2c.c @@ -0,0 +1,122 @@ +// bin2c.c +// +// convert a binary file into a C source vector +// +// THE "BEER-WARE LICENSE" (Revision 3.1415): +// sandro AT sigala DOT it wrote this file. As long as you retain this notice you can do +// whatever you want with this stuff. If we meet some day, and you think this stuff is +// worth it, you can buy me a beer in return. Sandro Sigala +// +// syntax: bin2c [-c] [-z] <input_file> <output_file> +// +// -c add the "const" keyword to definition +// -z terminate the array with a zero (useful for embedded C strings) +// +// examples: +// bin2c -c myimage.png myimage_png.cpp +// bin2c -z sometext.txt sometext_txt.cpp + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +int useconst = 0; +int zeroterminated = 0; + +int myfgetc(FILE *f) +{ + int c = fgetc(f); + if (c == EOF && zeroterminated) + { + zeroterminated = 0; + return 0; + } + return c; +} + +void process(const char *ifname, const char *ofname) +{ + FILE *ifile, *ofile; + ifile = fopen(ifname, "rb"); + if (ifile == NULL) + { + fprintf(stderr, "cannot open %s for reading\n", ifname); + exit(1); + } + ofile = fopen(ofname, "wb"); + if (ofile == NULL) + { + fprintf(stderr, "cannot open %s for writing\n", ofname); + exit(1); + } + char buf[PATH_MAX], *p; + const char *cp; + if ((cp = strrchr(ifname, '/')) != NULL) + { + ++cp; + } else { + if ((cp = strrchr(ifname, '\\')) != NULL) + ++cp; + else + cp = ifname; + } + strcpy(buf, cp); + for (p = buf; *p != '\0'; ++p) + { + if (!isalnum(*p)) + *p = '_'; + } + fprintf(ofile, "static %sunsigned char %s[] = {\n", useconst ? "const " : "", buf); + int c, col = 1; + while ((c = myfgetc(ifile)) != EOF) + { + if (col >= 78 - 6) + { + fputc('\n', ofile); + col = 1; + } + fprintf(ofile, "0x%.2x, ", c); + col += 6; + } + fprintf(ofile, "\n};\n"); + + fclose(ifile); + fclose(ofile); +} + +void usage(void) +{ + fprintf(stderr, "usage: bin2c [-cz] <input_file> <output_file>\n"); + exit(1); +} + +int main(int argc, char **argv) +{ + while (argc > 3) + { + if (!strcmp(argv[1], "-c")) + { + useconst = 1; + --argc; + ++argv; + } else if (!strcmp(argv[1], "-z")) + { + zeroterminated = 1; + --argc; + ++argv; + } else { + usage(); + } + } + if (argc != 3) + { + usage(); + } + process(argv[1], argv[2]); + return 0; +} diff --git a/nixpkgs/pkgs/development/embedded/bossa/default.nix b/nixpkgs/pkgs/development/embedded/bossa/default.nix new file mode 100644 index 000000000000..58ee0642fb38 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/bossa/default.nix @@ -0,0 +1,75 @@ +{ lib +, stdenv +, fetchFromGitHub +, wxGTK32 +, libX11 +, readline +, darwin +}: + +let + # BOSSA needs a "bin2c" program to embed images. + # Source taken from: + # http://wiki.wxwidgets.org/Embedding_PNG_Images-Bin2c_In_C + bin2c = stdenv.mkDerivation { + name = "bossa-bin2c"; + src = ./bin2c.c; + dontUnpack = true; + buildPhase = "cc $src -o bin2c"; + installPhase = "mkdir -p $out/bin; cp bin2c $out/bin/"; + }; + +in +stdenv.mkDerivation rec { + pname = "bossa"; + version = "1.9.1"; + + src = fetchFromGitHub { + owner = "shumatech"; + repo = "BOSSA"; + rev = version; + sha256 = "sha256-8M3MU/+Y1L6SaQ1yoC9Z27A/gGruZdopLnL1z7h7YJw="; + }; + + postPatch = '' + substituteInPlace Makefile \ + --replace "-arch x86_64" "" + ''; + + nativeBuildInputs = [ bin2c ]; + buildInputs = [ + wxGTK32 + libX11 + readline + ] ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Cocoa + ]; + + makeFlags = [ + "WXVERSION=3.2" + # Explicitly specify targets so they don't get stripped. + "bin/bossac" + "bin/bossash" + "bin/bossa" + ]; + env.NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations"; + + installPhase = '' + mkdir -p $out/bin + cp bin/bossa{c,sh,} $out/bin/ + ''; + + meta = with lib; { + description = "A flash programming utility for Atmel's SAM family of flash-based ARM microcontrollers"; + longDescription = '' + BOSSA is a flash programming utility for Atmel's SAM family of + flash-based ARM microcontrollers. The motivation behind BOSSA is + to create a simple, easy-to-use, open source utility to replace + Atmel's SAM-BA software. BOSSA is an acronym for Basic Open + Source SAM-BA Application to reflect that goal. + ''; + homepage = "http://www.shumatech.com/web/products/bossa"; + license = licenses.bsd3; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/cc-tool/default.nix b/nixpkgs/pkgs/development/embedded/cc-tool/default.nix new file mode 100644 index 000000000000..e2a511a0e328 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/cc-tool/default.nix @@ -0,0 +1,42 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +, boost +, libusb1 +, pkg-config +}: + +stdenv.mkDerivation rec { + pname = "cc-tool"; + version = "unstable-2020-05-19"; + + src = fetchFromGitHub { + owner = "dashesy"; + repo = pname; + rev = "19e707eafaaddee8b996ad27a9f3e1aafcb900d2"; + hash = "sha256:1f78j498fdd36xbci57jkgh25gq14g3b6xmp76imdpar0jkpyljv"; + }; + + nativeBuildInputs = [ autoreconfHook pkg-config ]; + buildInputs = [ boost libusb1 ]; + + postPatch = '' + substituteInPlace udev/90-cc-debugger.rules \ + --replace 'MODE="0666"' 'MODE="0660", GROUP="plugdev", TAG+="uaccess"' + ''; + + postInstall = '' + install -D udev/90-cc-debugger.rules $out/lib/udev/rules.d/90-cc-debugger.rules + ''; + + meta = with lib; { + description = "Command line tool for the Texas Instruments CC Debugger"; + longDescription = '' + cc-tool provides support for Texas Instruments CC Debugger + ''; + homepage = "https://github.com/dashesy/cc-tool"; + license = licenses.gpl2; + platforms = with platforms; linux ++ darwin; + maintainers = [ maintainers.CRTified ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/easypdkprog/default.nix b/nixpkgs/pkgs/development/embedded/easypdkprog/default.nix new file mode 100644 index 000000000000..92d1a550ea80 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/easypdkprog/default.nix @@ -0,0 +1,27 @@ +{ stdenv, lib, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "easypdkprog"; + version = "1.3"; + + src = fetchFromGitHub { + owner = "free-pdk"; + repo = "easy-pdk-programmer-software"; + rev = version; + sha256 = "0hc3gdmn6l01z63hzzwdhbdyy288gh5v219bsfm8fb1498vpnd6f"; + }; + + installPhase = '' + install -Dm755 -t $out/bin easypdkprog + '' + lib.optionalString stdenv.isLinux '' + install -Dm644 -t $out/etc/udev/rules.d Linux_udevrules/70-stm32vcp.rules + ''; + + meta = with lib; { + description = "Read, write and execute programs on PADAUK microcontroller"; + homepage = "https://github.com/free-pdk/easy-pdk-programmer-software"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ david-sawatzke ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/edl/default.nix b/nixpkgs/pkgs/development/embedded/edl/default.nix new file mode 100644 index 000000000000..2e1f09ffd208 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/edl/default.nix @@ -0,0 +1,45 @@ +{ lib, stdenv, fetchFromGitHub, python3Packages }: + +python3Packages.buildPythonPackage rec { + pname = "edl"; + version = "unstable-2022-09-07"; + + src = fetchFromGitHub rec { + owner = "bkerler"; + repo = "edl"; + rev = "f6b94da5faa003b48d24a5f4a8f0b8495626fd5b"; + fetchSubmodules = true; + hash = "sha256-bxnRy+inWNArE2gUA/qDPy7NKvqBm43sbxdIaTc9N28="; + }; + # edl has a spurious dependency on "usb" which has nothing to do with the + # project and was probably added by accident trying to add pyusb + postPatch = '' + sed -i '/'usb'/d' setup.py + ''; + # No tests set up + doCheck = false; + # EDL loaders are ELFs but shouldn't be touched, rest is Python anyways + dontStrip = true; + propagatedBuildInputs = with python3Packages; [ + pyusb + pyserial + docopt + pylzma + pycryptodome + lxml + colorama + # usb + capstone + keystone-engine + ]; + + meta = with lib; { + homepage = "https://github.com/bkerler/edl"; + description = "Qualcomm EDL tool (Sahara / Firehose / Diag)"; + license = licenses.mit; + maintainers = with maintainers; [ lorenz ]; + # Case-sensitive files in 'Loader' submodule + broken = stdenv.isDarwin; + }; +} + diff --git a/nixpkgs/pkgs/development/embedded/elf2uf2-rs/default.nix b/nixpkgs/pkgs/development/embedded/elf2uf2-rs/default.nix new file mode 100644 index 000000000000..c64380bec23d --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/elf2uf2-rs/default.nix @@ -0,0 +1,32 @@ +{ lib, stdenv, rustPlatform, fetchCrate, pkg-config, udev, CoreFoundation, DiskArbitration, Foundation }: + +rustPlatform.buildRustPackage rec { + pname = "elf2uf2-rs"; + version = "1.3.8"; + + src = fetchCrate { + inherit pname version; + sha256 = "sha256-wR2rxovUYBW9kKMFJG5lsRhtpI12L+HZe73kQyckEdI="; + }; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = lib.optional stdenv.isLinux udev + ++ lib.optionals stdenv.isDarwin [ + CoreFoundation + DiskArbitration + Foundation + ]; + + cargoHash = "sha256-gSEmNmVpREvD3lDJmcmPnN9keu7SaAIcO7fDhOBhu/E="; + + meta = with lib; { + description = "Convert ELF files to UF2 for USB Flashing Bootloaders"; + homepage = "https://github.com/JoNil/elf2uf2-rs"; + license = with licenses; [ bsd0 ]; + platforms = platforms.linux ++ platforms.darwin; + maintainers = with maintainers; [ polygon moni ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/fpga/apio/default.nix b/nixpkgs/pkgs/development/embedded/fpga/apio/default.nix new file mode 100644 index 000000000000..1ca1e3cd200d --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/apio/default.nix @@ -0,0 +1,80 @@ +{ lib +, buildPythonApplication +, fetchFromGitHub +, click +, semantic-version +, requests +, colorama +, pyserial +, wheel +, scons +, setuptools +, tinyprog +, flit-core +, pytestCheckHook +}: + +buildPythonApplication rec { + pname = "apio"; + version = "0.8.1"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "FPGAwars"; + repo = "apio"; + rev = "v${version}"; + sha256 = "sha256-04qAGTzusMT3GsaRxDoXNJK1Mslzxu+ugQclBJx8xzE="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace 'scons==4.2.0' 'scons' \ + --replace '==' '>=' + + substituteInPlace apio/managers/scons.py --replace \ + 'return "tinyprog --libusb --program"' \ + 'return "${tinyprog}/bin/tinyprog --libusb --program"' + substituteInPlace apio/util.py --replace \ + '_command = join(get_bin_dir(), "tinyprog")' \ + '_command = "${tinyprog}/bin/tinyprog"' + + # semantic-version seems to not support version numbers like the one of tinyprog in Nixpkgs (1.0.24.dev114+gxxxxxxx). + # See https://github.com/rbarrois/python-semanticversion/issues/47. + # This leads to an error like "Error: Invalid version string: '1.0.24.dev114+g97f6353'" + # when executing "apio upload" for a TinyFPGA. + # Replace the dot with a dash to work around this problem. + substituteInPlace apio/managers/scons.py --replace \ + 'version = semantic_version.Version(pkg_version)' \ + 'version = semantic_version.Version(pkg_version.replace(".dev", "-dev"))' + ''; + + nativeBuildInputs = [ + flit-core + ]; + + propagatedBuildInputs = [ + click + semantic-version + requests + colorama + pyserial + wheel + scons + setuptools # needs pkg_resources at runtime (technically not needed when tinyprog is also in this list because of the propagatedBuildInputs of tinyprog) + + tinyprog # needed for upload to TinyFPGA + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + pytestFlagsArray = [ "--offline" ]; + + meta = with lib; { + description = "Open source ecosystem for open FPGA boards"; + homepage = "https://github.com/FPGAwars/apio"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ Luflosi ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/fpga/ecpdap/default.nix b/nixpkgs/pkgs/development/embedded/fpga/ecpdap/default.nix new file mode 100644 index 000000000000..799915b1b7f6 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/ecpdap/default.nix @@ -0,0 +1,37 @@ +{ lib, stdenv, fetchFromGitHub, rustPlatform, pkg-config, libusb1, AppKit }: + +rustPlatform.buildRustPackage rec { + pname = "ecpdap"; + version = "0.1.8"; + + src = fetchFromGitHub { + owner = "adamgreig"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-KXfEQnbhUUKsCDKhPBjwjF9eJMuiCx5o7gOSzyWv36s="; + }; + + cargoSha256 = "sha256-BEfsNSzrdV/tnzWk4oOwchOupW6PzZ8TEx7zUzwLBV8="; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ libusb1 ] + ++ lib.optional stdenv.isDarwin AppKit; + + postInstall = '' + mkdir -p $out/etc/udev/rules.d + cp drivers/*.rules $out/etc/udev/rules.d + ''; + + meta = with lib; { + description = "A tool to program ECP5 FPGAs"; + longDescription = '' + ECPDAP allows you to program ECP5 FPGAs and attached SPI flash + using CMSIS-DAP probes in JTAG mode. + ''; + homepage = "https://github.com/adamgreig/ecpdap"; + license = licenses.asl20; + maintainers = with maintainers; [ expipiplus1 ]; + }; +} + diff --git a/nixpkgs/pkgs/development/embedded/fpga/fujprog/default.nix b/nixpkgs/pkgs/development/embedded/fpga/fujprog/default.nix new file mode 100644 index 000000000000..db1f42e3a266 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/fujprog/default.nix @@ -0,0 +1,39 @@ +{ lib, stdenv +, fetchFromGitHub +, cmake +, pkg-config +, IOKit +, libftdi1 +, libusb-compat-0_1 +}: + +stdenv.mkDerivation rec { + pname = "fujprog"; + version = "4.8"; + + src = fetchFromGitHub { + owner = "kost"; + repo = pname; + rev = "v${version}"; + sha256 = "08kzkzd5a1wfd1aycywdynxh3qy6n7z9i8lihkahmb4xac3chmz5"; + }; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + libftdi1 + libusb-compat-0_1 + ] ++ lib.optionals stdenv.isDarwin [ IOKit ]; + + meta = with lib; { + description = "JTAG programmer for the ULX3S and ULX2S open hardware FPGA development boards"; + homepage = "https://github.com/kost/fujprog"; + license = licenses.bsd2; + maintainers = with maintainers; [ trepetti ]; + platforms = platforms.all; + changelog = "https://github.com/kost/fujprog/releases/tag/v${version}"; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/fpga/icestorm/default.nix b/nixpkgs/pkgs/development/embedded/fpga/icestorm/default.nix new file mode 100644 index 000000000000..b660571eb3e5 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/icestorm/default.nix @@ -0,0 +1,70 @@ +{ lib, stdenv, fetchFromGitHub +, pkg-config, libftdi1 +, python3, pypy3 + +# PyPy yields large improvements in build time and runtime performance, and +# IceStorm isn't intended to be used as a library other than by the nextpnr +# build process (which is also sped up by using PyPy), so we use it by default. +# See 18839e1 for more details. +# +# FIXME(aseipp, 3/1/2021): pypy seems a bit busted since stdenv upgrade to gcc +# 10/binutils 2.34, so short-circuit this for now in passthru below (done so +# that downstream overrides can't re-enable pypy and break their build somehow) +, usePyPy ? stdenv.hostPlatform.system == "x86_64-linux" +}: + +stdenv.mkDerivation rec { + pname = "icestorm"; + version = "2020.12.04"; + + passthru = rec { + pythonPkg = if (false && usePyPy) then pypy3 else python3; + pythonInterp = pythonPkg.interpreter; + }; + + src = fetchFromGitHub { + owner = "YosysHQ"; + repo = "icestorm"; + rev = "7afc64b480212c9ac2ce7cb1622731a69a7d212c"; + sha256 = "0vxhqs2fampglg3xlfwb35229iv96kvlwp1gyxrdrmlpznhkqdrk"; + }; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ passthru.pythonPkg libftdi1 ]; + makeFlags = [ "PREFIX=$(out)" ]; + + enableParallelBuilding = true; + + # fix icebox_vlog chipdb path. icestorm issue: + # https://github.com/cliffordwolf/icestorm/issues/125 + # + # also, fix up the path to the chosen Python interpreter. for pypy-compatible + # platforms, it offers significant performance improvements. + patchPhase = '' + substituteInPlace ./icebox/icebox_vlog.py \ + --replace /usr/local/share "$out/share" + + for x in icefuzz/Makefile icebox/Makefile icetime/Makefile; do + substituteInPlace "$x" --replace python3 "${passthru.pythonInterp}" + done + + for x in $(find . -type f -iname '*.py'); do + substituteInPlace "$x" \ + --replace '/usr/bin/env python3' '${passthru.pythonInterp}' + done + ''; + + meta = { + description = "Documentation and tools for Lattice iCE40 FPGAs"; + longDescription = '' + Project IceStorm aims at reverse engineering and + documenting the bitstream format of Lattice iCE40 + FPGAs and providing simple tools for analyzing and + creating bitstream files. + ''; + homepage = "https://github.com/YosysHQ/icestorm/"; + license = lib.licenses.isc; + maintainers = with lib.maintainers; [ shell thoughtpolice emily ]; + platforms = lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/fpga/lattice-diamond/default.nix b/nixpkgs/pkgs/development/embedded/fpga/lattice-diamond/default.nix new file mode 100644 index 000000000000..f80261720cf6 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/lattice-diamond/default.nix @@ -0,0 +1,120 @@ +{ lib, stdenv, rpmextract, patchelf, makeWrapper, file, requireFile, glib, zlib, + freetype, fontconfig, xorg, libusb-compat-0_1, coreutils }: + +stdenv.mkDerivation { + pname = "diamond"; + version = "3.10"; + + nativeBuildInputs = [ rpmextract patchelf makeWrapper file ]; + + src = requireFile { + name = "diamond_3_10-base_x64-111-2-x86_64-linux.rpm"; + url = "http://www.latticesemi.com/view_document?document_id=52180"; + sha256 = "ec0b370cf8bd55831eeed7c5eadcabacbd6e63ac657c20209d672119a07a5c0f"; + }; + + buildCommand = '' + origprefix=usr/local/diamond/3.10_x64 + prefix=diamond + + echo "Unpacking $src..." + rpmextract $src + + # Move $pwd/usr/local/diamond/VERS to $out/diamond, cd. + mkdir -p $out/$prefix + rmdir $out/$prefix + mv $origprefix $out/$prefix + + cd $out + + # Extract all tarballs. + for tb in \ + cae_library/cae_library.tar.gz \ + embedded_source/embedded_source.tar.gz \ + ispfpga/ispfpga.tar.gz \ + synpbase/synpbase.tar.gz \ + tcltk/tcltk.tar.gz \ + bin/bin.tar.gz \ + examples/examples.tar.gz \ + data/data.tar.gz ; do + + echo "Extracting tarball $prefix/$tb" + cd $out/$prefix/$(dirname $tb) + tar xf $(basename $tb) + rm $(basename $tb) + done + + # Patch shebangs in start scripts . + cd $out/$prefix/bin/lin64 + for tool in \ + programmer \ + pgrcmd \ + diamond_env \ + powercal \ + model300 \ + update \ + diamond \ + debugger \ + ddtcmd \ + cableserver \ + revealrva \ + ipexpress \ + fileutility \ + diamond ; do + + echo "Patching script $prefix/bin/lin64/$tool..." + patchShebangs $tool + done + + # Patch executable ELFs. + for path in bin/lin64 ispfpga/bin/lin64 synpbase/linux_a_64 synpbase/linux_a_64/mbin; do + cd $out/$prefix/$path + for f in *; do + if ! file $f | grep -q "ELF 64-bit LSB executable" ; then + continue + fi + echo "Patching ELF $prefix/$path/$f..." + # We force RPATH otherwise libraries from LD_LIBRARY_PATH (which the + # tools mangle by themselves) will not be able to find their + # dependencies from nix. + patchelf \ + --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "$libPath:$out/$prefix/bin/lin64:$out/$prefix/ispfpga/bin/lin64" \ + --force-rpath \ + $f + done + done + + # Patch absolute /usr/bin/id path in script + sed -i -e "s#/usr/bin/id#${coreutils}/bin/id#" $out/$prefix/synpbase/bin/config/platform_set + + # Remove 32-bit libz. + rm $out/$prefix/bin/lin64/libz.{so,so.1} + + # Make wrappers. The purpose of these is just to call the target program + # using its absolute path - otherwise, it will crash. + mkdir -p bin + for tool in diamond pnmainc ddtcmd ; do + makeWrapper $out/$prefix/bin/lin64/$tool $out/bin/$tool + done + ''; + + libPath = lib.makeLibraryPath [ + glib zlib freetype fontconfig + xorg.libSM xorg.libICE xorg.libXrender xorg.libXext xorg.libX11 xorg.libXt + libusb-compat-0_1 + ]; + + meta = { + description = "Vendor development tools for Lattice FPGA devices"; + longDescription = '' + Lattice Diamond software is the leading-edge software design environment + for cost- sensitive, low-power Lattice FPGA architectures. It is the + next-generation replacement for ispLEVER. + ''; + homepage = "https://www.latticesemi.com/latticediamond"; + license = lib.licenses.unfree; + maintainers = with lib.maintainers; [ q3k ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/fpga/openfpgaloader/default.nix b/nixpkgs/pkgs/development/embedded/fpga/openfpgaloader/default.nix new file mode 100644 index 000000000000..615000e6eec1 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/openfpgaloader/default.nix @@ -0,0 +1,46 @@ +{ + cmake +, fetchFromGitHub +, hidapi +, lib +, libftdi1 +, libusb1 +, pkg-config +, stdenv +, udev +, zlib +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "openfpgaloader"; + version = "0.11.0"; + + src = fetchFromGitHub { + owner = "trabucayre"; + repo = "openFPGALoader"; + rev = "v${finalAttrs.version}"; + hash = "sha256-OiyuhDrK4w13lRmgfmMlZ+1gvRZCJxsOF6MzLy3CFpg="; + }; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + hidapi + libftdi1 + libusb1 + zlib + ] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform udev) [ + udev + ]; + + meta = { + description = "Universal utility for programming FPGAs"; + homepage = "https://github.com/trabucayre/openFPGALoader"; + license = lib.licenses.agpl3Only; + maintainers = with lib.maintainers; [ danderson ]; + platforms = lib.platforms.unix; + }; +}) diff --git a/nixpkgs/pkgs/development/embedded/fpga/tinyprog/default.nix b/nixpkgs/pkgs/development/embedded/fpga/tinyprog/default.nix new file mode 100644 index 000000000000..4872111b811c --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/tinyprog/default.nix @@ -0,0 +1,43 @@ +{ lib +, python3Packages +, fetchFromGitHub +}: + +with python3Packages; buildPythonApplication rec { + pname = "tinyprog"; + # `python setup.py --version` from repo checkout + version = "1.0.24.dev114+g${lib.substring 0 7 src.rev}"; + + src = fetchFromGitHub { + owner = "tinyfpga"; + repo = "TinyFPGA-Bootloader"; + rev = "97f6353540bf7c0d27f5612f202b48f41da75299"; + sha256 = "0zbrvvb957z2lwbfd39ixqdsnd2w4wfjirwkqdrqm27bjz308731"; + }; + + sourceRoot = "${src.name}/programmer"; + + propagatedBuildInputs = [ + pyserial + jsonmerge + intelhex + tqdm + six + packaging + setuptools + pyusb + ]; + + nativeBuildInputs = [ setuptools-scm ]; + + preBuild = '' + export SETUPTOOLS_SCM_PRETEND_VERSION="${version}" + ''; + + meta = with lib; { + homepage = "https://github.com/tinyfpga/TinyFPGA-Bootloader/tree/master/programmer"; + description = "Programmer for FPGA boards using the TinyFPGA USB Bootloader"; + maintainers = with maintainers; [ emily ]; + license = licenses.asl20; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/fpga/trellis/default.nix b/nixpkgs/pkgs/development/embedded/fpga/trellis/default.nix new file mode 100644 index 000000000000..f0ff4a47b4c3 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/fpga/trellis/default.nix @@ -0,0 +1,70 @@ +{ lib, stdenv, fetchFromGitHub, python3, boost, cmake }: + +let + rev = "488f4e71073062de314c55a037ede7cf03a3324c"; + # git describe --tags + realVersion = "1.2.1-14-g${builtins.substring 0 7 rev}"; + + main_src = fetchFromGitHub { + owner = "YosysHQ"; + repo = "prjtrellis"; + inherit rev; + hash = "sha256-Blbu+0rlM/3izbF0XCvkNpSAND0IclWEwK7anzyrpvw="; + name = "trellis"; + }; + + database_src = fetchFromGitHub { + owner = "YosysHQ"; + repo = "prjtrellis-db"; + rev = "35d900a94ff0db152679a67bf6e4fbf40ebc34aa"; + hash = "sha256-r6viR8y9ZjURGNbsa0/YY8lzy9kGzjuu408ntxwpqm0="; + name = "trellis-database"; + }; + +in stdenv.mkDerivation rec { + pname = "trellis"; + version = "unstable-2022-09-14"; + + srcs = [ main_src database_src ]; + sourceRoot = main_src.name; + + buildInputs = [ boost ]; + nativeBuildInputs = [ cmake python3 ]; + cmakeFlags = [ + "-DCURRENT_GIT_VERSION=${realVersion}" + # TODO: should this be in stdenv instead? + "-DCMAKE_INSTALL_DATADIR=${placeholder "out"}/share" + ]; + + preConfigure = '' + rmdir database && ln -sfv ${database_src} ./database + + cd libtrellis + ''; + + postInstall = lib.optionalString stdenv.isDarwin '' + for f in $out/bin/* ; do + install_name_tool -change "$out/lib/libtrellis.dylib" "$out/lib/trellis/libtrellis.dylib" "$f" + done + ''; + + doInstallCheck = true; + + installCheckPhase = '' + $out/bin/ecppack $out/share/trellis/misc/basecfgs/empty_lfe5u-85f.config /tmp/test.bin + ''; + + meta = with lib; { + description = "Documentation and bitstream tools for Lattice ECP5 FPGAs"; + longDescription = '' + Project Trellis documents the Lattice ECP5 architecture + to enable development of open-source tools. Its goal is + to provide sufficient information to develop a free and + open Verilog to bitstream toolchain for these devices. + ''; + homepage = "https://github.com/YosysHQ/prjtrellis"; + license = licenses.isc; + maintainers = with maintainers; [ q3k thoughtpolice emily rowanG077 ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/gputils/default.nix b/nixpkgs/pkgs/development/embedded/gputils/default.nix new file mode 100644 index 000000000000..69a901ea80f7 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/gputils/default.nix @@ -0,0 +1,19 @@ +{ lib, stdenv, fetchurl }: + +stdenv.mkDerivation rec { + pname = "gputils"; + version = "1.5.2"; + + src = fetchurl { + url = "mirror://sourceforge/gputils/${pname}-${version}.tar.bz2"; + sha256 = "sha256-j7iCCzHXwffHdhQcyzxPBvQK+RXaY3QSjXUtHu463fI="; + }; + + meta = with lib; { + homepage = "https://gputils.sourceforge.io"; + description = "A collection of tools for the Microchip (TM) PIC microcontrollers. It includes gpasm, gplink, and gplib"; + license = licenses.gpl2; + maintainers = with maintainers; [ yorickvp ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/jtag-remote-server/default.nix b/nixpkgs/pkgs/development/embedded/jtag-remote-server/default.nix new file mode 100644 index 000000000000..4a2c9c3df3d2 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/jtag-remote-server/default.nix @@ -0,0 +1,24 @@ +{ stdenv, fetchFromGitHub, lib, cmake, pkg-config, libftdi1 }: + +stdenv.mkDerivation rec { + pname = "jtag-remote-server"; + version = "1.2"; + + src = fetchFromGitHub { + owner = "jiegec"; + repo = pname; + rev = "v${version}"; + hash = "sha256-qtgO0BO2hvWi/E2RzGTTuQynKbh7/OLeoLcm60dqro8="; + }; + + nativeBuildInputs = [ cmake pkg-config ]; + buildInputs = [ libftdi1 ]; + + meta = with lib; { + description = "Remote JTAG server for remote debugging"; + homepage = "https://github.com/jiegec/jtag-remote-server"; + license = licenses.mit; + maintainers = with maintainers; [ nickcao ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/nmrpflash/default.nix b/nixpkgs/pkgs/development/embedded/nmrpflash/default.nix new file mode 100644 index 000000000000..62dea5d4c4d8 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/nmrpflash/default.nix @@ -0,0 +1,37 @@ +{ fetchFromGitHub +, lib +, libnl +, libpcap +, pkg-config +, stdenv +}: +stdenv.mkDerivation rec { + pname = "nmrpflash"; + version = "0.9.22"; + + src = fetchFromGitHub { + owner = "jclehner"; + repo = "nmrpflash"; + rev = "v${version}"; + sha256 = "sha256-gr/7tZYnuXFvfIUh2MmtgSbFoELTomQ4h05y/WFDhjo="; + }; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ libnl libpcap ]; + + PREFIX = "${placeholder "out"}"; + STANDALONE_VERSION = version; + + preInstall = '' + mkdir -p $out/bin + ''; + + meta = with lib; { + description = "Netgear Unbrick Utility"; + homepage = "https://github.com/jclehner/nmrpflash"; + license = licenses.gpl3; + maintainers = with maintainers; [ dadada ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/openocd/default.nix b/nixpkgs/pkgs/development/embedded/openocd/default.nix new file mode 100644 index 000000000000..39e9edc67722 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/openocd/default.nix @@ -0,0 +1,79 @@ +{ stdenv +, lib +, fetchurl +, pkg-config +, hidapi +, jimtcl +, libjaylink +, libusb1 +, libgpiod_1 + +, enableFtdi ? true, libftdi1 + +# Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters) +, extraHardwareSupport ? [] +}: + +stdenv.mkDerivation rec { + pname = "openocd"; + version = "0.12.0"; + src = fetchurl { + url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2"; + sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo="; + }; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ hidapi jimtcl libftdi1 libjaylink libusb1 ] + ++ + # tracking issue for v2 api changes https://sourceforge.net/p/openocd/tickets/306/ + lib.optional stdenv.isLinux libgpiod_1; + + configureFlags = [ + "--disable-werror" + "--disable-internal-jimtcl" + "--disable-internal-libjaylink" + "--enable-jtag_vpi" + "--enable-buspirate" + "--enable-remote-bitbang" + (lib.enableFeature enableFtdi "ftdi") + (lib.enableFeature stdenv.isLinux "linuxgpiod") + (lib.enableFeature stdenv.isLinux "sysfsgpio") + ] ++ + map (hardware: "--enable-${hardware}") extraHardwareSupport + ; + + enableParallelBuilding = true; + + env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ + "-Wno-error=cpp" + "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0 + ]); + + postInstall = lib.optionalString stdenv.isLinux '' + mkdir -p "$out/etc/udev/rules.d" + rules="$out/share/openocd/contrib/60-openocd.rules" + if [ ! -f "$rules" ]; then + echo "$rules is missing, must update the Nix file." + exit 1 + fi + ln -s "$rules" "$out/etc/udev/rules.d/" + ''; + + meta = with lib; { + description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing"; + longDescription = '' + OpenOCD provides on-chip programming and debugging support with a layered + architecture of JTAG interface and TAP support, debug target support + (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several + network interfaces are available for interactiving with OpenOCD: HTTP, + telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a + "remote target" for source-level debugging of embedded systems using the + GNU GDB program. + ''; + homepage = "https://openocd.sourceforge.net/"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ bjornfor prusnak ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/orbuculum/default.nix b/nixpkgs/pkgs/development/embedded/orbuculum/default.nix new file mode 100644 index 000000000000..e6a69e22be2d --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/orbuculum/default.nix @@ -0,0 +1,59 @@ +{ lib +, stdenv +, fetchFromGitHub +, meson +, ninja +, pkg-config +, czmq +, libusb1 +, ncurses +, SDL2 +}: + +stdenv.mkDerivation rec { + pname = "orbuculum"; + version = "2.1.0"; + + src = fetchFromGitHub { + owner = "orbcode"; + repo = pname; + rev = "V${version}"; + sha256 = "sha256-Ohcc8739W/EmDjOYhcMgzEPVhzbWrUYgsPLdy4qzxhY="; + }; + + prePatch = '' + substituteInPlace meson.build --replace \ + "/etc/udev/rules.d" "$out/etc/udev/rules.d" + ''; + + nativeBuildInputs = [ + meson + ninja + pkg-config + ]; + + buildInputs = [ + czmq + libusb1 + ncurses + SDL2 + ]; + + installFlags = [ + "INSTALL_ROOT=$(out)/" + ]; + + postInstall = '' + mkdir -p $out/etc/udev/rules.d/ + cp $src/Support/60-orbcode.rules $out/etc/udev/rules.d/ + ''; + + meta = with lib; { + description = "Cortex M SWO SWV Demux and Postprocess for the ORBTrace"; + homepage = "https://orbcode.org"; + changelog = "https://github.com/orbcode/orbuculum/blob/V${version}/CHANGES.md"; + license = licenses.bsd3; + maintainers = with maintainers; [ newam ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/platformio/chrootenv.nix b/nixpkgs/pkgs/development/embedded/platformio/chrootenv.nix new file mode 100644 index 000000000000..55adb0edaa75 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/platformio/chrootenv.nix @@ -0,0 +1,43 @@ +{ lib, buildFHSEnv, platformio-core }: + +let + pio-pkgs = pkgs: + let + inherit (platformio-core) python; + in + (with pkgs; [ + platformio-core + zlib + git + xdg-user-dirs + ncurses + ]) ++ (with python.pkgs; [ + python + setuptools + pip + bottle + ]); + +in +buildFHSEnv { + name = "platformio"; + + targetPkgs = pio-pkgs; + # disabled temporarily because fastdiff no longer support 32bit + # multiPkgs = pio-pkgs; + + meta = with lib; { + description = "An open source ecosystem for IoT development"; + homepage = "https://platformio.org"; + maintainers = with maintainers; [ mog ]; + license = licenses.asl20; + platforms = with platforms; linux; + }; + + extraInstallCommands = '' + ln -s $out/bin/platformio $out/bin/pio + ln -s ${platformio-core.udev}/lib $out/lib + ''; + + runScript = "platformio"; +} diff --git a/nixpkgs/pkgs/development/embedded/platformio/core.nix b/nixpkgs/pkgs/development/embedded/platformio/core.nix new file mode 100644 index 000000000000..82ccfa41c2f0 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/platformio/core.nix @@ -0,0 +1,190 @@ +{ lib +, python3Packages +, fetchFromGitHub +, fetchpatch +, git +, spdx-license-list-data +, substituteAll +}: + + +with python3Packages; buildPythonApplication rec { + pname = "platformio"; + version = "6.1.11"; + pyproject = true; + + # pypi tarballs don't contain tests - https://github.com/platformio/platformio-core/issues/1964 + src = fetchFromGitHub { + owner = "platformio"; + repo = "platformio-core"; + rev = "v${version}"; + hash = "sha256-NR4UyAt8q5sUGtz1Sy6E8Of7y9WrH9xpcAWzLBeDQmo="; + }; + + outputs = [ "out" "udev" ]; + + patches = [ + (substituteAll { + src = ./interpreter.patch; + interpreter = (python3Packages.python.withPackages (_: propagatedBuildInputs)).interpreter; + }) + (substituteAll { + src = ./use-local-spdx-license-list.patch; + spdx_license_list_data = spdx-license-list-data.json; + }) + ./missing-udev-rules-nixos.patch + (fetchpatch { + # restore PYTHONPATH when calling scons + # https://github.com/platformio/platformio-core/commit/097de2be98af533578671baa903a3ae825d90b94 + url = "https://github.com/platformio/platformio-core/commit/097de2be98af533578671baa903a3ae825d90b94.patch"; + hash = "sha256-yq+/QHCkhAkFND11MbKFiiWT3oF1cHhgWj5JkYjwuY0="; + revert = true; + }) + ]; + + nativeBuildInputs = [ + pythonRelaxDepsHook + setuptools + ]; + + pythonRelaxDeps = true; + + propagatedBuildInputs = [ + aiofiles + ajsonrpc + bottle + click + click-completion + colorama + git + lockfile + marshmallow + pyelftools + pyserial + requests + semantic-version + setuptools + spdx-license-list-data.json + starlette + tabulate + uvicorn + wsproto + zeroconf + + ]; + + preCheck = '' + export HOME=$(mktemp -d) + export PATH=$PATH:$out/bin + ''; + + nativeCheckInputs = [ + jsondiff + pytestCheckHook + ]; + + # Install udev rules into a separate output so all of platformio-core is not a dependency if + # you want to use the udev rules on NixOS but not install platformio in your system packages. + postInstall = '' + mkdir -p $udev/lib/udev/rules.d + cp platformio/assets/system/99-platformio-udev.rules $udev/lib/udev/rules.d/99-platformio-udev.rules + ''; + + disabledTestPaths = [ + "tests/commands/pkg/test_install.py" + "tests/commands/pkg/test_list.py" + "tests/commands/pkg/test_outdated.py" + "tests/commands/pkg/test_search.py" + "tests/commands/pkg/test_show.py" + "tests/commands/pkg/test_uninstall.py" + "tests/commands/pkg/test_update.py" + "tests/commands/test_boards.py" + "tests/commands/test_check.py" + "tests/commands/test_platform.py" + "tests/commands/test_run.py" + "tests/commands/test_test.py" + "tests/misc/test_maintenance.py" + # requires internet connection + "tests/misc/ino2cpp/test_ino2cpp.py" + ]; + + disabledTests = [ + # requires internet connection + "test_api_cache" + "test_ping_internet_ips" + ]; + + pytestFlagsArray = [ + "tests" + ] ++ (map (e: "--deselect tests/${e}") [ + "commands/pkg/test_exec.py::test_pkg_specified" + "commands/pkg/test_exec.py::test_unrecognized_options" + "commands/test_ci.py::test_ci_boards" + "commands/test_ci.py::test_ci_build_dir" + "commands/test_ci.py::test_ci_keep_build_dir" + "commands/test_ci.py::test_ci_lib_and_board" + "commands/test_ci.py::test_ci_project_conf" + "commands/test_init.py::test_init_custom_framework" + "commands/test_init.py::test_init_duplicated_boards" + "commands/test_init.py::test_init_enable_auto_uploading" + "commands/test_init.py::test_init_ide_atom" + "commands/test_init.py::test_init_ide_clion" + "commands/test_init.py::test_init_ide_eclipse" + "commands/test_init.py::test_init_ide_vscode" + "commands/test_init.py::test_init_incorrect_board" + "commands/test_init.py::test_init_special_board" + "commands/test_lib.py::test_global_install_archive" + "commands/test_lib.py::test_global_install_registry" + "commands/test_lib.py::test_global_install_repository" + "commands/test_lib.py::test_global_lib_list" + "commands/test_lib.py::test_global_lib_uninstall" + "commands/test_lib.py::test_global_lib_update" + "commands/test_lib.py::test_global_lib_update_check" + "commands/test_lib.py::test_install_duplicates" + "commands/test_lib.py::test_lib_show" + "commands/test_lib.py::test_lib_stats" + "commands/test_lib.py::test_saving_deps" + "commands/test_lib.py::test_search" + "commands/test_lib.py::test_update" + "commands/test_lib_complex.py::test_global_install_archive" + "commands/test_lib_complex.py::test_global_install_registry" + "commands/test_lib_complex.py::test_global_install_repository" + "commands/test_lib_complex.py::test_global_lib_list" + "commands/test_lib_complex.py::test_global_lib_uninstall" + "commands/test_lib_complex.py::test_global_lib_update" + "commands/test_lib_complex.py::test_global_lib_update_check" + "commands/test_lib_complex.py::test_install_duplicates" + "commands/test_lib_complex.py::test_lib_show" + "commands/test_lib_complex.py::test_lib_stats" + "commands/test_lib_complex.py::test_search" + "package/test_manager.py::test_download" + "package/test_manager.py::test_install_force" + "package/test_manager.py::test_install_from_registry" + "package/test_manager.py::test_install_lib_depndencies" + "package/test_manager.py::test_registry" + "package/test_manager.py::test_uninstall" + "package/test_manager.py::test_update_with_metadata" + "package/test_manager.py::test_update_without_metadata" + "test_builder.py::test_build_flags" + "test_builder.py::test_build_unflags" + "test_builder.py::test_debug_custom_build_flags" + "test_builder.py::test_debug_default_build_flags" + "test_misc.py::test_api_cache" + "test_misc.py::test_ping_internet_ips" + "test_misc.py::test_platformio_cli" + "test_pkgmanifest.py::test_packages" + ]); + + passthru = { + python = python3Packages.python; + }; + + meta = with lib; { + changelog = "https://github.com/platformio/platformio-core/releases/tag/v${version}"; + description = "An open source ecosystem for IoT development"; + downloadPage = "https://github.com/platformio/platformio-core"; + homepage = "https://platformio.org"; + license = licenses.asl20; + maintainers = with maintainers; [ mog makefu ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/platformio/default.nix b/nixpkgs/pkgs/development/embedded/platformio/default.nix new file mode 100644 index 000000000000..956d7dee06cd --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/platformio/default.nix @@ -0,0 +1,13 @@ +{ newScope, fetchFromGitHub, python3Packages }: + +let + callPackage = newScope self; + + self = { + platformio-core = python3Packages.callPackage ./core.nix { }; + + platformio-chrootenv = callPackage ./chrootenv.nix { }; + }; + +in +self diff --git a/nixpkgs/pkgs/development/embedded/platformio/interpreter.patch b/nixpkgs/pkgs/development/embedded/platformio/interpreter.patch new file mode 100644 index 000000000000..f7e212d57111 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/platformio/interpreter.patch @@ -0,0 +1,22 @@ +diff --git a/platformio/proc.py b/platformio/proc.py +index 707245a1..cae17a29 100644 +--- a/platformio/proc.py ++++ b/platformio/proc.py +@@ -165,7 +165,7 @@ def is_container(): + + + def get_pythonexe_path(): +- return os.environ.get("PYTHONEXEPATH", os.path.normpath(sys.executable)) ++ return "@interpreter@" + + + def copy_pythonpath_to_osenv(): +@@ -181,7 +181,7 @@ def copy_pythonpath_to_osenv(): + ) + if all(conditions): + _PYTHONPATH.append(p) +- os.environ["PYTHONPATH"] = os.pathsep.join(_PYTHONPATH) ++ os.environ["PYTHONPATH"] = os.pathsep.join(sys.path) + + + def where_is_program(program, envpath=None): diff --git a/nixpkgs/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch b/nixpkgs/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch new file mode 100644 index 000000000000..878470920577 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/platformio/missing-udev-rules-nixos.patch @@ -0,0 +1,12 @@ +diff --git a/platformio/exception.py b/platformio/exception.py +index 80ffb496..ea064f97 100644 +--- a/platformio/exception.py ++++ b/platformio/exception.py +@@ -49,6 +49,7 @@ class MissedUdevRules(InvalidUdevRules): + MESSAGE = ( + "Warning! Please install `99-platformio-udev.rules`. \nMore details: " + "https://docs.platformio.org/en/latest/core/installation/udev-rules.html" ++ "On NixOS set `services.udev.packages = with pkgs; [ platformio-core.udev ];`." + ) + + diff --git a/nixpkgs/pkgs/development/embedded/platformio/use-local-spdx-license-list.patch b/nixpkgs/pkgs/development/embedded/platformio/use-local-spdx-license-list.patch new file mode 100644 index 000000000000..ba9b55b788a1 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/platformio/use-local-spdx-license-list.patch @@ -0,0 +1,17 @@ +diff --git a/platformio/package/manifest/schema.py b/platformio/package/manifest/schema.py +index 95e08108..6c2cfaed 100644 +--- a/platformio/package/manifest/schema.py ++++ b/platformio/package/manifest/schema.py +@@ -276,9 +276,6 @@ class ManifestSchema(BaseSchema): + @staticmethod + @memoized(expire="1h") + def load_spdx_licenses(): +- version = "3.21" +- spdx_data_url = ( +- "https://raw.githubusercontent.com/spdx/license-list-data/" +- f"v{version}/json/licenses.json" +- ) +- return json.loads(fetch_remote_content(spdx_data_url)) ++ with open("@spdx_license_list_data@/json/licenses.json") as fd: ++ spdx = json.load(fd) ++ return spdx diff --git a/nixpkgs/pkgs/development/embedded/rshell/default.nix b/nixpkgs/pkgs/development/embedded/rshell/default.nix new file mode 100644 index 000000000000..a537af3692b4 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/rshell/default.nix @@ -0,0 +1,31 @@ +{ lib +, buildPythonApplication +, fetchPypi +, pyserial +, pyudev +, pythonOlder +}: + +buildPythonApplication rec { + pname = "rshell"; + version = "0.0.31"; + + disabled = pythonOlder "3.4"; + + src = fetchPypi { + inherit pname version; + sha256 = "7942b758a9ae5c6ff46516b0317f437dfce9f0721f3a3b635ebd501c9cd38fb9"; + }; + + propagatedBuildInputs = [ + pyserial + pyudev + ]; + + meta = with lib; { + homepage = "https://github.com/dhylands/rshell"; + description = "Remote Shell for MicroPython"; + license = licenses.mit; + maintainers = with maintainers; [ c0deaddict ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/stm32/stm32cubemx/default.nix b/nixpkgs/pkgs/development/embedded/stm32/stm32cubemx/default.nix new file mode 100644 index 000000000000..e3e0f2672cf2 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/stm32/stm32cubemx/default.nix @@ -0,0 +1,84 @@ +{ fdupes +, fetchzip +, icoutils +, imagemagick +, jdk17 +, lib +, makeDesktopItem +, stdenv +}: + +let + iconame = "STM32CubeMX"; +in +stdenv.mkDerivation rec { + pname = "stm32cubemx"; + version = "6.9.2"; + + src = fetchzip { + url = "https://sw-center.st.com/packs/resource/library/stm32cube_mx_v${builtins.replaceStrings ["."] [""] version}-lin.zip"; + sha256 = "sha256-x3ZRMtTvFGz2/0gJMx4zOx9rSnrSkCEl3pj5raeyVHg="; + stripRoot = false; + }; + + nativeBuildInputs = [ fdupes icoutils imagemagick ]; + desktopItem = makeDesktopItem { + name = "STM32CubeMX"; + exec = "stm32cubemx"; + desktopName = "STM32CubeMX"; + categories = [ "Development" ]; + icon = "stm32cubemx"; + comment = meta.description; + terminal = false; + startupNotify = false; + mimeTypes = [ + "x-scheme-handler/sgnl" + "x-scheme-handler/signalcaptcha" + ]; + }; + + buildCommand = '' + mkdir -p $out/{bin,opt/STM32CubeMX,share/applications} + + cp -r $src/MX/. $out/opt/STM32CubeMX/ + chmod +rx $out/opt/STM32CubeMX/STM32CubeMX + + cat << EOF > $out/bin/${pname} + #!${stdenv.shell} + ${jdk17}/bin/java -jar $out/opt/STM32CubeMX/STM32CubeMX + EOF + chmod +x $out/bin/${pname} + + icotool --extract $out/opt/STM32CubeMX/help/${iconame}.ico + fdupes -dN . > /dev/null + ls + for size in 16 24 32 48 64 128 256; do + mkdir -pv $out/share/icons/hicolor/"$size"x"$size"/apps + if [ $size -eq 256 ]; then + mv ${iconame}_*_"$size"x"$size"x32.png \ + $out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png + else + convert -resize "$size"x"$size" ${iconame}_*_256x256x32.png \ + $out/share/icons/hicolor/"$size"x"$size"/apps/${pname}.png + fi + done; + + cp ${desktopItem}/share/applications/*.desktop $out/share/applications + ''; + + meta = with lib; { + description = "A graphical tool for configuring STM32 microcontrollers and microprocessors"; + longDescription = '' + A graphical tool that allows a very easy configuration of STM32 + microcontrollers and microprocessors, as well as the generation of the + corresponding initialization C code for the Arm® Cortex®-M core or a + partial Linux® Device Tree for Arm® Cortex®-A core), through a + step-by-step process. + ''; + homepage = "https://www.st.com/en/development-tools/stm32cubemx.html"; + sourceProvenance = with sourceTypes; [ binaryBytecode ]; + license = licenses.unfree; + maintainers = with maintainers; [ angaz wucke13 ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/stm32/stm32flash/default.nix b/nixpkgs/pkgs/development/embedded/stm32/stm32flash/default.nix new file mode 100644 index 000000000000..d6e8d4598960 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/stm32/stm32flash/default.nix @@ -0,0 +1,27 @@ +{ lib, stdenv, fetchurl }: + +stdenv.mkDerivation rec { + pname = "stm32flash"; + version = "0.7"; + + src = fetchurl { + url = "mirror://sourceforge/${pname}/${pname}-${version}.tar.gz"; + sha256 = "sha256-xMnNi+x52mOxEdFXE+9cws2UfeykEdNdbjBl4ifcQUo="; + }; + + buildFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; + + installPhase = '' + # Manually copy, make install copies to /usr/local/bin + mkdir -pv $out/bin/ + cp stm32flash $out/bin/ + ''; + + meta = with lib; { + description = "Open source flash program for the STM32 ARM processors using the ST bootloader"; + homepage = "https://sourceforge.net/projects/stm32flash/"; + license = lib.licenses.gpl2; + platforms = platforms.all; # Should work on all platforms + maintainers = with maintainers; [ elitak ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/stm8/stm8flash/default.nix b/nixpkgs/pkgs/development/embedded/stm8/stm8flash/default.nix new file mode 100644 index 000000000000..1584ee7fdf07 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/stm8/stm8flash/default.nix @@ -0,0 +1,34 @@ +{ lib, stdenv, fetchFromGitHub, libusb1, pkg-config }: + +stdenv.mkDerivation rec { + pname = "stm8flash"; + version = "2022-03-27"; + + src = fetchFromGitHub { + owner = "vdudouyt"; + repo = "stm8flash"; + rev = "23305ce5adbb509c5cb668df31b0fd6c8759639c"; + sha256 = "sha256-fFoC2EKSmYyW2lqrdAh5A2WEtUMCenKse2ySJdNHu6w="; + }; + + strictDeps = true; + enableParallelBuilding = true; + + # NOTE: _FORTIFY_SOURCE requires compiling with optimization (-O) + env.NIX_CFLAGS_COMPILE = "-O"; + + preBuild = '' + export DESTDIR=$out; + ''; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ libusb1 ]; + + meta = with lib; { + homepage = "https://github.com/vdudouyt/stm8flash"; + description = "A tool for flashing STM8 MCUs via ST-LINK (V1 and V2)"; + maintainers = with maintainers; [ pkharvey ]; + license = licenses.gpl2; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/svdtools/default.nix b/nixpkgs/pkgs/development/embedded/svdtools/default.nix new file mode 100644 index 000000000000..4a57b0ace290 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/svdtools/default.nix @@ -0,0 +1,24 @@ +{ lib +, rustPlatform +, fetchCrate +}: + +rustPlatform.buildRustPackage rec { + pname = "svdtools"; + version = "0.3.6"; + + src = fetchCrate { + inherit version pname; + hash = "sha256-bk6kv13HMDSRBjShWnRZJzb0YX0zKljPoEC6tebkVKI="; + }; + + cargoHash = "sha256-MdYzYmbI7ZNLeLZdnLIVo9y2rvmGevEGy7t+2FFu5yo="; + + meta = with lib; { + description = "Tools to handle vendor-supplied, often buggy SVD files"; + homepage = "https://github.com/stm32-rs/svdtools"; + changelog = "https://github.com/stm32-rs/svdtools/blob/v${version}/CHANGELOG-rust.md"; + license = with licenses; [ asl20 /* or */ mit ]; + maintainers = with maintainers; [ newam ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/default.nix b/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/default.nix new file mode 100644 index 000000000000..7254becdbce7 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/default.nix @@ -0,0 +1,35 @@ +{ stdenv +, lib +, fetchFromGitHub +, cmake +, pkg-config +, callPackage +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "teensy-cmake-macros"; + version = "unstable-2023-04-15"; + + src = fetchFromGitHub { + owner = "newdigate"; + repo = "teensy-cmake-macros"; + rev = "dc401ed23e6e13a9db3cd2a65f611a4738df3b0e"; + hash = "sha256-E+BOlsCJtOScr3B5GSv1WM6rFv6cFYvm/iJ893fsmXM="; + }; + + propagatedBuildInputs = [ cmake pkg-config ]; + + passthru = { + hook = callPackage ./hook.nix { + teensy-cmake-macros = finalAttrs.finalPackage; + }; + }; + + meta = with lib; { + description = "CMake macros for building teensy projects"; + platforms = platforms.all; + homepage = "https://github.com/newdigate/teensy-cmake-macros"; + license = licenses.mit; + maintainers = [ maintainers.michaeldonovan ]; + }; +}) diff --git a/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/hook.nix b/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/hook.nix new file mode 100644 index 000000000000..83a4e6828d4a --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/hook.nix @@ -0,0 +1,17 @@ +{ lib +, makeSetupHook +, teensy-cmake-macros +}: + +makeSetupHook { + name = "teensy-cmake-macros-hook"; + + propagatedBuildInputs = [ teensy-cmake-macros ]; + + passthru = { inherit teensy-cmake-macros; }; + + meta = { + description = "A setup hook for teensy-cmake-macros"; + inherit (teensy-cmake-macros.meta) maintainers platforms broken; + }; +} ./setup-hook.sh diff --git a/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/setup-hook.sh b/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/setup-hook.sh new file mode 100644 index 000000000000..71026eedcf65 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/teensy-cmake-macros/setup-hook.sh @@ -0,0 +1,5 @@ +teensyCMakeMacrosEnvHook() { + cmakeFlagsArray+=(-DCMAKE_MODULE_PATH=@out@/lib/cmake) +} + +addEnvHooks "$targetOffset" teensyCMakeMacrosEnvHook diff --git a/nixpkgs/pkgs/development/embedded/teensy-loader-cli/default.nix b/nixpkgs/pkgs/development/embedded/teensy-loader-cli/default.nix new file mode 100644 index 000000000000..e8445a9955f2 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/teensy-loader-cli/default.nix @@ -0,0 +1,46 @@ +{ stdenv +, lib +, fetchFromGitHub +, go-md2man +, installShellFiles +, libusb-compat-0_1 +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "teensy-loader-cli"; + version = "2.2"; + + src = fetchFromGitHub { + owner = "PaulStoffregen"; + repo = "teensy_loader_cli"; + rev = finalAttrs.version; + sha256 = "sha256-C9Qhd6LhAES7X0sh4rofjAM+gxwuosahVQHeR76LyIo="; + }; + + nativeBuildInputs = [ + go-md2man + installShellFiles + ]; + + buildInputs = [ + libusb-compat-0_1 + ]; + + installPhase = '' + runHook preInstall + + install -Dm555 teensy_loader_cli $out/bin/teensy-loader-cli + install -Dm444 -t $out/share/doc/teensy-loader-cli *.md *.txt + go-md2man -in README.md -out teensy-loader-cli.1 + installManPage *.1 + + runHook postInstall + ''; + + meta = with lib; { + description = "Firmware uploader for the Teensy microcontroller boards"; + homepage = "https://www.pjrc.com/teensy/"; + license = licenses.gpl3Only; + platforms = platforms.unix; + }; +}) diff --git a/nixpkgs/pkgs/development/embedded/tytools/default.nix b/nixpkgs/pkgs/development/embedded/tytools/default.nix new file mode 100644 index 000000000000..1669ec239ac7 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/tytools/default.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, wrapQtAppsHook , qtbase}: + +stdenv.mkDerivation rec { + pname = "tytools"; + version = "0.9.8"; + + src = fetchFromGitHub { + owner = "Koromix"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-MKhh0ooDZI1Ks8vVuPRiHhpOqStetGaAhE2ulvBstxA="; + }; + + nativeBuildInputs = [ cmake pkg-config wrapQtAppsHook ]; + buildInputs = [ + qtbase + ]; + + meta = with lib; { + description = "Collection of tools to manage Teensy boards"; + homepage = "https://koromix.dev/tytools"; + license = licenses.unlicense; + platforms = platforms.unix; + maintainers = with maintainers; [ ahuzik ]; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/uisp/default.nix b/nixpkgs/pkgs/development/embedded/uisp/default.nix new file mode 100644 index 000000000000..0ae31bc24fb2 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/uisp/default.nix @@ -0,0 +1,20 @@ +{ lib, stdenv, fetchurl }: + +stdenv.mkDerivation rec { + pname = "uisp"; + version = "20050207"; + + src = fetchurl { + url = "https://savannah.nongnu.org/download/uisp/uisp-${version}.tar.gz"; + sha256 = "1bncxp5yxh9r1yrp04vvhfiva8livi1pwic7v8xj99q09zrwahvw"; + }; + + env.NIX_CFLAGS_COMPILE = "-Wno-error"; + + meta = { + description = "Tool for AVR microcontrollers which can interface to many hardware in-system programmers"; + license = lib.licenses.gpl2; + homepage = "https://savannah.nongnu.org/projects/uisp"; + platforms = lib.platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/wch-isp/default.nix b/nixpkgs/pkgs/development/embedded/wch-isp/default.nix new file mode 100644 index 000000000000..4bc2e0615724 --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/wch-isp/default.nix @@ -0,0 +1,27 @@ +{ lib, stdenv, fetchFromGitHub, pkg-config, libusb1 }: + +stdenv.mkDerivation rec { + pname = "wch-isp"; + version = "0.3.0"; + + src = fetchFromGitHub { + owner = "jmaselbas"; + repo = pname; + rev = "v${version}"; + hash = "sha256-cbQJgHZAdSfzRsf/srMlRd+QgGUPpP5r3kBTNCgINDw="; + }; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ libusb1 ]; + + installFlags = [ "DESTDIR=$(out)" "PREFIX=" ]; + installTargets = [ "install" "install-rules" ]; + + meta = { + description = "Firmware programmer for WCH microcontrollers over USB"; + license = lib.licenses.gpl2Only; + homepage = "https://github.com/jmaselbas/wch-isp"; + maintainers = with lib.maintainers; [ lesuisse ]; + platforms = lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/embedded/xc3sprog/default.nix b/nixpkgs/pkgs/development/embedded/xc3sprog/default.nix new file mode 100644 index 000000000000..fa9ceffafbbb --- /dev/null +++ b/nixpkgs/pkgs/development/embedded/xc3sprog/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchsvn, cmake, libusb-compat-0_1, libftdi }: + +# The xc3sprog project doesn't seem to make proper releases, they only put out +# prebuilt binary subversion snapshots on sourceforge. + +stdenv.mkDerivation rec { + version = "787"; + pname = "xc3sprog"; + + src = fetchsvn { + url = "https://svn.code.sf.net/p/xc3sprog/code/trunk"; + sha256 = "1rfhms3i7375kdlg0sdg5k52ix3xv5llj2dr30vamyg7pk74y8rx"; + rev = version; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libusb-compat-0_1 libftdi ]; + + cmakeFlags = [ + # file RPATH_CHANGE could not write new RPATH + "-DCMAKE_SKIP_BUILD_RPATH=ON" + # fix build with gcc 11+ + "-DCMAKE_CXX_STANDARD=14" + ]; + + meta = with lib; { + description = "Command-line tools for programming FPGAs, microcontrollers and PROMs via JTAG"; + homepage = "https://xc3sprog.sourceforge.net/"; + license = licenses.gpl2Plus; + platforms = platforms.linux; + maintainers = [ maintainers.bjornfor ]; + }; +} |