Skip to content

Commit

Permalink
Initial restructure to support multiple target architectures (#1675)
Browse files Browse the repository at this point in the history
As per discussion #1333.

Rearrange files and fix #includes:

* Rename `SmingCore` -> `Core`
* Rename `SmingCore/Platform` -> `Platform`
* Rename `system` -> `System`
* Move `Services/libb64` -> `Components`
* Move `Services/WebHelpers` -> `Core/Network`
* Remove `apptest`
* Move Esp8266-specific code:
	* Move most `Platform` sources -> `Arch/Esp8266/Platform`
	* Move some `SmingCore` sources -> `Arch/Esp2866/Core`
	* Rename `compiler` -> `Arch/Esp8266/Compiler`
	* Rename `tools` -> `Arch/Esp8266/Tools`
	* Move `SmingCore/Network/rBootHttpUpdate` -> `Arch/Esp2866/Core/Network`
	* Move `custom_heap` -> `Arch/Esp8266/Components`
	* Move some of `system` files -> `Arch/Esp8266/Components/esp8266` (reflects IDF layout)
	* Rename `appinit/user_main.cpp` -> `Arch/Esp8266/Components/esp8266/startup.cpp`
	* Rename `gdb` -> `Arch/Esp8266/Components/gdbstub`
	* Rename `appspecific/gdb` -> `Arch/Esp8266/Components/gdbstub/appcode`
	* Rename `Services/FATFS` -> `Arch/Esp8266/Components/fatfs`
	* Move `system/include/rboot-integration.h`, `appspecific/rboot/overrides.c` -> `Arch/Esp8266/Components/rboot/appcode`
	* Rename `Services/SpifFS` -> `Arch/Esp8266/Components/spiffs`
	* Move `include/user_config.h` -> `Arch/Esp8266/System/include`


Makefile revisions

* Remove `Makefile-project.mk`
* Rename `Makefile-rboot.mk` -> `Makefile-app.mk`
* Retain `Makefile-rboot.mk` (redirects to `Makefile-app.mk`) for backward compatibility
* Separate common script used by both Sming and App
	* `build.mk` contains host environment setup
	* Add directory definitions `ARCH_BASE`, `ARCH_SYS`, `ARCH_CORE`, `ARCH_COMPONENTS` and `ARCH_TOOLS`
	* `modules.mk` contains rule creation script
* Separate-out ESP8266-specific script:
	* `Arch/*/build.mk` included by `build.mk` file
	* `Arch/*/sming.mk` included by `Makefile`
	* `Arch/*/app.mk` included by `Makefile-app.mk`
* Change build output directory to `Arch/*/out`
* Pull related variable definitions and rules together
* Define macros to replace repetitive script: endeavour to name files or directories once only
* Ignore errors in all clean operations
* Use `TOOLS`, `TOOLS_CLEAN` and `CLEAN` variables containing pre-requisites for `tools`, `tools-clean` and `clean` targets
* Simplify user library building by adding to `LIBS`, each library gets an additional shorthand make target e.g. `make axtls`.
* Distribute PHONY declarations
* Add `decode-stacktrack` rule to application makefile
* Add `help` target to extract formatted makefile comments
* Add `list-config` target

Submodule handling

* third-party libraries: `rBoot`, `new-pwm`, `axtls-8266`, `umm_malloc`, `esp-open-lwip`, `lwip2` -> `Arch/Esp8266/Components`
* Move `.patch` file into related submodule parent directory
* Internal SDK moved into `Components/Sdk` and updated to use unpatched Version 3.0 release
* Move remaining `third-party` submodules into `Components`
* Revise Makefiles so that only those submodules required for a build are updated/patched and built
	* Add `SUBMODULES` variable to specify which submodules are required
	* Use `.submodule` file as consistent pre-requisite for update/patching of all submodules
	* Make `ARDUINO_LIBRARIES` a public variable to optionally restrict which libraries get loaded and built
	* Add `submodules` and `submodules-clean` rules to replace `third-party` and `libraries` rules

Other

* Add `building.md`
* Add help documentation to makefiles, with new `help` and `list-config` targets
* Update coding style directories and Travis checks
* Update Doxygen directories

Fixes:

* Add `libpwm_open` to `CUSTOM_TARGETS` so it builds with framework

Bugs found:

* Testing with `ENABLE_CUSTOM_LWIP=0` fails because of static definitions in `mem_manager.h` - also happens with existing build
  • Loading branch information
mikee47 authored and slaff committed May 1, 2019
1 parent 4311a9c commit 0e9832e
Show file tree
Hide file tree
Showing 424 changed files with 7,640 additions and 8,476 deletions.
110 changes: 58 additions & 52 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,94 +1,100 @@
[submodule "Sming/third-party/rboot"]
path = Sming/third-party/rboot
url = https://github.com/raburton/rboot.git
ignore = dirty
[submodule "Sming.wiki"]
path = docs/wiki
url = https://github.com/SmingHub/Sming.wiki.git
ignore = dirty
[submodule "Sming/third-party/pwm"]
path = Sming/third-party/pwm
[submodule "spiffs"]
path = Sming/Components/spiffs
url = https://github.com/pellepl/spiffs.git
ignore = dirty
[submodule "http-parser"]
path = Sming/Components/http-parser
url = https://github.com/nodejs/http-parser.git
ignore = dirty
[submodule "ws_parser"]
path = Sming/Components/ws_parser
url = https://github.com/charliesome/ws_parser.git
ignore = dirty
[submodule "mqtt-codec"]
path = Sming/Components/mqtt-codec
url = https://github.com/slaff/mqtt-codec.git
ignore = dirty
[submodule "libyuarel"]
path = Sming/Components/libyuarel
url = https://github.com/jacketizer/libyuarel.git
ignore = dirty

[submodule "ESP8266.rboot"]
path = Sming/Arch/Esp8266/Components/rboot/rboot
url = https://github.com/raburton/rboot.git
ignore = dirty
[submodule "ESP8266.new-pwm"]
path = Sming/Arch/Esp8266/Components/pwm/new-pwm
url = https://github.com/StefanBruens/ESP8266_new_pwm.git
ignore = dirty
[submodule "Sming/third-party/axtls-8266"]
path = Sming/third-party/axtls-8266
ignore = dirty
[submodule "ESP8266.axtls-8266"]
path = Sming/Arch/Esp8266/Components/axtls-8266/axtls-8266
url = https://github.com/igrr/axtls-8266.git
ignore = dirty
[submodule "Sming/third-party/spiffs"]
path = Sming/third-party/spiffs
url = https://github.com/pellepl/spiffs.git
[submodule "Sming/third-party/umm_malloc"]
path = Sming/third-party/umm_malloc
ignore = dirty
[submodule "ESP8266.umm_malloc"]
path = Sming/Arch/Esp8266/Components/custom_heap/umm_malloc
url = https://github.com/rhempel/umm_malloc.git
ignore = dirty
[submodule "Sming/third-party/esp-open-lwip"]
path = Sming/third-party/esp-open-lwip
[submodule "ESP8266.esp-open-lwip"]
path = Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip
url = https://github.com/pfalcon/esp-open-lwip.git
ignore = dirty
[submodule "Sming/third-party/http-parser"]
path = Sming/third-party/http-parser
url = https://github.com/nodejs/http-parser.git
[submodule "ESP8266.lwip2"]
path = Sming/Arch/Esp8266/Components/lwip2/lwip2
url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git
ignore = dirty
[submodule "Sming/third-party/ws_parser"]
path = Sming/third-party/ws_parser
url = https://github.com/charliesome/ws_parser.git

[submodule "ESP8266.Sdk"]
path = Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK
url = https://github.com/espressif/ESP8266_NONOS_SDK.git
ignore = dirty
[submodule "Sming/Libraries/Adafruit_ST7735"]
[submodule "ESP8266.esptool2"]
path = Sming/Arch/Esp8266/Tools/esptool2
url = https://github.com/raburton/esptool2.git
ignore = dirty

[submodule "Libraries.Adafruit_ST7735"]
path = Sming/Libraries/Adafruit_ST7735
url = https://github.com/adafruit/Adafruit-ST7735-Library.git
ignore = dirty
[submodule "Sming/Libraries/Adafruit_SSD1306"]
[submodule "Libraries.Adafruit_SSD1306"]
path = Sming/Libraries/Adafruit_SSD1306
url = https://github.com/adafruit/Adafruit_SSD1306.git
ignore = dirty
[submodule "Sming/Libraries/Adafruit_BME280_Library"]
[submodule "Libraries.Adafruit_BME280_Library"]
path = Sming/Libraries/Adafruit_BME280_Library
url = https://github.com/adafruit/Adafruit_BME280_Library.git
ignore = dirty
[submodule "Sming/Libraries/Adafruit_Sensor"]
[submodule "Libraries.Adafruit_Sensor"]
path = Sming/Libraries/Adafruit_Sensor
url = https://github.com/adafruit/Adafruit_Sensor
ignore = dirty
[submodule "Sming/third-party/lwip2"]
path = Sming/third-party/lwip2
url = https://github.com/d-a-v/esp82xx-nonos-linklayer.git
ignore = dirty
[submodule "Sming/third-party/ESP8266_NONOS_SDK"]
path = Sming/third-party/ESP8266_NONOS_SDK
url = https://github.com/espressif/ESP8266_NONOS_SDK.git
ignore = dirty
[submodule "tools/esptool2"]
path = tools/esptool2
url = https://github.com/raburton/esptool2.git
ignore = dirty
[submodule "Sming/Libraries/RingBufCPP"]
[submodule "Libraries.RingBufCPP"]
path = Sming/Libraries/RingBufCPP
url = https://github.com/wizard97/Embedded_RingBuf_CPP.git
ignore = dirty
[submodule "Sming/Libraries/IR"]
[submodule "Libraries.IR"]
path = Sming/Libraries/IR
url = https://github.com/markszabo/IRremoteESP8266.git
ignore = dirty
[submodule "Sming/Libraries/DHTesp"]
[submodule "Libraries.DHTesp"]
path = Sming/Libraries/DHTesp
url = https://github.com/beegee-tokyo/DHTesp.git
ignore = dirty
[submodule "Sming/third-party/ITEADLIB_Arduino_Nextion"]
[submodule "Libraries.ITEADLIB_Arduino_Nextion"]
path = Sming/Libraries/ITEADLIB_Arduino_Nextion
url = https://github.com/itead/ITEADLIB_Arduino_Nextion.git
ignore = dirty
[submodule "Sming/Libraries/DFRobotDFPlayerMini"]
[submodule "Libraries.DFRobotDFPlayerMini"]
path = Sming/Libraries/DFRobotDFPlayerMini
url = https://github.com/DFRobot/DFRobotDFPlayerMini.git
ignore = dirty
[submodule "Sming/Libraries/TM1637"]
[submodule "Libraries.TM1637"]
path = Sming/Libraries/TM1637
url = https://github.com/avishorp/TM1637.git
ignore = dirty
[submodule "Sming/third-party/mqtt-codec"]
path = Sming/third-party/mqtt-codec
url = https://github.com/slaff/mqtt-codec.git
ignore = dirty
[submodule "Sming/third-party/libyuarel"]
path = Sming/third-party/libyuarel
url = https://github.com/jacketizer/libyuarel.git

2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ script:
- 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
Expand Down
2 changes: 1 addition & 1 deletion .travis/tools/clang/format-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $CLANG_FORMAT --version
cd $SMING_HOME/..

# Get list of modified files
files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^[^.]*[.]\(c\|cpp\|h\)$' | grep -e Sming/SmingCore -e samples || true)"
files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^[^.]*[.]\(c\|cpp\|h\)$' | grep -e Sming/Core -e Sming/Platform -e Sming/Arch/.+/Core -e Sming/Arch/.+/Platform -e samples || true)"

for f in $files_to_lint; do

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Sming/Arch/Esp8266/Components/Sdk/ESP8266_NONOS_SDK
Submodule ESP8266_NONOS_SDK added at e4434a
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
* Note: uart_detach_all() should be called at startup, i.e. from user_init().
*/

#ifndef ESP_UART_H
#define ESP_UART_H
#pragma once

#if defined (__cplusplus)
extern "C" {
Expand Down Expand Up @@ -427,5 +426,3 @@ void uart_restore_interrupts();
#if defined (__cplusplus)
} // extern "C"
#endif

#endif // ESP_UART_H
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "Clock.h"
#include "Digital.h"

#include "espinc/uart.h"
#include "driver/uart.h"
#include "espinc/peri.h"

#include "Data/Buffer/SerialBuffer.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#include <user_config.h>
#include "gdb_hooks.h"
#include "gdb/gdb_hooks.h"

extern void __real_system_restart_local();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../include/user_config.h"
#include "../include/esp_cplusplus.h"
#include <user_config.h>
#include "include/esp_cplusplus.h"
#include <stdlib.h>

////////////////////////////////////////////////////////////////////////
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*
****/

#ifndef _SYSTEM_INCLUDE_ESP_CPLUSPLUS_H_
#define _SYSTEM_INCLUDE_ESP_CPLUSPLUS_H_
#pragma once

#ifdef __cplusplus
extern "C" {
Expand All @@ -23,5 +22,3 @@ extern void (*__init_array_start)(void);
extern void (*__init_array_end)(void);

void cpp_core_initialize();

#endif /* _SYSTEM_INCLUDE_ESP_CPLUSPLUS_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
*
****/

#ifndef _SYSTEM_INCLUDE_ESP_SYSTEMAPI_H_
#define _SYSTEM_INCLUDE_ESP_SYSTEMAPI_H_
#pragma once

#include <ets_sys.h>
#include <osapi.h>
Expand Down Expand Up @@ -126,5 +125,3 @@ extern void ets_isr_mask(unsigned intr);
extern void ets_isr_unmask(unsigned intr);

typedef signed short file_t;

#endif /* _SYSTEM_INCLUDE_ESP_SYSTEMAPI_H_ */
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
/*
* esp_promiscuous.h
*
* Internal structures for decoding WiFi in promiscuous mode
*
* See ESP8266 Technical Reference, Chapter 14: Sniffer Introduction
*/

#ifndef _ESP_WIFI_SNIFFER_H_
#define _ESP_WIFI_SNIFFER_H_

#include <user_config.h>

/* ==============================================
Promiscous callback structures, see ESP manual
============================================== */
struct RxControl {
signed rssi : 8;
unsigned rate : 4;
unsigned is_group : 1;
unsigned : 1;
unsigned sig_mode : 2;
unsigned legacy_length : 12;
unsigned damatch0 : 1;
unsigned damatch1 : 1;
unsigned bssidmatch0 : 1;
unsigned bssidmatch1 : 1;
unsigned MCS : 7;
unsigned CWB : 1;
unsigned HT_length : 16;
unsigned Smoothing : 1;
unsigned Not_Sounding : 1;
unsigned : 1;
unsigned Aggregation : 1;
unsigned STBC : 2;
unsigned FEC_CODING : 1;
unsigned SGI : 1;
unsigned rxend_state : 8;
unsigned ampdu_cnt : 8;
unsigned channel : 4;
unsigned : 12;
};

struct LenSeq {
uint16_t length;
uint16_t seq;
uint8_t address3[6];
};

struct sniffer_buf {
struct RxControl rx_ctrl;
uint8_t buf[36];
uint16_t cnt;
struct LenSeq lenseq[1];
};

struct sniffer_buf2 {
struct RxControl rx_ctrl;
uint8_t buf[112];
uint16_t cnt;
uint16_t len;
};

#endif /* _ESP_WIFI_SNIFFER_H_ */
/*
* esp_promiscuous.h
*
* Internal structures for decoding WiFi in promiscuous mode
*
* See ESP8266 Technical Reference, Chapter 14: Sniffer Introduction
*/

#pragma once

#include <user_config.h>

/* ==============================================
Promiscous callback structures, see ESP manual
============================================== */
struct RxControl {
signed rssi : 8;
unsigned rate : 4;
unsigned is_group : 1;
unsigned : 1;
unsigned sig_mode : 2;
unsigned legacy_length : 12;
unsigned damatch0 : 1;
unsigned damatch1 : 1;
unsigned bssidmatch0 : 1;
unsigned bssidmatch1 : 1;
unsigned MCS : 7;
unsigned CWB : 1;
unsigned HT_length : 16;
unsigned Smoothing : 1;
unsigned Not_Sounding : 1;
unsigned : 1;
unsigned Aggregation : 1;
unsigned STBC : 2;
unsigned FEC_CODING : 1;
unsigned SGI : 1;
unsigned rxend_state : 8;
unsigned ampdu_cnt : 8;
unsigned channel : 4;
unsigned : 12;
};

struct LenSeq {
uint16_t length;
uint16_t seq;
uint8_t address3[6];
};

struct sniffer_buf {
struct RxControl rx_ctrl;
uint8_t buf[36];
uint16_t cnt;
struct LenSeq lenseq[1];
};

struct sniffer_buf2 {
struct RxControl rx_ctrl;
uint8_t buf[112];
uint16_t cnt;
uint16_t len;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// Updated, compatible version of c_types.h
// Just removed types declared in <stdint.h>

#ifndef _SYSTEM_INCLUDE_ESPINC_C_TYPES_COMPATIBLE_H_
#define _SYSTEM_INCLUDE_ESPINC_C_TYPES_COMPATIBLE_H_
#pragma once

/*typedef unsigned char uint8_t;
typedef signed char sint8_t;
Expand Down Expand Up @@ -100,5 +99,3 @@ typedef unsigned char bool;


#endif /* !__cplusplus */

#endif /* _SYSTEM_INCLUDE_ESPINC_C_TYPES_COMPATIBLE_H_ */
Loading

0 comments on commit 0e9832e

Please sign in to comment.