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

nmigen tilegrid.json path issue when using symbiflow toolchain #123

Closed
nickoe opened this issue Jan 27, 2021 · 10 comments
Closed

nmigen tilegrid.json path issue when using symbiflow toolchain #123

nickoe opened this issue Jan 27, 2021 · 10 comments

Comments

@nickoe
Copy link

nickoe commented Jan 27, 2021

@litghost were very persisten that I should create an issue about this one in this repo, so here it is.

The error in short is:

FileNotFoundError: [Errno 2] No such file or directory: '/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/share/symbiflow/prjxray-db/xc7a35tcsg324-1/tilegrid.json'

Essentially it looks like the path to tilegrid.json is wrong, it is missing the artix7 folder that contains xc7a35tcpg236-1.

Writing Implementation FASM: top.fasm
The entire flow of VPR took 24.8408 seconds.
FASM extra: top_fasm_extra.fasm
writing final fasm
Writing bitstream ...
Traceback (most recent call last):
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/bin/xcfasm", line 8, in <module>
    sys.exit(main())
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/site-packages/xc_fasm/xc_fasm.py", line 63, in main
    emit_pudc_b_pullup=args.emit_pudc_b_pullup)
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/site-packages/xc_fasm/fasm2frames.py", line 120, in fasm2frames
    assembler = fasm_assembler.FasmAssembler(db)
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/site-packages/prjxray/fasm_assembler.py", line 32, in __init__
    self.grid = db.grid()
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/site-packages/prjxray/db.py", line 152, in grid
    self._read_tilegrid()
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/site-packages/prjxray/db.py", line 133, in _read_tilegrid
    'tilegrid.json')) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/share/symbiflow/prjxray-db/xc7a35tcsg324-1/tilegrid.json'
Traceback (most recent call last):
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/symbiflow-examples_deleteme/nmigen/nmigen-boards/nmigen_boards/arty_a7.py", line 219, in <module>
    ArtyA7Platform(toolchain="Symbiflow").build(Blinky(), do_program=False)
  File "/tmp/symbiflow-examples_deleteme/nmigen/nmigen/build/plat.py", line 99, in build
    products = plan.execute_local(build_dir)
  File "/tmp/symbiflow-examples_deleteme/nmigen/nmigen/build/run.py", line 98, in execute_local
    subprocess.check_call(["sh", "{}.sh".format(self.script)])
  File "/home/nickoe/symbiflow_toolchain_deleteme/xc7/conda/envs/xc7/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sh', 'build_top.sh']' returned non-zero exit status 1.

I am trying to use the symbiflow toolchain with nmigen, and I had to patch a little so it is not stright forward to test, but I made this script to document my steps taken:

#!/bin/bash -ex

# Following instructions...
# https://symbiflow-examples.readthedocs.io/en/latest/getting-symbiflow.html

cd /tmp
git clone https://github.com/SymbiFlow/symbiflow-examples symbiflow-examples_deleteme
cd symbiflow-examples_deleteme

export FPGA_FAM=xc7
export INSTALL_DIR=${HOME}/symbiflow_toolchain_deleteme

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O conda_installer.sh
bash conda_installer.sh -u -b -p $INSTALL_DIR/$FPGA_FAM/conda;
source "$INSTALL_DIR/$FPGA_FAM/conda/etc/profile.d/conda.sh";
conda env create --force -f ${FPGA_FAM}/environment.yml

mkdir -p $INSTALL_DIR/xc7/install

wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-install-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install
wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-xc7a50t_test-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install
wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-xc7a100t_test-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install
wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-xc7a200t_test-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install
wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-xc7z010_test-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install

conda activate $FPGA_FAM

# cloning forks/fixes of the nmigen stuff
git clone https://github.com/nickoe/nmigen.git -b fixup_symbiflow_toolchain_xilinx_7series
cd nmigen
pip install -e .

git clone https://github.com/nickoe/nmigen-boards.git -b basys3
cd nmigen-boards
pip install -e .

export PATH="$INSTALL_DIR/$FPGA_FAM/install/bin:$PATH";
conda activate $FPGA_FAM

set +x
echo
echo
echo
echo ============================================================
echo Run this:
echo
echo export FPGA_FAM=xc7
echo export INSTALL_DIR=${HOME}/symbiflow_toolchain_deleteme
echo export PATH="$INSTALL_DIR/$FPGA_FAM/install/bin:$PATH"
echo conda activate $FPGA_FAM
echo python3 -m nmigen_boards.arty_a7
echo
echo ============================================================
@acomodi
Copy link
Contributor

acomodi commented Jan 28, 2021

Thanks for filing this issue @nickoe!

I could reproduce the error and found the solution. Basically what is missing is the -d parameter to write_bitstream which identifies the FPGA family (artix7, zynq7, kintex7, etc), to get the correct database info.

By adding that, and calling python3 -m nmigen_boards.arty_a7 once again, I could get to the end of the flow.

@nickoe
Copy link
Author

nickoe commented Jan 28, 2021

@acomodi Thank you for investigating, I will try that when I get home and update my PR to nmigen.

@tcal-x
Copy link
Contributor

tcal-x commented Jan 28, 2021

@nickoe & @acomodi , this is great!

@mithro
Copy link
Contributor

mithro commented Jan 28, 2021

There should probably be a much better error messages?

@nickoe
Copy link
Author

