Skip to content

Instantly share code, notes, and snippets.

@notpeelz
Created August 31, 2020 03:46
Show Gist options
  • Save notpeelz/ab36302cff846c4cec2aa0689b2b9e6a to your computer and use it in GitHub Desktop.
Save notpeelz/ab36302cff846c4cec2aa0689b2b9e6a to your computer and use it in GitHub Desktop.
arduino-makefile nix workflow
ISP_PROG = stk500v1
ISP_PORT = /dev/ttyACM0
MONITOR_PORT = /dev/ttyUSB0
#AVRDUDE_OPTS = -U lfuse:w:0xF1:m -U hfuse:w:0xDD:m -U efuse:w:0xFF:m -v -v
BOOTLOADER_PATH = optiboot
BOOTLOADER_FILE = optiboot_attiny85_16000000L.hex
BOARD_TAG = attinyx5
BOARD_SUB = 85
VARIANT = tinyX5
F_CPU = 16000000L
ALTERNATE_CORE = tiny
BOOTLOADER_PARENT = $(ATTINY_CORE)/bootloaders
ARDUINO_VAR_PATH = $(ATTINY_CORE)/variants
ARDUINO_CORE_PATH := $(ATTINY_CORE)/cores/$(ALTERNATE_CORE)
BOARDS_TXT = "$(ATTINY_CORE)/boards.txt"
include $(ARDMK_DIR)/Arduino.mk
# !!! Important. You have to use 'make ispload' when using an ISP.
{ pkgs ? import <nixpkgs> {} }:
with pkgs.lib;
let
libraries = {};
in pkgs.mkShell {
ARDMK_DIR = pkgs.arduino-mk;
ARDUINO_DIR = "${pkgs.arduino}/share/arduino";
ARDUINO_LIB_PATH = (pkgs.runCommand "arduino-libs" {} ''
mkdir -p $out
libs=(${escapeShellArgs (attrValues libraries)})
i=0
for lib in "${concatStringsSep " " (attrNames libraries)}"; do
[ -z "$lib" ] && continue
cp -r "''${libs[i]}" $out/$lib
((i+=1))
done
'');
ATTINY_CORE = pkgs.fetchFromGitHub {
owner = "SpenceKonde";
repo = "ATTinyCore";
rev = "1.3.3";
sha256 = "0f2a97zwzj7iqxz4rvgqrkmb290911310nfb97y752nhrwgvd55f";
};
buildInputs = with pkgs; [
(python27.withPackages (ps: with ps; [
pyserial
]))
arduino
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment