environment: fix environment set up

Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
This commit is contained in:
Alessandro Comodi 2021-01-20 11:27:34 +01:00
parent e25c20a8f1
commit 3d4c9addf0
8 changed files with 76 additions and 16 deletions

View File

@ -22,8 +22,7 @@ import signal
import subprocess
import sys
import traceback
from prjxray.util import get_part_information, get_part_resources
from prjxray.util import get_fabric_for_part
from utils.create_environment import get_environment_variables
import junit_xml
@ -449,20 +448,10 @@ def main(argv):
os.makedirs(fuzzer_logdir)
assert os.path.exists(fuzzer_logdir)
# Set part information from the mapping files and set into the env
db_root = os.path.join(
os.environ['XRAY_DATABASE_DIR'], os.environ['XRAY_DATABASE'])
part = get_part_information(db_root, os.environ['XRAY_PART'])
os.environ['XRAY_DEVICE'] = part['device']
os.environ['XRAY_PACKAGE'] = part['package']
os.environ['XRAY_SPEED_GRADE'] = part['speedgrade']
fabric = get_fabric_for_part(db_root, os.environ['XRAY_PART'])
os.environ['XRAY_FABRIC'] = fabric
res_path = os.path.join(
os.environ['XRAY_DIR'], 'settings', os.environ['XRAY_DATABASE'])
resources = get_part_resources(res_path, os.environ['XRAY_PART'])
for number, pin in resources['pins'].items():
os.environ['XRAY_PIN_{:02d}'.format(number)] = pin
# Update the environment for a specific part
environment = get_environment_variables()
for key, value in environment.items():
os.environ[key] = value
exit_code = -1
args.retries += 1

View File

@ -32,3 +32,5 @@ export XRAY_ROI_GRID_Y1="0"
export XRAY_ROI_GRID_Y2="51"
source $(dirname ${BASH_SOURCE[0]})/../utils/environment.sh
eval $(python3 ${XRAY_UTILS_DIR}/create_environment.py)

View File

@ -22,3 +22,5 @@ export XRAY_EXCLUDE_ROI_TILEGRID=""
export XRAY_IOI3_TILES="RIOI3_X105Y9 LIOI3_X0Y9"
source $(dirname ${BASH_SOURCE[0]})/../utils/environment.sh
eval $(python3 ${XRAY_UTILS_DIR}/create_environment.py)

View File

@ -31,3 +31,5 @@ export XRAY_ROI_GRID_Y1="0"
export XRAY_ROI_GRID_Y2="51"
source $(dirname ${BASH_SOURCE[0]})/../utils/environment.sh
eval $(python3 ${XRAY_UTILS_DIR}/create_environment.py)

View File

@ -26,3 +26,5 @@ export XRAY_ROI_GRID_Y1="104"
export XRAY_ROI_GRID_Y2="156"
source $(dirname ${BASH_SOURCE[0]})/../utils/environment.sh
eval $(python3 ${XRAY_UTILS_DIR}/create_environment.py)

View File

@ -28,3 +28,5 @@ export XRAY_ROI_GRID_Y1="105"
export XRAY_ROI_GRID_Y2="155"
source $(dirname ${BASH_SOURCE[0]})/../utils/environment.sh
eval $(python3 ${XRAY_UTILS_DIR}/create_environment.py)

View File

@ -28,3 +28,5 @@ export XRAY_ROI_GRID_Y1="0"
export XRAY_ROI_GRID_Y2="51"
source $(dirname ${BASH_SOURCE[0]})/../utils/environment.sh
eval $(python3 ${XRAY_UTILS_DIR}/create_environment.py)

59
utils/create_environment.py Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017-2020 The Project X-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import os
from prjxray.util import get_part_information, get_part_resources, get_fabric_for_part
def get_environment_variables():
"""
This function returns a dict of environment settings for a given part.
It requires a basic setup of the prjxray environment that contains
information about the databse directory location, the FPGA part, etc.
One of the settings must be sourced, to set up the basic environment.
"""
environment = dict()
# Get base environment variables and resources' paths
part = os.environ['XRAY_PART']
database = os.environ['XRAY_DATABASE']
database_dir = os.environ['XRAY_DATABASE_DIR']
xray_root = os.environ['XRAY_DIR']
db_root = os.path.join(database_dir, database)
res_path = os.path.join(xray_root, 'settings', database)
# Get device information
part_info = get_part_information(db_root, part)
fabric = get_fabric_for_part(db_root, part)
resources = get_part_resources(res_path, os.environ['XRAY_PART'])
environment['XRAY_DEVICE'] = part_info['device']
environment['XRAY_PACKAGE'] = part_info['package']
environment['XRAY_SPEED_GRADE'] = part_info['speedgrade']
environment['XRAY_FABRIC'] = fabric
for number, pin in resources['pins'].items():
environment['XRAY_PIN_{:02d}'.format(number)] = pin
return environment
def main():
environment = get_environment_variables()
for key, value in environment.items():
print("export {}={}".format(key, value))
if __name__ == "__main__":
main()