Merge pull request #1678 from cesanta/esp8266

Improved Makefile to be able to flash
This commit is contained in:
Sergey Lyubka 2022-08-18 22:30:20 +01:00 committed by GitHub
commit 2bf25a1406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -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

View File

@ -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
```

View File

@ -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) {