Skip to content

Commit

Permalink
Merge pull request #55 from kireevco/crossplatform2
Browse files Browse the repository at this point in the history
Cross platform changes + #45 #26 #24
anakod committed May 10, 2015

Verified

This commit was signed with the committer’s verified signature.
reneme René Meusel
2 parents 69cf35a + 95ae10d commit 1bddd5e
Showing 110 changed files with 3,450 additions and 9,875 deletions.
120 changes: 60 additions & 60 deletions Basic_AirUpdate/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basic_AirUpdate/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Basic_AirUpdate/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <[email protected]>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Basic_AirUpdate/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
116 changes: 58 additions & 58 deletions Basic_Blink/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basic_Blink/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Basic_Blink/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Basic_Blink/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
120 changes: 60 additions & 60 deletions Basic_Interrupts/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basic_Interrupts/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Basic_Interrupts/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Basic_Interrupts/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
116 changes: 58 additions & 58 deletions Basic_ScannerI2C/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basic_ScannerI2C/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Basic_ScannerI2C/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Basic_ScannerI2C/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
120 changes: 60 additions & 60 deletions Basic_Serial/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basic_Serial/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Basic_Serial/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Basic_Serial/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
116 changes: 58 additions & 58 deletions Basic_WiFi/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Basic_WiFi/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Basic_WiFi/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Basic_WiFi/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
116 changes: 58 additions & 58 deletions Compass_HMC5883L/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Compass_HMC5883L/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions Compass_HMC5883L/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions Compass_HMC5883L/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
116 changes: 58 additions & 58 deletions FtpServer_Files/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion FtpServer_Files/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
352 changes: 20 additions & 332 deletions FtpServer_Files/Makefile
Original file line number Diff line number Diff line change
@@ -1,332 +1,20 @@
#############################################################
#
# Root Level Makefile
#
# (c) by CHERTS <sleuthhound@gmail.com>
#
#############################################################

# Sming Framework Path
SMF = ../Sming/

BUILD_BASE = out/build
FW_BASE = out/firmware

# Base directory for the compiler
XTENSA_TOOLS_ROOT ?= c:/Espressif/xtensa-lx106-elf/bin

# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= c:/Espressif/ESP8266_SDK

# esptool path and port
SDK_TOOLS ?= c:/Espressif/utils
ESPTOOL ?= $(SDK_TOOLS)/esptool.exe
COM_PORT ?= COM3
COM_SPEED ?= 230400

# name for the target project
TARGET = app

# which modules (subdirectories) of the project to include in compiling
MODULES = $(SMF)system $(SMF)system/helpers $(SMF)Wiring $(SMF)SmingCore $(SMF)SmingCore/Network $(SMF)SmingCore/Platform $(SMF)Services/SpifFS $(SMF)Services/ArduinoJson $(SMF)Services/WebHelpers $(SMF)Services/DateTime $(SMF)appinit app $(SMF)Libraries/DHT $(SMF)Libraries/LiquidCrystal $(SMF)Libraries/Bounce $(SMF)Libraries/Adafruit_GFX $(SMF)Libraries/TFT_ILI9163C $(SMF)Libraries/BMP180 $(SMF)Libraries/BH1750FVI $(SMF)Libraries/Adafruit_SSD1306 $(SMF)Libraries/OneWire $(SMF)Libraries/I2Cdev $(SMF)Libraries/HMC5883L
EXTRA_INCDIR = include $(SMF) $(SMF)system/include $(SMF)Wiring $(SMF)Libraries $(SMF)SmingCore $(SDK_BASE)/../include

# libraries used in this project, mainly provided by the SDK
USER_LIBDIR = $(SMF)compiler/lib
LIBS = microc microgcc hal phy pp net80211 openlwip wpa main

# compiler flags using during compilation of source files
CFLAGS = -Os -g -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106
CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -u call_user_start -Wl,-static -Wl,--gc-sections

# linker script used for the above linkier step
LD_PATH = $(SMF)compiler/ld/
LD_SCRIPT = $(LD_PATH)eagle.app.v6.cpp.ld

# BOOT = none
# BOOT = old - boot_v1.1
# BOOT = new - boot_v1.2+
BOOT?=none
# APP = 0 - eagle.flash.bin + eagle.irom0text.bin
# APP = 1 - user1.bin
# APP = 2 - user2.bin
APP?=0
# SPI_SPEED = 20MHz, 26.7MHz, 40MHz, 80MHz
SPI_SPEED?=40
# SPI_MODE: QIO, QOUT, DIO, DOUT
SPI_MODE?=QIO
# SPI_SIZE: 256KB, 512KB, 1024KB, 2048KB, 4096KB
SPI_SIZE?=512

