2018-09-03 10:23:15 +02:00
|
|
|
.PHONY: \
|
|
|
|
build-feather \
|
|
|
|
circuitpy-deps \
|
|
|
|
circuitpy-freeze-kmk-nrf \
|
|
|
|
devdeps \
|
|
|
|
freeze-nrf-vendor-deps \
|
|
|
|
lint
|
2018-09-03 05:06:53 +02:00
|
|
|
|
2018-09-16 09:15:16 +02:00
|
|
|
AMPY_PORT ?= /dev/ttyUSB0
|
|
|
|
AMPY_BAUD ?= 115200
|
|
|
|
AMPY_DELAY ?= 1.5
|
2018-09-04 01:46:12 +02:00
|
|
|
ARDUINO ?= /usr/share/arduino
|
2018-09-03 12:22:11 +02:00
|
|
|
|
2018-09-03 05:06:53 +02:00
|
|
|
devdeps: Pipfile.lock
|
2018-09-03 10:23:15 +02:00
|
|
|
@pipenv install --dev --ignore-pipfile
|
2018-09-03 05:06:53 +02:00
|
|
|
|
|
|
|
lint: devdeps
|
2018-09-03 10:23:15 +02:00
|
|
|
@pipenv run flake8
|
2018-09-03 05:06:53 +02:00
|
|
|
|
2018-09-22 08:44:03 +02:00
|
|
|
fix-isort: devdeps
|
2018-09-23 07:36:28 +02:00
|
|
|
@find kmk/ user_keymaps/ -name "*.py" | xargs pipenv run isort
|
2018-09-22 08:44:03 +02:00
|
|
|
|
2018-09-03 10:23:15 +02:00
|
|
|
.submodules: .gitmodules
|
2018-09-03 05:06:53 +02:00
|
|
|
@echo "===> Pulling dependencies, this may take several minutes"
|
|
|
|
@git submodule update --init --recursive
|
2018-09-03 10:23:15 +02:00
|
|
|
@touch .submodules
|
|
|
|
|
|
|
|
.circuitpy-deps: .submodules
|
2018-09-03 05:06:53 +02:00
|
|
|
@echo "===> Building circuitpython/mpy-cross"
|
|
|
|
@make -C vendor/circuitpython/mpy-cross
|
|
|
|
@echo "===> Pulling Nordic BLE stack"
|
2018-09-03 08:39:55 +02:00
|
|
|
@cd vendor/circuitpython/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh 2>/dev/null >/dev/null
|
2018-09-03 10:23:15 +02:00
|
|
|
@touch .circuitpy-deps
|
|
|
|
|
2018-09-04 01:22:04 +02:00
|
|
|
.micropython-deps: .submodules
|
|
|
|
@echo "===> Building micropython/mpy-cross"
|
|
|
|
@make -C vendor/micropython/mpy-cross
|
2018-09-17 22:25:37 +02:00
|
|
|
@touch .micropython-deps
|
2018-09-04 01:22:04 +02:00
|
|
|
|
2018-09-03 10:23:15 +02:00
|
|
|
circuitpy-deps: .circuitpy-deps
|
|
|
|
|
2018-09-04 01:22:04 +02:00
|
|
|
micropython-deps: .micropython-deps
|
|
|
|
|
2018-09-23 09:45:55 +02:00
|
|
|
vendor/micropython/ports/unix/micropython: vendor/micropython/ports/unix/modules/.kmk_frozen
|
|
|
|
@make -j4 -C vendor/micropython/ports/unix
|
|
|
|
|
|
|
|
micropython-build-unix: vendor/micropython/ports/unix/micropython
|
|
|
|
|
2018-09-03 10:23:15 +02:00
|
|
|
freeze-nrf-vendor-deps: vendor/circuitpython/ports/nrf/freeze/.kmk_frozen
|
2018-09-04 01:22:04 +02:00
|
|
|
freeze-teensy3.1-vendor-deps: vendor/micropython/ports/teensy/freeze/.kmk_frozen
|
2018-09-16 09:15:16 +02:00
|
|
|
freeze-stm32-vendor-deps: vendor/micropython/ports/stm32/freeze/.kmk_frozen
|
2018-09-04 01:22:04 +02:00
|
|
|
|
2018-09-23 09:45:55 +02:00
|
|
|
vendor/micropython/ports/unix/modules/.kmk_frozen: upy-freeze.txt
|
|
|
|
@echo "===> Preparing vendored dependencies for local development"
|
|
|
|
@rm -rf vendored_libs
|
|
|
|
@mkdir -p vendored_libs
|
|
|
|
@cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/unix/modules/
|
|
|
|
@touch $@
|
|
|
|
|
2018-09-03 10:23:15 +02:00
|
|
|
vendor/circuitpython/ports/nrf/freeze/.kmk_frozen: upy-freeze.txt
|
|
|
|
@echo "===> Preparing vendored dependencies for bundling"
|
|
|
|
@rm -rf vendor/circuitpython/ports/nrf/freeze/*
|
|
|
|
@cat $< | xargs -I '{}' cp -a {} vendor/circuitpython/ports/nrf/freeze/
|
|
|
|
@touch $@
|
|
|
|
|
2018-09-04 01:22:04 +02:00
|
|
|
vendor/micropython/ports/teensy/freeze/.kmk_frozen: upy-freeze.txt
|
|
|
|
@echo "===> Preparing vendored dependencies for bundling"
|
2018-09-17 05:50:05 +02:00
|
|
|
@mkdir -p vendor/micropython/ports/teensy/freeze/
|
2018-09-04 01:22:04 +02:00
|
|
|
@rm -rf vendor/micropython/ports/teensy/freeze/*
|
|
|
|
@cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/teensy/freeze/
|
|
|
|
@touch $@
|
|
|
|
|
2018-09-16 09:15:16 +02:00
|
|
|
vendor/micropython/ports/stm32/freeze/.kmk_frozen: upy-freeze.txt
|
|
|
|
@echo "===> Preparing vendored dependencies for bundling"
|
2018-09-17 05:50:05 +02:00
|
|
|
@mkdir -p vendor/micropython/ports/stm32/freeze/
|
2018-09-16 09:15:16 +02:00
|
|
|
@rm -rf vendor/micropython/ports/stm32/freeze/*
|
|
|
|
@cat $< | xargs -I '{}' cp -a {} vendor/micropython/ports/stm32/freeze/
|
|
|
|
@touch $@
|
|
|
|
|
2018-09-03 10:23:15 +02:00
|
|
|
circuitpy-freeze-kmk-nrf: freeze-nrf-vendor-deps
|
2018-09-03 05:06:53 +02:00
|
|
|
@echo "===> Preparing KMK source for bundling into CircuitPython"
|
2018-09-03 10:23:15 +02:00
|
|
|
@rm -rf vendor/circuitpython/ports/nrf/kmk*
|
2018-09-03 08:39:55 +02:00
|
|
|
@cp -av kmk vendor/circuitpython/ports/nrf/freeze/
|
2018-09-03 10:23:15 +02:00
|
|
|
|
2018-09-04 01:22:04 +02:00
|
|
|
micropython-freeze-kmk-teensy3.1: freeze-teensy3.1-vendor-deps
|
|
|
|
@echo "===> Preparing KMK source for bundling into MicroPython"
|
|
|
|
@rm -rf vendor/micropython/ports/teensy/kmk*
|
|
|
|
@cp -av kmk vendor/micropython/ports/teensy/memzip_files/
|
|
|
|
|
2018-09-16 09:15:16 +02:00
|
|
|
micropython-freeze-kmk-stm32: freeze-stm32-vendor-deps
|
|
|
|
@echo "===> Preparing KMK source for bundling into MicroPython"
|
|
|
|
@rm -rf vendor/micropython/ports/stm32/freeze/kmk*
|
|
|
|
@cp -av kmk vendor/micropython/ports/stm32/freeze/
|
|
|
|
|
2018-09-17 22:25:37 +02:00
|
|
|
circuitpy-build-nrf:
|
|
|
|
@echo "===> Building CircuitPython"
|
|
|
|
@make -C vendor/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze clean all
|
|
|
|
|
|
|
|
circuitpy-flash-nrf: circuitpy-build-nrf
|
|
|
|
@echo "===> Flashing CircuitPython with KMK and your keymap"
|
2018-09-23 07:36:28 +02:00
|
|
|
@sudo make -C vendor/circuitpython/ports/nrf BOARD=feather_nrf52832 SERIAL=${AMPY_PORT} SD=s132 FROZEN_MPY_DIR=freeze dfu-gen dfu-flash
|
2018-09-03 10:23:15 +02:00
|
|
|
|
2018-09-17 22:25:37 +02:00
|
|
|
micropython-build-teensy3.1:
|
2018-09-23 07:36:28 +02:00
|
|
|
#@cp entrypoints/teensy31.py vendor/micropython/ports/teensy/memzip_files/main.py
|
2018-09-17 22:25:37 +02:00
|
|
|
@make -C vendor/micropython/ports/teensy/ BOARD=TEENSY_3.1 all
|
|
|
|
|
|
|
|
micropython-flash-teensy3.1: micropython-build-teensy3.1
|
2018-09-23 07:36:28 +02:00
|
|
|
@sudo make -C vendor/micropython/ports/teensy/ BOARD=TEENSY_3.1 deploy
|
2018-09-04 01:22:04 +02:00
|
|
|
|
2018-09-17 22:25:37 +02:00
|
|
|
micropython-build-pyboard:
|
|
|
|
@make -j4 -C vendor/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze all
|
|
|
|
|
|
|
|
micropython-flash-pyboard: micropython-build-pyboard
|
2018-09-23 07:36:28 +02:00
|
|
|
@sudo make -j4 -C vendor/micropython/ports/stm32/ BOARD=PYBV11 FROZEN_MPY_DIR=freeze deploy
|
2018-09-16 09:15:16 +02:00
|
|
|
|
|
|
|
micropython-flash-pyboard-entrypoint:
|
|
|
|
@echo "===> Flashing entrypoints if they doesn't already exist"
|
|
|
|
@sleep 4
|
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm /flash/main.py 2>/dev/null
|
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm /flash/boot.py 2>/dev/null
|
2018-09-23 07:36:28 +02:00
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put kmk/entrypoints/global.py /flash/main.py
|
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put kmk/entrypoints/handwire/pyboard_boot.py /flash/boot.py
|
2018-09-16 09:15:16 +02:00
|
|
|
@echo "===> Flashed keyboard successfully!"
|
|
|
|
|
2018-09-03 10:23:15 +02:00
|
|
|
circuitpy-flash-nrf-entrypoint:
|
2018-09-03 08:39:55 +02:00
|
|
|
@echo "===> Flashing entrypoint if it doesn't already exist"
|
|
|
|
@sleep 2
|
2018-09-16 09:15:16 +02:00
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm main.py 2>/dev/null
|
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} put entrypoints/feather_nrf52832.py main.py
|
2018-09-03 08:39:55 +02:00
|
|
|
@echo "===> Flashed keyboard successfully!"
|
2018-09-03 05:06:53 +02:00
|
|
|
|
2018-09-23 07:36:28 +02:00
|
|
|
ifndef USER_KEYMAP
|
2018-09-03 22:51:04 +02:00
|
|
|
build-feather-nrf52832:
|
2018-09-23 07:36:28 +02:00
|
|
|
@echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!"
|
2018-09-17 22:25:37 +02:00
|
|
|
|
|
|
|
flash-feather-nrf52832:
|
2018-09-23 07:36:28 +02:00
|
|
|
@echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!"
|
2018-09-03 22:51:04 +02:00
|
|
|
else
|
|
|
|
build-feather-nrf52832: lint devdeps circuitpy-deps circuitpy-freeze-kmk-nrf
|
2018-09-17 22:25:37 +02:00
|
|
|
@echo "===> Preparing keyboard script for bundling into CircuitPython"
|
2018-09-23 07:36:28 +02:00
|
|
|
@cp -av ${USER_KEYMAP} vendor/circuitpython/ports/nrf/freeze/kmk_keyboard_user.py
|
2018-09-17 22:25:37 +02:00
|
|
|
@$(MAKE) circuitpy-build-nrf
|
|
|
|
|
|
|
|
flash-feather-nrf52832: lint devdeps circuitpy-deps circuitpy-freeze-kmk-nrf
|
2018-09-03 10:23:15 +02:00
|
|
|
@echo "===> Preparing keyboard script for bundling into CircuitPython"
|
2018-09-23 07:36:28 +02:00
|
|
|
@cp -av ${USER_KEYMAP} vendor/circuitpython/ports/nrf/freeze/kmk_keyboard_user.py
|
2018-09-03 10:23:15 +02:00
|
|
|
@$(MAKE) circuitpy-flash-nrf circuitpy-flash-nrf-entrypoint
|
2018-09-03 22:51:04 +02:00
|
|
|
endif
|
2018-09-03 10:23:15 +02:00
|
|
|
|
2018-09-23 07:36:28 +02:00
|
|
|
ifndef USER_KEYMAP
|
2018-09-04 01:22:04 +02:00
|
|
|
build-teensy-3.1:
|
2018-09-23 07:36:28 +02:00
|
|
|
@echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!"
|
2018-09-17 22:25:37 +02:00
|
|
|
|
|
|
|
flash-teensy-3.1:
|
2018-09-23 07:36:28 +02:00
|
|
|
@echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!"
|
2018-09-04 01:22:04 +02:00
|
|
|
else
|
|
|
|
build-teensy-3.1: lint devdeps micropython-deps micropython-freeze-kmk-teensy3.1
|
2018-09-17 22:25:37 +02:00
|
|
|
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
2018-09-23 07:36:28 +02:00
|
|
|
@cp -av ${USER_KEYMAP} vendor/micropython/ports/teensy/freeze/kmk_keyboard_user.py
|
2018-09-17 22:25:37 +02:00
|
|
|
@$(MAKE) ARDUINO=${ARDUINO} micropython-build-teensy3.1
|
|
|
|
|
|
|
|
flash-teensy-3.1: lint devdeps micropython-deps micropython-freeze-kmk-teensy3.1
|
2018-09-04 01:22:04 +02:00
|
|
|
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
2018-09-23 07:36:28 +02:00
|
|
|
@cp -av ${USER_KEYMAP} vendor/micropython/ports/teensy/freeze/kmk_keyboard_user.py
|
2018-09-04 01:46:12 +02:00
|
|
|
@$(MAKE) ARDUINO=${ARDUINO} micropython-flash-teensy3.1
|
2018-09-04 01:22:04 +02:00
|
|
|
endif
|
|
|
|
|
2018-09-23 07:36:28 +02:00
|
|
|
ifndef USER_KEYMAP
|
2018-09-16 09:15:16 +02:00
|
|
|
build-pyboard:
|
2018-09-23 07:36:28 +02:00
|
|
|
@echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!"
|
2018-09-17 22:25:37 +02:00
|
|
|
|
|
|
|
flash-pyboard:
|
2018-09-23 07:36:28 +02:00
|
|
|
@echo "===> Must provide a USER_KEYMAP (usually from user_keymaps/...) to build!"
|
2018-09-16 09:15:16 +02:00
|
|
|
else
|
|
|
|
build-pyboard: lint devdeps micropython-deps micropython-freeze-kmk-stm32
|
2018-09-17 22:25:37 +02:00
|
|
|
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
2018-09-23 07:36:28 +02:00
|
|
|
@cp -av ${USER_KEYMAP} vendor/micropython/ports/stm32/freeze/kmk_keyboard_user.py
|
2018-09-17 22:25:37 +02:00
|
|
|
@$(MAKE) AMPY_PORT=/dev/ttyACM0 AMPY_BAUD=115200 micropython-build-pyboard
|
|
|
|
|
|
|
|
flash-pyboard: lint devdeps micropython-deps micropython-freeze-kmk-stm32
|
2018-09-16 09:15:16 +02:00
|
|
|
@echo "===> Preparing keyboard script for bundling into MicroPython"
|
2018-09-23 07:36:28 +02:00
|
|
|
@cp -av ${USER_KEYMAP} vendor/micropython/ports/stm32/freeze/kmk_keyboard_user.py
|
2018-09-16 09:15:16 +02:00
|
|
|
@$(MAKE) AMPY_PORT=/dev/ttyACM0 AMPY_BAUD=115200 micropython-flash-pyboard micropython-flash-pyboard-entrypoint
|
|
|
|
endif
|
|
|
|
|
2018-09-03 08:39:55 +02:00
|
|
|
# Fully wipe the board with only stock CircuitPython
|
|
|
|
burn-it-all-with-fire: lint devdeps
|
|
|
|
@echo "===> Flashing STOCK CircuitPython with no KMK or user keyboard scripts, and wiping entrypoint"
|
|
|
|
@echo "===> This is the nuclear option. Ctrl-C to cancel, or any key to continue"
|
|
|
|
@read
|
2018-09-03 05:06:53 +02:00
|
|
|
@echo "===> Pulling dependencies, this may take several minutes"
|
|
|
|
@git submodule update --init --recursive
|
|
|
|
@echo "===> Building circuitpython/mpy-cross"
|
|
|
|
@make -C vendor/circuitpython/mpy-cross
|
|
|
|
@echo "===> Pulling Nordic BLE stack"
|
2018-09-03 08:39:55 +02:00
|
|
|
@cd vendor/circuitpython/ports/nrf && ./drivers/bluetooth/download_ble_stack.sh 2>/dev/null >/dev/null
|
2018-09-03 05:06:53 +02:00
|
|
|
@echo "===> Preparing KMK source for bundling into CircuitPython"
|
2018-09-03 10:23:15 +02:00
|
|
|
@rm -rf vendor/circuitpython/ports/nrf/*
|
2018-09-03 08:39:55 +02:00
|
|
|
@echo "===> Building CircuitPython WITHOUT KMK or user keyboard script to induce ImportError"
|
2018-09-03 10:23:15 +02:00
|
|
|
@$(MAKE) circuitpy-flash-nrf
|
2018-09-03 05:06:53 +02:00
|
|
|
@echo "===> Wiping keyboard config"
|
2018-09-03 08:39:55 +02:00
|
|
|
@sleep 2
|
2018-09-16 09:15:16 +02:00
|
|
|
@-timeout -k 5s 10s pipenv run ampy -p ${AMPY_PORT} -d ${AMPY_DELAY} -b ${AMPY_BAUD} rm main.py 2>/dev/null
|
2018-09-03 08:39:55 +02:00
|
|
|
@echo "===> Wiped! Probably safe to flash keyboard, try Python serial REPL to verify?"
|