Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (56 loc) · 2.24 KB
/
Copy pathMakefile
File metadata and controls
67 lines (56 loc) · 2.24 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
# Release helper for Cardputer-Keyboard-Mouse.
#
# Produces the two distribution artifacts in release/:
#
# Cardputer-Keyboard-Mouse-full.bin - merged image (bootloader + partition
# table + boot_app0 + app), flash at
# offset 0x0. For M5Burner / esptool users.
# Cardputer-Keyboard-Mouse-app.bin - app-only image. For M5Launcher
# (https://bmorcelli.github.io/Launcher/),
# which installs it into its own partition
# table without touching its bootloader.
#
# Requires PlatformIO (the pio CLI, or the default ~/.platformio install).
PROJECT := Cardputer-Keyboard-Mouse
ENV := cardputer-adv
BUILD_DIR := .pio/build/$(ENV)
RELEASE_DIR := release
PIO ?= $(shell command -v pio 2>/dev/null || echo $(HOME)/.platformio/penv/bin/pio)
ESPTOOL ?= $(HOME)/.platformio/penv/bin/python -m esptool
BOOT_APP0 := $(HOME)/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin
FULL_BIN := $(RELEASE_DIR)/$(PROJECT)-full.bin
APP_BIN := $(RELEASE_DIR)/$(PROJECT)-app.bin
.PHONY: all build release test flash clean help
all: release
# pio owns incremental builds; delegate unconditionally.
build:
@test -x "$(PIO)" || { \
echo "error: pio not found - install PlatformIO first"; \
exit 1; }
$(PIO) run -e $(ENV)
release: build
mkdir -p $(RELEASE_DIR)
$(ESPTOOL) --chip esp32s3 merge-bin -o $(FULL_BIN) \
0x0 $(BUILD_DIR)/bootloader.bin \
0x8000 $(BUILD_DIR)/partitions.bin \
0xe000 $(BOOT_APP0) \
0x10000 $(BUILD_DIR)/firmware.bin
cp $(BUILD_DIR)/firmware.bin $(APP_BIN)
@echo
@echo "Release artifacts:"
@ls -la $(RELEASE_DIR)
@echo
@echo " $(FULL_BIN): flash at 0x0 (M5Burner / esptool)"
@echo " $(APP_BIN): app-only (M5Launcher)"
test:
$(PIO) test -e native
flash: build
$(PIO) run -e $(ENV) -t upload
clean:
$(PIO) run -t clean
rm -rf $(RELEASE_DIR)
help:
@echo "make release - build + produce full and app-only bins in $(RELEASE_DIR)/"
@echo "make test - run the native unit tests"
@echo "make flash - build + upload over USB"
@echo "make clean - clean the PlatformIO build + remove $(RELEASE_DIR)/"