Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ports_psoc6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: mpy-psoc6_${{ matrix.board }}_${{ steps.commit_sha.outputs.sha_short }}
path: ports/psoc6/build/firmware.hex
path: ports/psoc6/build-${{ matrix.board }}/firmware.hex

# Jobs only relevant for Infineon fork
on-target-test:
Expand Down
2 changes: 1 addition & 1 deletion lib/mtb-psoc6-libs
146 changes: 46 additions & 100 deletions ports/psoc6/Makefile
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
BOARD ?=

# Check if the ModusToolbox setup has been initialized
# If that is the case, get active board
MTB_LIB_DIR = ../../lib/mtb-psoc6-libs
MTB_LIBS_APP_INFO = $(MTB_LIB_DIR)/build/get_app_info.txt

ifneq ($(wildcard $(MTB_LIBS_APP_INFO)),)
ACTIVE_BOARD = $(shell egrep '^ *MTB_TARGET' $(MTB_LIBS_APP_INFO) | sed 's/^.*= *//g' | sed 's/APP_//')
endif
MTB_LIBS_DIR = ../../lib/mtb-psoc6-libs
include mpconfigport.mk
-include $(MTB_LIBS_DIR)/mtb-bsp-setup.mk

# Get active board from mtb-lib previous runs
# The board is set only after make mtb_init
# has been run.
# The only target allowed to run without BOARD defined is 'submodules' or 'help'
ifeq ($(BOARD),)
ifeq ($(ACTIVE_BOARD),)
ifneq ($(MAKECMDGOALS), submodules)
$(error ModusToolbox not initialized. Run "make mtb_init BOARD=<target-board>" to configure the environment. )
endif
else
BOARD = $(ACTIVE_BOARD)
endif
ifneq ($(filter $(MAKECMDGOALS),submodules help),$(MAKECMDGOALS))
$(error No active board is set. Run "make BOARD=<target-board>" to initialize the ModusToolbox libraries and set the active board. )
endif
endif

BOARD_DIR = boards/$(BOARD)

$(info PSoC6 board : $(BOARD))

ifeq ($(wildcard $(BOARD_DIR)/.),)
$(error Invalid BOARD specified)
endif
BUILD ?= build-$(BOARD)

# Files that are generated and needed before the QSTR build.
QSTR_GENERATED_HEADERS = build/pins_qstr.h
QSTR_GENERATED_HEADERS =$(BUILD)/pins_qstr.h
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h $(QSTR_GENERATED_HEADERS)
QSTR_GLOBAL_DEPENDENCIES += $(BOARD_DIR)/mpconfigboard.h $(QSTR_GENERATED_HEADERS)

MICROPY_FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest.py
FROZEN_MANIFEST ?= $(MICROPY_FROZEN_MANIFEST)

MICROPY_FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py
FROZEN_MANIFEST = $(MICROPY_FROZEN_MANIFEST)

ifneq ($(FROZEN_MANIFEST),)
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
Expand All @@ -52,7 +32,6 @@ CONFIG ?= Debug

# include py core make definitions
include ../../py/mkenv.mk
include mpconfigport.mk
-include $(BOARD_DIR)/mpconfigboard.mk
include $(TOP)/py/py.mk
include $(TOP)/extmod/extmod.mk
Expand Down Expand Up @@ -204,31 +183,33 @@ ifeq ($(MP_LOGGER_DEBUG), 1)
CFLAGS += -DMICROPY_LOGGER_DEBUG=1
endif

$(BUILD)/firmware.elf: $(OBJ) $(MPY_MTB_LIBRARIES) $(LIBS)
$(info )
-include $(TOP)/lib/mtb-psoc6-libs/mtb-makefile.mk

$(BUILD)/firmware.elf: $(OBJ) $(LIBS)
$(info Linking $@ $^ $(LIBS) ...)
$(Q) $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(info Linking $@ done.)
$(Q) $(SIZE) $@ -A
$(info )


$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
$(Q) $(OBJCOPY) -O ihex $^ $@


# include adapter makefile
-include $(TOP)/lib/mtb-psoc6-libs/makefile_mtb.mk
mpy_build: $(BUILD)/firmware.hex

MPY_CROSS_FLAGS += -march=armv7m

build: mtb_get_build_flags $(GENERATED_PINS) $(BUILD)/firmware.hex
all: mtb_init mtb_get_build_flags mpy_build

clean: mtb_clean

all: build
rebuild: clean all

#clean: mtb_clean
qdeploy: mtb_program
deploy: all mtb_program

rebuild: clean mtb_clean all
qdeploy_multi: mtb_program_multi
deploy_multi: all mtb_program_multi

TESTS ?=-d psoc6
DEV0 ?= /dev/ttyACM0
Expand All @@ -240,7 +221,6 @@ test:
$(info Running PSoC6 tests)
$(Q) cd ../../tests ; ./run-tests.py --target psoc6 --device $(DEV0) $(TESTS)


MULTI_TESTS ?= $(shell cd ../../tests; find ./psoc6/multi/ -type f -name "*.py")

test_multi:
Expand All @@ -250,70 +230,36 @@ test_multi:

$(Q) cd ../../tests ; ./run-multitests.py -i pyb:$(DEV0) -i pyb:$(DEV1) $(MULTI_TESTS)

