Skip to content

Commit 8da61de

Browse files
committed
QuartusUSBJTAG: fix to use copied env again
This was removed prior but can not work at least for the exporter as os.env is per process and for all subprocesses. In the epxorter case this leads to interference between different exported resources.
1 parent 23f2254 commit 8da61de

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

labgrid/driver/quartuspgmdriver.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ def operate(self, filename=None, operation="P", devnum=1) -> tuple[str, str]:
6464
lib_path = importlib.machinery.PathFinder.find_spec('libfilsel').origin
6565

6666
ld_preload = [lib_path, os.getenv('LD_PRELOAD', "")]
67-
os.environ["LD_PRELOAD"] = os.pathsep.join(ld_preload)
68-
os.environ["FILSEL_ORG_PATH"] = str((Path(os.path.expanduser('~')) / ".jtag.conf").resolve())
67+
my_env = os.environ.copy()
68+
my_env["LD_PRELOAD"] = os.pathsep.join(ld_preload)
69+
my_env["FILSEL_ORG_PATH"] = str((Path(os.path.expanduser('~')) / ".jtag.conf").resolve())
6970

7071
cable = f"'{self.interface.device_name} on {self.interface.host}:{self.interface.jtagd_port} {self.interface.device_port}'"
7172
operation = f"'{operation};{filename}@{str(devnum)}'"
@@ -81,9 +82,9 @@ def operate(self, filename=None, operation="P", devnum=1) -> tuple[str, str]:
8182
conf_temp.write(cfg.encode("utf-8"))
8283
conf_temp.flush()
8384
log.info("Flashing with command: %s", cmd)
84-
os.environ["FILSEL_DEST_PATH"] = conf_temp.name
85+
my_env["FILSEL_DEST_PATH"] = conf_temp.name
8586

86-
process = subprocess.Popen(cmd, shell=True,
87+
process = subprocess.Popen(cmd, shell=True, env=my_env,
8788
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
8889
stdout, stderr = process.communicate()
8990

labgrid/remote/exporter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,16 @@ def _start(self, start_params):
390390
# find the right path to the library and modify the env
391391
lib_path = importlib.machinery.PathFinder.find_spec('libhwsf').origin
392392
ld_preload = [lib_path, os.getenv('LD_PRELOAD', "")]
393-
os.environ["LD_PRELOAD"] = os.pathsep.join(ld_preload)
394-
os.environ["HWSF_DEV"] = "path:" + self.local.device.sys_name
393+
my_env = os.environ.copy()
394+
my_env["LD_PRELOAD"] = os.pathsep.join(ld_preload)
395+
my_env["HWSF_DEV"] = "path:" + self.local.device.sys_name
395396

396397
cmd = f"{self.local.jtagd_cmd} --foreground --port {self.jtagd_port} --config {self.cfg_tempfile.name}"
397398

398399
self.logger.info("starting jtagd for %s on port %s with command LD_PRELOAD+=%s HWSF_DEV=%s %s",
399400
self.local.device.sys_name, self.jtagd_port, lib_path,
400-
os.environ['HWSF_DEV'], cmd)
401-
self.child = subprocess.Popen(cmd, shell=True, preexec_fn=os.setsid)
401+
my_env['HWSF_DEV'], cmd)
402+
self.child = subprocess.Popen(cmd, env=my_env, shell=True, preexec_fn=os.setsid)
402403

403404
def _stop(self, start_params):
404405
"""Stop ``jtagd`` subprocess"""

0 commit comments

Comments
 (0)