2020-01-14 22:32:59 +01:00
|
|
|
export PYTHONPATH := $(PWD)/tools/nrfutil:$(PWD)/tools/intelhex:$(PYTHONPATH)
|
|
|
|
|
2020-12-04 20:33:05 +01:00
|
|
|
PYTHON ?= python3
|
|
|
|
PYTEST ?= pytest-3
|
|
|
|
|
2020-05-09 15:09:28 +02:00
|
|
|
all : bootloader reloader micropython
|
2020-01-14 22:32:59 +01:00
|
|
|
|
2020-08-15 21:45:18 +02:00
|
|
|
# If BOARD is undefined then set it up so that expanding it issues an
|
|
|
|
# error. That ensures that rules that expand BOARD will be automatically
|
|
|
|
# disabled (and give a useful error message) but it creates an additional
|
|
|
|
# problem which is that we must never unconditionally expand BOARD.
|
|
|
|
# We workaround this by using BOARD_SAFE for every unconditional
|
|
|
|
# expansion.
|
2020-06-20 21:14:56 +02:00
|
|
|
ifdef BOARD
|
2020-08-15 21:45:18 +02:00
|
|
|
BOARD_SAFE = $(BOARD)
|
2020-06-20 21:14:56 +02:00
|
|
|
endif
|
2020-08-15 21:45:18 +02:00
|
|
|
BOARD ?= $(error Please set BOARD=)
|
2020-08-21 22:11:26 +02:00
|
|
|
VERSION ?= $(patsubst v%,%,$(shell git describe --tags))
|
2020-01-20 09:05:31 +01:00
|
|
|
|
2020-01-14 22:32:59 +01:00
|
|
|
clean :
|
2020-02-01 14:40:19 +01:00
|
|
|
$(RM) -r \
|
2020-01-20 09:05:31 +01:00
|
|
|
bootloader/_build-$(BOARD)_nrf52832 \
|
2020-05-09 15:09:28 +02:00
|
|
|
reloader/build-$(BOARD) reloader/src/boards/$(BOARD)/bootloader.h \
|
2020-01-14 22:32:59 +01:00
|
|
|
micropython/mpy-cross/build \
|
2020-06-23 10:43:58 +02:00
|
|
|
micropython/ports/nrf/build-$(BOARD)-s132 \
|
2020-08-15 21:45:18 +02:00
|
|
|
wasp/boards/$(BOARD)/watch.py
|
2020-01-14 22:32:59 +01:00
|
|
|
|
2020-11-06 21:15:45 +01:00
|
|
|
# Avoid a recursive update... it grabs far too much
|
2020-01-14 22:32:59 +01:00
|
|
|
submodules :
|
2020-11-06 21:15:45 +01:00
|
|
|
git submodule update --init
|
|
|
|
(cd bootloader; git submodule update --init)
|
|
|
|
(cd micropython/ports/nrf; $(MAKE) submodules)
|
|
|
|
(cd reloader; git submodule update --init)
|
|
|
|
(cd wasp/modules/bma42x-upy; git submodule update --init)
|
2020-01-14 22:32:59 +01:00
|
|
|
|
2020-08-15 21:45:18 +02:00
|
|
|
bootloader: build-$(BOARD_SAFE)
|
2020-06-11 22:46:04 +02:00
|
|
|
$(RM) bootloader/_build-$(BOARD)_nrf52832//$(BOARD)_nrf52832_bootloader-*-nosd.hex
|
2020-01-20 09:05:31 +01:00
|
|
|
$(MAKE) -C bootloader/ BOARD=$(BOARD)_nrf52832 all genhex
|
2020-12-04 20:33:05 +01:00
|
|
|
$(PYTHON) tools/hexmerge.py \
|
2020-01-20 09:05:31 +01:00
|
|
|
bootloader/_build-$(BOARD)_nrf52832/$(BOARD)_nrf52832_bootloader-*-nosd.hex \
|
2020-01-14 22:32:59 +01:00
|
|
|
bootloader/lib/softdevice/s132_nrf52_6.1.1/s132_nrf52_6.1.1_softdevice.hex \
|
2020-08-02 13:12:37 +02:00
|
|
|
-o build-$(BOARD)/bootloader.hex
|
2020-12-04 20:33:05 +01:00
|
|
|
$(PYTHON) tools/hex2c.py build-$(BOARD)/bootloader.hex > \
|
2020-04-26 20:21:28 +02:00
|
|
|
reloader/src/boards/$(BOARD)/bootloader.h
|
2020-12-04 20:33:05 +01:00
|
|
|
$(PYTHON) -m nordicsemi dfu genpkg \
|
2020-07-26 22:03:30 +02:00
|
|
|
--bootloader bootloader/_build-$(BOARD)_nrf52832//$(BOARD)_nrf52832_bootloader-*-nosd.hex \
|
|
|
|
--softdevice bootloader/lib/softdevice/s132_nrf52_6.1.1/s132_nrf52_6.1.1_softdevice.hex \
|
2020-08-02 13:12:37 +02:00
|
|
|
build-$(BOARD)/bootloader-daflasher.zip
|
2020-01-14 22:32:59 +01:00
|
|
|
|
2020-08-15 21:45:18 +02:00
|
|
|
reloader: bootloader build-$(BOARD_SAFE)
|
2020-05-09 15:09:28 +02:00
|
|
|
$(MAKE) -C reloader/ BOARD=$(BOARD)
|
2020-11-07 10:30:15 +01:00
|
|
|
cp reloader/build-$(BOARD)/reloader*.zip build-$(BOARD)
|
2020-05-09 15:09:28 +02:00
|
|
|
|
2020-01-20 09:07:35 +01:00
|
|
|
softdevice:
|
|
|
|
micropython/ports/nrf/drivers/bluetooth/download_ble_stack.sh
|
|
|
|
|
2020-08-15 21:45:18 +02:00
|
|
|
wasp/boards/$(BOARD_SAFE)/watch.py : wasp/boards/$(BOARD_SAFE)/watch.py.in
|
|
|
|
(cd wasp; ../tools/preprocess.py boards/$(BOARD)/watch.py.in > boards/$(BOARD)/watch.py) \
|
|
|
|
|| ($(RM) wasp/boards/$(BOARD)/watch.py; false)
|
|
|
|
|
2021-12-31 18:39:50 +01:00
|
|
|
micropython/mpy-cross/mpy-cross:
|
2020-01-20 09:05:31 +01:00
|
|
|
$(MAKE) -C micropython/mpy-cross
|
2021-12-31 18:39:50 +01:00
|
|
|
|
|
|
|
micropython: build-$(BOARD_SAFE) wasp/boards/$(BOARD_SAFE)/watch.py micropython/mpy-cross/mpy-cross
|
2020-01-30 22:45:35 +01:00
|
|
|
$(RM) micropython/ports/nrf/build-$(BOARD)-s132/frozen_content.c
|
2020-01-21 23:10:50 +01:00
|
|
|
$(MAKE) -C micropython/ports/nrf \
|
|
|
|
BOARD=$(BOARD) SD=s132 \
|
2020-02-09 20:47:57 +01:00
|
|
|
MICROPY_VFS_LFS2=1 \
|
2020-06-09 22:29:00 +02:00
|
|
|
FROZEN_MANIFEST=$(PWD)/wasp/boards/$(BOARD)/manifest.py \
|
|
|
|
USER_C_MODULES=$(PWD)/wasp/modules
|
2020-12-04 20:33:05 +01:00
|
|
|
$(PYTHON) -m nordicsemi dfu genpkg \
|
2020-01-14 22:32:59 +01:00
|
|
|
--dev-type 0x0052 \
|
2020-01-20 09:05:31 +01:00
|
|
|
--application micropython/ports/nrf/build-$(BOARD)-s132/firmware.hex \
|
2020-08-02 13:12:37 +02:00
|
|
|
build-$(BOARD)/micropython.zip
|
|
|
|
|
2020-08-15 21:45:18 +02:00
|
|
|
build-$(BOARD_SAFE):
|
|
|
|
mkdir -p build-$(BOARD)
|
2020-01-20 09:07:35 +01:00
|
|
|
|
2020-01-14 22:32:59 +01:00
|
|
|
dfu:
|
2020-12-04 20:33:05 +01:00
|
|
|
$(PYTHON) -m nordicsemi dfu serial --package micropython.zip --port /dev/ttyACM0
|
2020-01-14 22:32:59 +01:00
|
|
|
|
|
|
|
flash:
|
2020-05-09 15:07:32 +02:00
|
|
|
pyocd erase -t nrf52 --mass
|
2020-01-20 09:08:22 +01:00
|
|
|
pyocd flash -t nrf52 bootloader.hex
|
2020-01-14 22:32:59 +01:00
|
|
|
|
2020-01-28 22:25:17 +01:00
|
|
|
debug:
|
|
|
|
arm-none-eabi-gdb \
|
|
|
|
bootloader/_build-$(BOARD)_nrf52832/$(BOARD)_nrf52832_bootloader-*-nosd.out \
|
|
|
|
-ex "target extended-remote /dev/ttyACM0" \
|
|
|
|
-ex "monitor swdp_scan" \
|
|
|
|
-ex "attach 1" \
|
|
|
|
-ex "load"
|
|
|
|
|
2021-12-31 18:39:50 +01:00
|
|
|
apps/%.mpy: apps/%.py micropython/mpy-cross/mpy-cross
|
|
|
|
./micropython/mpy-cross/mpy-cross -mno-unicode -march=armv7m $<
|
|
|
|
APPS_PY=$(wildcard apps/*.py)
|
|
|
|
APPS_MPY=$(APPS_PY:%.py=%.mpy)
|
|
|
|
.PHONY: apps
|
|
|
|
apps: $(APPS_MPY)
|
|
|
|
|
2020-02-22 22:17:30 +01:00
|
|
|
docs:
|
2020-02-24 09:51:25 +01:00
|
|
|
$(RM) -rf docs/build/html/*
|
2020-02-22 22:17:30 +01:00
|
|
|
$(MAKE) -C docs html
|
2020-02-24 09:51:25 +01:00
|
|
|
touch docs/build/html/.nojekyll
|
2020-02-22 22:17:30 +01:00
|
|
|
|
2020-01-31 20:36:55 +01:00
|
|
|
sim:
|
2020-05-10 15:10:04 +02:00
|
|
|
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=.:wasp/boards/simulator:wasp \
|
2020-12-04 20:33:05 +01:00
|
|
|
$(PYTHON) -i wasp/boards/simulator/main.py
|
|
|
|
|
2020-12-04 21:31:14 +01:00
|
|
|
ifeq ("$(origin K)", "command line")
|
|
|
|
PYTEST_RESTRICT = -k '$(K)'
|
|
|
|
endif
|
|
|
|
|
2020-12-04 20:33:05 +01:00
|
|
|
check:
|
|
|
|
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=.:wasp/boards/simulator:wasp \
|
2020-12-04 21:31:14 +01:00
|
|
|
$(PYTEST) -v -W ignore $(PYTEST_RESTRICT) wasp/boards/simulator
|
2020-12-04 20:33:05 +01:00
|
|
|
|
2020-01-31 20:36:55 +01:00
|
|
|
|
2020-05-09 15:09:28 +02:00
|
|
|
.PHONY: bootloader reloader docs micropython
|
2020-01-14 22:32:59 +01:00
|
|
|
|
2020-08-21 22:11:26 +02:00
|
|
|
dist: DIST=../wasp-os-$(VERSION)
|
|
|
|
dist: k9
|
|
|
|
k9: p8
|
|
|
|
p8: pinetime
|
2020-08-21 22:24:42 +02:00
|
|
|
pinetime : mrproper
|
|
|
|
mrproper :
|
|
|
|
$(RM) -r \
|
|
|
|
$(DIST) build-* \
|
|
|
|
bootloader/_build-* \
|
|
|
|
reloader/build-* \
|
|
|
|
reloader/src/boards/*/bootloader.h \
|
|
|
|
micropython/mpy-cross/build \
|
|
|
|
micropython/ports/nrf/build-*
|
2020-08-21 22:11:26 +02:00
|
|
|
k9 p8 pinetime:
|
2020-08-21 22:24:42 +02:00
|
|
|
$(RM) wasp/boards/$@/watch.py
|
2020-08-21 22:11:26 +02:00
|
|
|
$(MAKE) BOARD=$@ all
|
|
|
|
dist: docs
|
|
|
|
mkdir -p $(DIST)/docs
|
|
|
|
cp COPYING COPYING.LGPL README.rst $(DIST)
|
|
|
|
cp -r docs/build/html/* $(DIST)/docs
|
2020-08-21 22:24:42 +02:00
|
|
|
cp -r build-*/ $(DIST)
|
2020-08-21 22:11:26 +02:00
|
|
|
cp -r tools/ $(DIST)
|
|
|
|
(cd $(DIST); ln -s docs/_images/ res)
|
|
|
|
find $(DIST) -name __pycache__ | xargs $(RM) -r
|
|
|
|
tar -C .. -zcf $(DIST).tar.gz $(notdir $(DIST))
|
2021-06-03 20:56:28 +02:00
|
|
|
(cd ..; zip -9r $(DIST).zip $(notdir $(DIST)))
|