From dd59296be9c7589406b668d085a18d2349d498f3 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 18 Aug 2022 14:57:28 -0300 Subject: [PATCH] Improved Makefile to be able to flash subtle mod in main.c comment --- examples/esp8266/Makefile | 21 ++++++++++++++++++--- examples/esp8266/README.md | 6 +++++- examples/esp8266/src/main/main.c | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/esp8266/Makefile b/examples/esp8266/Makefile index e838935d..aedce8d7 100644 --- a/examples/esp8266/Makefile +++ b/examples/esp8266/Makefile @@ -1,13 +1,28 @@ THISDIR = $(realpath $(CURDIR)) ROOTDIR = $(realpath $(CURDIR)/../..) +DOCKER ?= docker run --rm $(DA) -v $(ROOTDIR):$(ROOTDIR) -w $(THISDIR) docker.io/mdashnet/8266 +CMD ?= make -C src defconfig app +PORT ?= /dev/ttyUSB0 all: example example: true -build: src/main/main.c src/main/wifi.c Makefile - docker run --rm -v $(ROOTDIR):$(ROOTDIR) -w $(THISDIR) docker.io/mdashnet/8266 make -C src defconfig app +build: Makefile $(wildcard src/main/*) + $(DOCKER) $(CMD) + +flash: +flash: CMD = python /esp/components/esptool_py/esptool/esptool.py \ + --chip esp8266 --port $(PORT) --baud 115200 --before default_reset \ + --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m \ + --flash_size 2MB 0x10000 $(THISDIR)/src/build/mongoose-example.bin +flash: DA = --device $(PORT) +flash: build + +.PHONY: build clean: - rm -rf build +clean: CMD = rm -rf src/build +clean: build + diff --git a/examples/esp8266/README.md b/examples/esp8266/README.md index 324abb9e..61fa661e 100644 --- a/examples/esp8266/README.md +++ b/examples/esp8266/README.md @@ -14,5 +14,9 @@ To build this application, follow these steps: 4. Run `make`. This invokes a Docker-based build. A firmware will be built in the `src/build/` directory: ```sh - make example + make build + ``` +5. Flash your ESP8266. If you have esptool.py installed, the build process will end telling you the command to flash your device. You can just run `make` again to use Docker: + ```sh + make flash PORT=/your/serial ``` diff --git a/examples/esp8266/src/main/main.c b/examples/esp8266/src/main/main.c index 125a478b..55708e2a 100644 --- a/examples/esp8266/src/main/main.c +++ b/examples/esp8266/src/main/main.c @@ -18,7 +18,7 @@ static void cb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { // Event handler for a client connection - fetch the first web page in history // To enable TLS for HTTP, -// 1. Copy "ca.pem" file to the ESP32 flash FS +// 1. Copy "ca.pem" file to the ESP8266 flash FS // 2. Add TLS init snippet for the connection, see examples/http-client static void cb2(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { if (ev == MG_EV_CONNECT) {