Skip to content

Commit 2ed9b49

Browse files
committed
Merge pull request #4 from george-hopkins/replace-esptool
Proposal: Replace esptool by esptool.py
2 parents 69b1fcc + 43eaa85 commit 2ed9b49

File tree

3 files changed

+82
-110
lines changed

3 files changed

+82
-110
lines changed

basic_example/Makefile

+27-36
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
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
5-
#
6-
# This make file still needs some work.
1+
# Makefile for ESP8266 projects
72
#
3+
# Thanks to:
4+
# - zarya
5+
# - Jeroen Domburg (Sprite_tm)
6+
# - Christian Klippel (mamalala)
7+
# - Tommie Gannert (tommie)
88
#
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+
915
# Output directors to store intermediate compiled files
1016
# relative to the project directory
1117
BUILD_BASE = build
1218
FW_BASE = firmware
1319

14-
# Base directory for the compiler
20+
# base directory for the compiler
1521
XTENSA_TOOLS_ROOT ?= /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin
1622

1723
# base directory of the ESP8266 SDK package, absolute
1824
SDK_BASE ?= /opt/Espressif/ESP8266_SDK
1925

20-
#Esptool.py path and port
26+
# esptool.py path and port
2127
ESPTOOL ?= esptool.py
2228
ESPPORT ?= /dev/ttyUSB0
2329

@@ -26,7 +32,7 @@ TARGET = app
2632

2733
# which modules (subdirectories) of the project to include in compiling
2834
MODULES = driver user
29-
EXTRA_INCDIR = include /opt/Espressif/include
35+
EXTRA_INCDIR = include
3036

3137
# libraries used in this project, mainly provided by the SDK
3238
LIBS = c gcc hal pp phy net80211 lwip wpa main
@@ -47,10 +53,8 @@ SDK_INCDIR = include include/json
4753

4854
# we create two different files for uploading into the flash
4955
# these are the names and options to generate them
50-
FW_FILE_1 = 0x00000
51-
FW_FILE_1_ARGS = -bo $@ -bs .text -bs .data -bs .rodata -bc -ec
52-
FW_FILE_2 = 0x40000
53-
FW_FILE_2_ARGS = -es .irom0.text $@ -ec
56+
FW_FILE_1_ADDR = 0x00000
57+
FW_FILE_2_ADDR = 0x40000
5458

5559
# select which tools to use as compiler, librarian and linker
5660
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
@@ -62,7 +66,6 @@ LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
6266
####
6367
#### no user configurable options below here
6468
####
65-
FW_TOOL ?= /usr/bin/esptool
6669
SRC_DIR := $(MODULES)
6770
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))
6871

@@ -81,8 +84,8 @@ INCDIR := $(addprefix -I,$(SRC_DIR))
8184
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
8285
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
8386

84-
FW_FILE_1 := $(addprefix $(FW_BASE)/,$(FW_FILE_1).bin)
85-
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)
8689

8790
V ?= $(VERBOSE)
8891
ifeq ("$(V)","1")
@@ -98,20 +101,16 @@ vpath %.c $(SRC_DIR)
98101
define compile-objects
99102
$1/%.o: %.c
100103
$(vecho) "CC $$<"
101-
$(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 $$@
102105
endef
103106

104107
.PHONY: all checkdirs flash clean
105108

106109
all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)
107110

108-
$(FW_FILE_1): $(TARGET_OUT)
109-
$(vecho) "FW $@"
110-
$(Q) $(FW_TOOL) -eo $(TARGET_OUT) $(FW_FILE_1_ARGS)
111-
112-
$(FW_FILE_2): $(TARGET_OUT)
113-
$(vecho) "FW $@"
114-
$(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)
115114

116115
$(TARGET_OUT): $(APP_AR)
117116
$(vecho) "LD $@"
@@ -126,21 +125,13 @@ checkdirs: $(BUILD_DIR) $(FW_BASE)
126125
$(BUILD_DIR):
127126
$(Q) mkdir -p $@
128127

