Merge branch 'adafruit:master' into master

This commit is contained in:
jgartrel authored and GitHub committed 2023-04-24 18:24:29 -07:00
commit b6a4fa3fa4
9 files changed
+131 -88

No files matched your search

+11 -11
View File
@@ -2,8 +2,13 @@ name: Build
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
@@ -16,17 +21,15 @@ jobs:
- 'feather52840sense'
- 'itsybitsy52840'
- 'ledglasses_nrf52840'
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'true'
@@ -58,14 +61,11 @@ jobs:
# Install library dependency
arduino-cli lib install "Adafruit AHRS" "Adafruit APDS9960 Library" "Adafruit Arcada Library" "Adafruit BMP280 Library" "Adafruit Circuit Playground" "Adafruit EPD" "Adafruit GFX Library" "Adafruit HX8357 Library" "Adafruit ILI9341" "Adafruit LIS3MDL" "Adafruit LSM6DS" "Adafruit NeoPixel" "Adafruit NeoMatrix" "Adafruit Sensor Calibration" "Adafruit SHT31 Library" "Adafruit SSD1306" "Adafruit ST7735 and ST7789 Library" "SdFat - Adafruit Fork"
arduino-cli lib install "Arduino_TensorFlowLite" "MIDI Library"
arduino-cli lib install "MIDI Library" "Firmata"
# TODO use firmata master to prevent build error with gcc v9 (should be remove after 2.5.9 is released)
# https://github.com/firmata/arduino/pull/438
git clone --depth 1 https://github.com/firmata/arduino.git $HOME/Arduino/libraries/firmata
# TODO temporarily remove TinyUSB pre-1.0.0 version install by arduino-cli
rm -r $HOME/Arduino/libraries/Adafruit_TinyUSB_Library
# Arduino_TensorFlowLite is removed per maintainer request https://github.com/arduino/library-registry/pull/1748
# Find a way to compile later, skip TFL example for now
# arduino-cli lib install "Arduino_TensorFlowLite"
# Library summary
arduino-cli lib list
+4 -4
View File
@@ -179,13 +179,13 @@ const char* dbg_err_str(int32_t err_id); // TODO move to other place
#define PRINT_LOCATION() PRINTF("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
#define PRINT_MESS(x) PRINTF("%s: %d: %s \r\n" , __FUNCTION__, __LINE__, (char*)(x))
#define PRINT_HEAP() if (CFG_DEBUG >= 3) PRINTF("\n%s: %d: Heap free: %d\r\n", __FUNCTION__, __LINE__, util_heap_get_free_size())
#define PRINT_STR(x) PRINTF("%s: %d: " #x " = %s\r\n" , __FUNCTION__, __LINE__, (char*)(x) )
#define PRINT_INT(x) PRINTF("%s: %d: " #x " = %ld\r\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
#define PRINT_FLOAT(x) PRINTF("%s: %d: " #x " = %f\r\n" , __FUNCTION__, __LINE__, (float) (x) )
#define PRINT_STR(x) PRINTF(#x " = %s\r\n" , (char*)(x) )
#define PRINT_INT(x) PRINTF(#x " = %ld\r\n", (uint32_t) (x) )
#define PRINT_FLOAT(x) PRINTF(#x " = %f\r\n" , (float) (x) )
#define PRINT_HEX(x) \
do {\
PRINTF("%s: %d: " #x " = 0x", __PRETTY_FUNCTION__, __LINE__);\
PRINTF(#x " = 0x");\
char fmt[] = "%00X\r\n";\
fmt[2] += 2*sizeof(x); /* Hex with correct size */\
PRINTF(fmt, (x) );\
+25 -6
View File
@@ -74,22 +74,41 @@ uint32_t readResetReason(void)
return _reset_reason;
}
static void reset_mcu(uint32_t gpregret)
{
// disable SD
sd_softdevice_disable();
// Disable all interrupts
NVIC->ICER[0]=0xFFFFFFFF;
NVIC->ICPR[0]=0xFFFFFFFF;
#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
NVIC->ICER[1]=0xFFFFFFFF;
NVIC->ICPR[1]=0xFFFFFFFF;
#endif
NRF_POWER->GPREGRET = gpregret;
NVIC_SystemReset();
// maybe yield ?
while(1) {}
}
void enterUf2Dfu(void)
{
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
NVIC_SystemReset();
reset_mcu(DFU_MAGIC_UF2_RESET);
}
void enterSerialDfu(void)
{
NRF_POWER->GPREGRET = DFU_MAGIC_SERIAL_ONLY_RESET;
NVIC_SystemReset();
// shut down everything
reset_mcu(DFU_MAGIC_SERIAL_ONLY_RESET);
}
void enterOTADfu(void)
{
NRF_POWER->GPREGRET = DFU_MAGIC_OTA_RESET;
NVIC_SystemReset();
reset_mcu(DFU_MAGIC_OTA_RESET);
}
void waitForEvent(void)
+1 -1
View File
@@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
name=Adafruit nRF52 Boards
version=1.3.0
version=1.4.0
# Compile variables
# -----------------
+88 -64
View File
@@ -2,98 +2,122 @@ import os
import glob
import sys
import subprocess
from subprocess import Popen, PIPE
import time
from multiprocessing import Pool
SUCCEEDED = "\033[32msucceeded\033[0m"
FAILED = "\033[31mfailed\033[0m"
SKIPPED = "\033[35mskipped\033[0m"
WARNING = "\033[33mwarnings\033[0m "
exit_status = 0
success_count = 0
fail_count = 0
skip_count = 0
build_format = '| {:25} | {:35} | {:18} | {:6} |'
build_separator = '-' * 88
default_boards = [ 'cluenrf52840', 'cplaynrf52840', 'feather52832', 'feather52840', 'feather52840sense', 'itsybitsy52840' ]
default_boards = [
'cluenrf52840',
'cplaynrf52840',
'feather52832',
'feather52840',
'feather52840sense',
'itsybitsy52840'
]
build_boards = []
# build all variants if input not existed
if len(sys.argv) > 1:
build_boards.append(sys.argv[1])
else:
build_boards = default_boards
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
all_examples.sort()
def build_a_example(arg):
variant = arg[0]
sketch = arg[1]
def build_examples(variant):
global exit_status, success_count, fail_count, skip_count, build_format, build_separator
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant,
's140v6' if variant != 'feather52832' else 's132v6')
# succeeded, failed, skipped
ret = [0, 0, 0]
start_time = time.monotonic()
# Skip if contains: ".board.test.skip" or ".all.test.skip"
# Skip if not contains: ".board.test.only" for a specific board
sketchdir = os.path.dirname(sketch)
if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
success = SKIPPED
ret[2] = 1
elif glob.glob(sketchdir + "/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
success = SKIPPED
ret[2] = 1
else:
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# get stderr into a form where warning/error was output to stderr
if build_result.returncode != 0:
ret[1] = 1
success = FAILED
else:
ret[0] = 1
if build_result.stderr:
success = WARNING
else:
success = SUCCEEDED
build_duration = time.monotonic() - start_time
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success,
'{:5.2f}s'.format(build_duration)))
if success != SKIPPED:
# Build failed
if build_result.returncode != 0:
print(build_result.stdout.decode("utf-8"))
# Build with warnings
if build_result.stderr:
print(f"::group::warning-message")
print(build_result.stderr.decode("utf-8"))
print(f"::endgroup::")
return ret
def build_all_examples(variant):
print('\n')
print(build_separator)
print('| {:^84} |'.format('Board ' + variant))
print(build_separator)
print(build_format.format('Library', 'Example', '\033[39mResult\033[0m', 'Time'))
print(build_separator)
fqbn = "adafruit:nrf52:{}:softdevice={},debug=l0".format(variant, 's140v6' if variant != 'feather52832' else 's132v6')
for sketch in all_examples:
# skip TinyUSB library examples for nRF52832
if variant == 'feather52832' and "libraries/Adafruit_TinyUSB_Arduino" in sketch:
continue
args = [[variant, s] for s in all_examples]
with Pool() as pool:
result = pool.map(build_a_example, args)
# sum all element of same index (column sum)
return list(map(sum, list(zip(*result))))
start_time = time.monotonic()
# Skip if contains: ".board.test.skip" or ".all.test.skip"
# Skip if not contains: ".board.test.only" for a specific board
sketchdir = os.path.dirname(sketch)
if os.path.exists(sketchdir + '/.all.test.skip') or os.path.exists(sketchdir + '/.' + variant + '.test.skip'):
success = SKIPPED
skip_count += 1
elif glob.glob(sketchdir+"/.*.test.only") and not os.path.exists(sketchdir + '/.' + variant + '.test.only'):
success = SKIPPED
skip_count += 1
else:
build_result = subprocess.run("arduino-cli compile --warnings all --fqbn {} {}".format(fqbn, sketch), shell=True, stdout=PIPE, stderr=PIPE)
if __name__ == "__main__":
# build all variants if input not existed
if len(sys.argv) > 1:
build_boards.append(sys.argv[1])
else:
build_boards = default_boards
# get stderr into a form where warning/error was output to stderr
if build_result.returncode != 0:
exit_status = build_result.returncode
success = FAILED
fail_count += 1
else:
success_count += 1
if build_result.stderr:
success = WARNING
else:
success = SUCCEEDED
# All examples in libraries except TinyUSB which has its own ci to build
all_examples = list(glob.iglob('libraries/**/*.ino', recursive=True))
all_examples = [i for i in all_examples if "Adafruit_TinyUSB_Arduino" not in i]
all_examples.sort()
build_duration = time.monotonic() - start_time
build_time = time.monotonic()
print(build_format.format(sketch.split(os.path.sep)[1], os.path.basename(sketch), success, '{:5.2f}s'.format(build_duration)))
# succeeded, failed, skipped
total_result = [0, 0, 0]
if success != SKIPPED:
# Build failed
if build_result.returncode != 0:
print(build_result.stdout.decode("utf-8"))
# Build with warnings
if build_result.stderr:
print(build_result.stderr.decode("utf-8"))
for board in build_boards:
fret = build_all_examples(board)
if len(fret) == len(total_result):
total_result = [total_result[i] + fret[i] for i in range(len(fret))]
build_time = time.monotonic()
build_time = time.monotonic() - build_time
for board in build_boards:
build_examples(board)
print(build_separator)
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1], FAILED, total_result[2], SKIPPED, build_time))
print(build_separator)
print(build_separator)
build_time = time.monotonic() - build_time
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(success_count, SUCCEEDED, fail_count, FAILED, skip_count, SKIPPED, build_time))
print(build_separator)
sys.exit(exit_status)
sys.exit(total_result[1])