Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi bsp ci build #88

Merged
merged 11 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/ports_psoc6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
board: [CY8CPROTO-062-4343W]
board:
- CY8CPROTO-062-4343W
- CY8CPROTO-063-BLE
outputs:
commit_sha: ${{ steps.commit_sha.outputs.sha_short }}

Expand Down Expand Up @@ -48,7 +50,8 @@ jobs:
needs: server-build
strategy:
matrix:
board: [CY8CPROTO-062-4343W]
board:
- CY8CPROTO-062-4343W
steps:
- uses: actions/checkout@v3
- name: Download binaries
Expand All @@ -60,7 +63,7 @@ jobs:
- name: Setup devices
run: |
cp mpy-psoc6_${{ matrix.board }}_${{ needs.server-build.outputs.commit_sha }}/firmware.hex .
source tools/ci.sh && ci_psoc6_flash_multiple_devices firmware.hex
source tools/ci.sh && ci_psoc6_flash_multiple_devices ${{ matrix.board }} firmware.hex tools/psoc6/${{ runner.name }}-devs.yml
- name: Run psoc6 multi test
run: |
cd tests
Expand All @@ -86,7 +89,9 @@ jobs:
needs: [server-build, on-target-test]
strategy:
matrix:
board: [CY8CPROTO-062-4343W]
board:
- CY8CPROTO-062-4343W
- CY8CPROTO-063-BLE
if: startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'infineon'
steps:
- name: Download binaries
Expand Down
15 changes: 14 additions & 1 deletion ports/psoc6/mtb-libs/makefile_mtb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,22 @@ mtb_get_build_flags: mtb_build
$(eval LDFLAGS += $(shell $(PYTHON) $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)/mtb_build_info.py ldflags $(MPY_MTB_BOARD_BUILD_OUTPUT_DIR)/.cylinker $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)))
$(eval QSTR_GEN_CFLAGS += $(INC) $(CFLAGS))

# When multiple types of boards are connected, a devs file needs to be provided.
# When working locally, if a "local-devs.yml" file is placed in "tools/psoc6"
# it will be used
ifneq ($(DEVS_FILE),)
MULTI_BOARD_DEVS_OPTS = -b $(BOARD) -y $(DEVS_FILE)
else
DFLT_LOCAL_DEVS_FILE_NAME = local-devs.yml
LOCAL_DEVS_FILE=$(TOP)/tools/psoc6/$(DFLT_LOCAL_DEVS_FILE_NAME)
ifneq (,$(wildcard $(LOCAL_DEVS_FILE)))
MULTI_BOARD_DEVS_OPTS = -b $(BOARD) -y $(LOCAL_DEVS_FILE)
endif
endif

