-
-
Save me-no-dev/dc8d25d0f7b03f1b645b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET ?= $(notdir $(shell pwd)) | |
PYTHON ?= python | |
HOME_DIR ?= $(shell echo ~) | |
ARDUINO_DIR ?= $(HOME_DIR)/arduino-1.6.8 | |
ARDUINO_HARDWARE ?= $(ARDUINO_DIR)/hardware | |
ARDUINO_BUILDER ?= $(ARDUINO_DIR)/arduino-builder | |
ARDUINO_TOOLS ?= $(ARDUINO_DIR)/tools-builder | |
ARDUINO_LIBS ?= $(ARDUINO_DIR)/libraries | |
SKETCHBOOK_DIR ?= $(HOME_DIR)/Arduino | |
MKSPIFFS ?= $(ARDUINO_DIR)/hardware/esp8266com/esp8266/tools/mkspiffs/mkspiffs | |
ESPOTA_PY ?= $(ARDUINO_DIR)/hardware/esp8266com/esp8266/tools/espota.py | |
ESPTOOL ?= $(ARDUINO_DIR)/hardware/esp8266com/esp8266/tools/esptool/esptool | |
OTA_IP ?= esp8266.local | |
OTA_PORT ?= 8266 | |
RESET_METHOD ?= nodemcu | |
UPLOAD_PORT ?= /dev/ttyUSB0 | |
# UPLOAD_BAUD ?= 57600 | |
UPLOAD_BAUD ?= 115200 | |
# UPLOAD_BAUD ?= 230400 | |
# UPLOAD_BAUD ?= 460800 | |
# UPLOAD_BAUD ?= 921600 | |
CPU_FREQ ?= 160 | |
FLASH_FREQ ?= 80 | |
FLASH_MODE ?= qio | |
FLASH_SIZE ?= 4M3M | |
CORE_DEBUG ?= Disabled | |
CORE_DEBUG_LEVEL ?= None____ | |
WARNING_FLAGS ?= all | |
IDE_VERSION ?= 10608 | |
ARDUINO_FQBN="esp8266com:esp8266:generic:CpuFrequency=$(CPU_FREQ),FlashFreq=$(FLASH_FREQ),FlashMode=$(FLASH_MODE),UploadSpeed=$(UPLOAD_BAUD),FlashSize=$(FLASH_SIZE),ResetMethod=$(ESPTOOL_RESET),Debug=$(CORE_DEBUG),DebugLevel=$(CORE_DEBUG_LEVEL)-ide-version=$(IDE_VERSION)" | |
.PHONY: clean all upload upload_fs upload_bin upload_py | |
BUILD_PATH=$(shell realpath build) | |
all: build/$(TARGET).ino.bin | |
build/$(TARGET).ino.bin: | |
mkdir -p build | |
$(ARDUINO_BUILDER) -dump-prefs -logger=machine -warnings=$(WARNING_FLAGS) \ | |
-hardware=$(ARDUINO_HARDWARE) \ | |
-tools=$(ARDUINO_TOOLS) \ | |
-built-in-libraries=$(ARDUINO_LIBS) \ | |
-libraries=$(SKETCHBOOK_DIR)/libraries \ | |
-fqbn=$(ARDUINO_FQBN) \ | |
-build-path=$(BUILD_PATH) \ | |
$(TARGET).ino > $(BUILD_PATH)/build-prefs.txt | |
$(ARDUINO_BUILDER) -compile -logger=machine -warnings=$(WARNING_FLAGS) -verbose \ | |
-hardware=$(ARDUINO_HARDWARE) \ | |
-tools=$(ARDUINO_TOOLS) \ | |
-built-in-libraries=$(ARDUINO_LIBS) \ | |
-libraries=$(SKETCHBOOK_DIR)/libraries \ | |
-fqbn=$(ARDUINO_FQBN) \ | |
-build-path=$(BUILD_PATH) \ | |
$(TARGET).ino | |
clean: | |
-rm -rf build | |
upload: build/$(TARGET).ino.bin | |
$(ESPTOOL) -vv -cd $(ESPTOOL_RESET) -cb $(UPLOAD_BAUD) -cp $(UPLOAD_PORT) \ | |
-ca 0x000000 -cf build/$(TARGET).ino.bin | |
ota: build/$(TARGET).ino.bin | |
$(PYTHON) $(ESPOTA_PY) -i $(OTA_IP) -p $(OTA_PORT) -f build/$(TARGET).ino.bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment