Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sming Host Emulator #1692

Merged
merged 19 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .appveyor/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
REM Windows build script

SET SMING_HOME=%APPVEYOR_BUILD_FOLDER%\Sming

IF "%SMING_ARCH%" == "Esp8266" SET ESP_HOME=c:\Espressif

cd %SMING_HOME%
gcc -v

make help
make list-config

REM Compile the tools first
make tools V=1 || goto :error

cd %SMING_HOME%
make STRICT=1 || goto :error


if "%SMING_ARCH%" == "Host" (

REM Build a couple of basic applications
make Basic_Serial || goto :error
make Basic_ProgMem || goto :error

REM Run basic tests
cd %SMING_HOME%\..\tests\HostTests
make flash || goto :error

) ELSE (

make Basic_Blink V=1 || goto :error
make Basic_Ssl || goto :error
make Basic_SmartConfig || goto :error

)

goto :EOF

:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%
26 changes: 26 additions & 0 deletions .appveyor/install.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
REM Windows install script

goto :%SMING_ARCH%

:Esp8266

IF "%SDK_VERSION%" == "1.5.0" (
choco install esp8266-udk --source https://www.myget.org/F/kireevco-chocolatey/ -y --no-progress
mkdir c:\Espressif\utils\ESP8266
copy /b c:\Espressif\utils\memanalyzer.exe c:\Espressif\utils\ESP8266\memanalyzer.exe
copy /b c:\Espressif\utils\esptool.exe c:\Espressif\utils\ESP8266\esptool.exe
) ELSE (
choco install esp8266-udk --source https://www.myget.org/F/sming/ -y --no-progress
)

goto :EOF


:Host

REM Ensure MinGW installation is up to date
mingw-get update
mingw-get upgrade

goto :EOF

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ vssver2.scc

.metadata
.submodule
/Sming/Arch/Host/Components/lwip/Windows/src
/Sming/Arch/Host/Components/lwip/Windows/tmp
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@
[submodule "Libraries.ArduinoJson"]
path = Sming/Libraries/ArduinoJson
url = https://github.com/bblanchon/ArduinoJson.git

[submodule "Host.lwip"]
path = Sming/Arch/Host/Components/lwip/lwip
url = git://git.savannah.gnu.org/lwip.git
ignore = dirty
80 changes: 32 additions & 48 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@ env:
global:
- SDK_BUILD=258
- secure: D/cPk+sL2MNHLtfuU/rMiVN63+CTFpo9Chqa39LEH5VloGqC5f7RyIi2Maa3C/U2JQfM01HlsNR7E5bB0W8DQYbtzBDTqbZ4C7ppZRU5jCQ+L51ERKJ0EAV3KkaravQCRbWt3tlgOp6Xk6xaRMBaHEGrdbFjHYgEMPVteUQNr0A=
matrix:
jobs:
include:
- os: linux
env: SDK_VERSION=1.5.0
- os: linux
env: SDK_VERSION=2.0.0
- os: linux
env: SDK_VERSION=3.0.0
- stage: test
os: linux
dist: xenial
addons:
apt:
packages:
- clang-format-6.0
- gcc-multilib
- g++-multilib
env: SMING_ARCH=Host

- stage: build
os: linux
env: SMING_ARCH=Esp8266 SDK_VERSION=1.5.0

- stage: build
os: linux
env: SMING_ARCH=Esp8266 SDK_VERSION=2.0.0

- stage: build
os: linux
env: SMING_ARCH=Esp8266 SDK_VERSION=3.0.0

git:
submodules: false

