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 program #81

Merged
merged 3 commits into from
Sep 7, 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
19 changes: 14 additions & 5 deletions ports/psoc6/mtb-libs/makefile_mtb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ MPY_MTB_BOARD_BUILD_OUTPUT_DIR := $(MPY_MTB_BOARD_BUILD_DIR)/$(MPY_MTB_TARGET)/$

MPY_MTB_LIB_NAME = $(file < $(MPY_MTB_BOARD_BUILD_OUTPUT_DIR)/artifact.rsp)

MTB_HOME ?= $(HOME)/ModusToolbox
OPENOCD_HOME ?= $(MTB_HOME)/tools_3.0/openocd

# $(info MPY_DIR_OF_MTB_ADAPTER_MAKEFILE : $(MPY_DIR_OF_MTB_ADAPTER_MAKEFILE))

# $(info MPY_MTB_MAIN_MAKEFILE : $(MPY_MTB_MAIN_MAKEFILE))
Expand All @@ -30,7 +27,7 @@ OPENOCD_HOME ?= $(MTB_HOME)/tools_3.0/openocd
# $(info MPY_MTB_BOARD_BUILD_DIR : $(MPY_MTB_BOARD_BUILD_DIR))
# $(info MPY_MTB_BOARD_BUILD_OUTPUT_DIR : $(MPY_MTB_BOARD_BUILD_OUTPUT_DIR))

mtb_init: mtb_add_bsp mtb_set_bsp mtb_get_libs
mtb_init: mtb_deinit mtb_add_bsp mtb_set_bsp mtb_get_libs
$(info )
$(info Initializing ModusToolbox libs for board $(BOARD))

Expand Down Expand Up @@ -125,11 +122,23 @@ else
HEX_FILE = $(EXT_HEX_FILE)
endif

MTB_HOME ?= $(HOME)/ModusToolbox
OPENOCD_HOME ?= $(MTB_HOME)/tools_3.0/openocd

# Selection of openocd cfg files based on board
OPENOCD_CFG_SEARCH = $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)/bsps/TARGET_APP_$(BOARD)/config/GeneratedSource

ifeq ($(BOARD),CY8CPROTO-062-4343W)
OPENOCD_TARGET_CFG=psoc6_2m.cfg
else ifeq ($(BOARD),CY8CPROTO-063-BLE)
OPENOCD_TARGET_CFG=psoc6.cfg
endif

program: $(PROG_DEPS)
@:
$(info )
$(info Programming using openocd ...)
openocd -s $(OPENOCD_HOME)/scripts -s $(MTB_BASE_EXAMPLE_MAKEFILE_DIR)/bsps/TARGET_APP_$(BOARD)/config/GeneratedSource -c "source [find interface/kitprog3.cfg]; $(SERIAL_ADAPTER_CMD) ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program $(HEX_FILE) verify reset exit;"
openocd -s $(OPENOCD_HOME)/scripts -s $(OPENOCD_CFG_SEARCH) -c "source [find interface/kitprog3.cfg]; $(SERIAL_ADAPTER_CMD) ; source [find target/$(OPENOCD_TARGET_CFG)]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program $(HEX_FILE) verify reset exit;"
$(info Programming done.)

program_multi: attached_devs
Expand Down
60 changes: 47 additions & 13 deletions tools/psoc6/mpy-psoc6.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exit /b 0
exit /b 0

:cmd_firmware_deploy
call :mpy_firmware_deploy %2 %3
call :mpy_firmware_deploy %2 %3 %4
exit /b 0

:cmd_device_erase
Expand Down Expand Up @@ -79,12 +79,24 @@ exit /b 0

:mpy_firmware_deploy

Rem Board is yet unused. In future the suitable target .cfg selection needs to be based on the board.
set board=%~1
set hex_file=%~2
set serial_adapter_sn=%~3

if "%board%" == "CY8CPROTO-062-4343W" (
call set target_cfg=psoc6_2m.cfg
) else if "%board%" == "CY8CPROTO-063-BLE" (
call set target_cfg=psoc6.cfg
)

if [%serial_adapter_sn%] == [] (
call set serial_adapter_opt=
) else (
call set serial_adapter_opt="adapter serial %serial_adapter_sn%"
)

echo Deploying Micropython...
openocd.exe -s openocd\scripts -s openocd\board -c "source [find interface/kitprog3.cfg]; ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program %hex_file% verify reset exit;"
openocd.exe -s openocd\scripts -s openocd\board -c "source [find interface/kitprog3.cfg]; %serial_adapter_opt% ; source [find target/%target_cfg%]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program %hex_file% verify reset exit;"

exit /b 0

