Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Cucci authored Aug 25, 2017
1 parent af92259 commit a78567f
Show file tree
Hide file tree
Showing 9 changed files with 1,221 additions and 0 deletions.
134 changes: 134 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of object file images to be generated ()
# GEN_BINS - list of binaries to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
TARGET = eagle
#FLAVOR = release
FLAVOR = debug

#EXTRA_CCFLAGS += -u

ifndef PDIR # {
GEN_IMAGES= eagle.app.v6.out
GEN_BINS= eagle.app.v6.bin
SPECIAL_MKTARGETS=$(APP_MKTARGETS)
SUBDIRS= \
user \
driver
endif # } PDIR

LDDIR = $(SDK_PATH)/ld

CCFLAGS += -Os

TARGET_LDFLAGS = \
-nostdlib \
-Wl,-EL \
--longcalls \
--text-section-literals

ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -O2
endif

ifeq ($(FLAVOR),release)
TARGET_LDFLAGS += -g -O0
endif

COMPONENTS_eagle.app.v6 = \
user/libuser.a \
driver/libdriver.a

LINKFLAGS_eagle.app.v6 = \
-L$(SDK_PATH)/lib \
-Wl,--gc-sections \
-nostdlib \
-T$(LD_FILE) \
-Wl,--no-check-sections \
-u call_user_start \
-Wl,-static \
-Wl,--start-group \
-lcirom \
-lcrypto \
-lespconn \
-lespnow \
-lfreertos \
-lgcc \
-lhal \
-ljson \
-llwip \
-lmain \
-lmesh \
-lmirom \
-lnet80211 \
-lnopoll \
-lphy \
-lpp \
-lpwm \
-lsmartconfig \
-lspiffs \
-lssl \
-lwpa \
-lwps \
-lhkc \
$(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group

DEPENDS_eagle.app.v6 = \
$(LD_FILE) \
$(LDDIR)/eagle.rom.addr.v6.ld

#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#

#UNIVERSAL_TARGET_DEFINES = \

# Other potential configuration flags include:
# -DTXRX_TXBUF_DEBUG
# -DTXRX_RXBUF_DEBUG
# -DWLAN_CONFIG_CCX
CONFIGURATION_DEFINES = -DICACHE_FLASH

DEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)

DDEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)


#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
## freertos added by HacK
INCLUDES += -I $(SDK_PATH)/include/freertos
sinclude $(SDK_PATH)/Makefile

.PHONY: FORCE
FORCE:

62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Sonoff-HomeKit implementation

Firmware to control your Sonoff natively and directly through HomeKit.

Only [iTead Sonoff Basic](http://sonoff.itead.cc/en/products/sonoff/sonoff-basic) is supported.

# Build instructions for Sonoff-Homekit

## Prerequisites
- [ESP8266-HomeKit](https://github.com/HomeACcessoryKid/ESP8266-HomeKit)

## Build Instructions

### Setting your WiFi
If you did not set up your WiFi, do so by uncommenting the first block of code in the user_init routine and filling the SSID and password. After, do not forget to to comment it out again and remove your password. Its bad for flash to write it each time and you would not want to upload your password to GitHub by accident.

### Compiling

```bash
~$ export SDK_PATH=<your SDK directory>
~$ export BIN_PATH=<where your binaries will be>
~$ cd HomeKit-Sonoff
~/HomeKit-Sonoff$ ./gen_misc.sh
```
Use all the defaults or experiment with alternatives...
This will create (after several minutes) the files:
* $BIN_PATH/eagle.flash.bin
* $BIN_PATH/eagle.irom0text.bin

If you answer all the questions by default, ESP8266-HomeKit will need more space than originally foreseen in ESP8266_RTOS_SDK 1.5.0 which was to start irom at 0x20000. To address this it is needed to change the `ESP8266_RTOS_SDK/ld/eagle.app.v6.ld` file:

```diff
diff ld/eagle.app.v6.ld.0 ld/eagle.app.v6.ld
29c29,30
< irom0_0_seg : org = 0x40220000, len = 0x5C000
---
> /*irom0_0_seg : org = 0x40220000, len = 0x5C000 */
> irom0_0_seg : org = 0x40214000, len = 0x67000
```

for convenience also change the master `ESP8266_RTOS_SDK/Makefile`:
```diff
diff ESP8266/source/ESP8266_RTOS_SDK-master-v1.5.0/Makefile Makefile
271c271
< @echo "eagle.irom0text.bin---->0x20000"
---
> @echo "eagle.irom0text.bin---->0x14000"
```
### Flashing:

```bash
esptool.py --baud 230400 -p /dev/yourUSBid write_flash 0x00000 $BIN_PATH/eagle.flash.bin 0x14000 $BIN_PATH/eagle.irom0text.bin
```

### Usage:

- After boot, if the device is not yet paired, an srp-key is calculated in about 25 seconds
- After that the server starts and mulicastdns starts to advertize
- The default pincode is `031-45-154`
- The code writes clients keys to sector 0x13000
- After you unpair from the original device, the keys will be destroyed and you can pair again.
- if something went wrong, go to the foundation, and change the `signature` string to something else and you can start from scratch
43 changes: 43 additions & 0 deletions driver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef PDIR
GEN_LIBS = libdriver.a
endif


#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#DEFINES +=

#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#

INCLUDES := $(INCLUDES) -I $(PDIR)include
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

Loading

0 comments on commit a78567f

Please sign in to comment.