129-
firmware:
128+
$(FW_BASE):
130129
$(Q) mkdir -p $@
131130

132-
flash: firmware/0x00000.bin firmware/0x40000.bin
133-
-$(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)
134133

135134
clean:
136-
$(Q) rm -f $(APP_AR)
137-
$(Q) rm -f $(TARGET_OUT)
138-
$(Q) rm -rf $(BUILD_DIR)
139-
$(Q) rm -rf $(BUILD_BASE)
140-
141-
142-
$(Q) rm -f $(FW_FILE_1)
143-
$(Q) rm -f $(FW_FILE_2)
144-
$(Q) rm -rf $(FW_BASE)
135+
$(Q) rm -rf $(FW_BASE) $(BUILD_BASE)
145136

146137
$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))

blinky/Makefile

+27-36
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
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
5-
#
6-
# This make file still needs some work.
1+
# Makefile for ESP8266 projects
72
#
3+
# Thanks to:
4+
# - zarya
5+
# - Jeroen Domburg (Sprite_tm)
6+
# - Christian Klippel (mamalala)
7+
# - Tommie Gannert (tommie)
88
#
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+
915
# Output directors to store intermediate compiled files
1016
# relative to the project directory
1117
BUILD_BASE = build
1218
FW_BASE = firmware
1319

14-
# Base directory for the compiler
20+
# base directory for the compiler
1521
XTENSA_TOOLS_ROOT ?= /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin
1622

1723
# base directory of the ESP8266 SDK package, absolute
1824
SDK_BASE ?= /opt/Espressif/ESP8266_SDK
1925

20-
#Esptool.py path and port
26+
# esptool.py path and port
2127
ESPTOOL ?= esptool.py
2228
ESPPORT ?= /dev/ttyUSB0
2329

@@ -26,7 +32,7 @@ TARGET = app
2632

2733
# which modules (subdirectories) of the project to include in compiling
2834
MODULES = driver user
29-
EXTRA_INCDIR = include /opt/Espressif/include
35+
EXTRA_INCDIR = include
3036

3137
# libraries used in this project, mainly provided by the SDK
3238
LIBS = c gcc hal pp phy net80211 lwip wpa main
@@ -47,10 +53,8 @@ SDK_INCDIR = include include/json
4753

4854
# we create two different files for uploading into the flash
4955
# these are the names and options to generate them
50-
FW_FILE_1 = 0x00000
51-
FW_FILE_1_ARGS = -bo $@ -bs .text -bs .data -bs .rodata -bc -ec
52-
FW_FILE_2 = 0x40000
53-
FW_FILE_2_ARGS = -es .irom0.text $@ -ec
56+
FW_FILE_1_ADDR = 0x00000
57+
FW_FILE_2_ADDR = 0x40000
5458

5559
# select which tools to use as compiler, librarian and linker
5660
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
@@ -62,7 +66,6 @@ LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
6266
####
6367
#### no user configurable options below here
6468
####
65-
FW_TOOL ?= /usr/bin/esptool
6669
SRC_DIR := $(MODULES)
6770
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))
6871

@@ -81,8 +84,8 @@ INCDIR := $(addprefix -I,$(SRC_DIR))
8184
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
8285
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
8386

84-
FW_FILE_1 := $(addprefix $(FW_BASE)/,$(FW_FILE_1).bin)
85-
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)
8689

8790
V ?= $(VERBOSE)
8891
ifeq ("$(V)","1")
@@ -98,20 +101,16 @@ vpath %.c $(SRC_DIR)
98101
define compile-objects
99102
$1/%.o: %.c
100103
$(vecho) "CC $$<"
101-
$(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 $$@
102105
endef
103106

104107
.PHONY: all checkdirs flash clean
105108

106109
all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)
107110

