Skip to content

Commit 5c4dcc3

Browse files
authored
Merge pull request stm32duino#976 from fpistm/CI
[CI] Build built-in libraries
2 parents ff40983 + f14d8b9 commit 5c4dcc3

File tree

5 files changed

+154
-28
lines changed

5 files changed

+154
-28
lines changed

CI/build/arduino-cli.py

+37-5
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,28 @@ def check_status(status, build_conf, boardKo):
493493
bin_copy(build_conf[0], sketch_name)
494494
nb_build_passed += 1
495495
elif status[1] == 1:
496-
result = "\033[31mfailed\033[0m "
497-
boardKo.append(build_conf[0])
498-
if args.ci:
499-
cat(os.path.join(build_conf[3], sketch_name + ".log"))
500-
nb_build_failed += 1
496+
# Check if failed due to a region overflowed
497+
logFile = os.path.join(build_conf[3], sketch_name + ".log")
498+
ld_pattern = re.compile("arm-none-eabi/bin/ld:")
499+
overflow_pattern = re.compile(
500+
"will not fit in region|region .+ overflowed by [\\d]+ bytes"
501+
)
502+
for i, line in enumerate(open(logFile)):
503+
if ld_pattern.search(line):
504+
# If one ld line is not for region overflowed --> failed
505+
if overflow_pattern.search(line) is None:
506+
result = "\033[31mfailed\033[0m "
507+
boardKo.append(build_conf[0])
508+
if args.ci:
509+
cat(logFile)
510+
nb_build_failed += 1
511+
break
512+
else:
513+
# else consider it succeeded
514+
result = "\033[32msucceeded\033[0m"
515+
if args.bin:
516+
empty_bin(build_conf[0], sketch_name)
517+
nb_build_passed += 1
501518
else:
502519
result = "\033[31merror\033[0m "
503520

@@ -626,6 +643,21 @@ def log_final_result():
626643
print(output_dir)
627644

628645

646+
# Create an empty binary
647+
def empty_bin(board_name, sketch_name):
648+
empty_path = os.path.abspath(os.path.join(output_dir, board_name, bin_dir))
649+
createFolder(empty_path)
650+
empty_file = os.path.join(
651+
empty_path, sketch_name + "_COULD_NOT_FIT_IN_THIS_BOARD.bin"
652+
)
653+
try:
654+
f = open(empty_file, "w")
655+
except IOError:
656+
print("Cannot create empty binary: ", empty_file)
657+
else:
658+
f.close()
659+
660+
629661
# Create a "bin" directory for each board and copy all binary files
630662
# from the builder output directory into it
631663
def bin_copy(board_name, sketch_name):
+115-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,122 @@
1+
/*
2+
* This sketch is for CI build purpose.
3+
* It allows to test build of built-in libraries
4+
* and can not be executed.
5+
*/
6+
7+
#include <EEPROM.h>
8+
#ifndef STM32MP1xx
9+
#include <IWatchdog.h>
10+
#endif
11+
#ifdef TIMER_SERVO
12+
#include <Servo.h>
13+
#endif
14+
#include <SPI.h>
15+
#include <SoftwareSerial.h>
16+
#include <Wire.h>
17+
18+
#ifndef USER_BTN
19+
#define USER_BTN 2
20+
#endif
21+
22+
#ifndef LED_BUILTIN
23+
#define LED_BUILTIN 13
24+
#endif
25+
26+
#ifndef PIN_SERIAL_RX
27+
#define PIN_SERIAL_RX 0
28+
#endif
29+
30+
#ifndef PIN_SERIAL_TX
31+
#define PIN_SERIAL_TX 1
32+
#endif
33+
34+
#ifndef Serial
35+
HardwareSerial Serial(PIN_SERIAL_RX, PIN_SERIAL_TX);
36+
#endif
37+
38+
#ifdef TIMER_SERVO
39+
Servo servo;
40+
#endif
41+
SoftwareSerial swSerial(10, 11);
42+
143
void setup() {
2-
// put your setup code here, to run once:
44+
// Serial HW & SW
45+
#if !defined(USBD_USE_CDC) && !defined(DISABLE_GENERIC_SERIALUSB)
46+
Serial.setRx(PIN_SERIAL_RX);
47+
Serial.setTx(digitalPinToPinName(PIN_SERIAL_TX));
48+
#endif
49+
Serial.begin(9600); // start serial for output
50+
while (!Serial) {};
51+
52+
swSerial.begin(4800);
53+
swSerial.write("x");
54+
if (!swSerial.isListening()) {
55+
swSerial.listen();
56+
if (swSerial.available()) {
57+
swSerial.read();
58+
}
59+
}
60+
swSerial.end();
61+
62+
// EEPROM
63+
byte value = EEPROM.read(0x01);
64+
EEPROM.write(EEPROM.length()-1, value);
65+
66+
#ifndef STM32MP1xx
67+
// IWDG
68+
if (!IWatchdog.isReset(true)) {
69+
IWatchdog.begin(10000000);
70+
IWatchdog.isEnabled();
71+
}
72+
IWatchdog.reload();
73+
#endif
374

75+
#ifdef TIMER_SERVO
76+
// Servo
77+
servo.attach(3, 900, 2100);
78+
servo.write(1500);
79+
servo.detach();
80+
#endif
81+
82+
// SPI
83+
SPISettings settings(SPI_SPEED_CLOCK_DEFAULT, MSBFIRST, SPI_MODE_0);
84+
SPI.setMISO(PIN_SPI_MISO);
85+
SPI.setMOSI(PIN_SPI_MOSI);
86+
SPI.setSCLK(PIN_SPI_SCK);
87+
SPI.setSSEL(digitalPinToPinName(PIN_SPI_SS));
88+
SPI.begin(PIN_SPI_SS);
89+
SPI.beginTransaction(1, settings);
90+
SPI.endTransaction();
91+
SPI.transfer(1);
92+
SPI.end();
93+
94+
// Wire
95+
Wire.setSCL(PIN_WIRE_SCL);
96+
Wire.setSDA(digitalPinToPinName(PIN_WIRE_SDA));
97+
Wire.setClock(400000);
98+
Wire.begin(4);
99+
Wire.onRequest(requestEvent);
100+
Wire.onReceive(receiveEvent);
101+
Wire.beginTransmission(4);
102+
Wire.endTransmission();
103+
Wire.requestFrom(2, 1);
104+
Wire.end();
4105
}
5106

