-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (60 loc) · 2.72 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
ifeq ($(origin IDF_PATH),undefined)
$(error You must "source ./lib/esp-idf/export.sh" before building)
endif
SHELL := /usr/bin/env bash
COPROC_RESERVE_MEM ?= 8176
CROSS := riscv32-esp-elf-
CC := $(CROSS)gcc
STRIP := $(CROSS)strip
CFLAGS := -mabi=ilp32 -mcmodel=medlow -march=rv32imc -Os -ggdb3 -nostdlib -ffunction-sections
CFLAGS += -isystem $(IDF_PATH)/components/esp_common/include
CFLAGS += -isystem $(IDF_PATH)/components/esp_hw_support/include
CFLAGS += -isystem $(IDF_PATH)/components/esp_rom/include
CFLAGS += -isystem $(IDF_PATH)/components/hal/include
CFLAGS += -isystem $(IDF_PATH)/components/hal/esp32s2/include
CFLAGS += -isystem $(IDF_PATH)/components/hal/platform_port/include
CFLAGS += -isystem $(IDF_PATH)/components/log/include
CFLAGS += -isystem $(IDF_PATH)/components/soc/include
CFLAGS += -isystem $(IDF_PATH)/components/soc/esp32s2/include
CFLAGS += -isystem $(IDF_PATH)/components/ulp/ulp_common/include
CFLAGS += -isystem $(IDF_PATH)/components/ulp/ulp_common/include/esp32s2
CFLAGS += -isystem $(IDF_PATH)/components/ulp/ulp_riscv/include
CFLAGS += -isystem $(IDF_PATH)/components/ulp/ulp_riscv/include/esp32s2
CFLAGS += -isystem $(IDF_PATH)/components/ulp/ulp_riscv/ulp_core/include
CFLAGS += -isystem ulp/include
CFLAGS += -DCOPROC_RESERVE_MEM=$(COPROC_RESERVE_MEM)
CFLAGS += -DCONFIG_IDF_TARGET_ESP32S2
ifeq ($(DEBUG),1)
CFLAGS += -DDEBUG
endif
LDFLAGS := -Wl,-A,elf32-esp32s2ulp -nostdlib --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections
LDFLAGS += -Wl,-T,build/ulp.ld
SRCS ?= ulp/main.c
SRCS += $(IDF_PATH)/components/ulp/ulp_common/ulp_common.c
SRCS += $(IDF_PATH)/components/ulp/ulp_riscv/ulp_core/ulp_riscv_adc.c
SRCS += $(IDF_PATH)/components/ulp/ulp_riscv/ulp_core/ulp_riscv_utils.c
SRCS += $(IDF_PATH)/components/ulp/ulp_riscv/ulp_core/start.S
.PHONY: flash-all
flash-all: circuitpy/lib /Volumes/CIRCUITPY
rsync -avhP --exclude secrets.py.example --delete circuitpy/ /Volumes/CIRCUITPY
.PHONY: flash
flash: circuitpy/ulp.py /Volumes/CIRCUITPY
rsync -avhP --exclude secrets.py.example --exclude calibration.json --exclude lib --exclude font --delete circuitpy/ /Volumes/CIRCUITPY
.PHONY: flash-git-diff
flash-git-diff: circuitpy/ulp.py /Volumes/CIRCUITPY
rsync -avhP --exclude secrets.py.example --exclude lib --exclude font --delete --files-from=<(git diff --name-only circuitpy/) ./ /Volumes/CIRCUITPY
build:
mkdir -p build
build/ulp: build/ulp-debug build
$(STRIP) -g -o $@ $<
build/ulp-debug: $(SRCS) build/ulp.ld build
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS)
build/ulp.ld: ulp/link.ld build
$(CC) -E -P -xc $(CFLAGS) -o $@ $<
.PHONY: clean
clean:
rm -f build/* circuitpy/ulp.py
circuitpy/ulp.py: build/ulp templates/ulp.py.j2
python ./support/ulp_builder.py
/Volumes/CIRCUITPY:
test -d /Volumes/CIRCUITPY