add python script to help building cmake, build all imxrt boards with ci

This commit is contained in:
hathach 2023-05-10 13:09:15 +07:00
parent 4c796b89d8
commit 8e3bdd2391
11 changed files with 221 additions and 8 deletions

View File

@ -1,4 +1,4 @@
name: CMake Build ARM
name: CMake ARM
on:
push:
@ -51,8 +51,4 @@ jobs:
run: python3 tools/get_family_deps.py ${{ matrix.family }}
- name: Build
run: |
mkdir -p examples/build
cd examples/build
cmake -DFAMILY=${{ matrix.family }} -DBOARD=mimxrt1060_evk ..
cmake --build .
run: python tools/build_cmake.py ${{ matrix.family }}

View File

@ -0,0 +1,15 @@
set(MCU_VARIANT MIMXRT1011)
set(JLINK_DEVICE MIMXRT1011DAE5A)
set(PYOCD_TARGET mimxrt1010)
set(NXPLINK_DEVICE MIMXRT1011xxxxx:EVK-MIMXRT1010)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/evkmimxrt1010_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1011DAE5A
CFG_EXAMPLE_VIDEO_READONLY
)
endfunction()

View File

@ -0,0 +1,15 @@
set(MCU_VARIANT MIMXRT1015)
set(JLINK_DEVICE MIMXRT1015DAF5A)
set(PYOCD_TARGET mimxrt1015)
set(NXPLINK_DEVICE MIMXRT1015xxxxx:EVK-MIMXRT1015)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/evkmimxrt1015_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1015DAF5A
CFG_EXAMPLE_VIDEO_READONLY
)
endfunction()

View File

@ -0,0 +1,14 @@
set(MCU_VARIANT MIMXRT1021)
set(JLINK_DEVICE MIMXRT1021DAG5A)
set(PYOCD_TARGET mimxrt1020)
set(NXPLINK_DEVICE MIMXRT1021xxxxx:EVK-MIMXRT1020)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/evkmimxrt1020_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1021DAG5A
)
endfunction()

View File

@ -0,0 +1,16 @@
set(MCU_VARIANT MIMXRT1024)
set(JLINK_DEVICE MIMXRT1024DAG5A)
set(PYOCD_TARGET mimxrt1024)
set(NXPLINK_DEVICE MIMXRT1024xxxxx:MIMXRT1024-EVK)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/evkmimxrt1024_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1024DAG5A
CFG_EXAMPLE_VIDEO_READONLY
#-Wno-error=array-bounds
)
endfunction()

View File

@ -0,0 +1,16 @@
set(MCU_VARIANT MIMXRT1052)
set(JLINK_DEVICE MIMXRT1052xxxxB)
set(PYOCD_TARGET mimxrt1050)
set(NXPLINK_DEVICE MIMXRT1052xxxxB:EVK-MIMXRT1050)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/evkbimxrt1050_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1052DVL6B
BOARD_TUD_RHPORT=0
BOARD_TUH_RHPORT=1
)
endfunction()

View File

@ -0,0 +1,21 @@
set(MCU_VARIANT MIMXRT1062)
set(JLINK_DEVICE MIMXRT1062xxx6A)
set(PYOCD_TARGET mimxrt1060)
set(NXPLINK_DEVICE MIMXRT1062xxxxA:EVK-MIMXRT1060)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/teensy40_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1062DVL6A
BOARD_TUD_RHPORT=0
BOARD_TUH_RHPORT=1
)
endfunction()
# flash by using teensy_loader_cli https://github.com/PaulStoffregen/teensy_loader_cli
# Make sure it is in your PATH
# flash: $(BUILD)/$(PROJECT).hex
# teensy_loader_cli --mcu=imxrt1062 -v -w $<

View File

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h>
#include "teensy40_flexspi_nor_config.h"
/* Component ID definition, used by tools. */
#ifndef FSL_COMPONENT_ID

View File