nickoe commented Jan 28, 2021

@mithro I am not sure anything easy can be done for that, but the symbiflow_write_bitstream does not seem to have any help text, so I don't really know what args it takes. Or maybe it is just nmigen that should print the failing command?

@mithro
Copy link
Contributor

mithro commented Jan 28, 2021

@mithro I am not sure anything easy can be done for that, but the symbiflow_write_bitstream does not seem to have any help text, so I don't really know what args it takes. Or maybe it is just nmigen that should print the failing command?

@acomodi logged f4pga/f4pga-arch-defs#1985 -- That should most certainly be fixed!

nickoe added a commit to nickoe/symbiflow-arch-defs that referenced this issue Jan 28, 2021
DBROOT depends on the DEVICE variable, so we need to be past any code
that set DEVICE before settting DBROOT.

This cause nmigen fail when using the symbiflow toolchain. See:

chipsalliance/f4pga-examples#123
nickoe added a commit to nickoe/symbiflow-arch-defs that referenced this issue Jan 28, 2021
DBROOT depends on the DEVICE variable, so we need to be past any code
that set DEVICE before settting DBROOT.

This cause nmigen fail when using the symbiflow toolchain. See:
chipsalliance/f4pga-examples#123

This regression was caused in b355148
@nickoe
Copy link
Author

nickoe commented Jan 28, 2021

Mmm, I think the is a regression in the symbiflow_write_bitstream, I patched that, but it still errors about the tilegrid.json missing. It appears that this file is only defined for some devices, is this expected?

EDIT: Remove red herring for readability.

nickoe added a commit to nickoe/symbiflow-arch-defs that referenced this issue Jan 28, 2021
DBROOT depends on the DEVICE variable, so we need to be past any code
that set DEVICE before settting DBROOT.

This cause nmigen fail when using the symbiflow toolchain. See:
chipsalliance/f4pga-examples#123

This regression was caused in b355148

Signed-off-by: Nick Østergaard <oe.nick@gmail.com>
@nickoe
Copy link
Author

nickoe commented Jan 28, 2021

Ok, the last thing with the tilegrid appears fixed with conda install -c litex-hub prjxray-db=0.0_0239_gd87c844=20201120_145821.

@nickoe
Copy link
Author

nickoe commented Jan 28, 2021

It appears that the suggestion proposed in #123 (comment) is not required, but certainly related to the issue. There was a bug in symbiflow_write_bitstream, it should find the db root by itself, there is a proposed patch in:

f4pga/f4pga-arch-defs#1986

In other words, using those patches I was able to build a bit file successfully, but it appears there is another issue with the builtin flashing stuff with the products.

+ xcfasm --db-root /home/nickoe/symbiflow_install/xc7/conda/envs/xc7/share/symbiflow/prjxray-db/artix7 --part xc7a35tcpg236-1 --part_file /home/nickoe/symbiflow_install/xc7/conda/envs/xc7/share/symbiflow/prjxray-db/artix7/xc7a35tcpg236-1/part.yaml --sparse --emit_pudc_b_pullup --fn_in top.fasm --bit_out top.bit
ERROR: failed to set programming file
Traceback (most recent call last):
  File "/home/nickoe/symbiflow_install/xc7/conda/envs/xc7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/nickoe/symbiflow_install/xc7/conda/envs/xc7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/nickoe/nmigen_test/nmigen-boards/nmigen_boards/basys3.py", line 215, in <module>
    Basys3Platform(toolchain="Symbiflow").build(Blinky(), do_program=True)
  File "/home/nickoe/nmigen_test/nmigen/nmigen/build/plat.py", line 103, in build
    self.toolchain_program(products, name, **(program_opts or {}))
  File "/home/nickoe/nmigen_test/nmigen-boards/nmigen_boards/basys3.py", line 198, in toolchain_program
    subprocess.run([djtgcfg, "prog", "-d", "Basys3", "-i", "0", "-f", bitstream_filename], check=True)
  File "/home/nickoe/symbiflow_install/xc7/conda/envs/xc7/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['djtgcfg', 'prog', '-d', 'Basys3', '-i', '0', '-f', '/tmp/nmigen_qy2eulgo_top.bit']' returned non-zero exit status 1.

Clearly the bit stream is just named top.bit and put in the build folder, but nmigen thinks there is a file in tmp...

nickoe added a commit to nickoe/symbiflow-arch-defs that referenced this issue Jan 28, 2021
DBROOT depends on the DEVICE variable, so we need to be past any code
that set DEVICE before settting DBROOT.

This cause nmigen fail when using the symbiflow toolchain. See:
chipsalliance/f4pga-examples#123

This regression was caused in b355148

Signed-off-by: Nick Østergaard <oe.nick@gmail.com>
nickoe added a commit to nickoe/symbiflow-arch-defs that referenced this issue Jan 29, 2021
DBROOT depends on the DEVICE variable, so we need to be past any code
that set DEVICE before settting DBROOT.

This cause nmigen fail when using the symbiflow toolchain. See:
chipsalliance/f4pga-examples#123

This regression was caused in b355148

Signed-off-by: Nick Østergaard <oe.nick@gmail.com>
@nickoe
Copy link
Author

nickoe commented Jan 31, 2021

This is resolved with this fix in arch defs, nickoe/symbiflow-arch-defs@e16b209

@nickoe nickoe closed this as completed Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants