-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
55 lines (37 loc) · 1.71 KB
/
Makefile
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
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
# --- 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
clean:
@rm -rf build
build:
@mkdir -p build
tinygo build $(LD_FLAGS) -target=$(TARGET) -size=$(SIZE) -opt=z -print-allocs=main -o ./build/$(FILE) ./src
flash:
tinygo flash $(LD_FLAGS) -target=$(TARGET) -size=$(SIZE) -opt=z -print-allocs=main ./src
monitor:
tinygo monitor -target=$(TARGET)
# --- 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) -size=$(SIZE) -opt=$(DEBUG_OPT) -o ./build/debug.elf $(SRC)
debug: build-for-debug
tinygo gdb -target=$(TARGET) -size=$(SIZE) -opt=$(DEBUG_OPT) -ocd-output -programmer=jlink $(SRC)
debug-dap: build-for-debug
tinygo gdb -target=$(TARGET) -size=$(SIZE) -opt=$(DEBUG_OPT) -ocd-output -programmer=cmsis-dap $(SRC)