Skip to content

Commit

Permalink
Merge pull request #26 from cnlohr/revert-14-docker_support
Browse files Browse the repository at this point in the history
Revert "Support for Docker and OSX for esp-open-sdk toolchain"
  • Loading branch information
cnlohr authored Aug 25, 2016
2 parents 29cbdf9 + 21db68e commit 96886ee
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 115 deletions.
26 changes: 2 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ It is excellent!

- [esp82XX-basic](https://github.com/con-f-use/esp82XX-basic)
- [Colorchord](https://github.com/cnlohr/colorchord)
- [esp8266ws8212i2c](https://github.com/cnlohr/esp8266ws8212i2s)
- [esp8266ws2812i2c](https://github.com/cnlohr/esp8266ws2812i2s)
- [espusb](https://github.com/cnlohr/espusb)
- Migration of others in progress

Expand Down Expand Up @@ -177,29 +177,7 @@ To make a release, just tag a commit with `git tag -a 'v1.3.3.7' -m 'Your releas
After that, the github web-interface will allow you to make a release out of the new tag and include the binary file.
To make the zip file invoke `make projectname-version-binaries.tgz` (Tab-autocomplete is your friend).
## Docker support
Docker support for esp82xx is experimental and makes the following assumptions:
1. You have a working and relatively recent (>1.12) Docker installation.
2. You have a copy of esptool.py installed **in your base system** (`pip install esptool`) and accessible in your `$PATH`.
3. **You ran `docker pull brainstorm/dockcross-esp-open-sdk` before the next lines.**
To enable cross-compiling inside docker (disabled by default in esp82xx), it should be sufficient to enable
the following configuration directive in `user.cfg`:
```
#DOCKER=no
DOCKER=yes
```
Then run:
1. `docker pull brainstorm/dockcross-esp-open-sdk`
2. `make burn`, `make netburn`, etc... the usual suspects.
## ToDo
- Include libraries for usb, ws2812s and ethernet as soon as they are stable
- Switch to a more convenient, flexible and optimized docker image: https://hub.docker.com/r/vowstar/esp8266/
- Include libraries for usb, ws8212s and ethernet as soon as they are stable
7 changes: 0 additions & 7 deletions common.mf
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ CP = cp
SDK_DEFAULT = $(HOME)/esp8266/esp-open-sdk
OPTS += -DWEB_PORT=$(WEB_PORT) -DCOM_PORT=$(COM_PORT) -DBACKEND_PORT=$(BACKEND_PORT) $(EXTRAOPTS)
ESP_ROOT := $(shell echo "$$ESP_ROOT")
ifeq ($(strip $(DOCKER)), yes)
ESP_ROOT := $(DOCKER_SDK_DEFAULT)
else ifeq ($(strip $(ESP_ROOT)),)
$(warning Warning: No shell variable 'ESP_ROOT', using '$(SDK_DEFAULT)')
ESP_ROOT := $(SDK_DEFAULT)
DOCKCROSS =
endif
ifeq ($(strip $(ESP_ROOT)),)
$(warning Warning: No shell variable 'ESP_ROOT', using '$(SDK_DEFAULT)')
ESP_ROOT := $(SDK_DEFAULT)
Expand Down
87 changes: 26 additions & 61 deletions main.mf
Original file line number Diff line number Diff line change
Expand Up @@ -16,72 +16,45 @@ getips ... Get a list with IPs of esp82xxs connected to your network
usbburn .. Burn via PRE-RELEASE USB loader (will probably change)
usbweb ... Burn webpage by PRE-RELEASE USB loader (will probably change)

More commands: all, clean, purge
endef

define inside_docker
# Cross-compile toolchain in a docker image
ifeq ($(strip $(DOCKER)), yes)
INCL += $(DOCKER_PREFIX)/esp82xx/include $(DOCKER_PREFIX)
$(eval SRCS:=$(addprefix $(DOCKER_PREFIX), $(SRCS)))
$(eval FW_FILE1:=$(addprefix $(DOCKER_PREFIX), $(FW_FILE1)))
$(eval FW_FILE2:=$(addprefix $(DOCKER_PREFIX), $(FW_FILE2)))
$(eval TARGET:=$(addprefix $(DOCKER_PREFIX), $(TARGET)))
$(eval CC:=$(DOCKCROSS) $(CC))
$(eval ESP_ROOT:=$(DOCKER_SDK_DEFAULT))
$(eval ESPTOOL_PY:=$(DOCKCROSS) $(ESPTOOL_PY))
else
DOCKCROSS=
DOCKER_PREFIX=
endif
endef

define outside_docker
# Make sure the actual burning of the chip is done with the system-wide esptool.py
# since it's the only one that has working (privileged) /dev/*USB access.
ifeq ($(strip $(DOCKER)), yes)
$(warning Warning: Docker cannot flash via in-docker esptool.py (yet) due to USB issues, see: http://bit.ly/2b9qFY2)
$(eval ESPTOOL_PY:=$(shell which esptool.py))
$(eval FW_FILE1:= image.elf-0x00000.bin)
$(eval FW_FILE2:= image.elf-0x40000.bin)
endif
More commands: all, clean, purge
endef

.PHONY : all clean cleanall netburn burnweb burn $(BIN_TARGET) netweb getips help
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))

LIBS = main lwip ssl upgrade net80211 wpa phy lwip pp crypto
INCL = $(SDK)/include esp82xx/include .

FW_FILE1 = image.elf-0x00000.bin
FW_FILE2 = image.elf-0x40000.bin
TARGET = image.elf


SRCS = esp82xx/fwsrc/uart.c \
esp82xx/fwsrc/esp82xxutil.c \
esp82xx/fwsrc/flash_rewriter.c \
esp82xx/fwsrc/http.c \
esp82xx/fwsrc/commonservices.c \
esp82xx/fwsrc/http_custom.c \
esp82xx/fwsrc/mdns.c \
esp82xx/fwsrc/mfs.c \
user/custom_commands.c \
user/user_main.c
esp82xx/fwsrc/esp82xxutil.c \
esp82xx/fwsrc/flash_rewriter.c \
esp82xx/fwsrc/http.c \
esp82xx/fwsrc/commonservices.c \
esp82xx/fwsrc/http_custom.c \
esp82xx/fwsrc/mdns.c \
esp82xx/fwsrc/mfs.c \
user/custom_commands.c \
user/user_main.c

LIBS = main lwip ssl upgrade net80211 wpa phy lwip pp crypto
INCL = $(SDK)/include esp82xx/include .

CFLAGS = -mlongcalls -Os $(addprefix -I,$(INCL) $(call uniq, $(patsubst %/,%,$(dir $(SRCS))))) $(OPTS) -DVERSSTR='$(VERSSTR)'

LDFLAGS_CORE = -Wl,--relax -Wl,--gc-sections -nostdlib -L$(XTLIB) \
-L$(XTGCCLIB) $(addprefix $(SDK)/lib/lib,$(addsuffix .a,$(LIBS))) \
$(XTGCCLIB) -T $(SDK)/ld/eagle.app.v6.ld
# -flto -Wl,--relax -Wl,--gc-sections
-L$(XTGCCLIB) $(addprefix $(SDK)/lib/lib,$(addsuffix .a,$(LIBS))) \
$(XTGCCLIB) -T $(SDK)/ld/eagle.app.v6.ld
# -flto -Wl,--relax -Wl,--gc-sections

LINKFLAGS = $(LDFLAGS_CORE) -B$(XTLIB)

BIN_TARGET = $(PROJECT_NAME)-$(VERSION)-binaries.zip

ifneq (,$(findstring -DDEBUG,$(OPTS)))
$(warning Debug is enabled!)
FLASH_WRITE_FLAGS += --verify
$(warning Debug is enabled!)
FLASH_WRITE_FLAGS += --verify
endif

##########################################################################RULES
Expand All @@ -93,42 +66,34 @@ help :
all : $(FW_FILE1) $(FW_FILE2)

$(FW_FILE1) $(FW_FILE2) : $(TARGET)
$(ESPTOOL_PY) elf2image $(TARGET)
PATH=$(PATH):$(FOLDERPREFIX) $(ESPTOOL_PY) elf2image $(TARGET)

$(TARGET) : $(SRCS) Makefile
$(eval $(call inside_docker))
$(CC) $(CFLAGS) $(SRCS) -flto $(LINKFLAGS) -o $(TARGET)
$(CC) $(CFLAGS) $(SRCS) -flto $(LINKFLAGS) -o $@

debug : $(TARGET)
nm -S -n $(TARGET) > image.map
$(PREFIX)objdump -S $(TARGET) > image.lst
$(PREFIX)size -A $(TARGET) | grep -v debug



ifeq ($(CHIP), 8285)
burn : $(FW_FILE1) $(FW_FILE2)
$(eval $(call outside_docker))
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(FLASH_WRITE_FLAGS) 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
burn : $(FW_FILE1) $(FW_FILE2)
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(FLASH_WRITE_FLAGS) -fs 8m -fm dout 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
else ifeq ($(CHIP), 8266)
burn : $(FW_FILE1) $(FW_FILE2)
$(eval $(call outside_docker))
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(FLASH_WRITE_FLAGS) 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
else
$(error Error: Unknown chip '$(CHIP)')
endif

burnweb :
$(eval $(call outside_docker))
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) clean page.mpfs #Always rebuild page.mpfs
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(PAGE_OFFSET) web/page.mpfs)||(true)

@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) clean page.mpfs #Always rebuild page.mpfs
($(ESPTOOL_PY) $(FWBURNFLAGS) --port $(PORT) write_flash $(PAGE_OFFSET) web/page.mpfs)||(true)
#If you have space, MFS should live at 0x100000. It can also live at
#0x10000. But, then it is limited to 180kB. You might need to do this if
# you have a 512kB, or 1M ESP variant.

netburn : $(FW_FILE1) $(FW_FILE2)
$(eval $(call outside_docker))
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) execute_reflash
web/execute_reflash $(IP) $(FW_FILE1) $(FW_FILE2)

Expand All @@ -152,7 +117,7 @@ $(BIN_TARGET): $(FW_FILE1) $(FW_FILE2)

getips:
$(info Detecting possible IPs for ESP82XX modules...)
$(info Needs 'nmap' and takes some time especially if none are connected)
$(info Needs 'nmap' and takes some time especiallay if none are connected)
sudo nmap -sP 192.168.0.0/24 | grep -iP "espressif|esp" -B2 | grep -oP "(\d{1,3}\.){3,3}\d\d{1,3}"

clean :
Expand Down
9 changes: 2 additions & 7 deletions user.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

CHIP = 8266
IP = 192.168.4.1 # does not actually set the IP in firmware
PORT = /dev/ttyUSB0 # could also be, i.e: /dev/ttyACM0 or /dev/cu.usbserial-xxxxxxxx
FWBURNFLAGS = # things like "--baud 940200" to be passed to esptool.py
PORT = /dev/ttyUSB0 # could also be /dev/ttyACM0
WEB_PORT = 80
COM_PORT = 7777
BACKEND_PORT = 7878
Expand All @@ -14,11 +13,6 @@ PAGE_OFFSET = 65536 # 1048576
SDK_DEFAULT = $(HOME)/esp8266/esp-open-sdk
ESP_GCC_VERS = 4.8.5

DOCKER = no
DOCKER_PREFIX = /work/
DOCKER_SDK_DEFAULT = /home/espbuild/esp-open-sdk
DOCKCROSS = $(HOME)/bin/dockcross-xtensa

OPTS += -DICACHE_FLASH
#OPTS += -DVERIFY_FLASH_WRITE
#OPTS += -DDEBUG
Expand All @@ -30,3 +24,4 @@ PAGE_TITLE = esp82xx-basic
PAGE_SCRIPT =
PAGE_HEADING = Welcome to the basic Web-GUI
PAGE_INFO = This is the basic web interface for esp82xx-series chips

16 changes: 8 additions & 8 deletions web/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ page.mpfs : mfsmaker $(wildcard page/*) Makefile
$(RM) -r tmp
$(CP) -r page tmp
$(info $(PROJECT_URL))
sed -ie 's/{{PAGE_TITLE}}/$(subst /,\/,$(PAGE_TITLE))/' tmp/index.html
sed -ie 's/{{PAGE_SCRIPT}}/$(subst /,\/,$(PAGE_SCRIPT))/' tmp/index.html
sed -ie 's/{{PAGE_HEADING}}/$(subst /,\/,$(PAGE_HEADING))/' tmp/index.html
sed -ie 's/{{PAGE_INFO}}/$(subst /,\/,$(PAGE_INFO))/' tmp/index.html
sed -ie 's/{{VERSSTR}}/$(subst ",,$(VERSSTR))/' tmp/index.html
sed -ie 's/{{PROJECT_URL}}/$(subst ",,$(subst /,\/,$(PROJECT_URL)))/' tmp/index.html
sed -ie 's/{{PROJECT_NAME}}/$(subst ",,$(PROJECT_NAME))/' tmp/index.html
sed -ie 's/{{PAGE_JQUERYFL}}/$(subst page/,,$(wildcard page/jquery*gz))/' tmp/index.html
sed -i 's/{{PAGE_TITLE}}/$(subst /,\/,$(PAGE_TITLE))/' tmp/index.html
sed -i 's/{{PAGE_SCRIPT}}/$(subst /,\/,$(PAGE_SCRIPT))/' tmp/index.html
sed -i 's/{{PAGE_HEADING}}/$(subst /,\/,$(PAGE_HEADING))/' tmp/index.html
sed -i 's/{{PAGE_INFO}}/$(subst /,\/,$(PAGE_INFO))/' tmp/index.html
sed -i 's/{{VERSSTR}}/$(subst ",,$(VERSSTR))/' tmp/index.html
sed -i 's/{{PROJECT_URL}}/$(subst ",,$(subst /,\/,$(PROJECT_URL)))/' tmp/index.html
sed -i 's/{{PROJECT_NAME}}/$(subst ",,$(PROJECT_NAME))/' tmp/index.html
sed -i 's/{{PAGE_JQUERYFL}}/$(subst page/,,$(wildcard page/jquery*gz))/' tmp/index.html
./mfsmaker tmp page.mpfs

push : pushtodev page.mpfs
Expand Down
4 changes: 0 additions & 4 deletions web/compat.h

This file was deleted.

5 changes: 3 additions & 2 deletions web/execute_reflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <libusb-1.0/libusb.h>
#include "compat.h"
#include "md5.h"
#include <libusb-1.0/libusb.h>

struct libusb_device_handle *devh = NULL;



#define BLOCK_SIZE 65536
#define SECTOR_SIZE 4096
#define PADDING 1024
Expand All @@ -33,6 +33,7 @@ struct libusb_device_handle *devh = NULL;
int sendsize_max = PADDING;
int use_usb = 0;


int sockfd;
struct sockaddr_in servaddr,cliaddr;

Expand Down
1 change: 0 additions & 1 deletion web/mfsmaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <sys/stat.h>
#include <string.h>
#include <stdint.h>
#include "compat.h"

#define SPI_FLASH_SEC_SIZE 4096
#define MFS_STARTFLASHSECTOR 0x100
Expand Down
1 change: 0 additions & 1 deletion web/pushtodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <stdlib.h>
#include <string.h>
#include <libusb-1.0/libusb.h>
#include "compat.h"

struct libusb_device_handle *devh = NULL;

Expand Down

0 comments on commit 96886ee

Please sign in to comment.