Skip to content

Commit eaf1b94

Browse files
tekka007mfalkvidd
authored andcommitted
ESP32: Support HW (#865)
This fixes #968
1 parent d1aa419 commit eaf1b94

22 files changed

+643
-30
lines changed

.ci/arduino.groovy

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def parseWarnings(String key) {
2626
excludePattern: '''.*/EEPROM\\.h,.*/Dns\\.cpp,.*/socket\\.cpp,.*/util\\.h,.*/Servo\\.cpp,
2727
.*/Adafruit_NeoPixel\\.cpp,.*/UIPEthernet.*,.*/SoftwareSerial\\.cpp,
2828
.*/pins_arduino\\.h,.*/Stream\\.cpp,.*/USBCore\\.cpp,.*/Wire\\.cpp,
29-
.*/hardware/STM32F1.*,.*/hardware/esp8266.*,.*/libraries/SD/.*''',
29+
.*/hardware/STM32F1.*,.*/hardware/esp8266.*,.*/hardware/espressif/esp32.*,
30+
.*/libraries/SD/.*''',
31+
3032
healthy: '', includePattern: '', messagesPattern: '',
3133
parserConfigurations: [[parserName: 'Arduino/AVR', pattern: 'compiler_'+key+'.log']],
3234
unHealthy: '', unstableNewAll: '0', unstableTotalAll: '0'
@@ -47,6 +49,8 @@ def buildMySensorsMicro(config, sketches, String key) {
4749
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
4850
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
4951
sketches[sketch].path != config.library_root+'examples/GatewayGSMMQTTClient/GatewayGSMMQTTClient.ino' &&
52+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
53+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
5054
sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino') {
5155
buildArduino(config, fqbn, sketches[sketch].path, key+'_MySensorsMicro')
5256
}
@@ -80,6 +84,8 @@ def buildMySensorsGw(config, sketches, String key) {
8084
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
8185
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
8286
sketches[sketch].path != config.library_root+'examples/GatewayGSMMQTTClient/GatewayGSMMQTTClient.ino' &&
87+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
88+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
8389
sketches[sketch].path != config.library_root+'examples/GatewaySerialRS485/GatewaySerialRS485.ino' &&
8490
sketches[sketch].path != config.library_root+'examples/MotionSensorRS485/MotionSensorRS485.ino') {
8591
buildArduino(config, fqbn, sketches[sketch].path, key+'_MySensorsGw')
@@ -112,6 +118,8 @@ def buildArduinoUno(config, sketches, String key) {
112118
if (sketches[sketch].path != config.library_root+'examples/GatewayESP8266/GatewayESP8266.ino' &&
113119
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
114120
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
121+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
122+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
115123
sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino') {
116124
buildArduino(config, fqbn, sketches[sketch].path, key+'_ArduinoUno')
117125
}
@@ -143,6 +151,8 @@ def buildArduinoMega(config, sketches, String key) {
143151
if (sketches[sketch].path != config.library_root+'examples/GatewayESP8266/GatewayESP8266.ino' &&
144152
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
145153
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
154+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
155+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
146156
sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino') {
147157
buildArduino(config, fqbn, sketches[sketch].path, key+'_ArduinoMega')
148158
}
@@ -174,6 +184,8 @@ def buildSTM32F1(config, sketches, String key) {
174184
if (sketches[sketch].path != config.library_root+'examples/GatewayESP8266/GatewayESP8266.ino' &&
175185
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
176186
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
187+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
188+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
177189
sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino') {
178190
buildArduino(config, fqbn, sketches[sketch].path, key+'_STM32F1')
179191
}
@@ -209,6 +221,8 @@ def buildEsp8266(config, sketches, String key) {
209221
sketches[sketch].path != config.library_root+'examples/GatewayW5100/GatewayW5100.ino' &&
210222
sketches[sketch].path != config.library_root+'examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino' &&
211223
sketches[sketch].path != config.library_root+'examples/GatewayGSMMQTTClient/GatewayGSMMQTTClient.ino' &&
224+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
225+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
212226
sketches[sketch].path != config.library_root+'examples/MotionSensorRS485/MotionSensorRS485.ino' &&
213227
sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino' &&
214228
sketches[sketch].path != config.library_root+'examples/SoilMoistSensor/SoilMoistSensor.ino') {
@@ -234,6 +248,54 @@ def buildEsp8266(config, sketches, String key) {
234248
}
235249
}
236250

251+
def buildEsp32(config, sketches, String key) {
252+
def fqbn = '-fqbn espressif:esp32:node32s -warnings=default -prefs build.f_cpu=80000000 -prefs build.mcu=esp32'
253+
config.pr.setBuildStatus(config, 'PENDING', 'Toll gate (ESP32 - '+key+')', 'Building...', '${BUILD_URL}flowGraphTable/')
254+
try {
255+
for (sketch = 0; sketch < sketches.size(); sketch++) {
256+
if (sketches[sketch].path != config.library_root+'examples/BatteryPoweredSensor/BatteryPoweredSensor.ino' &&
257+
sketches[sketch].path != config.library_root+'examples/BinarySwitchSleepSensor/BinarySwitchSleepSensor.ino' &&
258+
sketches[sketch].path != config.library_root+'examples/CO2Sensor/CO2Sensor.ino' &&
259+
sketches[sketch].path != config.library_root+'examples/DustSensor/DustSensor.ino' &&
260+
sketches[sketch].path != config.library_root+'examples/DustSensorDSM/DustSensorDSM.ino' &&
261+
sketches[sketch].path != config.library_root+'examples/EnergyMeterPulseSensor/EnergyMeterPulseSensor.ino' &&
262+
sketches[sketch].path != config.library_root+'examples/LightSensor/LightSensor.ino' &&
263+
sketches[sketch].path != config.library_root+'examples/LogOTANode/LogOTANode.ino' &&
264+
sketches[sketch].path != config.library_root+'examples/MotionSensor/MotionSensor.ino' &&
265+
sketches[sketch].path != config.library_root+'examples/MotionSensorRS485/MotionSensorRS485.ino' &&
266+
sketches[sketch].path != config.library_root+'examples/PassiveNode/PassiveNode.ino' &&
267+
sketches[sketch].path != config.library_root+'examples/GatewaySerialRS485/GatewaySerialRS485.ino' &&
268+
sketches[sketch].path != config.library_root+'examples/GatewayW5100/GatewayW5100.ino' &&
269+
sketches[sketch].path != config.library_root+'examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino' &&
270+
sketches[sketch].path != config.library_root+'examples/GatewayGSMMQTTClient/GatewayGSMMQTTClient.ino' &&
271+
sketches[sketch].path != config.library_root+'examples/GatewayESP8266/GatewayESP8266.ino' &&
272+
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
273+
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
274+
sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino' &&
275+
sketches[sketch].path != config.library_root+'examples/MotionSensorRS485/MotionSensorRS485.ino' &&
276+
sketches[sketch].path != config.library_root+'examples/SoilMoistSensor/SoilMoistSensor.ino') {
277+
buildArduino(config, '-prefs build.flash_freq=80m -prefs build.flash_size=4MB '+fqbn, sketches[sketch].path, key+'_Esp32')
278+
}
279+
}
280+
} catch (ex) {
281+
echo "Build failed with: "+ ex.toString()
282+
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (ESP32 - '+key+')', 'Build error', '${BUILD_URL}')
283+
throw ex
284+
} finally {
285+
parseWarnings(key+'_Esp32')
286+
}
287+
if (currentBuild.currentResult == 'UNSTABLE') {
288+
config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (ESP32 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new')
289+
if (config.is_pull_request) {
290+
error 'Termiated due to warnings found'
291+
}
292+
} else if (currentBuild.currentResult == 'FAILURE') {
293+
config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (ESP32 - '+key+')', 'Build error', '${BUILD_URL}')
294+
} else {
295+
config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (ESP32 - '+key+')', 'Pass', '')
296+
}
297+
}
298+
237299
def buildnRF5(config, sketches, String key) {
238300
def fqbn = '-fqbn sandeepmistry:nRF5:Generic_nRF52832 -prefs build.f_cpu=16000000 -prefs build.mcu=cortex-m4'
239301
config.pr.setBuildStatus(config, 'PENDING', 'Toll gate (nRF5 - '+key+')', 'Building...', '${BUILD_URL}flowGraphTable/')
@@ -246,6 +308,8 @@ def buildnRF5(config, sketches, String key) {
246308
sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' &&
247309
sketches[sketch].path != config.library_root+'examples/GatewayGSMMQTTClient/GatewayGSMMQTTClient.ino' &&
248310
sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' &&
311+
sketches[sketch].path != config.library_root+'examples/GatewayESP32/GatewayESP32.ino' &&
312+
sketches[sketch].path != config.library_root+'examples/GatewayESP32MQTTClient/GatewayESP32MQTTClient.ino' &&
249313
sketches[sketch].path != config.library_root+'examples/GatewaySerialRS485/GatewaySerialRS485.ino' &&
250314
sketches[sketch].path != config.library_root+'examples/GatewayW5100/GatewayW5100.ino' &&
251315
sketches[sketch].path != config.library_root+'examples/GatewayW5100MQTTClient/GatewayW5100MQTTClient.ino' &&

.ci/pipeline.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def call(Closure body) {
9797
stage('MySensorsGW (tests)') {
9898
arduino.buildMySensorsGw(config, config.tests, 'Tests')
9999
}
100+
stage('ESP32 (tests)') {
101+
arduino.buildEsp32(config, config.tests, 'Tests')
102+
}
100103
stage('nRF52832 (tests)') {
101104
arduino.buildnRF52832(config, config.tests, 'Tests')
102105
}
@@ -142,11 +145,16 @@ def call(Closure body) {
142145
stage('ESP8266 (examples)') {
143146
arduino.buildEsp8266(config, config.examples, 'Examples')
144147
}
148+
// No point in building examples for ESP32 yet
149+
/*
150+
stage('ESP32 (examples)') {
151+
arduino.buildEsp32(config, config.examples, 'Examples')
152+
}
153+
*/
145154
// No point in building examples for STM32F1 yet
146155
/*
147156
stage('STM32F1 (Examples)') {
148157
arduino.buildSTM32F1(config, config.tests, 'Examples')
149-
}
150158
*/
151159
stage('ArduinoUno (examples)') {
152160
arduino.buildArduinoUno(config, config.examples, 'Examples')

MyConfig.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,8 @@
13421342
* @brief Define this for Ethernet GW based on the ENC28J60 module.
13431343
* @def MY_GATEWAY_ESP8266
13441344
* @brief Define this for Ethernet GW based on the ESP8266.
1345+
* @def MY_GATEWAY_ESP32
1346+
* @brief Define this for Ethernet GW based on the ESP32.
13451347
* @def MY_GATEWAY_LINUX
13461348
* @brief Define this for Ethernet GW based on Linux.
13471349
* @def MY_GATEWAY_TINYGSM
@@ -1351,6 +1353,7 @@
13511353
//#define MY_GATEWAY_W5100
13521354
//#define MY_GATEWAY_ENC28J60
13531355
//#define MY_GATEWAY_ESP8266
1356+
//#define MY_GATEWAY_ESP32
13541357
//#define MY_GATEWAY_LINUX
13551358
//#define MY_GATEWAY_TINYGSM
13561359

@@ -1823,6 +1826,19 @@
18231826
#endif
18241827
/** @}*/ // End of ESP8266SettingGrpPub group
18251828

1829+
/**
1830+
* @defgroup ESP32SettingGrpPub ESP32
1831+
* @ingroup PlatformSettingGrpPub
1832+
* @brief These options control ESP32 specific configurations.
1833+
* @{
1834+
*/
1835+
1836+
//
1837+
// no ESP32 settings
1838+
//
1839+
1840+
/** @}*/ // End of ESP32SettingGrpPub group
1841+
18261842
/**
18271843
* @defgroup LinuxSettingGrpPub Linux
18281844
* @ingroup PlatformSettingGrpPub
@@ -1891,7 +1907,7 @@
18911907
* MY_IS_GATEWAY is true when @ref MY_GATEWAY_FEATURE is set.
18921908
* MY_NODE_TYPE contain a string describing the class of sketch/node (gateway/repeater/node).
18931909
*/
1894-
#if defined(MY_GATEWAY_SERIAL) || defined(MY_GATEWAY_W5100) || defined(MY_GATEWAY_ENC28J60) || defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_LINUX) || defined(MY_GATEWAY_MQTT_CLIENT) || defined(MY_GATEWAY_TINYGSM)
1910+
#if defined(MY_GATEWAY_SERIAL) || defined(MY_GATEWAY_W5100) || defined(MY_GATEWAY_ENC28J60) || defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)|| defined(MY_GATEWAY_LINUX) || defined(MY_GATEWAY_MQTT_CLIENT) || defined(MY_GATEWAY_TINYGSM)
18951911
#define MY_GATEWAY_FEATURE
18961912
#define MY_IS_GATEWAY (true)
18971913
#define MY_NODE_TYPE "GW"
@@ -2053,6 +2069,7 @@
20532069
#define MY_GATEWAY_W5100
20542070
#define MY_GATEWAY_ENC28J60
20552071
#define MY_GATEWAY_ESP8266
2072+
#define MY_GATEWAY_ESP32
20562073
#define MY_GATEWAY_LINUX
20572074
#define MY_GATEWAY_TINYGSM
20582075
#define MY_IP_ADDRESS 192,168,178,66

MySensors.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#include "hal/architecture/MyHw.h"
6060
#if defined(ARDUINO_ARCH_ESP8266)
6161
#include "hal/architecture/ESP8266/MyHwESP8266.cpp"
62+
#elif defined(ARDUINO_ARCH_ESP32)
63+
#include "hal/architecture/ESP32/MyHwESP32.cpp"
6264
#elif defined(ARDUINO_ARCH_AVR)
6365
#include "drivers/AVR/DigitalWriteFast/digitalWriteFast.h"
6466
#include "hal/architecture/AVR/MyHwAVR.cpp"
@@ -203,8 +205,8 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
203205
#if !defined(MY_PORT)
204206
#error You must define MY_PORT (controller or gateway port to open)
205207
#endif
206-
#if defined(MY_GATEWAY_ESP8266)
207-
// GATEWAY - ESP8266
208+
#if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32)
209+
// GATEWAY - ESP8266 / ESP32
208210
#include "core/MyGatewayTransportEthernet.cpp"
209211
#elif defined(MY_GATEWAY_LINUX)
210212
// GATEWAY - Generic Linux
@@ -286,7 +288,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
286288
// RAM ROUTING TABLE
287289
#if defined(MY_RAM_ROUTING_TABLE_FEATURE) && defined(MY_REPEATER_FEATURE)
288290
// activate feature based on architecture
289-
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_STM32F1) || defined(TEENSYDUINO) || defined(__linux__)
291+
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_STM32F1) || defined(TEENSYDUINO) || defined(__linux__)
290292
#define MY_RAM_ROUTING_TABLE_ENABLED
291293
#elif defined(ARDUINO_ARCH_AVR)
292294
#if defined(__avr_atmega1280__) || defined(__avr_atmega1284__) || defined(__avr_atmega2560__)
@@ -416,6 +418,8 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs
416418
#include "hal/architecture/ESP8266/MyMainESP8266.cpp"
417419
#elif defined(ARDUINO_ARCH_NRF5)
418420
#include "hal/architecture/NRF5/MyMainNRF5.cpp"
421+
#elif defined(ARDUINO_ARCH_ESP32)
422+
#include "hal/architecture/ESP32/MyMainESP32.cpp"
419423
#elif defined(__linux__)
420424
#include "hal/architecture/Linux/MyMainLinuxGeneric.cpp"
421425
#elif defined(ARDUINO_ARCH_STM32F1)

core/MyCapabilities.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@
160160
#define MY_CAP_ARCH "N"
161161
#elif defined(ARDUINO_ARCH_ESP8266)
162162
#define MY_CAP_ARCH "E"
163+
#elif defined(ARDUINO_ARCH_ESP32)
164+
#define MY_CAP_ARCH "F"
163165
#elif defined(ARDUINO_ARCH_AVR)
164166
#define MY_CAP_ARCH "A"
165167
#elif defined(ARDUINO_ARCH_STM32F1)

0 commit comments

Comments
 (0)