Skip to content

Commit

Permalink
tools/psoc6/mpy-psoc6.py: Modidifications for windows enablement.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Nov 15, 2023
1 parent f164482 commit e53e156
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions tools/psoc6/mpy-psoc6.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ def openocd_board_conf_download(board):


def openocd_program(board, hex_file, serial_adapter_sn=None):

if opsys == "linux":
openocd = "openocd"
elif opsys == "win":
openocd = "openocd.exe"

for brd in boards:
if board == brd["name"]:
ocd_cfg_file = brd["ocd_cfg_file"]
Expand All @@ -142,14 +148,16 @@ def openocd_program(board, hex_file, serial_adapter_sn=None):
serial_adapter_opt = "adapter serial " + str(serial_adapter_sn)

openocd_cmd = (
'openocd -s openocd/scripts -s openocd/board -c "source [find interface/kitprog3.cfg];'
openocd
+ ' -s openocd/scripts -s openocd/board -c "source [find interface/kitprog3.cfg];'
+ str(serial_adapter_opt)
+ " ; source [find target/"
+ str(ocd_cfg_file)
+ "]; psoc6 allow_efuse_program off; psoc6 sflash_restrictions 1; program "
+ str(hex_file)
+ ' verify reset exit;"'
)
print(openocd_cmd)
openocd_args = shlex.split(openocd_cmd)

try:
Expand Down Expand Up @@ -199,7 +207,6 @@ def validate_board_index(board_index):
print("+---------+-----------------------------------+")
print("")
print("")
print()

board_index = int(input("Please type the desired board ID: "))
validate_board_index(board_index)
Expand Down Expand Up @@ -230,8 +237,6 @@ def device_setup(board, version, quiet=False):
print("MicroPython PSoC6 Version :: ", version)

openocd_download_install()
board = "CY8CPROTO-062-4343W"
version = "latest"
openocd_board_conf_download(board)
mpy_firmware_download("hello-world", board, "v0.3.0")
mpy_firmware_download("mpy-psoc6", board, version)
Expand Down Expand Up @@ -302,15 +307,23 @@ def extract_arduino_lab():

def launch_arduino_lab():
print("Launching Arduino Lab for Micropython...")

if opsys == "linux":
mpy_ide = ["arduino-lab-micropython-ide"]
elif opsys == "win":
mpy_ide = ["Arduino Lab for Micropython.exe"]

mpyinolab_dir = "arduino-lab-mpy"
parent_dir = os.path.abspath(os.curdir)
os.chdir(mpyinolab_dir)
mpy_ide = os.path.join(mpyinolab_dir, "arduino-lab-micropython-ide")

try:
ide_proc = subprocess.Popen([mpy_ide])
ide_proc = subprocess.Popen(mpy_ide)
ide_proc.wait()
except:
raise Exception("error: Could not launch Arduino Lab IDE")

os.chdir(parent_dir)

download_arduino_lab()
extract_arduino_lab()
Expand Down Expand Up @@ -375,9 +388,9 @@ def parser_device_erase(args):
parser_qs = subparser.add_parser(
"quick-start",
description="Setup of MicroPython IDE and PSoC6 board. \
Use this command for a guided installation and \
quick start using MicroPython PSoC6.",
)
Use this command for a guided installation and \
quick start using MicroPython PSoC6.",
)
parser_qs.add_argument(
"-b", "--board", default=None, type=str, help="PSoC6 prototyping kit name"
)
Expand All @@ -390,9 +403,9 @@ def parser_device_erase(args):
parser_ds = subparser.add_parser(
"device-setup",
description="Setup of MicroPython PSoC6 board. \
Use this command to install the deployment tools \
and MicroPython firmware binary, and deploy the \
firmware on the PSoC6 device.",
Use this command to install the deployment tools \
and MicroPython firmware binary, and deploy the \
firmware on the PSoC6 device.",
)
parser_ds.add_argument(
"-b", "--board", default=None, type=str, help="PSoC6 prototyping kit name"
Expand Down Expand Up @@ -429,7 +442,7 @@ def parser_device_erase(args):
for the selected board.",
)
parser_de.add_argument(
"-b", "--board", default=None, type=str, help="PSoC6 prototyping kit name"
"-b", "--board", default=None, type=str, required=True, help="PSoC6 prototyping kit name"
)
parser_de.add_argument(
"-q", action="store_true", help="Quiet. Do not prompt any user confirmation request"
Expand Down

0 comments on commit e53e156

Please sign in to comment.