From b892aef6c31cfcf97f77b59d91952b2388fba766 Mon Sep 17 00:00:00 2001 From: tekka Date: Sun, 5 Nov 2017 14:19:42 +0100 Subject: [PATCH] Jenkins: Add STM32F1 support (#972) --- .ci/arduino.groovy | 33 +++++++++++++++++++++++++++++- .ci/pipeline.groovy | 9 ++++++++ drivers/RF24/RF24.h | 2 ++ hal/architecture/MyHwSTM32F1.cpp | 3 ++- hal/architecture/MyHwSTM32F1.h | 10 +++------ hal/architecture/MyMainSTM32F1.cpp | 2 -- 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/.ci/arduino.groovy b/.ci/arduino.groovy index 734a925..11a717b 100644 --- a/.ci/arduino.groovy +++ b/.ci/arduino.groovy @@ -26,7 +26,7 @@ def parseWarnings(String key) { excludePattern: '''.*/EEPROM\\.h,.*/Dns\\.cpp,.*/socket\\.cpp,.*/util\\.h,.*/Servo\\.cpp, .*/Adafruit_NeoPixel\\.cpp,.*/UIPEthernet.*,.*/SoftwareSerial\\.cpp, .*/pins_arduino\\.h,.*/Stream\\.cpp,.*/USBCore\\.cpp,.*/Wire\\.cpp, - .*/hardware/esp8266.*,.*/libraries/SD/.*''', + .*/hardware/STM32F1.*,.*/hardware/esp8266.*,.*/libraries/SD/.*''', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'Arduino/AVR', pattern: 'compiler_'+key+'.log']], unHealthy: '', unstableNewAll: '0', unstableTotalAll: '0' @@ -164,6 +164,37 @@ def buildArduinoMega(config, sketches, String key) { } } +def buildSTM32F1(config, sketches, String key) { + def fqbn = '-fqbn stm32duino:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=DFUUploadMethod,cpu_speed=speed_72mhz,opt=osstd' + config.pr.setBuildStatus(config, 'PENDING', 'Toll gate (STM32F1 - '+key+')', 'Building...', '${BUILD_URL}flowGraphTable/') + try { + for (sketch = 0; sketch < sketches.size(); sketch++) { + if (sketches[sketch].path != config.library_root+'examples/GatewayESP8266/GatewayESP8266.ino' && + sketches[sketch].path != config.library_root+'examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino' && + sketches[sketch].path != config.library_root+'examples/GatewayESP8266OTA/GatewayESP8266OTA.ino' && + sketches[sketch].path != config.library_root+'examples/SensebenderGatewaySerial/SensebenderGatewaySerial.ino') { + buildArduino(config, fqbn, sketches[sketch].path, key+'_STM32F1') + } + } + } catch (ex) { + echo "Build failed with: "+ ex.toString() + config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (STM32F1 - '+key+')', 'Build error', '${BUILD_URL}') + throw ex + } finally { + parseWarnings(key+'_STM32F1') + } + if (currentBuild.currentResult == 'UNSTABLE') { + config.pr.setBuildStatus(config, 'ERROR', 'Toll gate (STM32F1 - '+key+')', 'Warnings found', '${BUILD_URL}warnings2Result/new') + if (config.is_pull_request) { + error 'Termiated due to warnings found' + } + } else if (currentBuild.currentResult == 'FAILURE') { + config.pr.setBuildStatus(config, 'FAILURE', 'Toll gate (STM32F1 - '+key+')', 'Build error', '${BUILD_URL}') + } else { + config.pr.setBuildStatus(config, 'SUCCESS', 'Toll gate (STM32F1 - '+key+')', 'Pass', '') + } +} + def buildEsp8266(config, sketches, String key) { def fqbn = '-fqbn esp8266:esp8266:generic -prefs build.f_cpu=80000000 -prefs build.mcu=esp8266' config.pr.setBuildStatus(config, 'PENDING', 'Toll gate (ESP8266 - '+key+')', 'Building...', '${BUILD_URL}flowGraphTable/') diff --git a/.ci/pipeline.groovy b/.ci/pipeline.groovy index edd04bd..36b9951 100644 --- a/.ci/pipeline.groovy +++ b/.ci/pipeline.groovy @@ -109,6 +109,9 @@ def call(Closure body) { stage('ESP8266 (tests)') { arduino.buildEsp8266(config, config.tests, 'Tests') } + stage('STM32F1 (tests)') { + arduino.buildSTM32F1(config, config.tests, 'Tests') + } stage('ArduinoUno (tests)') { arduino.buildArduinoUno(config, config.tests, 'Tests') } @@ -139,6 +142,12 @@ def call(Closure body) { stage('ESP8266 (examples)') { arduino.buildEsp8266(config, config.examples, 'Examples') } + // No point in building examples for STM32F1 yet + /* + stage('STM32F1 (Examples)') { + arduino.buildSTM32F1(config, config.tests, 'Examples') + } + */ stage('ArduinoUno (examples)') { arduino.buildArduinoUno(config, config.examples, 'Examples') } diff --git a/drivers/RF24/RF24.h b/drivers/RF24/RF24.h index ec50e8d..0634cd2 100644 --- a/drivers/RF24/RF24.h +++ b/drivers/RF24/RF24.h @@ -105,7 +105,9 @@ _SPI; #include #include +#if !defined(_BV) #define _BV(x) (1<<(x)) //!< _BV() +#endif #if defined(__arm__) || defined(__linux__) #include diff --git a/hal/architecture/MyHwSTM32F1.cpp b/hal/architecture/MyHwSTM32F1.cpp index ccd7013..c8a5e54 100644 --- a/hal/architecture/MyHwSTM32F1.cpp +++ b/hal/architecture/MyHwSTM32F1.cpp @@ -126,7 +126,8 @@ void hwRandomNumberInit(void) regs->SMPR1 |= ADC_SMPR1_SMP16; uint32_t seed = 0; - uint16_t currentValue, newValue = 0; + uint16_t currentValue = 0; + uint16_t newValue = 0; for (uint8_t i = 0; i<32; i++) { const uint32_t timeout = hwMillis() + 20; diff --git a/hal/architecture/MyHwSTM32F1.h b/hal/architecture/MyHwSTM32F1.h index 66925ce..f123700 100644 --- a/hal/architecture/MyHwSTM32F1.h +++ b/hal/architecture/MyHwSTM32F1.h @@ -1,4 +1,4 @@ -/* +/* * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each @@ -38,13 +38,9 @@ #define snprintf_P snprintf #define vsnprintf_P vsnprintf #define strncpy_P strncpy +#define printf_P printf #define yield() // not defined -// emulated EEPROM (experimental) -#define EEPROM_PAGE_SIZE (uint16_t)1024 -#define EEPROM_SIZE (uint16_t)2048 -#define EEPROM_START_ADDRESS ((uint32_t)(0x8000000 + 128 * EEPROM_PAGE_SIZE - 2 * EEPROM_PAGE_SIZE)) - #ifndef MY_SERIALDEVICE #define MY_SERIALDEVICE Serial #endif @@ -76,4 +72,4 @@ uint8_t hwReadConfig(const int addr); #define MY_CRITICAL_SECTION #endif /* DOXYGEN */ -#endif \ No newline at end of file +#endif diff --git a/hal/architecture/MyMainSTM32F1.cpp b/hal/architecture/MyMainSTM32F1.cpp index 83f90ce..dbc9f21 100644 --- a/hal/architecture/MyMainSTM32F1.cpp +++ b/hal/architecture/MyMainSTM32F1.cpp @@ -17,8 +17,6 @@ * version 2 as published by the Free Software Foundation. */ -extern "C" void __libc_init_array(void); - // Force init to be called *first*, i.e. before static object allocation. // Otherwise, statically allocated objects that need libmaple may fail. __attribute__(( constructor (101))) void premain()