Skip to content

Commit

Permalink
Merge pull request #17 from devicehive/develop
Browse files Browse the repository at this point in the history
Uploadable webpage.
  • Loading branch information
devrn authored Oct 28, 2016
2 parents 3f19714 + ae81f7b commit de68d26
Show file tree
Hide file tree
Showing 41 changed files with 885 additions and 198 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ firmware-src/pages/pages.h
esp-utils/build
esp-utils/.settings
sdk/lib/libc.a
release/build
release/*.zip
release/*.tar.gz
firmware-src/pages/debug.log
192 changes: 98 additions & 94 deletions DeviceHiveESP8266.md

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# DeviceHive ESP8266 Firmware
Special firmware for usage ESP8266 in DeviceHive clouds.
Special firmware for usage ESP8266 as local web server with RESTful API and as DeviceHive clouds client.
This repo consist of few parts of this project which can be used with
other projects. Each project has dedicated readme file.

![](images/demo-device.jpg?raw=true)
Photo above is a real photo of the demo device contructed with esp8266. See
http://youtu.be/hzi4djt-wdg

# [DeviceHiveESP8266.md](DeviceHiveESP8266.md)
This is the main documentation file for this firmware. Document contains
commands specification, describes all features and firmware usage.
[Click here to open it.](DeviceHiveESP8266.md)

# Demo videos
Zero wireless configuring with Android http://youtu.be/2J98YDpbJKo
DeviceHive clouds demos:
BH1750 Ambient light http://youtu.be/AkSFdO0soyo
DS18B20 + iButton + DHT11 http://youtu.be/IuvxwCPNZCc
Muscle connected to the cloud http://youtu.be/8L96nBNHE14
Expand Down Expand Up @@ -58,15 +64,12 @@ means that command and parameters is written correctly and you can use it as
a sample.

# release
Pre built binaries of utils and released firmwares.
Scripts for generating binary releases.

# sdk
SDK from chip manufactor. Included in this repo to make sure that we are
using the same version of this SDK to avoid any surprises from changing APIs

# DeviceHiveESP8266.md
Document contains cloud commands specification for this firmware. [Click here to open it.](DeviceHiveESP8266.md)

# License
The MIT License. See LICENSE file. Except sdk directory, it has ESPRSSIF MIT
License, see sdk/License file for details.
Expand Down
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ v0.4
- new playgrounds support

v0.5
- uploadable web page
- mDNS
- local embedded web server with tools and samples
- local RESTful API
- support for some popular sensor devices
- bug fixes
- bug fixes
16 changes: 8 additions & 8 deletions esp-utils/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC = g++
CFLAGS = -c -Wall
LDFLAGS = -s -Os
CXX ?= g++
CFLAGS += -c -Wall
LDFLAGS += -s -Os
LIBS =
OBJDIR = build
SOURCES = $(wildcard common/*.cpp)
Expand All @@ -19,18 +19,18 @@ all: $(SOURCES) $(ESPTERMINAL) $(ESPFLASHER)

$(ESPTERMINAL): $(ALLOBJECTS)
@echo "LD $@"
@$(CC) $(LDFLAGS) $(LIBS) $(COMMONOBJECTS) $@.o -o $@
@$(CXX) $(LDFLAGS) $(LIBS) $(COMMONOBJECTS) $@.o -o $@

$(ESPFLASHER): $(ALLOBJECTS)
@echo "LD $@"
@$(CC) $(LDFLAGS) $(LIBS) $(COMMONOBJECTS) $@.o -o $@
@$(CXX) $(LDFLAGS) $(LIBS) $(COMMONOBJECTS) $@.o -o $@

$(OBJDIR)/%.o: %.cpp
@echo "CC $<"
@echo "CXX $<"
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $< -o $@
@$(CXX) $(CFLAGS) $< -o $@

rebuild: clean all

clean:
@rm -rf $(OBJDIR)
@rm -rf $(OBJDIR)
10 changes: 8 additions & 2 deletions esp-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ To quit from terminal press Ctrl+Q

# esp-flasher usage
Run application and it will try to detect device automatically. If no parameters
were specified it also will try to open files 0x00000.bin and 0x40000.bin in
current directory and flash them to corresponding addresses.
were specified it also will try to open files devicehive.bin in current directory
and directory with its binary and flash them to corresponding addresses.
You can specify port name in first argument if you want to specify it manually.
You also can specify which files have to be written in devices in arguments by
pairs hex address <space> file name. For exmaple:
esp-flasher COM2 0x00000 boot.img 0x40000 spi.img
esp-flasher 0x40000 myimagefile.bin
There also `--developer` and `--reboot` arguments which supposed to be used by
developers only. First enables incremental flash mode, it compares previosuly
flashed file (should be saved as `devicehive.bin.prev`) and if differences are
minimal it will flash only them to save time on flashing. `--reboot` argument
simply reboot chip (serial adapter RTS should connected to GPIO0, DTR to RTS
pin).

# License
see LICENSE file
Expand Down
2 changes: 1 addition & 1 deletion esp-utils/common/serialport_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ SerialPort::~SerialPort() {

unsigned int SerialPort::write_native(const void *data, unsigned int len) {
ssize_t bw;
ssize_t total = 0;
size_t total = 0;
do {
bw = write(mCom, (char *)data + total, len - total);
total += bw;
Expand Down
36 changes: 34 additions & 2 deletions esp-utils/esp-flasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ void force_flash_mode(SerialPort *port) {
port->setDtr(false);
}

void reboot(SerialPort *port) {
// Typically dev boards have:
// RTS is connected to GPIO0
// DTR is connected to RTS
port->setDtr(false);
port->sleep(50);
port->setDtr(true);
port->sleep(50);
port->setDtr(false);
}

int main(int argc, char* argv[]) {
setbuf(stdout, NULL);
int currentArg = 1;
Expand Down Expand Up @@ -471,9 +482,12 @@ int main(int argc, char* argv[]) {

bool developerMode = false;
if(argc > currentArg) {
if(strncmp(argv[1], "--developer", 5) == 0) {
if(strncmp(argv[currentArg], "--developer", 5) == 0) {
currentArg++;
developerMode = true;
} else if(strncmp(argv[currentArg], "--reboot", 5) == 0) {
reboot(port);
return 0;
}
}

Expand All @@ -493,7 +507,25 @@ int main(int argc, char* argv[]) {
"0x7C000 <- default configuration\r\n"
);
}
isSuccess = flash_file(port, (char*)"devicehive.bin", 0x00000,
char dh[] = "devicehive.bin";
int l = strlen(argv[0]);
char df[l + sizeof(dh)];
char *filename = dh;
FILE *fl = fopen(dh, "rb");
if(fl) { // if in current dir present
fclose(fl);
} else { // check the directory with binary
strcpy(df, argv[0]);
while(l >= 0) {
if(df[l] == '/' || df[l] == '\\') {
strcpy(&df[l + 1], dh);
filename = df;
break;
}
l--;
}
}
isSuccess = flash_file(port, filename, 0x00000,
developerMode ? (char*)"devicehive.bin.prev" : NULL);
if(isSuccess && !developerMode)
isSuccess = flash_default_config(port);
Expand Down
25 changes: 20 additions & 5 deletions firmware-src/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
</tool>
<tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.961213307" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release.1674875864" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.exe.release">
<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.1242938638" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.58433370" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.release.option.optimization.level.1242938638" name="Optimization Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
<option id="gnu.cpp.compiler.mingw.exe.release.option.debugging.level.58433370" name="Debug Level" superClass="gnu.cpp.compiler.mingw.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release.2002459360" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.release">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.610307888" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.627804478" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.723611317" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.mingw.exe.release.option.optimization.level.610307888" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.release.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.release.option.debugging.level.627804478" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.release.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.none" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.723611317" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${PWD}/../sdk/include&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1979945552" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
Expand Down Expand Up @@ -110,6 +110,21 @@
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="disassemble" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildTarget>disassemble</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="reboot" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>reboot</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>
7 changes: 6 additions & 1 deletion firmware-src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AR = $(CROSS_COMPILE)ar
SIZE = $(CROSS_COMPILE)size
PAGESH = pages/pages.h

.PHONY: all flash full_flash terminal clean
.PHONY: all flash full_flash terminal clean disassemble reboot

all: $(FIRMWARE)

Expand Down Expand Up @@ -70,3 +70,8 @@ clean:
@rm -f $(PAGESH)
@rm -f $(FIRMWARE).prev

disassemble:
@$(CROSS_COMPILE)objdump -d $(TARGETELF) > $(OBJDIR)/disassemble.txt

reboot:
@(cd $(dir $(FIRMWARE)) && ./../../esp-utils/build/esp-flasher --reboot)
18 changes: 12 additions & 6 deletions firmware-src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,31 @@ Actually we need just: 'Xtensa crosstool-NG' (https://github.com/jcmvbkbc/crosst
SDK is already in this repo.

# Firmware usage
Flash firmware( 0x00000.bin and 0x40000 from firmware directory) to the device with
Flash firmware (devicehive.bin firmware directory) to the device with
esp-flasher util (see esp-util project on top of the repo). You can also use any other
flasher for esp8266 (esptool - https://github.com/themadinventor/esptool for example).
Connect to device terminal via serial port with esp-terminal (see esp-util project).
You can also use any other serial port terminal with escape sequences support. PuTTY
for Windows OS ( http://www.putty.org/ ) or 'screen' util under Linux for example.
This firmware has quite regular unix like terminal via UART. Autocomplete and command
Firmware should be flashed at 0x0 SPI chip address. Connect to device terminal
via serial port with esp-terminal (see esp-util project). You can also use any
other serial port terminal with escape sequences support. PuTTY for Windows OS
( http://www.putty.org/ ) or 'screen' util under Linux for example. This
firmware has quite regular unix like terminal via UART. Autocomplete and command
history are supported.
Type' 'help' in terminal to see all aviable commands. At first you need to configure
device. Type 'configure' in terminal to run configuration util on it. Enter network
and server parameters, device will be rebooted. Now you can send command via
DeviceHive cloud to device. Please refer to ESP8266 firmware commands documentation
to find which commands are supported(see the top of this repo).

#genbin.sh
# genbin.sh
Small util to extract binary images for flashing for compiled file. Might be useful
for other projects. Usage:
genbin.sh <path to elf file> [<output directory>]

# pages
This directory contains web pages which will be embedded into firmware. Rebuild
(make rebuild) sources after changing content of this pages or run mannually
`gen_pages.sh` script to update it.

# License
MIT. See LICENSE file.

Expand Down
2 changes: 1 addition & 1 deletion firmware-src/devicehive.ld
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MEMORY
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x7A000
irom0_0_seg : org = 0x40210000, len = 0x58000
}

PHDRS
Expand Down
Loading

0 comments on commit de68d26

Please sign in to comment.