enjoy-digital / litex

Build your hardware, easily!
Other
2.77k stars 538 forks source link

Native windows Vivado and WSL2 Litex build fails to find toolchain #1930

Open exitrip opened 2 months ago

exitrip commented 2 months ago

Kinda an edge case, but I'm also not sure how friendly Vivado's linux installer would work with WSL2...

calling python3 -m litex_boards.targets.colorlight_i9plus --build --toolchain=vivado in an otherwise working (with Lattice chips) Litex WSL2 install fails to properly use the windows exe tools.

I can't find any place Litex calls rdiArgs.sh, to try to point to rdiArgs.bat

I'm not sure about the relationship between rdiArgs (which is the only place I can find the string lnx64) and how Litex handles path resolution. Nor do I know anything about how Vivado uses Java...

/mnt/d/Xilinx/Vivado/2023.2/bin/rdiArgs.sh: line 38: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
WARNING: /mnt/d/Xilinx/Vivado/2023.2/tps/lnx64/jre17.0.7_7 does not exist.
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
ERROR: Could not find 64-bit executable.
ERROR: /mnt/d/Xilinx/Vivado/2023.2/bin/unwrapped/lnx64.o/vivado does not exist

Does anyone have experience installing Vivado in WSL?

linhz0hz commented 2 months ago

I have similar questions with gowin toolchain actually. How do you pass a path inside WSL to a windows program so it is properly identified? Some searching online suggested that you can reference it using \wsl.localhost\Ubuntu\home\

On the other hand, I am checking if litex can be made to work with powershell directly.

nmk456 commented 1 month ago

I've been trying to do this as well and ran into the same issue. I did some testing and found out it's because litex sees it's in WSL and tries to call the linux command to run Vivado (vivado) instead of the Windows one (vivado.bat). Every Vivado installation has both of these scripts included, but not the respective binaries for other platforms. That's what the lnx64.o/vivado does not exist error is about, it's looking for the Linux lnx64.o binary when only the Windows win64.o one exists.

I tried to work around this by running the litex build and modifying the build.sh script it generated to use the Windows version of the command. I was able to get it to run successfully with this process:

This is a somewhat involved process but I'd like to be able to use WSL so I might make a PR to implement this in vivado.py if I have the time (and if I can figure out how). It would be nice if there was a way to get around the whole path issue, because that would make this much easier.