Skip to content

Commit 4cc3251

Browse files
committed
Merge branch 'master' of github.com:adafruit/ArduinoCore-samd
2 parents ed2dded + c14e078 commit 4cc3251

File tree

15 files changed

+178
-7
lines changed

15 files changed

+178
-7
lines changed

.github/workflows/githubci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
arduino-platform: ['metro_m0', 'hallowing', 'circuitplayground_m0',
11+
'metro_m4', 'pybadge_m4', 'pygamer_m4', 'hallowing_m4', 'pyportal_m4', 'pyportal_m4_titano']
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Setup Python
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: '3.x'
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
24+
- name: Checkout submodules
25+
shell: bash
26+
run: |
27+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
28+
git submodule sync --recursive
29+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive
30+
31+
- name: Install Arduino CLI and Tools
32+
run: |
33+
# make all our directories we need for files and libraries
34+
mkdir $HOME/.arduino15
35+
mkdir $HOME/.arduino15/packages
36+
mkdir $HOME/Arduino
37+
mkdir $HOME/Arduino/libraries
38+
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
39+
echo "::add-path::$GITHUB_WORKSPACE/bin"
40+
41+
- name: Install BSP and Libraries
42+
env:
43+
BSP_URL: https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
44+
BSP_PATH: .arduino15/packages/adafruit/hardware/samd
45+
LIB_DEPS: FlashStorage SD
46+
run: |
47+
arduino-cli config init
48+
arduino-cli core update-index
49+
arduino-cli core update-index --additional-urls $BSP_URL
50+
arduino-cli core install arduino:samd --additional-urls $BSP_URL
51+
arduino-cli core install adafruit:samd --additional-urls $BSP_URL
52+
# Repalce release BSP with our code
53+
BSP_VERSION=`eval ls $HOME/$BSP_PATH`
54+
rm -r $HOME/$BSP_PATH/*
55+
ln -s $GITHUB_WORKSPACE $HOME/$BSP_PATH/$BSP_VERSION
56+
arduino-cli lib install $LIB_DEPS
57+
58+
- name: Build examples
59+
run: python3 extras/build_all.py ${{ matrix.arduino-platform }}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Arduino Core for SAMD21 and SAMD51 CPU
22

3+
[![Build Status](https://github.com/adafruit/ArduinoCore-samd/workflows/Build/badge.svg)](https://github.com/adafruit/ArduinoCore-samd/actions)
4+
35
This repository contains the source code and configuration files of the Arduino Core
46
for Atmel's SAMD21 and SAMD51 processor (used on the Arduino/Genuino Zero, MKR1000 and MKRZero boards).
57

cores/arduino/Print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Print
5858

5959
// default to zero, meaning "a single write may block"
6060
// should be overriden by subclasses with buffering
61-
virtual size_t availableForWrite() { return 0; }
61+
virtual int availableForWrite() { return 0; }
6262

6363
size_t print(const __FlashStringHelper *);
6464
size_t print(const String &);

cores/arduino/USB/CDC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int Serial_::available(void)
160160
return usb.available(CDC_ENDPOINT_OUT);
161161
}
162162

163-
size_t Serial_::availableForWrite(void)
163+
int Serial_::availableForWrite(void)
164164
{
165165
// return the number of bytes left in the current bank,
166166
// always EP size - 1, because bank is flushed on every write

cores/arduino/USB/USBAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Serial_ : public Stream
129129
void end(void);
130130

131131
virtual int available(void);
132-
virtual size_t availableForWrite(void);
132+
virtual int availableForWrite(void);
133133
virtual int peek(void);
134134
virtual int read(void);
135135
virtual void flush(void);

cores/arduino/Uart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ int Uart::available()
131131
return rxBuffer.available();
132132
}
133133

134-
size_t Uart::availableForWrite()
134+
int Uart::availableForWrite()
135135
{
136136
return txBuffer.availableForStore();
137137
}

cores/arduino/Uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Uart : public HardwareSerial
3333
void begin(unsigned long baudrate, uint16_t config);
3434
void end();
3535
int available();
36-
size_t availableForWrite();
36+
int availableForWrite();
3737
int peek();
3838
int read();
3939
void flush();

extras/build_all.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import os
2+
import glob
3+
import sys
4+
import subprocess
5+
import time
6+
7+
all_warnings = False
8+
exit_status = 0
9+
success_count = 0
10+
fail_count = 0
11+
skip_count = 0
12+
13+
build_format = '| {:22} | {:30} | {:9} '
14+
build_separator = '-' * 80
15+
16+
default_boards = [ 'metro_m0', 'metro_m4', 'circuitplayground_m0']
17+
18+
build_boards = []
19+
20+
# build all variants if input not existed
21+
if len(sys.argv) > 1:
22+
build_boards.append(sys.argv[1])
23+
else:
24+
build_boards = default_boards
25+
26+
def errorOutputFilter(line):
27+
if len(line) == 0:
28+
return False
29+
if line.isspace(): # Note: empty string does not match here!
30+
return False
31+
# TODO: additional items to remove?
32+
return True
33+
34+
35+
def build_examples(variant):
36+
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
37+
38+
print('\n')
39+
print(build_separator)
40+
print('| {:^76} |'.format('Board ' + variant))
41+
print(build_separator)
42+
print((build_format + '| {:6} |').format('Library', 'Example', 'Result', 'Time'))
43+
print(build_separator)
44+
45+
fqbn = "adafruit:samd:adafruit_{}".format(variant)
46+
47+
for sketch in glob.iglob('libraries/**/*.ino', recursive=True):
48+
start_time = time.monotonic()
49+
50+
# Skip if contains: ".board.test.skip" or ".all.test.skip"
51+
# Skip if not contains: ".board.test.only" for a specific board
52+
sketchdir = os.path.dirname(sketch)
53+
if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
54+
success = "\033[33mskipped\033[0m "
55+
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.build.' + variant):
56+
success = "\033[33mskipped\033[0m "
57+
else:
58+
# TODO - preferably, would have STDERR show up in **both** STDOUT and STDERR.
59+
# preferably, would use Python logging handler to get both distinct outputs and one merged output
60+
# for now, split STDERR when building with all warnings enabled, so can detect warning/error output.
61+
if all_warnings:
62+
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
63+
else:
64+
build_result = subprocess.run("arduino-cli compile --warnings default --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
65+
66+
# get stderr into a form where len(warningLines) indicates a true warning was output to stderr
67+
warningLines = [];
68+
if all_warnings and build_result.stderr:
69+
tmpWarningLines = build_result.stderr.decode("utf-8").splitlines()
70+
warningLines = list(filter(errorOutputFilter, (tmpWarningLines)))
71+
72+
if build_result.returncode != 0:
73+
exit_status = build_result.returncode
74+
success = "\033[31mfailed\033[0m "
75+
fail_count += 1
76+
elif len(warningLines) != 0:
77+
exit_status = -1
78+
success = "\033[31mwarnings\033[0m "
79+
fail_count += 1
80+
else:
81+
success = "\033[32msucceeded\033[0m"
82+
success_count += 1
83+
84+
build_duration = time.monotonic() - start_time
85+
86+
print((build_format + '| {:5.2f}s |').format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, build_duration))
87+
88+
if success != "\033[33mskipped\033[0m ":
89+
if build_result.returncode != 0:
90+
print(build_result.stdout.decode("utf-8"))
91+
if (build_result.stderr):
92+
print(build_result.stderr.decode("utf-8"))
93+
if len(warningLines) != 0:
94+
for line in warningLines:
95+
print(line)
96+
else:
97+
skip_count += 1
98+
99+
build_time = time.monotonic()
100+
101+
for board in build_boards:
102+
build_examples(board)
103+
104+
print(build_separator)
105+
build_time = time.monotonic() - build_time
106+
print("Build Summary: {} \033[32msucceeded\033[0m, {} \033[31mfailed\033[0m, {} \033[33mskipped\033[0m and took {:.2f}s".format(success_count, fail_count, skip_count, build_time))
107+
print(build_separator)
108+
109+
sys.exit(exit_status)

libraries/I2S/examples/InputSerialPlotter/.metro_m0.test.only

Whitespace-only changes.

0 commit comments

Comments
 (0)