Expand Down Expand Up @@ -151,19 +163,30 @@ exit /b 0
Rem Board selection
set board=%~1
set board_list[0]=CY8CPROTO-062-4343W
set board_list[1]=CY8CPROTO-063-BLE
if [%board%]==[] (
echo:
echo Supported MicroPython PSoC6 boards
echo +---------+-----------------------------------+
echo ^| ID ^| Board ^|
echo +---------+-----------------------------------+
echo ^| 0 ^| CY8CPROTO-062-4343W (default^) ^|
echo ^| 0 ^| CY8CPROTO-062-4343W ^|
echo +---------+-----------------------------------+
echo ^| 1 ^| CY8CPROTO-063-BLE ^|
echo +---------+-----------------------------------+
echo:
echo No user selection required. Only one choice.
set /a board_index=0
echo:
Rem set /p/( "board_index=Please type the desired board ID. " --> Uncomment and remove preselection above when more options are available
set /P board_index=Please type the desired board ID:

if !board_index! LSS 0 (
echo error: board ID not valid
exit /b 1
)

if !board_index! GTR 1 (
echo error: board ID not valid
exit /b 1
)

call set board=%%board_list[!board_index!]%%
)
echo MicroPython PSoC6 Board :: %board%
Expand Down Expand Up @@ -212,19 +235,30 @@ exit /b 0
Rem Board selection
set board=%~1
set board_list[0]=CY8CPROTO-062-4343W
set board_list[1]=CY8CPROTO-063-BLE
if [%board%]==[] (
echo:
echo Supported MicroPython PSoC6 boards
echo +---------+-----------------------------------+
echo ^| ID ^| Board ^|
echo +---------+-----------------------------------+
echo ^| 0 ^| CY8CPROTO-062-4343W (default^) ^|
echo ^| 0 ^| CY8CPROTO-062-4343W ^|
echo +---------+-----------------------------------+
echo ^| 1 ^| CY8CPROTO-063-BLE ^|
echo +---------+-----------------------------------+
echo:
echo No user selection required. Only one choice.
set /a board_index=0
echo:
Rem set /p/( "board_index=Please type the desired board ID. " --> Uncomment and remove preselection above when more options are available
set /P board_index=Please type the desired board ID:

if !board_index! LSS 0 (
echo error: board ID not valid
exit /b 1
)

if !board_index! GTR 1 (
echo error: board ID not valid
exit /b 1
)

call set board=%%board_list[!board_index!]%%
)
echo MicroPython PSoC6 Board :: %board%
Expand Down
36 changes: 28 additions & 8 deletions tools/psoc6/mpy-psoc6.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

###################
# Script Functions
###################
Expand Down Expand Up @@ -49,9 +51,22 @@ function help {
function mpy_firmware_deploy {
board=$1
hex_file=$2
serial_adapter_sn=$3

if [ "$board" = "CY8CPROTO-062-4343W" ]; then
target_cfg=psoc6_2m.cfg
elif [ "$board" = "CY8CPROTO-063-BLE" ]; then
target_cfg=psoc6.cfg
fi

if [ "$serial_adapter_sn" = "" ]; then
serial_adapter_opt=
else
serial_adapter_opt="adapter serial ${serial_adapter_sn}"
fi

echo Deploying firmware...
openocd -s openocd\scripts -s openocd/board -c "source [find interface/kitprog3.cfg]; ; source [find target/psoc6_2m.cfg]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program ${hex_file} verify reset exit;"
openocd -s openocd/scripts -s openocd/board -c "source [find interface/kitprog3.cfg]; ${serial_adapter_opt} ; source [find target/${target_cfg}]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program ${hex_file} verify reset exit;"
}

function mpy_firmware_download {
Expand Down Expand Up @@ -124,26 +139,31 @@ board=""

function select_board {
board=$1
board_list=(CY8CPROTO-062-4343W)
board_list=(CY8CPROTO-062-4343W \
CY8CPROTO-063-BLE)

if [ "$board" = "" ]; then
echo ''
echo ' Supported MicroPython PSoC6 boards '
echo '+---------+-----------------------------------+'
echo '| ID | Board |'
echo '+---------+-----------------------------------+'
echo '| 0 | CY8CPROTO-062-4343W (default) |'
echo '| 0 | CY8CPROTO-062-4343W |'
echo '+---------+-----------------------------------+'
echo '| 1 | CY8CPROTO-063-BLE |'
echo '+---------+-----------------------------------+'
echo ''
echo 'No user selection required. Only one choice.'

board_index=0
echo ''

# Uncomment and remove preselection above when more options are available
# echo Please type the desired board ID.
# read board_index

echo Please type the desired board ID.
read board_index
if [ "$board_index" -lt 0 ] || [ "$board_index" -gt 1 ]; then
echo "error: board ID not valid"
exit 1
fi
board=${board_list[${board_index}]}
fi

Expand Down Expand Up @@ -259,7 +279,7 @@ case $1 in
mpy_device_setup $2 $3 $4
;;
"firmware-deploy")
mpy_firmware_deploy $2 $3
mpy_firmware_deploy $2 $3 $4
;;
"device-erase")
mpy_device_erase $2 $3
Expand Down
Loading