forked from esper-hub/esper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Device.mk
127 lines (89 loc) · 3 KB
/
Device.mk
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Load configuration
ifndef CONFIG
include $(SITEDIR)/Configuration.mk
else
include $(SITEDIR)/Configuration.mk.$(CONFIG)
endif
# Sanity checking some required variables
ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Configuration.mk or set in environment.)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Configuration.mk or set in environment.)
endif
# Add required modules
MODULES += $(BASEDIR)/framework/devices
MODULES += $(BASEDIR)/framework/features
MODULES += $(BASEDIR)/framework/managers
MODULES += $(BASEDIR)/framework/services
MODULES += $(BASEDIR)/framework/util
MODULES += $(BASEDIR)/framework
# Add device module either from site or from esper
ifneq ($(wildcard $(SITEDIR)/devices/$(DEVICE)), )
MODULES += $(SITEDIR)/devices/$(DEVICE)
else
MODULES += $(BASEDIR)/devices/$(DEVICE)
endif
# Ensure we have a version string
VERSION ?= ""
ifeq ($(VERSION), "")
VERSION := $(shell date +%s)
ifeq ($(shell git -C $(SITEDIR) rev-parse --is-inside-work-tree), true)
VERSION := $(VERSION)-$(shell git -C $(SITEDIR) describe --always)
endif
$(warning VERSION is not set. Please ensure to set a version for productive builds. Using '$(VERSION)')
endif
# Load the device overrides
-include $(SITEDIR)/devices/$(DEVICE)/Device.mk
# Define config defaults
LOGGING ?= true
LOGGING_DEBUG ?= false
HEARTBEAT_ENABLED ?= false
HEARTBEAT_TOPIC ?= $(MQTT_REALM)/heartbeat
UPDATE_ENABLED ?= false
UPDATE_URL ?= $(MQTT_HOST):80/firmware
UPDATE_INTERVAL ?= 3600
UPDATE_DELAY ?= 300
UPDATE_TOPIC ?= $(MQTT_REALM)/update
INFO_HTTP_ENABLED ?= false
INFO_HTTP_PORT ?= 80
# Pass options to source code
USER_CFLAGS += -DDEVICE=\"$(DEVICE)\"
USER_CFLAGS += -DVERSION=\"$(VERSION)\"
USER_CFLAGS += -DLOGGING=$(LOGGING)
USER_CFLAGS += -DLOGGING_DEBUG=$(LOGGING_DEBUG)
USER_CFLAGS += -DMQTT_HOST=\"$(MQTT_HOST)\"
USER_CFLAGS += -DMQTT_PORT=$(MQTT_PORT)
USER_CFLAGS += -DMQTT_REALM=\"$(MQTT_REALM)\"
USER_CFLAGS += -DMQTT_USERNAME=\"$(MQTT_USERNAME)\"
USER_CFLAGS += -DMQTT_PASSWORD=\"$(MQTT_PASSWORD)\"
USER_CFLAGS += -DHEARTBEAT_ENABLED=$(HEARTBEAT_ENABLED)
USER_CFLAGS += -DHEARTBEAT_TOPIC=\"$(HEARTBEAT_TOPIC)\"
USER_CFLAGS += -DUPDATE_ENABLED=$(UPDATE_ENABLED)
USER_CFLAGS += -DUPDATE_URL=\"$(UPDATE_URL)\"
USER_CFLAGS += -DUPDATE_INTERVAL=$(UPDATE_INTERVAL)
USER_CFLAGS += -DUPDATE_DELAY=$(UPDATE_DELAY)
USER_CFLAGS += -DUPDATE_TOPIC=\"$(UPDATE_TOPIC)\"
USER_CFLAGS += -DINFO_HTTP_ENABLED=$(INFO_HTTP_ENABLED)
USER_CFLAGS += -DINFO_HTTP_PORT=$(INFO_HTTP_PORT)
# Use Release
SMING_RELEASE = 1
# Disable SPIFFS
DISABLE_SPIFFS = 1
# Use alternative bootloader
RBOOT_ENABLED = 1
RBOOT_BIG_FLASH = 0
RBOOT_TWO_ROMS = 1
RBOOT_RTC_ENABLED = 0
RBOOT_LD_0 = $(BASEDIR)/rom0.ld
RBOOT_LD_1 = $(BASEDIR)/rom1.ld
# For ESP01 - enhanced version
SPI_SIZE = 1M
# Work-around for encoding errors in terminal during ESP boot
COM_OPTS += --raw
# Include main makefile
include $(SMING_HOME)/Makefile-rboot.mk
# Write the manifest
all: $(FW_BASE)/version
$(FW_BASE)/version:
echo -n "$(VERSION)" > $(FW_BASE)/version