Sonoff customized firmware

master
informatic 2017-09-29 21:01:56 +02:00
parent 3abe49fb0e
commit 6dd651647a
6 changed files with 135 additions and 0 deletions

42
sonoff/Makefile Normal file
View File

@ -0,0 +1,42 @@
#####################################################################
#### 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
ifeq ($(RBOOT_ENABLED), 1)
include $(SMING_HOME)/Makefile-rboot.mk
else
include $(SMING_HOME)/Makefile-project.mk
endif
$(APP_AR): $(OBJ)
$(vecho) "AR $@"
@echo "char* BUILD_ID = \"$(shell git rev-parse --short HEAD)-$(shell TZ=UTC date +%Y%m%d-%H%M%S)\";" > $(BUILD_BASE)/ver.c
cat $(BUILD_BASE)/ver.c
$(CC) -c $(BUILD_BASE)/ver.c -o $(BUILD_BASE)/ver.o
$(Q) $(AR) cru $@ $^ $(BUILD_BASE)/ver.o
ota: all
-mkdir ../master/ota/$(DEVICE) >/dev/null
cp -r out/firmware/* ../master/ota/$(DEVICE)
python ../master/client.py $(DEVICE) control ota
remoteota: all
scp -r out/firmware/rom*.bin root@sound:/var/www/api/1/ota/$(DEVICE)/
python ../master/remoteclient.py $(DEVICE) \$$implementation/ota true

16
sonoff/Makefile-user.mk Normal file
View File

@ -0,0 +1,16 @@
MODULES = app ../spejsiot ../spejsiot/endpoints
DISABLE_SPIFFS = 1
USER_CFLAGS = -I../common
#ENABLE_SSL = 1
RBOOT_ENABLED = 1
RBOOT_BIG_FLASH = 0
RBOOT_TWO_ROMS = 1
RBOOT_RTC_ENABLED = 1
# these next options only needed when using two rom mode
RBOOT_ROM_0 ?= rom0
RBOOT_LD_0 ?= rboot.rom0.ld
RBOOT_ROM_1 ?= rom1
RBOOT_LD_1 ?= rboot.rom1.ld
SPI_SIZE = 1M
SPI_MODE = dout

View File

@ -0,0 +1,10 @@
#include <SpejsNode.h>
#include <endpoints/OutputEndpoint.h>
SpejsNode node("switch");
void init() {
node.statusLED.config(13, LOW);
node.init();
node.registerEndpoint("relay", new OutputEndpoint(12));
}

View File

@ -0,0 +1,45 @@
#ifndef __USER_CONFIG_H__
#define __USER_CONFIG_H__
#ifdef __cplusplus
extern "C" {
#endif
// UART config
#define SERIAL_BAUD_RATE 115200
// ESP SDK config
#define LWIP_OPEN_SRC
#define USE_US_TIMER
// Default types
#define __CORRECT_ISO_CPP_STDLIB_H_PROTO
#include <limits.h>
#include <stdint.h>
// Override c_types.h include and remove buggy espconn
#define _C_TYPES_H_
#define _NO_ESPCON_
// Updated, compatible version of c_types.h
// Just removed types declared in <stdint.h>
#include <espinc/c_types_compatible.h>
// System API declarations
#include <esp_systemapi.h>
// C++ Support
#include <esp_cplusplus.h>
// Extended string conversion for compatibility
#include <stringconversion.h>
// Network base API
#include <espinc/lwip_includes.h>
// Beta boards
#define BOARD_ESP01
#ifdef __cplusplus
}
#endif
#endif

11
sonoff/rboot.rom0.ld Normal file
View File

@ -0,0 +1,11 @@
/* Linker Script for rboot */
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 = 0x40202010, len = (512K - 0x2010)
}
INCLUDE "common.ld"

11
sonoff/rboot.rom1.ld Normal file
View File

@ -0,0 +1,11 @@
/* Linker Script for rboot */
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 = 0x40202010+512K, len = (512K - 0x2010)
}
INCLUDE "common.ld"