attached_devs:
@:
$(eval ATTACHED_TARGET_LIST = $(shell fw-loader --device-list | sed -n -e 's/[0-9]: KitProg3 CMSIS-DAP BULK-//' -e 's/FW Version[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*//p'| sed -n 's/^[ \t]*//p'))
$(eval ATTACHED_TARGET_LIST = $(shell $(PYTHON) $(TOP)/tools/psoc6/get-devs.py serial-number $(MULTI_BOARD_DEVS_OPTS)))
$(eval ATTACHED_TARGETS_NUMBER = $(words $(ATTACHED_TARGET_LIST)))
$(info Number of attached targets : $(ATTACHED_TARGETS_NUMBER))
$(info List of attached targets : $(ATTACHED_TARGET_LIST))
Expand Down
9 changes: 6 additions & 3 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function ci_powerpc_build {
########################################################################################
# ports/psoc6

MPY_MTB_CI_DOCKER_VERSION=0.4.0
MPY_MTB_CI_DOCKER_VERSION=0.5.0

function ci_psoc6_setup {
# Access to serial device
Expand Down Expand Up @@ -266,9 +266,12 @@ function ci_psoc6_deploy {
}

function ci_psoc6_flash_multiple_devices {
board=$1
# hex file including path with respect to micropython root
hex_file=$1
docker exec mtb-ci make program_multi EXT_HEX_FILE=../../${hex_file}
hex_file=$2
devs_file=$3

docker exec mtb-ci make program_multi BOARD=${board} EXT_HEX_FILE=../../${hex_file} DEVS_FILE=../../${devs_file}
}

function ci_psoc6_run_tests {
Expand Down
185 changes: 185 additions & 0 deletions tools/psoc6/get-devs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# This script support the discovery of attached KitProg3 devices

import argparse, glob, os, re, subprocess, yaml


def get_devs_from_yml(dev_yml):
if not os.path.exists(dev_yml):
raise Exception("devices .yml file does not exit")

board_sn_map = []
with open(dev_yml, "r") as devs_f:
board_sn_map = yaml.safe_load(devs_f)

return board_sn_map


def udevadm_get_kitprog3_attached_devs():
def get_ttyACM_dev_list():
return glob.glob(os.path.join("/dev", "ttyACM*"), recursive=False)

def get_udevadm_port_attrs_output(dev):
dev_param = "--name=" + str(dev)
cmd_line_args = ["udevadm", "info", dev_param, "--attribute-walk"]
udevadm_output_lines = []
try:
udevadm_proc = subprocess.Popen(cmd_line_args, stdout=subprocess.PIPE)
while True:
line = udevadm_proc.stdout.readline()
udevadm_output_lines.append(line)
if not line:
break
except:
raise Exception("udevadm error")

return udevadm_output_lines

def is_kitprog_device(udevadm_output_lines):
def is_device_attr_found(line, pattern):
attr = re.search(pattern, str(line))
if attr is not None:
return True

return False

# It is a kitprog probe is these matches
# are found in the device attributes
required_attr_match = [
'ATTRS{interface}=="KitProg\d USBUART"',
'ATTRS{product}==".*KitProg\d.*"',
]

attr_found_count = 0

for line in udevadm_output_lines:
for req_match in required_attr_match:
if is_device_attr_found(line, req_match):
attr_found_count += 1

if attr_found_count == len(required_attr_match):
return True

return False

def get_kitprog_serial_number(udevadm_output_lines):
for line in udevadm_output_lines:
attr = re.search('ATTRS{serial}=="[a-zA-Z0-9]*"', str(line))
if attr is not None:
sn = attr.group()[len("ATTRS{serial}==") :]
sn = sn.strip('"')
return sn

return ""

kitprog_devs = []
dev_list = get_ttyACM_dev_list()

if dev_list is not []:
for dev in dev_list:
udevadm_output_lines = get_udevadm_port_attrs_output(dev)
if is_kitprog_device(udevadm_output_lines):
sn = get_kitprog_serial_number(udevadm_output_lines)
# new kp device
kp_dev = {}
kp_dev["port"] = dev
kp_dev["sn"] = sn

kitprog_devs.append(kp_dev)

return kitprog_devs


def get_devices_serial_num(board=None, devs_yml=None):
sn_list = []
port_sn_map = udevadm_get_kitprog3_attached_devs()

if board is not None and devs_yml is not None:
board_sn_map = get_devs_from_yml(devs_yml)

for dev in port_sn_map:
for listed_board in board_sn_map:
if board == listed_board["board"]:
if dev["sn"] in listed_board["sn"]:
sn_list.append(dev["sn"])
break
else:
for dev in port_sn_map:
sn_list.append(dev["sn"])

return sn_list


def get_devices_port(board=None, devs_yml=None):
port_list = []
port_sn_map = udevadm_get_kitprog3_attached_devs()

if board is not None and devs_yml is not None:
board_sn_map = get_devs_from_yml(devs_yml)

for dev in port_sn_map:
for listed_board in board_sn_map:
if board == listed_board["board"]:
if dev["sn"] in listed_board["sn"]:
port_list.append(dev["port"])
break
else:
for dev in port_sn_map:
port_list.append(dev["port"])

return port_list


if __name__ == "__main__":
pass


def parser():
def main_parser_func(args):
parser.print_help()

def parse_validate_opt_arg_mutual_required(args):
if args.devs_yml and args.board is None:
parser.error("--devs-yml requires --board.")
if args.board and args.devs_yml is None:
parser.error("--board requires --dev-yml.")

def parser_get_devices_serial_num(args):
parse_validate_opt_arg_mutual_required(args)
devs_serial = get_devices_serial_num(args.board, args.devs_yml)
print(*devs_serial)

def parser_get_devices_port(args):
parse_validate_opt_arg_mutual_required(args)
devs_port = get_devices_port(args.board, args.devs_yml)
print(*devs_port)

parser = argparse.ArgumentParser(description="Get kitprog3 device utility")

subparser = parser.add_subparsers()
parser.set_defaults(func=main_parser_func)

# Get devices serial numbers
parser_sn = subparser.add_parser(
"serial-number", description="Get kitprog3 devices serial number list"
)
parser_sn.add_argument("-b", "--board", type=str, help="Board name")
parser_sn.add_argument(
"-y", "--devs-yml", type=str, help="Device list yml with board - serial number map"
)
parser_sn.set_defaults(func=parser_get_devices_serial_num)

# Get devices port
parser_port = subparser.add_parser("port", description="Get kitprog3 devices port list")
parser_port.add_argument("-b", "--board", type=str, help="Board name")
parser_port.add_argument(
"-y", "--devs-yml", type=str, help="Device list yml with board - serial number map"
)
parser_port.set_defaults(func=parser_get_devices_port)

# Parser call
args = parser.parse_args()
args.func(args)


if __name__ == "__main__":
parser()
8 changes: 8 additions & 0 deletions tools/psoc6/ifx-mpy-hil-devs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- board: CY8CPROTO-062-4343W
sn:
- 072002F302098400
- 1C14031D03201400
- board: CY8CPROTO-063-BLE
sn:
- 100D0F1400052400
- 03180F1400052400
Loading