help:
port_help:
@:
$(info )
$(info ----------)
$(info Basic flow)
$(info ----------)
$(info )
$(info Prior working on a specific board, it is required to initialise ONCE the)
$(info ModusToolbox setup and retrieve all necessary assets for the specified)
$(info board:)
$(info )
$(info $$ make mtb_init BOARD=<board>)
$(info )
$(info Then repeatedly build the firmware:)
$(info )
$(info $$ make )
$(info )
$(info and flash the firmware on the device with:)
$(info )
$(info $$ make program)
$(info Available commands:)
$(info )
$(info make submodules Initialize port required submodules.)
$(info make BOARD=<board_name> Build the project for the specified board.)
$(info .. The board name needs to be specified only the first time.)
$(info .. Then simply run "make" to build for the same board.)
$(info make rebuild Build the project after cleaning previous build.)
$(info make deploy Build and deploy the project to the specified board.)
$(info make qdeploy Deploy the project to the specified board without rebuilding.)
$(info make deploy_multi Deploy the project to multiple boards.)
$(info make qdeploy_multi Deploy the project to multiple boards without rebuilding.)
$(info make clean Clean the build files.)
$(info make test Run the on-target test in tests/psoc6 folder. Uses /dev/ttyACM0.)
$(info .. Optionally, pass TESTS variable for change the tests set. )
$(info make test_multi Run multi-instance tests on-target test in tests/psoc6/multi folder.)
$(info .. Uses /dev/ttyACM0 and /dev/ttyACM1.)
$(info .. Optionally, pass MULTI_TESTS variable for change the tests set. )
$(info make help Show this help.)
$(info )
$(info 'make program' will also build the .hex file if any changes occurred in the code.)
$(info )
$(info -------------)
$(info Build targets)
$(info -------------)
$(info )
$(info The default 'make' target is 'build' when called without arguments.)
$(info - build Compile the MicroPython program binary file. )
$(info - clean Remove the '/build' folders with all object files and intermediate build support files.)
$(info - rebuild Clean before build.)
$(info )
$(info ---------------)
$(info Program targets)
$(info ---------------)
$(info )
$(info - program Flash the board device with the built micropython firmware. )
$(info - program_multi Flash multiple board deviced. )
$(info Options: )
$(info - EXT_HEX_FILE An external .hex file can be provided to the program targets, instead of building from the sources.)
$(info )
$(info ------------)
$(info Test targets)
$(info ------------)
$(info )
$(info - test Run the on-target test in tests/psoc6 folder. Uses /dev/ttyACM0.)
$(info .. Optionally, pass TESTS variable for change the tests set. )
$(info - test_multi Run multi-instance tests on-target test in tests/psoc6/multi folder.)
$(info .. Uses /dev/ttyACM0 and /dev/ttyACM1.)
$(info .. Optionally, pass MULTI_TESTS variable for change the tests set. )
$(info )
$(info --------------------)
$(info ModusToolbox targets)
$(info --------------------)
$(info EXT_HEX_FILE An external .hex file can be provided to the deploy targets, instead of building from the sources.)
$(info )
$(info - mtb_init BOARD=<board> Add the board support package required firmware assets, set the bsp )
$(info .. as active in the ModusToolbox project, and retrieves all required additional )
$(info .. middleware assets for MicroPython. )
$(info - mtb_deinit Clean all ModusToolbox shared and board support package dependencies assets.)
$(info - mtb_add_bsp Add a board support package. Only the ones integrated in MicroPython are supported. )
$(info - mtb_set_bsp Set the board as active in the ModusToolbox project. )

help: port_help mtb_bsp_help mtb_build_help
.DEFAULT_GOAL := all

.PHONY: build test test_multi program_multi help
.PHONY: all clean rebuild deploy qdeploy deploy_multi qdeploy_multi test test_multi help

# include py core make definitions
include $(TOP)/py/mkrules.mk
22 changes: 14 additions & 8 deletions ports/psoc6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@ Retrieve submodules:

make submodules

Then initialize the ModusToolbox™ environment:

make mtb_init BOARD=<board-name>

Build the firmware:

make
make BOARD=CY8CKIT_062S2_AI

> [!NOTE]
> The first time we call `make` the board needs to be specified with
> `BOARD=<board>`. This is required as the ModusToolbox libraries need to be
> initialized for the selected board.
> This board will then be set as the default board for subsequent builds, you
> can just call `make` without the `BOARD=` argument.

To build and program the device:
And flash it to the board:

make program
make deploy

> [!NOTE]
> This will also build the firmware if it has not been built yet.
> Use `deploy` target to avoid rebuilding the firmware.

Find more information about the available makefile targets:

make help


# Run micropython

Use any serial terminal (putty, minicom..) and establish a session with your device with 115200 bauds and 8-N-1 configuration.
7 changes: 3 additions & 4 deletions tools/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,11 @@ function ci_psoc6_setup {

function ci_psoc6_build {
board=$1
docker exec mtb-ci make mtb_init BOARD=${board}
docker exec mtb-ci make
docker exec mtb-ci make BOARD=${board}
}

function ci_psoc6_deploy {
docker exec mtb-ci make program
docker exec mtb-ci make deploy
}

function ci_psoc6_flash_multiple_devices {
Expand All @@ -390,7 +389,7 @@ function ci_psoc6_flash_multiple_devices {
hex_file=$2
devs_file=$3

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

function ci_psoc6_run_tests {
Expand Down
Loading