addons:
apt:
sources:
Expand All @@ -27,53 +45,19 @@ addons:
- doxygen-gui
- graphviz
- xmlstarlet
- clang-format-6.0
install:
- sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0 100
- if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "osx" ]; then export
SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-macos-x86_64.zip"; fi
- if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then export
SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-linux-x86_64.tar.gz"; fi
- mkdir -p $TRAVIS_BUILD_DIR/opt/esp-alt-sdk
- if [ "$SDK_VERSION" == "1.5.0" ]; then wget https://bintray.com/artifact/download/kireevco/generic/${SDK_FILE_NAME};
fi
- if [ "$SDK_VERSION" == "1.5.0" ]; then bsdtar -xf ${SDK_FILE_NAME} -C $TRAVIS_BUILD_DIR/opt/esp-alt-sdk;
fi
- if [[ "$SDK_VERSION" != "1.5.0" && "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/nodemcu/nodemcu-firmware/raw/2d958750b56fc60297f564b4ec303e47928b5927/tools/esp-open-sdk.tar.xz;
tar -Jxvf esp-open-sdk.tar.xz; ln -s `pwd`/esp-open-sdk/xtensa-lx106-elf $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/.
; fi
- if [ "$SDK_VERSION" == "2.0.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then wget
https://www.espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v2.0.0_16_08_10.zip
-O sdk.zip; unzip sdk.zip; ln -s `pwd`/ESP8266_NONOS_SDK/ $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/sdk;
export DEPLOY='true'; fi
script:
- env
- unset SPIFFY
- unset ESPTOOL2

- export SMING_HOME=$TRAVIS_BUILD_DIR/Sming
- export ESP_HOME=$TRAVIS_BUILD_DIR/opt/esp-alt-sdk
- if [ "$SDK_VERSION" == "3.0.0" ]; then export SDK_BASE=$SMING_HOME/third-party/ESP8266_NONOS_SDK;
fi
- export PATH=$PATH:$ESP_HOME/xtensa-lx106-elf/bin:$ESP_HOME/utils/:$SMING_HOME/../.travis/tools
- cd $SMING_HOME
- if [ "$SDK_VERSION" == "2.0.0" ]; then ../.travis/tools/clang/format-pr.sh; fi
- cd $SMING_HOME
- make help
- make list-config
- make STRICT=1
- make samples
- make clean samples-clean
- make ENABLE_CUSTOM_HEAP=1 STRICT=1
- make Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3
- make dist-clean; make HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1
install: .travis/install.sh

script: .travis/build.sh

deploy:
provider: script
script: sh $TRAVIS_BUILD_DIR/.travis/deploy.sh $TRAVIS_TAG
script: .travis/deploy.sh $TRAVIS_TAG
skip_cleanup: true
on:
tags: true
condition: "$DEPLOY == true"
condition: "$SDK_VERSION==2.0.0"

notifications:
webhooks:
urls:
Expand Down
48 changes: 48 additions & 0 deletions .travis/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -ex # exit with nonzero exit code if anything fails

env
unset SPIFFY
unset ESPTOOL2

export SMING_HOME=$TRAVIS_BUILD_DIR/Sming

# Check coding style
if [ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]; then
.travis/tools/clang/format-pr.sh;
fi

# Setup ARCH SDK paths
if [ "$SMING_ARCH" == "Esp8266" ]; then
export ESP_HOME=$TRAVIS_BUILD_DIR/opt/esp-alt-sdk
if [ "$SDK_VERSION" == "3.0.0" ]; then
export SDK_BASE=$SMING_HOME/third-party/ESP8266_NONOS_SDK
fi

export PATH=$PATH:$ESP_HOME/xtensa-lx106-elf/bin:$ESP_HOME/utils/
fi

# Full compile checks please
export STRICT=1

# Diagnostic info
cd $SMING_HOME
make help
make list-config

# Build the framework
make
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could try also parallel build splitting this command to the following two:

make submodules
make -j

Copy link
Contributor Author

@mikee47 mikee47 May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could.... I gave it a brief try with appveyor but after one initial failure didn't bother any further as I figured what we really need is a clear and accurate log for when it goes wrong. I had a hell of a job with the initial CI updates on appveyor, had to remote terminal into the server to find out how to fix things so really rather not have to do that if poss.!

The --output-sync option might help but haven't tried it - I have make 3.81 under MinGW which doesn't have the option anyway. I use parallel building all the time under Windows, on an 8-core system it kind of speeds things up just a teeny bit :-)

I suspect on a VM parallel builds wouldn't help much anyway. My Linux install is running under VirtualBox and really doesn't like parallel builds at all, but that's my problem!

I suspect we'd also need lwip:

make submodules
make lwip
make -j


if [ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]; then
make Basic_Blink Basic_DateTime Basic_Delegates Basic_Interrupts Basic_ProgMem Basic_Serial Basic_Servo LiveDebug DEBUG_VERBOSE_LEVEL=3
cd ../tests/HostTests
make flash
else
make samples
make clean samples-clean
make ENABLE_CUSTOM_HEAP=1 STRICT=1
make Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3

make dist-clean
make HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1
fi
2 changes: 1 addition & 1 deletion .travis/deploy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e # exit with nonzero exit code if anything fails
set -ex # exit with nonzero exit code if anything fails

TAG=$1
if [ -z $TAG ]; then
Expand Down
34 changes: 34 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -ex # exit with nonzero exit code if anything fails

if [ "$TRAVIS_BUILD_STAGE_NAME" == "Test" ]; then
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0 100
fi

if [ "$SMING_ARCH" == "Esp8266" ]; then
if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "osx" ]; then
SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-macos-x86_64.zip"
fi

if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-linux-x86_64.tar.gz"
fi

mkdir -p $TRAVIS_BUILD_DIR/opt/esp-alt-sdk

if [ "$SDK_VERSION" == "1.5.0" ]; then
wget --no-verbose https://bintray.com/artifact/download/kireevco/generic/${SDK_FILE_NAME}
bsdtar -xf ${SDK_FILE_NAME} -C $TRAVIS_BUILD_DIR/opt/esp-alt-sdk
fi

if [ "$SDK_VERSION" != "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
wget --no-verbose https://github.com/nodemcu/nodemcu-firmware/raw/2d958750b56fc60297f564b4ec303e47928b5927/tools/esp-open-sdk.tar.xz
tar -Jxvf esp-open-sdk.tar.xz; ln -s $(pwd)/esp-open-sdk/xtensa-lx106-elf $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/.
fi

if [ "$SDK_VERSION" == "2.0.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
wget --no-verbose https://www.espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v2.0.0_16_08_10.zip -O sdk.zip
unzip sdk.zip
ln -s $(pwd)/ESP8266_NONOS_SDK/ $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/sdk
fi
fi # Esp8266
11 changes: 11 additions & 0 deletions Sming/Arch/Esp8266/Components/driver/include/driver/pwm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#if defined(__cplusplus)
extern "C" {
#endif

#include <pwm.h>

#if defined(__cplusplus)
}
#endif
12 changes: 12 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_wifi/include/esp_smartconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#if defined (__cplusplus)
extern "C" {
#endif

#include <smartconfig.h>

#if defined (__cplusplus)
}
#endif

11 changes: 11 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_wifi/include/esp_wifi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <user_interface.h>

#ifdef __cplusplus
}
#endif
42 changes: 1 addition & 41 deletions Sming/Arch/Esp8266/Platform/WifiEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,7 @@ WifiEventsClass WifiEvents;

WifiEventsClass::WifiEventsClass()
{
wifi_set_event_handler_cb(staticWifiEventHandler);
}

void WifiEventsClass::onStationConnect(StationConnectDelegate delegateFunction)
{
onSTAConnect = delegateFunction;
}

void WifiEventsClass::onStationDisconnect(StationDisconnectDelegate delegateFunction)
{
onSTADisconnect = delegateFunction;
}

void WifiEventsClass::onStationAuthModeChange(StationAuthModeChangeDelegate delegateFunction)
{
onSTAAuthModeChange = delegateFunction;
}

void WifiEventsClass::onStationGotIP(StationGotIPDelegate delegateFunction)
{
onSTAGotIP = delegateFunction;
}

void WifiEventsClass::onAccessPointConnect(AccessPointConnectDelegate delegateFunction)
{
onSOFTAPConnect = delegateFunction;
}

void WifiEventsClass::onAccessPointDisconnect(AccessPointDisconnectDelegate delegateFunction)
{
onSOFTAPDisconnect = delegateFunction;
}

void WifiEventsClass::onAccessPointProbeReqRecved(AccessPointProbeReqRecvedDelegate delegateFunction)
{
onSOFTAPProbeReqRecved = delegateFunction;
}

void WifiEventsClass::staticWifiEventHandler(System_Event_t* evt)
{
WifiEvents.WifiEventHandler(evt);
wifi_set_event_handler_cb([](System_Event_t* evt) { WifiEvents.WifiEventHandler(evt); });
}

void WifiEventsClass::WifiEventHandler(System_Event_t* evt)
Expand Down
4 changes: 0 additions & 4 deletions Sming/Arch/Esp8266/app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#
###

ifndef ESP_HOME
$(error ESP_HOME variable is not set to a valid directory.)
endif

##@Building

.PHONY: all
Expand Down
9 changes: 2 additions & 7 deletions Sming/Arch/Esp8266/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#
##############

CFLAGS += -DARCH_ESP8266
CFLAGS += -DARCH_ESP8266
CXXFLAGS += -fno-rtti -fno-exceptions

ifndef ESP_HOME
$(error ESP_HOME variable is not set to a valid directory.)
Expand All @@ -17,12 +18,6 @@ endif
## MacOS / Linux:
# ESP_HOME = /opt/esp-open-sdk

#ifeq ($(OS),Windows_NT)
# # Convert Windows paths to POSIX paths
# ESP_HOME := $(subst \,/,$(addprefix /,$(subst :,,$(ESP_HOME))))
# ESP_HOME := $(subst //,/,$(ESP_HOME))
#endif

CONFIG_VARS += ESP_HOME
ESP_HOME := $(call FixPath,$(ESP_HOME))
export ESP_HOME
Expand Down
Loading