forked from cnlohr/esp82xx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.mf
197 lines (153 loc) · 6.88 KB
/
main.mf
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
define USAGE
Usage: make [command] [VARIABLES]
all......... Build the binaries
debug....... Build a .map and .lst file. Useful for seeing what's going on
behind the scenes.
burn ....... Write firmware to chip using a regular serial port
burnweb .... Write data for the Web-GUI to chip using a regular serial
port
netburn .... Same as 'burn' but transfer firmware over the network rather
than the serial port (if supported by the existing firmware
on the chip)
netweb ..... Same as 'burnweb' but transfer data over network if supported
by firmware currently on the chip
getips ..... Get a list with IPs of esp82xxs connected to your network
project .... Make the current working direcotry an esp82xx project
gitproject . Same as 'make project' but also initialiezes the current folder
as git repository and pushes it to GIT_ORIGIN.
Example:
make gitproject GIT_ORIGIN=https://github.com/USER/YREPO.git
usbburn .... Burn via PRE-RELEASE USB loader (will probably change)
usbweb ..... Burn webpage by PRE-RELEASE USB loader (will probably change)
initdefault Burn default initial data to ROM (may be needed after erase)
init3v3 .... Burn default values to rom but for use with system_get_vdd33
erase ...... Totally erase chip.
More commands: all, clean, purge, dumprom, cleanproject
endef
.PHONY : all clean purge netburn burnweb burn $(BIN_TARGET) netweb getips help project gitproject cleanproject
FW_FILE1 = image.elf-0x00000.bin
FW_FILE2 = image.elf-0x40000.bin
TARGET = image.elf
SRCS += esp82xx/fwsrc/uart.c \
esp82xx/fwsrc/esp82xxutil.c \
esp82xx/fwsrc/flash_rewriter.c \
esp82xx/fwsrc/http.c \
esp82xx/fwsrc/commonservices.c \
esp82xx/fwsrc/http_custom.c \
esp82xx/fwsrc/mdns.c \
esp82xx/fwsrc/mfs.c \
user/custom_commands.c \
user/user_main.c
LIBS += main lwip ssl upgrade net80211 wpa phy lwip crypto
ifneq ($(CUSTOMPP), 1)
LIBS += pp
endif
INCL = $(SDK)/include esp82xx/include .
CFLAGS = -mlongcalls -Os $(addprefix -I,$(INCL) $(call uniq, $(patsubst %/,%,$(dir $(SRCS))))) $(OPTS) -DVERSSTR='$(VERSSTR)'
LDFLAGS_CORE = -Wl,--relax -Wl,--gc-sections -nostdlib -L$(XTLIB) \
-L$(XTGCCLIB) $(addprefix $(SDK)/lib/lib,$(addsuffix .a,$(LIBS))) \
$(XTGCCLIB) -T $(LINKERSCRIPT) -T $(SDK)/ld/eagle.rom.addr.v6.ld
# -flto -Wl,--relax -Wl,--gc-sections
LINKFLAGS = $(LDFLAGS_CORE) -B$(XTLIB) $(LDFLAGS_POST)
BIN_TARGET = $(PROJECT_NAME)-$(VERSION)-binaries.zip
ifneq (,$(findstring -DDEBUG,$(OPTS)))
$(warning Debug is enabled!)
FLASH_WRITE_FLAGS += --verify
endif
ifeq ($(SDK),$(PWD)/esp82xx/toolchain/esp_nonos_sdk)
SDK_DEP := esp82xx/toolchain/esp_nonos_sdk/Makefile
endif
##########################################################################RULES
help :
$(info $(value USAGE))
@true
all : $(FW_FILE1) $(FW_FILE2)
$(FW_FILE1) $(FW_FILE2) : $(TARGET)
PATH=$(PATH):$(FOLDERPREFIX) $(ESPTOOL_PY) elf2image $(TARGET)
@#no need to set things like dout, and memory size. This data is copied from the ESP back to itself on write.
$(TARGET) : $(SRCS) Makefile $(SDK_DEP)
$(CC) $(CFLAGS) $(SRCS) -flto $(LINKFLAGS) -o $@
debug : $(TARGET)
nm -S -n $(TARGET) > image.map
$(PREFIX)objdump -S $(TARGET) > image.lst
$(PREFIX)size -A $(TARGET) | grep -v debug
ifeq ($(CHIP), 8285)
burn : $(FW_FILE1) $(FW_FILE2)
$(info NOTICE: Currently burning for ESP8285. If you are on a '66 reconfigure CHIP.)
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(FLASH_WRITE_FLAGS) -fs 8m -fm dout 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
else ifeq ($(CHIP), 8266)
burn : $(FW_FILE1) $(FW_FILE2)
$(info NOTICE: Currently burning for ESP8266. If you are on an '85 reconfigure CHIP.)
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash -fm dio $(FLASH_WRITE_FLAGS) 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
else
$(error Error: Unknown chip '$(CHIP)')
endif
burnweb :
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) clean page.mpfs #Always rebuild page.mpfs
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(PAGE_OFFSET) web/page.mpfs)||(true)
#If you have space, MFS should live at 0x100000. It can also live at
#0x10000. But, then it is limited to 180kB. You might need to do this if
# you have a 512kB, or 1M ESP variant.
netburn : $(FW_FILE1) $(FW_FILE2)
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) execute_reflash
web/execute_reflash $(IP) $(FW_FILE1) $(FW_FILE2)
netweb :
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) push
usbburn : $(FW_FILE1) $(FW_FILE2)
web/execute_reflash USB $(FW_FILE1) $(FW_FILE2)
usbweb : $(FW_FILE1) $(FW_FILE2)
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) usbpush
$(BIN_TARGET): $(FW_FILE1) $(FW_FILE2)
@cd web \
&& $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) page.mpfs \
&& $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) execute_reflash \
&& $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) pushtodev \
&& cd ..
zip $@ $(FW_FILE1) $(FW_FILE2) web/execute_reflash web/mfsmaker web/pushtodev web/page.mpfs
wipechip :
dd if=/dev/zero of=/tmp/zeroes bs=1M count=1
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash 0x0 /tmp/zeroes)||(true)
getips :
$(info Detecting possible IPs for ESP82XX modules...)
$(info Needs 'nmap' and takes some time especiallay if none are connected)
sudo nmap -sP 192.168.0.0/24 | grep -iP "espressif|esp" -B2 | grep -oP "(\d{1,3}\.){3,3}\d\d{1,3}"
clean :
$(RM) $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SRCS))) $(TARGET) image.map image.lst $(CLEAN_EXTRA)
dumprom :
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) read_flash 0 1048576 dump.bin)||(true)
initdefault :
$(ESPTOOL_PY) $(BURNFLAGS) --port $(PORT) write_flash 0x3FC000 esp82xx/data/esp_init_data_default.bin
init3v3 :
$(ESPTOOL_PY) $(BURNFLAGS) --port $(PORT) write_flash 0x3FC000 esp82xx/data/esp_init_data_adc33.bin
erase:
$(ESPTOOL_PY) $(BURNFLAGS) --port $(PORT) erase_flash
purge : clean
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) clean
$(RM) $(FW_FILE1) $(FW_FILE2) $(BIN_TARGET)
bump_submodule :
cd esp82xx; git pull origin master; git submodule update --init --recursive; cd ..
Makefile : esp82xx/Makefile.example
user.cfg : esp82xx/user.cfg.example
web/page/index.html : esp82xx/web/page/index.html
web/page/example.js : esp82xx/web/page/example.js
Makefile user.cfg web/page/index.html web/page/example.js :
mkdir -p web/page user; \
cp -n $< $@; \
touch $@
project : Makefile user.cfg web/page/index.html web/page/example.js
ln -s $(patsubst %,../../%,$(wildcard esp82xx/web/page/jquery-*)) ../../esp82xx/web/page/menuinterface.js web/page/ 2>/dev/null; \
ln -s $(patsubst %,../%,$(wildcard esp82xx/web/*)) web/ 2>/dev/null; \
cp -rn esp82xx/fwsrc/user/ .;
ifeq ($(SDK),$(PWD)/esp82xx/toolchain/esp_nonos_sdk)
$(SDK_DEP) :
@echo "Warning: SDK is missing, trying to get it from github:" >&2
@cd esp82xx && git submodule update --init --recursive
endif
gitproject: project
git init .
git add .
git remote add origin $(GIT_ORIGIN)
git commit -m 'Initial commit'
git push
cleanproject :
$(RM) -r use* web/