Skip to content

Commit 6967352

Browse files
committed
[CI] Build built-in libraries
Since {whole-archive} option has been removed the CI is not fully relevant. So need to explicitly used basic functions of the built-in library. The arduino-cli script have been updated to handle properly region overflowed which is not a real issue while there is no other issue. Signed-off-by: Frederic Pillon <[email protected]>
1 parent ad5c2b3 commit 6967352

File tree

2 files changed

+152
-7
lines changed

2 files changed

+152
-7
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+
}

0 commit comments

Comments
 (0)