-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
97 lines (71 loc) · 2 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
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
91
92
93
94
95
96
97
PORT ?= /dev/ttyUSB0
BUILDDIR ?= build
IDF_PATH ?= $(shell pwd)/esp-idf
IDF_BRANCH ?= master
IDF_EXPORT_QUIET ?= 0
SHELL := /usr/bin/env bash
# General targets
.PHONY: all
all: build flash
.PHONY: install
install: flash
# Preparation
.PHONY: prepare
prepare: submodules sdk
.PHONY: submodules
submodules:
git submodule update --init --recursive
.PHONY: sdk
sdk:
rm -rf "$(IDF_PATH)"
git clone --recursive --branch "$(IDF_BRANCH)" https://github.com/espressif/esp-idf.git
cd "$(IDF_PATH)"; bash install.sh all
source "$(IDF_PATH)/export.sh" && idf.py --preview set-target esp32c6
.PHONY: menuconfig
menuconfig:
source "$(IDF_PATH)/export.sh" && idf.py menuconfig
# Cleaning
.PHONY: clean
clean:
rm -rf "$(BUILDDIR)"
.PHONY: fullclean
fullclean:
source "$(IDF_PATH)/export.sh" && idf.py fullclean
# Building
.PHONY: build
build:
source "$(IDF_PATH)/export.sh" && idf.py build
.PHONY: image
image:
cd "$(BUILDDIR)"; dd if=/dev/zero bs=1M count=16 of=flash.bin
cd "$(BUILDDIR)"; dd if=bootloader/bootloader.bin bs=1 seek=4096 of=flash.bin conv=notrunc
cd "$(BUILDDIR)"; dd if=partition_table/partition-table.bin bs=1 seek=36864 of=flash.bin conv=notrunc
cd "$(BUILDDIR)"; dd if=main.bin bs=1 seek=65536 of=flash.bin conv=notrunc
# Hardware
.PHONY: flash
flash: build
source "$(IDF_PATH)/export.sh" && idf.py flash -p $(PORT)
.PHONY: erase
erase:
source "$(IDF_PATH)/export.sh" && idf.py erase-flash -p $(PORT)
.PHONY: monitor
monitor:
source "$(IDF_PATH)/export.sh" && idf.py monitor -p $(PORT)
# Emulation
.PHONY: qemu
qemu: image
cd "$(BUILDDIR)"; qemu-system-xtensa -nographic -machine esp32 -drive 'file=flash.bin,if=mtd,format=raw'
# Tools
.PHONY: size
size:
source "$(IDF_PATH)/export.sh" && idf.py size
.PHONY: size-components
size-components:
source "$(IDF_PATH)/export.sh" && idf.py size-components
.PHONY: size-files
size-files:
source "$(IDF_PATH)/export.sh" && idf.py size-files
# Formatting
.PHONY: format
format:
find main/ -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' | xargs clang-format -i