@ -0,0 +1,21 @@
set(MCU_VARIANT MIMXRT1062)
set(JLINK_DEVICE MIMXRT1062xxx6A)
set(PYOCD_TARGET mimxrt1060)
set(NXPLINK_DEVICE MIMXRT1062xxxxA:EVK-MIMXRT1060)
function(update_board TARGET)
target_sources(${TARGET} PUBLIC
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/teensy41_flexspi_nor_config.c
)
target_compile_definitions(${TARGET} PUBLIC
CPU_MIMXRT1062DVL6A
BOARD_TUD_RHPORT=0
BOARD_TUH_RHPORT=1
)
endfunction()
# flash by using teensy_loader_cli https://github.com/PaulStoffregen/teensy_loader_cli
# Make sure it is in your PATH
# flash: $(BUILD)/$(PROJECT).hex
# teensy_loader_cli --mcu=imxrt1062 -v -w $<

View File

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <bsp/imxrt/boards/teensy_40/teensy40_flexspi_nor_config.h>
#include "teensy41_flexspi_nor_config.h"
/* Component ID definition, used by tools. */
#ifndef FSL_COMPONENT_ID

99
tools/build_cmake.py Normal file
View File

@ -0,0 +1,99 @@
import os
import sys
import time
import subprocess
import pathlib
from multiprocessing import Pool
import build_utils
SUCCEEDED = "\033[32msucceeded\033[0m"
FAILED = "\033[31mfailed\033[0m"
SKIPPED = "\033[33mskipped\033[0m"
build_separator = '-' * 106
make_iar_option = 'CC=iccarm'
def filter_with_input(mylist):
if len(sys.argv) > 1:
input_args = list(set(mylist).intersection(sys.argv))
if len(input_args) > 0:
mylist[:] = input_args
def build_family(family, make_option):
all_boards = []
for entry in os.scandir("hw/bsp/{}/boards".format(family)):
if entry.is_dir() and entry.name != 'pico_sdk':
all_boards.append(entry.name)
all_boards.sort()
# success, failed, skipped
ret = [0, 0, 0]
for board in all_boards:
start_time = time.monotonic()
# Generate build
r = subprocess.run(f"cmake examples -B cmake-build-ci-{board} -G \"Ninja\" -DFAMILY={family} -DBOARD"
f"={board}", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
# Build
if r.returncode == 0:
r = subprocess.run(f"cmake --build cmake-build-ci-{board}", shell=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
duration = time.monotonic() - start_time
if r.returncode == 0:
status = SUCCEEDED
ret[0] += 1
else:
status = FAILED
ret[1] += 1
flash_size = "-"
sram_size = "-"
example = 'all'
print(build_utils.build_format.format(example, board, status, "{:.2f}s".format(duration), flash_size, sram_size))
if r.returncode != 0:
# group output in CI
print(f"::group::{board} build error")
print(r.stdout.decode("utf-8"))
print(f"::endgroup::")
return ret
if __name__ == '__main__':
# IAR CC
if make_iar_option not in sys.argv:
make_iar_option = ''
# If family are not specified in arguments, build all
all_families = []
for entry in os.scandir("hw/bsp"):
if entry.is_dir() and os.path.isdir(entry.path + "/boards") and entry.name != 'espressif':
all_families.append(entry.name)
filter_with_input(all_families)
all_families.sort()
print(build_separator)
print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
total_time = time.monotonic()
# succeeded, failed, skipped
total_result = [0, 0, 0]
for family in all_families:
fret = build_family(family, make_iar_option)
if len(fret) == len(total_result):
total_result = [total_result[i] + fret[i] for i in range(len(fret))]
total_time = time.monotonic() - total_time
print(build_separator)
print("Build Summary: {} {}, {} {}, {} {} and took {:.2f}s".format(total_result[0], SUCCEEDED, total_result[1],
FAILED, total_result[2], SKIPPED, total_time))
print(build_separator)
sys.exit(total_result[1])