ifeq ($(BOOT), new)
boot = new
else
ifeq ($(BOOT), old)
boot = old
else
boot = none
endif
endif

ifeq ($(APP), 1)
app = 1
else
ifeq ($(APP), 2)
app = 2
else
app = 0
endif
endif

ifeq ($(SPI_SPEED), 26.7)
freqdiv = 1
else
ifeq ($(SPI_SPEED), 20)
freqdiv = 2
else
ifeq ($(SPI_SPEED), 80)
freqdiv = 15
else
freqdiv = 0
endif
endif
endif


ifeq ($(SPI_MODE), QOUT)
mode = 1
else
ifeq ($(SPI_MODE), DIO)
mode = 2
else
ifeq ($(SPI_MODE), DOUT)
mode = 3
else
mode = 0
endif
endif
endif

# flash larger than 1024KB only use 1024KB to storage user1.bin and user2.bin
ifeq ($(SPI_SIZE), 256)
size = 1
flash = 256
else
ifeq ($(SPI_SIZE), 1024)
size = 2
flash = 1024
else
ifeq ($(SPI_SIZE), 2048)
size = 3
flash = 1024
else
ifeq ($(SPI_SIZE), 4096)
size = 4
flash = 1024
else
size = 0
flash = 512
endif
endif
endif
endif

ifeq ($(flash), 512)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x41000
endif
endif
else
ifeq ($(flash), 1024)
ifeq ($(app), 1)
addr = 0x01000
else
ifeq ($(app), 2)
addr = 0x81000
endif
endif
endif
endif

ifneq ($(boot), none)
ifneq ($(app),0)
LD_SCRIPT = $(LD_PATH)eagle.app.v6.$(boot).$(flash).app$(app).cpp.ld
BIN_NAME = user$(app).$(flash).$(boot)
endif
else
app = 0
endif

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json

# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
CXX := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-g++
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
OBJCOPY := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objcopy
OBJDUMP := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-objdump

SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c*))
C_OBJ := $(patsubst %.c,%.o,$(SRC))
CXX_OBJ := $(patsubst %.cpp,%.o,$(C_OBJ))
OBJ := $(patsubst %.o,$(BUILD_BASE)/%.o,$(CXX_OBJ))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

#LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := $(addprefix -T,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))

V ?= $(VERBOSE)
ifeq ("$(V)","1")
Q :=
vecho := @true
else
Q := @
vecho := @echo
endif

vpath %.c $(SRC_DIR)
vpath %.cpp $(SRC_DIR)

define compile-objects
$1/%.o: %.c
$(vecho) "CC $$<"
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
$1/%.o: %.cpp
$(vecho) "C+ $$<"
$(Q) $(CXX) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CXXFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean

all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)

$(TARGET_OUT): $(APP_AR)
$(vecho) "LD $@"
$(Q) $(LD) -L$(USER_LIBDIR) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(vecho) "Run objcopy, please wait..."
$(Q) $(OBJCOPY) --only-section .text -O binary $@ eagle.app.v6.text.bin
$(Q) $(OBJCOPY) --only-section .data -O binary $@ eagle.app.v6.data.bin
$(Q) $(OBJCOPY) --only-section .rodata -O binary $@ eagle.app.v6.rodata.bin
$(Q) $(OBJCOPY) --only-section .irom0.text -O binary $@ eagle.app.v6.irom0text.bin
$(vecho) "objcopy done"
$(vecho) "Run gen_appbin.exe"
ifeq ($(app), 0)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 0 $(mode) $(freqdiv) $(size)
$(Q) mv eagle.app.flash.bin $(FW_BASE)/eagle.flash.bin
$(Q) mv eagle.app.v6.irom0text.bin $(FW_BASE)/eagle.irom0text.bin
$(vecho) "Make fs init stub"
$(Q) cat $(FW_BASE)/eagle.irom0text.bin $(SMF)/compiler/data/blankfs.bin > $(FW_BASE)/eagle.irom0text.fs.bin
$(Q) rm eagle.app.v6.*
$(vecho) "No boot needed."
$(vecho) "Generate eagle.flash.bin and eagle.irom0text.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.flash.bin-------->0x00000"
$(vecho) "eagle.irom0text.bin---->0x9000"
else
ifeq ($(boot), new)
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 2 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.2 and +"
else
$(Q) $(SDK_TOOLS)/gen_appbin.exe $@ 1 $(mode) $(freqdiv) $(size)
$(vecho) "Support boot_v1.1 and +"
endif
$(Q) mv eagle.app.flash.bin $(FW_BASE)/upgrade/$(BIN_NAME).bin
$(Q) rm eagle.app.v6.*
$(vecho) "Generate $(BIN_NAME).bin successully in folder $(FW_BASE)/upgrade."
$(vecho) "boot_v1.x.bin------->0x00000"
$(vecho) "$(BIN_NAME).bin--->$(addr)"
endif
$(vecho) "Done"