6107
void loop() {
7-
// put your main code here, to run repeatedly:
108+
}
8109

110+
// Wire
111+
// function that executes whenever data is received from master
112+
// this function is registered as an event, see setup()
113+
void receiveEvent(int) {
114+
while (1 < Wire.available()) {
115+
Wire.read();
116+
}
9117
}
118+
// function that executes whenever data is requested by master
119+
// this function is registered as an event, see setup()
120+
void requestEvent() {
121+
Wire.write("x");
122+
}

system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h

-17
Original file line numberDiff line numberDiff line change
@@ -4969,16 +4969,13 @@ typedef struct
49694969
tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_RTCAPBEN);\
49704970
UNUSED(tmpreg); \
49714971
} while(0U)
4972-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
49734972
#define __HAL_RCC_USART3_CLK_ENABLE() do { \
49744973
__IO uint32_t tmpreg = 0x00U; \
49754974
SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
49764975
/* Delay after an RCC peripheral clock enabling */ \
49774976
tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART3EN);\
49784977
UNUSED(tmpreg); \
49794978
} while(0U)
4980-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
4981-
49824979
#if defined(STM32F413xx) || defined(STM32F423xx)
49834980
#define __HAL_RCC_UART4_CLK_ENABLE() do { \
49844981
__IO uint32_t tmpreg = 0x00U; \
@@ -5098,9 +5095,7 @@ typedef struct
50985095
#endif /* STM32F413xx || STM32F423xx */
50995096
#define __HAL_RCC_RTCAPB_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_RTCAPBEN))
51005097
#define __HAL_RCC_SPI3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI3EN))
5101-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
51025098
#define __HAL_RCC_USART3_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART3EN))
5103-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
51045099
#if defined(STM32F413xx) || defined(STM32F423xx)
51055100
#define __HAL_RCC_UART4_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART4EN))
51065101
#define __HAL_RCC_UART5_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_UART5EN))
@@ -5140,9 +5135,7 @@ typedef struct
51405135
#endif /* STM32F413xx || STM32F423xx */
51415136
#define __HAL_RCC_RTCAPB_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_RTCAPBEN)) != RESET)
51425137
#define __HAL_RCC_SPI3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) != RESET)
5143-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
51445138
#define __HAL_RCC_USART3_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) != RESET)
5145-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx | STM32F423xx */
51465139
#if defined(STM32F413xx) || defined(STM32F423xx)
51475140
#define __HAL_RCC_UART4_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) != RESET)
51485141
#define __HAL_RCC_UART5_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) != RESET)
@@ -5171,9 +5164,7 @@ typedef struct
51715164
#endif /* STM32F413xx || STM32F423xx */
51725165
#define __HAL_RCC_RTCAPB_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_RTCAPBEN)) == RESET)
51735166
#define __HAL_RCC_SPI3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_SPI3EN)) == RESET)
5174-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
51755167
#define __HAL_RCC_USART3_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART3EN)) == RESET)
5176-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx | STM32F423xx */
51775168
#if defined(STM32F413xx) || defined(STM32F423xx)
51785169
#define __HAL_RCC_UART4_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART4EN)) == RESET)
51795170
#define __HAL_RCC_UART5_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_UART5EN)) == RESET)
@@ -5445,9 +5436,7 @@ typedef struct
54455436
#define __HAL_RCC_LPTIM1_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_LPTIM1RST))
54465437
#endif /* STM32F413xx || STM32F423xx */
54475438
#define __HAL_RCC_SPI3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI3RST))
5448-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
54495439
#define __HAL_RCC_USART3_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_USART3RST))
5450-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
54515440
#if defined(STM32F413xx) || defined(STM32F423xx)
54525441
#define __HAL_RCC_UART4_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART4RST))
54535442
#define __HAL_RCC_UART5_FORCE_RESET() (RCC->APB1RSTR |= (RCC_APB1RSTR_UART5RST))
@@ -5475,9 +5464,7 @@ typedef struct
54755464
#define __HAL_RCC_LPTIM1_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_LPTIM1RST))
54765465
#endif /* STM32F413xx || STM32F423xx */
54775466
#define __HAL_RCC_SPI3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI3RST))
5478-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
54795467
#define __HAL_RCC_USART3_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART3RST))
5480-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
54815468
#if defined(STM32F413xx) || defined(STM32F423xx)
54825469
#define __HAL_RCC_UART4_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART4RST))
54835470
#define __HAL_RCC_UART5_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_UART5RST))
@@ -5633,9 +5620,7 @@ typedef struct
56335620
#endif /* STM32F413xx || STM32F423xx */
56345621
#define __HAL_RCC_RTCAPB_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_RTCAPBLPEN))
56355622
#define __HAL_RCC_SPI3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI3LPEN))
5636-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
56375623
#define __HAL_RCC_USART3_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_USART3LPEN))
5638-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
56395624
#if defined(STM32F413xx) || defined(STM32F423xx)
56405625
#define __HAL_RCC_UART4_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART4LPEN))
56415626
#define __HAL_RCC_UART5_CLK_SLEEP_ENABLE() (RCC->APB1LPENR |= (RCC_APB1LPENR_UART5LPEN))
@@ -5664,9 +5649,7 @@ typedef struct
56645649
#endif /* STM32F413xx || STM32F423xx */
56655650
#define __HAL_RCC_RTCAPB_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_RTCAPBLPEN))
56665651
#define __HAL_RCC_SPI3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI3LPEN))
5667-
#if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
56685652
#define __HAL_RCC_USART3_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART3LPEN))
5669-
#endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
56705653
#if defined(STM32F413xx) || defined(STM32F423xx)
56715654
#define __HAL_RCC_UART4_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART4LPEN))
56725655
#define __HAL_RCC_UART5_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_UART5LPEN))

variants/Generic_F410Cx/variant.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ extern "C" {
9999
#define PIN_WIRE_SCL PB8
100100

101101
// Timer Definitions
102-
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
103102
#define TIMER_TONE TIM6
104-
#define TIMER_SERVO TIM7
103+
#define TIMER_SERVO TIM11
105104

106105
// UART Definitions
107106
#define SERIAL_UART_INSTANCE 2 // Connected to ST-Link

variants/Generic_F410Rx/variant.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ extern "C" {
100100
#endif
101101

102102
// Timer Definitions
103-
// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
104103
#define TIMER_TONE TIM6
105-
#define TIMER_SERVO TIM7
104+
#define TIMER_SERVO TIM11
106105

107106
// SPI definitions
108107
#define PIN_SPI_SS PA4

0 commit comments

Comments
 (0)