tweak Makefile for sdk 2.0.0

pull/193/head
Thorsten von Eicken 8 years ago
parent 8a8649aab6
commit c5d51a0654
  1. 84
      Makefile
  2. 21
      esp-link/main.c

@ -4,7 +4,6 @@
# Makefile heavily adapted to esp-link and wireless flashing by Thorsten von Eicken # Makefile heavily adapted to esp-link and wireless flashing by Thorsten von Eicken
# Lots of work, in particular to support windows, by brunnels # Lots of work, in particular to support windows, by brunnels
# Original from esphttpd and others... # Original from esphttpd and others...
# VERBOSE=1
# #
# Start by setting the directories for the toolchain a few lines down # Start by setting the directories for the toolchain a few lines down
# the default target will build the firmware images # the default target will build the firmware images
@ -52,35 +51,37 @@ ESP_HOSTNAME ?= esp-link
# Base directory for the compiler. Needs a / at the end. # Base directory for the compiler. Needs a / at the end.
# Typically you'll install https://github.com/pfalcon/esp-open-sdk # Typically you'll install https://github.com/pfalcon/esp-open-sdk
# IMPORTANT: use esp-open-sdk `make STANDALONE=n`: the SDK bundled with esp-open-sdk will *not* work!
XTENSA_TOOLS_ROOT ?= $(abspath ../esp-open-sdk/xtensa-lx106-elf/bin)/ XTENSA_TOOLS_ROOT ?= $(abspath ../esp-open-sdk/xtensa-lx106-elf/bin)/
# Firmware version # Firmware version
# WARNING: if you change this expect to make code adjustments elsewhere, don't expect # WARNING: if you change this expect to make code adjustments elsewhere, don't expect
# that esp-link will magically work with a different version of the SDK!!! # that esp-link will magically work with a different version of the SDK!!!
SDK_VERS ?= esp_iot_sdk_v1.5.4 SDK_VERS ?= esp_iot_sdk_v2.0.0.p1
# Try to find the firmware manually extracted, e.g. after downloading from Espressif's BBS, # Try to find the firmware manually extracted, e.g. after downloading from Espressif's BBS,
# http://bbs.espressif.com/viewforum.php?f=46 # http://bbs.espressif.com/viewforum.php?f=46
SDK_BASE ?= $(wildcard ../$(SDK_VERS)) SDK_BASE ?= $(wildcard ../$(SDK_VERS))
# If the firmware isn't there, see whether it got downloaded as part of esp-open-sdk # If the firmware isn't there, see whether it got downloaded as part of esp-open-sdk
ifeq ($(SDK_BASE),) # This used to work at some point, but is not supported, uncomment if you feel lucky ;-)
SDK_BASE := $(wildcard $(XTENSA_TOOLS_ROOT)/../../$(SDK_VERS)) #ifeq ($(SDK_BASE),)
endif #SDK_BASE := $(wildcard $(XTENSA_TOOLS_ROOT)/../../$(SDK_VERS))
#endif
# Clean up SDK path # Clean up SDK path
SDK_BASE := $(abspath $(SDK_BASE)) SDK_BASE := $(abspath $(SDK_BASE))
$(warning Using SDK from $(SDK_BASE)) $(warning Using SDK from $(SDK_BASE))
# Path to bootloader file # Path to bootloader file
BOOTFILE ?= $(SDK_BASE/bin/boot_v1.5.bin) BOOTFILE ?= $(SDK_BASE/bin/boot_v1.6.bin)
# Esptool.py path and port, only used for 1-time serial flashing # Esptool.py path and port, only used for 1-time serial flashing
# Typically you'll use https://github.com/themadinventor/esptool # Typically you'll use https://github.com/themadinventor/esptool
# Windows users use the com port i.e: ESPPORT ?= com3 # Windows users use the com port i.e: ESPPORT ?= com3
ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py) ESPTOOL ?= $(abspath ../esp-open-sdk/esptool/esptool.py)
ESPPORT ?= /dev/ttyUSB0 ESPPORT ?= /dev/ttyUSB0
ESPBAUD ?= 460800 ESPBAUD ?= 230400
# --------------- chipset configuration --------------- # --------------- chipset configuration ---------------
@ -117,8 +118,6 @@ MODULES ?= mqtt rest syslog web-server
# #
# Adding JPG or PNG files (and any other compressed formats) is not recommended, because GZIP # Adding JPG or PNG files (and any other compressed formats) is not recommended, because GZIP
# compression does not work effectively on compressed files. # compression does not work effectively on compressed files.
#Static gzipping is disabled by default.
GZIP_COMPRESSION ?= yes GZIP_COMPRESSION ?= yes
# If COMPRESS_W_HTMLCOMPRESSOR is set to "yes" then the static css and js files will be compressed with # If COMPRESS_W_HTMLCOMPRESSOR is set to "yes" then the static css and js files will be compressed with
@ -226,8 +225,8 @@ endif
# which modules (subdirectories) of the project to include in compiling # which modules (subdirectories) of the project to include in compiling
LIBRARIES_DIR = libraries LIBRARIES_DIR = libraries
MODULES += espfs httpd user serial cmd esp-link MODULES += espfs httpd user serial cmd esp-link
MODULES += $(foreach sdir,$(LIBRARIES_DIR),$(wildcard $(sdir)/*)) MODULES += $(foreach sdir,$(LIBRARIES_DIR),$(wildcard $(sdir)/*))
EXTRA_INCDIR = include . EXTRA_INCDIR = include .
# libraries used in this project, mainly provided by the SDK # libraries used in this project, mainly provided by the SDK
@ -250,18 +249,17 @@ LD_SCRIPT1 := build/eagle.esphttpd1.v6.ld
LD_SCRIPT2 := build/eagle.esphttpd2.v6.ld LD_SCRIPT2 := build/eagle.esphttpd2.v6.ld
# various paths from the SDK used in this project # various paths from the SDK used in this project
SDK_LIBDIR = lib SDK_LIBDIR = lib
SDK_LDDIR = ld SDK_LDDIR = ld
SDK_INCDIR = include include/json SDK_INCDIR = include include/json
SDK_TOOLSDIR = tools SDK_TOOLSDIR = tools
# select which tools to use as compiler, librarian and linker # select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc
AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc
OBJCP := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objcopy OBJCP := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objcopy
OBJDP := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objdump OBJDP := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objdump
#### ####
SRC_DIR := $(MODULES) SRC_DIR := $(MODULES)
@ -273,14 +271,14 @@ SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))
SDK_TOOLS := $(addprefix $(SDK_BASE)/,$(SDK_TOOLSDIR)) SDK_TOOLS := $(addprefix $(SDK_BASE)/,$(SDK_TOOLSDIR))
APPGEN_TOOL := $(addprefix $(SDK_TOOLS)/,$(APPGEN_TOOL)) APPGEN_TOOL := $(addprefix $(SDK_TOOLS)/,$(APPGEN_TOOL))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC)) $(BUILD_BASE)/espfs_img.o OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC)) $(BUILD_BASE)/espfs_img.o
LIBS := $(addprefix -l,$(LIBS)) LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
USER1_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).user1.out) USER1_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).user1.out)
USER2_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).user2.out) USER2_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).user2.out)
INCDIR := $(addprefix -I,$(SRC_DIR)) INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
@ -381,7 +379,7 @@ $(FW_BASE)/user2.bin: $(USER2_OUT) $(FW_BASE)
$(Q) $(OBJCP) --only-section .data -O binary $(USER2_OUT) eagle.app.v6.data.bin $(Q) $(OBJCP) --only-section .data -O binary $(USER2_OUT) eagle.app.v6.data.bin
$(Q) $(OBJCP) --only-section .rodata -O binary $(USER2_OUT) eagle.app.v6.rodata.bin $(Q) $(OBJCP) --only-section .rodata -O binary $(USER2_OUT) eagle.app.v6.rodata.bin
$(Q) $(OBJCP) --only-section .irom0.text -O binary $(USER2_OUT) eagle.app.v6.irom0text.bin $(Q) $(OBJCP) --only-section .irom0.text -O binary $(USER2_OUT) eagle.app.v6.irom0text.bin
$(Q) COMPILE=gcc PATH=$(XTENSA_TOOLS_ROOT):$(PATH) python $(APPGEN_TOOL) $(USER2_OUT) 2 $(ESP_FLASH_MODE) $(ESP_FLASH_FREQ_DIV) $(ESP_SPI_SIZE) 0 $(Q) COMPILE=gcc PATH=$(XTENSA_TOOLS_ROOT):$(PATH) python $(APPGEN_TOOL) $(USER2_OUT) 2 $(ESP_FLASH_MODE) $(ESP_FLASH_FREQ_DIV) $(ESP_SPI_SIZE) 1
$(Q) rm -f eagle.app.v6.*.bin $(Q) rm -f eagle.app.v6.*.bin
$(Q) mv eagle.app.flash.bin $@ $(Q) mv eagle.app.flash.bin $@
$(Q) if [ $$(stat -c '%s' $@) -gt $$(( $(ESP_FLASH_MAX) )) ]; then echo "$@ too big!"; false; fi $(Q) if [ $$(stat -c '%s' $@) -gt $$(( $(ESP_FLASH_MAX) )) ]; then echo "$@ too big!"; false; fi
@ -430,23 +428,23 @@ $(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage
$(Q) cp -r html/wifi/*.png html_compressed/wifi; $(Q) cp -r html/wifi/*.png html_compressed/wifi;
$(Q) cp -r html/wifi/*.js html_compressed/wifi; $(Q) cp -r html/wifi/*.js html_compressed/wifi;
ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes") ifeq ("$(COMPRESS_W_HTMLCOMPRESSOR)","yes")
$(Q) echo "Compression assets with htmlcompressor. This may take a while..." $(Q) echo "Compressing assets with htmlcompressor. This may take a while..."
$(Q) java -jar tools/$(HTML_COMPRESSOR) \ $(Q) java -jar tools/$(HTML_COMPRESSOR) \
-t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \
-o $(abspath ./html_compressed)/ \ -o $(abspath ./html_compressed)/ \
$(HTML_PATH)head- \ $(HTML_PATH)head- \
$(HTML_PATH)*.html $(HTML_PATH)*.html
$(Q) java -jar tools/$(HTML_COMPRESSOR) \ $(Q) java -jar tools/$(HTML_COMPRESSOR) \
-t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \ -t html --remove-surrounding-spaces max --remove-quotes --remove-intertag-spaces \
-o $(abspath ./html_compressed)/wifi/ \ -o $(abspath ./html_compressed)/wifi/ \
$(WIFI_PATH)*.html $(WIFI_PATH)*.html
$(Q) echo "Compression assets with yui-compressor. This may take a while..." $(Q) echo "Compressing assets with yui-compressor. This may take a while..."
$(Q) for file in `find html_compressed -type f -name "*.js"`; do \ $(Q) for file in `find html_compressed -type f -name "*.js"`; do \
java -jar tools/$(YUI_COMPRESSOR) $$file --line-break 0 -o $$file; \ java -jar tools/$(YUI_COMPRESSOR) $$file --line-break 0 -o $$file; \
done done
$(Q) for file in `find html_compressed -type f -name "*.css"`; do \ $(Q) for file in `find html_compressed -type f -name "*.css"`; do \
java -jar tools/$(YUI_COMPRESSOR) $$file -o $$file; \ java -jar tools/$(YUI_COMPRESSOR) $$file -o $$file; \
done done
else else
$(Q) cp -r html/head- html_compressed; $(Q) cp -r html/head- html_compressed;
$(Q) cp -r html/*.html html_compressed; $(Q) cp -r html/*.html html_compressed;
@ -457,25 +455,25 @@ ifeq (,$(findstring mqtt,$(MODULES)))
$(Q) rm -rf html_compressed/mqtt.js $(Q) rm -rf html_compressed/mqtt.js
endif endif
$(Q) for file in `find html_compressed -type f -name "*.htm*"`; do \ $(Q) for file in `find html_compressed -type f -name "*.htm*"`; do \
cat html_compressed/head- $$file >$${file}-; \ cat html_compressed/head- $$file >$${file}-; \
mv $$file- $$file; \ mv $$file- $$file; \
done done
$(Q) rm html_compressed/head- $(Q) rm html_compressed/head-
$(Q) cd html_compressed; find . \! -name \*- | ../espfs/mkespfsimage/mkespfsimage > ../build/espfs.img; cd ..; $(Q) cd html_compressed; find . \! -name \*- | ../espfs/mkespfsimage/mkespfsimage > ../build/espfs.img; cd ..;
$(Q) ls -sl build/espfs.img $(Q) ls -sl build/espfs.img
$(Q) cd build; $(OBJCP) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.espfs \ $(Q) cd build; $(OBJCP) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.espfs \
espfs.img espfs_img.o; cd .. espfs.img espfs_img.o; cd ..
# edit the loader script to add the espfs section to the end of irom with a 4 byte alignment. # edit the loader script to add the espfs section to the end of irom with a 4 byte alignment.
# we also adjust the sizes of the segments 'cause we need more irom0 # we also adjust the sizes of the segments 'cause we need more irom0
build/eagle.esphttpd1.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.1024.app1.ld build/eagle.esphttpd1.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.1024.app1.ld
$(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \ $(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \
-e '/^ irom0_0_seg/ s/6B000/7C000/' \ -e '/^ irom0_0_seg/ s/6B000/7C000/' \
$(SDK_LDDIR)/eagle.app.v6.new.1024.app1.ld >$@ $(SDK_LDDIR)/eagle.app.v6.new.1024.app1.ld >$@
build/eagle.esphttpd2.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.1024.app2.ld build/eagle.esphttpd2.v6.ld: $(SDK_LDDIR)/eagle.app.v6.new.1024.app2.ld
$(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \ $(Q) sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4);' -e 'a *(.espfs)' -e '}' \
-e '/^ irom0_0_seg/ s/6B000/7C000/' \ -e '/^ irom0_0_seg/ s/6B000/7C000/' \
$(SDK_LDDIR)/eagle.app.v6.new.1024.app2.ld >$@ $(SDK_LDDIR)/eagle.app.v6.new.1024.app2.ld >$@
espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/ espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/
$(Q) $(MAKE) -C espfs/mkespfsimage GZIP_COMPRESSION="$(GZIP_COMPRESSION)" $(Q) $(MAKE) -C espfs/mkespfsimage GZIP_COMPRESSION="$(GZIP_COMPRESSION)"

@ -122,13 +122,30 @@ extern uint32_t _binary_espfs_img_start;
extern void app_init(void); extern void app_init(void);
extern void mqtt_client_init(void); extern void mqtt_client_init(void);
void user_rf_pre_init(void) { void ICACHE_FLASH_ATTR
user_rf_pre_init(void) {
//default is enabled //default is enabled
system_set_os_print(DEBUG_SDK); system_set_os_print(DEBUG_SDK);
} }
/* user_rf_cal_sector_set is a required function that is called by the SDK to get a flash
* sector number where it can store RF calibration data. This was introduced with SDK 1.5.4.1
* and is necessary because Espressif ran out of pre-reserved flash sectors. Ooops... */
uint32 ICACHE_FLASH_ATTR
user_rf_cal_sector_set(void) {
uint32_t sect = 0;
switch (system_get_flash_size_map()) {
case FLASH_SIZE_4M_MAP_256_256: // 512KB
sect = 128 - 10; // 0x76000
default:
sect = 128; // 0x80000
}
return sect;
}
// Main routine to initialize esp-link. // Main routine to initialize esp-link.
void user_init(void) { void ICACHE_FLASH_ATTR
user_init(void) {
// uncomment the following three lines to see flash config messages for troubleshooting // uncomment the following three lines to see flash config messages for troubleshooting
//uart_init(115200, 115200); //uart_init(115200, 115200);
//logInit(); //logInit();

Loading…
Cancel
Save