$(APP_AR): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

checkdirs: $(BUILD_DIR) $(FW_BASE)

$(BUILD_DIR):
$(Q) mkdir -p $@

$(FW_BASE):
$(Q) mkdir -p $@
$(Q) mkdir -p $@/upgrade

flashonefile: all
$(OBJCOPY) --only-section .text -O binary $(TARGET_OUT) eagle.app.v6.text.bin
$(OBJCOPY) --only-section .data -O binary $(TARGET_OUT) eagle.app.v6.data.bin
$(OBJCOPY) --only-section .rodata -O binary $(TARGET_OUT) eagle.app.v6.rodata.bin
$(OBJCOPY) --only-section .irom0.text -O binary $(TARGET_OUT) eagle.app.v6.irom0text.bin
$(SDK_TOOLS)/gen_appbin_old.exe $(TARGET_OUT) v6
$(SDK_TOOLS)/gen_flashbin.exe eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin 0x9000
rm -f eagle.app.v6.data.bin
rm -f eagle.app.v6.flash.bin
rm -f eagle.app.v6.irom0text.bin
rm -f eagle.app.v6.rodata.bin
rm -f eagle.app.v6.text.bin
rm -f eagle.app.sym
mv eagle.app.flash.bin $(FW_BASE)/
$(vecho) "No boot needed."
$(vecho) "Generate eagle.app.flash.bin successully in folder $(FW_BASE)."
$(vecho) "eagle.app.flash.bin-------->0x00000"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.app.flash.bin

flashboot: all flashinit
ifeq ($(boot), new)
$(vecho) "Flash boot_v1.2 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.2.bin
endif
ifeq ($(boot), old)
$(vecho) "Flash boot_v1.1 and +"
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(SDK_BASE)/bin/boot_v1.1.bin
endif
ifeq ($(boot), none)
$(vecho) "No boot needed."
endif

flash: all
ifeq ($(app), 0)
$(shell taskkill /f /im termite.exe)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
ifeq ($(boot), none)
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash 0x00000 $(FW_BASE)/eagle.flash.bin 0x9000 $(FW_BASE)/eagle.irom0text.fs.bin
else
$(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED) write_flash $(addr) $(FW_BASE)/upgrade/$(BIN_NAME).bin
endif
endif

flashinit:
$(vecho) "Flash init data default and blank data."
$(ESPTOOL) -p $(COM_PORT) write_flash 0x4B000 $(SMF)/compiler/data/blankfs.bin 0x7c000 $(SDK_BASE)/bin/esp_init_data_default.bin 0x7e000 $(SDK_BASE)/bin/blank.bin

rebuild: clean all

clean:
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -rf $(BUILD_DIR)
$(Q) rm -rf $(BUILD_BASE)
$(Q) rm -rf $(FW_BASE)

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
#####################################################################
#### Please don't change this file. Use Makefile-user.mk instead ####
#####################################################################
# Including user Makefile.
# Should be used to set project-specific parameters
include ./Makefile-user.mk

# Important parameters check.
# We need to make sure SMING_HOME and ESP_HOME variables are set.
# You can use Makefile-user.mk in each project or use enviromental variables to set it globally.

ifndef SMING_HOME
$(error SMING_HOME is not set. Please configure it in Makefile-user.mk)
endif
ifndef ESP_HOME
$(error ESP_HOME is not set. Please configure it in Makefile-user.mk)
endif

# Include main Sming Makefile
include $(SMING_HOME)/Makefile-project.mk
27 changes: 27 additions & 0 deletions FtpServer_Files/Makefile-user.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Local build configuration
## Parameters configured here will override default and ENV values.
## Uncomment and change examples:

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif

## MacOS / Linux:
#ESP_HOME = /opt/esp-open-sdk

## SMING_HOME sets the path where Sming framework is located.
## Windows:
# SMING_HOME = c:/tools/sming/Sming

# MacOS / Linux
# SMING_HOME = /opt/sming/Sming

## COM port parameter is reqruied to flash firmware correctly.
## Windows:
# COM_PORT = COM3

# MacOS / Linux:
# COM_PORT = /dev/tty.usbserial

# Com port speed
# COM_SPEED = 115200
116 changes: 58 additions & 58 deletions HttpClient_ThingSpeak/.cproject

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion HttpClient_ThingSpeak/.project
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
</projectDescription>
Loading

0 comments on commit 1bddd5e

Please sign in to comment.