-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (64 loc) · 2.93 KB
/
Makefile
File metadata and controls
90 lines (64 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
SIZE ?= full
TARGET ?= xiao-ble
ifneq ($(TARGET),nano-33-ble-s140v6-uf2)
FILE = ht_$(TARGET)_$(VERSION).uf2
else
FILE = ht_nano-33-ble_$(VERSION).uf2
endif
.PHONY: clean build flash monitor
# --- Go maintenance targets ---
bump-deps:
go get -u github.com/go-gl/mathgl@latest
go get -u github.com/tracktum/go-ahrs@latest
go get -u tinygo.org/x/bluetooth@latest
go get -u tinygo.org/x/drivers@latest
go get -u tinygo.org/x/tinydraw@latest
go get -u tinygo.org/x/tinyfont@latest
go mod tidy
llvm:
brew install llvm@20
brew install lld@20
brew link --force --overwrite llvm@20
brew link --force --overwrite lld@20
# --- Common targets ---
VERSION ?= $(shell git describe --tags)
LD_FLAGS := -ldflags="-X 'main.Version=$(VERSION)'" # https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications
EXTRA_TAGS = nogopls # to include all source files, even those excluded for gopls
clean:
@rm -rf build
@rm -rf softdevice
softdevice:
@mkdir -p softdevice
gopath=$$(tinygo env | grep GOPATH | sed 's/GOPATH="\(.*\)"/\1/'); \
bluetooth_ver=$$(cat go.mod | grep "bluetooth v"| sed "s/.* //"); \
ln -s $$gopath/pkg/mod/tinygo.org/x/bluetooth@$$bluetooth_ver/s140_nrf52_6.1.1 ./softdevice/; \
ln -s $$gopath/pkg/mod/tinygo.org/x/bluetooth@$$bluetooth_ver/s140_nrf52_7.3.0 ./softdevice/
build: softdevice
@mkdir -p build
tinygo build $(LD_FLAGS) -tags=$(EXTRA_TAGS) -target=$(TARGET) -size=$(SIZE) -opt=z -print-allocs=HeadTracker -o ./build/$(FILE) ./src
flash: softdevice
tinygo flash $(LD_FLAGS) -tags=$(EXTRA_TAGS) -target=$(TARGET) -size=$(SIZE) -opt=z -print-allocs=HeadTracker ./src
monitor:
tinygo monitor -target=$(TARGET) -port=/dev/tty.usbmodem1101
# --- Arduino Nano 33 BLE bootloader targets ---
UF2_BOOTLOADER_HEX=./build/arduino_nano_33_ble_bootloader-0.7.0_s140_6.1.1.hex
$(UF2_BOOTLOADER_HEX):
@curl -L -o $(UF2_BOOTLOADER_HEX) https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/0.7.0/arduino_nano_33_ble_bootloader-0.7.0_s140_6.1.1.hex
flash-uf2-bootloader: $(UF2_BOOTLOADER_HEX)
nrfjprog -f nrf52 --eraseall
nrfjprog -f nrf52 --program $(UF2_BOOTLOADER_HEX)
flash-uf2-bootloader-dap: $(UF2_BOOTLOADER_HEX)
openocd -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "transport select swd" -c "program $(UF2_BOOTLOADER_HEX) verify reset exit"
# --- Debug targets ---
DEBUG_OPT=1
build-for-debug:
tinygo build -target=$(TARGET) -tags=$(EXTRA_TAGS) -size=$(SIZE) -opt=$(DEBUG_OPT) -o ./build/debug.elf $(SRC)
debug: build-for-debug
tinygo gdb -target=$(TARGET) -tags=$(EXTRA_TAGS) -size=$(SIZE) -opt=$(DEBUG_OPT) -ocd-output -programmer=jlink $(SRC)
debug-dap: build-for-debug
tinygo gdb -target=$(TARGET) -tags=$(EXTRA_TAGS) -size=$(SIZE) -opt=$(DEBUG_OPT) -ocd-output -programmer=cmsis-dap $(SRC)
# --- Test targets ---
test-flash:
tinygo flash -target=xiao-ble -opt=z -port=/dev/tty.usbmodem101 ./test
test-monitor:
tinygo monitor -target=xiao-ble -port=/dev/tty.usbmodem101