108-
$(FW_FILE_1): $(TARGET_OUT)
109-
$(vecho) "FW $@"
110-
$(Q) $(FW_TOOL) -eo $(TARGET_OUT) $(FW_FILE_1_ARGS)
111-
112-
$(FW_FILE_2): $(TARGET_OUT)
113-
$(vecho) "FW $@"
114-
$(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)
115114

116115
$(TARGET_OUT): $(APP_AR)
117116
$(vecho) "LD $@"
@@ -126,21 +125,13 @@ checkdirs: $(BUILD_DIR) $(FW_BASE)
126125
$(BUILD_DIR):
127126
$(Q) mkdir -p $@
128127

129-
firmware:
128+
$(FW_BASE):
130129
$(Q) mkdir -p $@
131130

132-
flash: firmware/0x00000.bin firmware/0x40000.bin
133-
-$(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)
134133

135134
clean:
136-
$(Q) rm -f $(APP_AR)
137-
$(Q) rm -f $(TARGET_OUT)
138-
$(Q) rm -rf $(BUILD_DIR)
139-
$(Q) rm -rf $(BUILD_BASE)
140-
141-
142-
$(Q) rm -f $(FW_FILE_1)
143-
$(Q) rm -f $(FW_FILE_2)
144-
$(Q) rm -rf $(FW_BASE)
135+
$(Q) rm -rf $(FW_BASE) $(BUILD_BASE)
145136

146137
$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))

example.Makefile

+28-38
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
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
52
#
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)
98
#
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+
1015
# Output directors to store intermediate compiled files
1116
# relative to the project directory
1217
BUILD_BASE = build
1318
FW_BASE = firmware
1419

15-
# Base directory for the compiler
20+
# base directory for the compiler
1621
XTENSA_TOOLS_ROOT ?= /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin
1722

1823
# base directory of the ESP8266 SDK package, absolute
1924
SDK_BASE ?= /opt/Espressif/ESP8266_SDK
2025

21-
#Esptool.py path and port
26+
# esptool.py path and port
2227
ESPTOOL ?= esptool.py
2328
ESPPORT ?= /dev/ttyUSB0
2429

@@ -27,7 +32,7 @@ TARGET = app
2732

2833
# which modules (subdirectories) of the project to include in compiling
2934
MODULES = driver user
30-
EXTRA_INCDIR = include /opt/Espressif/include
35+
EXTRA_INCDIR = include
3136

3237
# libraries used in this project, mainly provided by the SDK
3338
LIBS = c gcc hal pp phy net80211 lwip wpa main
@@ -48,10 +53,8 @@ SDK_INCDIR = include include/json
4853

4954
# we create two different files for uploading into the flash
5055
# 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
5558

5659
# select which tools to use as compiler, librarian and linker
5760
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
@@ -63,7 +66,6 @@ LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
6366
####
6467
#### no user configurable options below here
6568
####
66-
FW_TOOL ?= /usr/bin/esptool
6769
SRC_DIR := $(MODULES)
6870
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))
6971

@@ -82,8 +84,8 @@ INCDIR := $(addprefix -I,$(SRC_DIR))
8284
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
8385
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
8486

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)
8789

8890
V ?= $(VERBOSE)
8991
ifeq ("$(V)","1")
@@ -99,20 +101,16 @@ vpath %.c $(SRC_DIR)
99101
define compile-objects
100102
$1/%.o: %.c
101103
$(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 $$@
103105
endef
104106

105-
.PHONY: all checkdirs clean
107+
.PHONY: all checkdirs flash clean
106108

107109
all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)
108110

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)
116114

117115
$(TARGET_OUT): $(APP_AR)
118116
$(vecho) "LD $@"
@@ -127,21 +125,13 @@ checkdirs: $(BUILD_DIR) $(FW_BASE)
127125
$(BUILD_DIR):
128126
$(Q) mkdir -p $@
129127

130-
firmware:
128+
$(FW_BASE):
131129
$(Q) mkdir -p $@
132130

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)
135133

136134
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)
146136

147137
$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))

0 commit comments

Comments
 (0)