1
- # tnx to mamalala
2
- # Changelog
3
- # Changed the variables to include the header file directory
4
- # Added global var for the XTENSA tool root
1
+ # Makefile for ESP8266 projects
5
2
#
6
- # This make file still needs some work.
7
- #
8
- # Updated for SDK 0.9.3
3
+ # Thanks to:
4
+ # - zarya
5
+ # - Jeroen Domburg (Sprite_tm)
6
+ # - Christian Klippel (mamalala)
7
+ # - Tommie Gannert (tommie)
9
8
#
9
+ # Changelog:
10
+ # - 2014-10-06: Changed the variables to include the header file directory
11
+ # - 2014-10-06: Added global var for the Xtensa tool root
12
+ # - 2014-11-23: Updated for SDK 0.9.3
13
+ # - 2014-12-25: Replaced esptool by esptool.py
14
+
10
15
# Output directors to store intermediate compiled files
11
16
# relative to the project directory
12
17
BUILD_BASE = build
13
18
FW_BASE = firmware
14
19
15
- # Base directory for the compiler
20
+ # base directory for the compiler
16
21
XTENSA_TOOLS_ROOT ?= /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin
17
22
18
23
# base directory of the ESP8266 SDK package, absolute
19
24
SDK_BASE ?= /opt/Espressif/ESP8266_SDK
20
25
21
- # Esptool .py path and port
26
+ # esptool .py path and port
22
27
ESPTOOL ?= esptool.py
23
28
ESPPORT ?= /dev/ttyUSB0
24
29
@@ -27,7 +32,7 @@ TARGET = app
27
32
28
33
# which modules (subdirectories) of the project to include in compiling
29
34
MODULES = driver user
30
- EXTRA_INCDIR = include /opt/Espressif/include
35
+ EXTRA_INCDIR = include
31
36
32
37
# libraries used in this project, mainly provided by the SDK
33
38
LIBS = c gcc hal pp phy net80211 lwip wpa main
@@ -48,10 +53,8 @@ SDK_INCDIR = include include/json
48
53
49
54
# we create two different files for uploading into the flash
50
55
# these are the names and options to generate them
51
- FW_FILE_1 = 0x00000
52
- FW_FILE_1_ARGS = -bo $@ -bs .text -bs .data -bs .rodata -bc -ec
53
- FW_FILE_2 = 0x40000
54
- FW_FILE_2_ARGS = -es .irom0.text $@ -ec
56
+ FW_FILE_1_ADDR = 0x00000
57
+ FW_FILE_2_ADDR = 0x40000
55
58
56
59
# select which tools to use as compiler, librarian and linker
57
60
CC := $(XTENSA_TOOLS_ROOT ) /xtensa-lx106-elf-gcc
@@ -63,7 +66,6 @@ LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
63
66
# ###
64
67
# ### no user configurable options below here
65
68
# ###
66
- FW_TOOL ?= /usr/bin/esptool
67
69
SRC_DIR := $(MODULES )
68
70
BUILD_DIR := $(addprefix $(BUILD_BASE ) /,$(MODULES ) )
69
71
@@ -82,8 +84,8 @@ INCDIR := $(addprefix -I,$(SRC_DIR))
82
84
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR ) )
83
85
MODULE_INCDIR := $(addsuffix /include,$(INCDIR ) )
84
86
85
- FW_FILE_1 := $(addprefix $(FW_BASE ) /,$(FW_FILE_1 ) .bin)
86
- FW_FILE_2 := $(addprefix $(FW_BASE ) /,$(FW_FILE_2 ) .bin)
87
+ FW_FILE_1 := $(addprefix $(FW_BASE ) /,$(FW_FILE_1_ADDR ) .bin)
88
+ FW_FILE_2 := $(addprefix $(FW_BASE ) /,$(FW_FILE_2_ADDR ) .bin)
87
89
88
90
V ?= $(VERBOSE )
89
91
ifeq ("$(V ) ","1")
@@ -99,20 +101,16 @@ vpath %.c $(SRC_DIR)
99
101
define compile-objects
100
102
$1/%.o: %.c
101
103
$(vecho ) "CC $$< "
102
- $(Q ) $(CC ) $(INCDIR ) $(MODULE_INCDIR ) $(EXTRA_INCDIR ) $(SDK_INCDIR ) $(CFLAGS ) -c $$< -o $$@
104
+ $(Q ) $(CC ) $(INCDIR ) $(MODULE_INCDIR ) $(EXTRA_INCDIR ) $(SDK_INCDIR ) $(CFLAGS ) -c $$< -o $$@
103
105
endef
104
106
105
- .PHONY : all checkdirs clean
107
+ .PHONY : all checkdirs flash clean
106
108
107
109
all : checkdirs $(TARGET_OUT ) $(FW_FILE_1 ) $(FW_FILE_2 )
108
110
109
- $(FW_FILE_1 ) : $(TARGET_OUT )
110
- $(vecho ) " FW $@ "
111
- $(Q ) $(FW_TOOL ) -eo $(TARGET_OUT ) $(FW_FILE_1_ARGS )
112
-
113
- $(FW_FILE_2 ) : $(TARGET_OUT )
114
- $(vecho ) " FW $@ "
115
- $(Q ) $(FW_TOOL ) -eo $(TARGET_OUT ) $(FW_FILE_2_ARGS )
111
+ $(FW_BASE ) /% .bin : $(TARGET_OUT ) | $(FW_BASE )
112
+ $(vecho ) " FW $( FW_BASE) /"
113
+ $(Q ) $(ESPTOOL ) elf2image -o $(FW_BASE ) / $(TARGET_OUT )
116
114
117
115
$(TARGET_OUT ) : $(APP_AR )
118
116
$(vecho ) " LD $@ "
@@ -127,21 +125,13 @@ checkdirs: $(BUILD_DIR) $(FW_BASE)
127
125
$(BUILD_DIR ) :
128
126
$(Q ) mkdir -p $@
129
127
130
- firmware :
128
+ $( FW_BASE ) :
131
129
$(Q ) mkdir -p $@
132
130
133
- flash : firmware/0x00000.bin firmware/0x40000.bin
134
- - $(ESPTOOL ) --port $(ESPPORT ) write_flash 0x00000 firmware/0x00000.bin 0x40000 firmware/0x40000.bin
131
+ flash : $( FW_FILE_1 ) $( FW_FILE_2 )
132
+ $(ESPTOOL ) --port $(ESPPORT ) write_flash $( FW_FILE_1_ADDR ) $( FW_FILE_1 ) $( FW_FILE_2_ADDR ) $( FW_FILE_2 )
135
133
136
134
clean :
137
- $(Q ) rm -f $(APP_AR )
138
- $(Q ) rm -f $(TARGET_OUT )
139
- $(Q ) rm -rf $(BUILD_DIR )
140
- $(Q ) rm -rf $(BUILD_BASE )
141
-
142
-
143
- $(Q) rm -f $(FW_FILE_1)
144
- $(Q) rm -f $(FW_FILE_2)
145
- $(Q) rm -rf $(FW_BASE)
135
+ $(Q ) rm -rf $(FW_BASE ) $(BUILD_BASE )
146
136
147
137
$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
0 commit comments