From cad8afe0842cd73f5b73949fa12eab1fda326055 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral <38422348+umarcor@users.noreply.github.com> Date: Tue, 2 Aug 2022 13:30:28 +0200 Subject: [PATCH] f4pga/wrappers: do not use shell scripts for quicklogic's 'write_*' commands (#599) --- f4pga/wrappers/sh/__init__.py | 20 +++++++++++++---- .../sh/quicklogic/write_binary.f4pga.sh | 22 ------------------- .../sh/quicklogic/write_bitheader.f4pga.sh | 22 ------------------- .../sh/quicklogic/write_jlink.f4pga.sh | 22 ------------------- .../sh/quicklogic/write_openocd.f4pga.sh | 22 ------------------- 5 files changed, 16 insertions(+), 92 deletions(-) delete mode 100755 f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh delete mode 100755 f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh delete mode 100755 f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh delete mode 100755 f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh diff --git a/f4pga/wrappers/sh/__init__.py b/f4pga/wrappers/sh/__init__.py index e6d6e35..7c4cf57 100644 --- a/f4pga/wrappers/sh/__init__.py +++ b/f4pga/wrappers/sh/__init__.py @@ -22,6 +22,7 @@ from sys import argv as sys_argv, stdout, stderr from os import environ from pathlib import Path +from shutil import which from subprocess import check_call @@ -47,6 +48,12 @@ def run_sh(script): check_call([str(script)]+sys_argv[1:], env=f4pga_environ) +def run_pym(module): + stdout.flush() + stderr.flush() + check_call([which('python3'), '-m' , module]+sys_argv[1:], env=f4pga_environ) + + def generate_constraints(): print("[F4PGA] Running (deprecated) generate constraints") run_sh(ROOT / SH_SUBDIR / "generate_constraints.f4pga.sh") @@ -121,18 +128,23 @@ def fasm2bels(): print("[F4PGA] Running (deprecated) fasm2bels") run_sh(ROOT / "quicklogic/fasm2bels.f4pga.sh") + def write_bitheader(): print("[F4PGA] Running (deprecated) write bitheader") - run_sh(ROOT / "quicklogic/write_bitheader.f4pga.sh") + print("Converting bitstream to C Header") + run_pym('quicklogic_fasm.bitstream_to_header') def write_binary(): print("[F4PGA] Running (deprecated) write binary") - run_sh(ROOT / "quicklogic/write_binary.f4pga.sh") + print("Converting bitstream to flashable binary format") + run_pym('quicklogic_fasm.bitstream_to_binary') def write_jlink(): print("[F4PGA] Running (deprecated) write jlink") - run_sh(ROOT / "quicklogic/write_jlink.f4pga.sh") + print("Converting bitstream to JLink script") + run_pym('quicklogic_fasm.bitstream_to_jlink') def write_openocd(): print("[F4PGA] Running (deprecated) write openocd") - run_sh(ROOT / "quicklogic/write_openocd.f4pga.sh") + print("Converting bitstream to OpenOCD script") + run_pym('quicklogic_fasm.bitstream_to_openocd') diff --git a/f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh deleted file mode 100755 index d5ebeb3..0000000 --- a/f4pga/wrappers/sh/quicklogic/write_binary.f4pga.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -echo "Converting bitstream to flashable binary format" -`which python3` -m quicklogic_fasm.bitstream_to_binary $@ diff --git a/f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh deleted file mode 100755 index f0d6eef..0000000 --- a/f4pga/wrappers/sh/quicklogic/write_bitheader.f4pga.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -echo "Converting bitstream to C Header" -`which python3` -m quicklogic_fasm.bitstream_to_header $@ diff --git a/f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh deleted file mode 100755 index 6c85fb5..0000000 --- a/f4pga/wrappers/sh/quicklogic/write_jlink.f4pga.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -echo "Converting bitstream to JLink script" -`which python3` -m quicklogic_fasm.bitstream_to_jlink $@ diff --git a/f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh b/f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh deleted file mode 100755 index 345fb6b..0000000 --- a/f4pga/wrappers/sh/quicklogic/write_openocd.f4pga.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2020-2022 F4PGA Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -echo "Converting bitstream to OpenOCD script" -`which python3` -m quicklogic_fasm.bitstream_to_openocd $@