Skip to content

Commit 87f04d5

Browse files
agattidpgeorge
authored andcommitted
esp8266/Makefile: Fix local toolchain builds on recent Linux systems.
This commit fixes compilation for the ESP8266 port when using a local toolchain on relatively recent Linux systems. The documentation asks the user to delete the esptool instance that comes with the toolchain, in favour of using the one provided by the system. On Linux systems that are at least two years old (looking at the CI Ubuntu image as an example), the version of esptool installed with the package manager isn't called `esptool.py` but just `esptool`. The Makefile didn't take that into account and used `esptool.py` without checking if such a command exists, making builds fail. Now preference is given to the `esptool` command, falling back to `esptool.py` only if the former command does not exist or it is not available to the current user, to maintain compatibility with old setups. Signed-off-by: Alessandro Gatti <[email protected]>
1 parent b4f53a0 commit 87f04d5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ports/esp8266/Makefile

+9-4
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ else ifneq ($(shell cat $(CONFVARS_FILE)), $(FROZEN_MANIFEST) $(UART_OS))
185185
$(shell echo $(FROZEN_MANIFEST) $(UART_OS) > $(CONFVARS_FILE))
186186
endif
187187

188+
ESPTOOL := $(shell command -v esptool 2> /dev/null)
189+
ifndef ESPTOOL
190+
ESPTOOL = esptool.py
191+
endif
192+
188193
$(BUILD)/uart.o: $(CONFVARS_FILE)
189194

190195
FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
@@ -193,27 +198,27 @@ FROZEN_EXTRA_DEPS = $(CONFVARS_FILE)
193198

194199
deploy: $(FWBIN)
195200
$(ECHO) "Writing $< to the board"
196-
$(Q)esptool.py --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $<
201+
$(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) write_flash --verify --flash_size=$(FLASH_SIZE) --flash_mode=$(FLASH_MODE) 0 $<
197202

198203
erase:
199204
$(ECHO) "Erase flash"
200-
$(Q)esptool.py --port $(PORT) --baud $(BAUD) erase_flash
205+
$(Q)$(ESPTOOL) --port $(PORT) --baud $(BAUD) erase_flash
201206

202207
reset:
203208
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
204209

205210
ifeq ($(BOARD_VARIANT),OTA)
206211
$(FWBIN): $(BUILD)/firmware.elf
207212
$(ECHO) "Create $@"
208-
$(Q)esptool.py elf2image $^
213+
$(Q)$(ESPTOOL) elf2image $^
209214
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $(BUILD)/firmware-ota.bin
210215

211216
$(Q)cat $(YAOTA8266)/yaota8266.bin $(BUILD)/firmware-ota.bin > $@
212217
$(Q)$(PYTHON) $(YAOTA8266)/ota-client/ota_client.py sign $@
213218
else
214219
$(FWBIN): $(BUILD)/firmware.elf
215220
$(ECHO) "Create $@"
216-
$(Q)esptool.py elf2image $^
221+
$(Q)$(ESPTOOL) elf2image $^
217222
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@
218223
endif
219224

0 commit comments

Comments
 (0)