--- tags: Develop, FPGA --- # CFU Playground On Tang Nano 9K ![](https://i.imgur.com/GeBaRtM.jpg) [TOC] ## Normal Steps ### 0. Install Prerequires. - [Gowin EDA Education Ver](http://www.gowinsemi.com.cn/faq.aspx) ```bash # Add To Environment Variable export PATH="$HOME/<Gowin EDA Path>/IDE/bin/:$PATH" ``` - [Open FPGA Loader](https://github.com/trabucayre/openFPGALoader) - Python Pip Packages ```shell=bash sudo apt install python3-pip python-is-python3 python3 -m pip install meson ninja ``` ### 1. Clone CFU Playground Repo. ```shell=bash mkdir CFU-Playground && cd CFU-Playground/ git clone https://github.com/google/CFU-Playground.git ``` ### 2. Download RISCV GCC Toolchains. ```shell=bash cd Downloads/ wget https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.08/riscv64-unknown-elf-gcc-10.1.0-2020.08.2-x86_64-linux-ubuntu14.tar.gz # Extract GCC tar xvfz riscv64-unknown-elf-gcc-10.1.0-2020.08.2-x86_64-linux-ubuntu14.tar.gz # Add To Environment Variable export PATH="$HOME/<RiscV GCC Path>/bin/:$PATH" ``` ### 3. Use LiteX To Flash Bitstream. Include RISCV SoftCPU And Bootloader. ```shell=bash # Switch To LiteX Folder cd ~LiteX/ # Download Setup Script wget https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py # Give Execute Permission chmod +x litex_setup.py # Initialize And Update LiteX Development Environment ./litex_setup.py --init --install ./litex_setup.py --update # Flash **Bitstream** And **Bootloader** Into Tang Nano 9K python3 -m litex_boards.targets.sipeed_tang_nano_9k --build --flash ``` ### 4. Use LiteX-Term Test Serial Communication. ```shell=bash litex_term /dev/ttyUSB1 ``` ![](https://i.imgur.com/8gX2xhI.png) ### 5. Follow the CFU Playgound Setup Guides. From Steps 3 On. - https://cfu-playground.readthedocs.io/en/latest/setup-guide.html ## WSL Solution ### USB - https://blog.golioth.io/program-mcu-from-wsl2-with-usb-support/ ### Bridge To WSL ```powershell usbipd.exe wsl list usbipd wsl attach --busid <BUSID> ``` ![](https://i.imgur.com/MIfHYs0.png) ### openFPGALoader - https://forums.balena.io/t/balenalib-balena-machine-name-ubuntu-focal-udevadm-issues/343862 ```bash sudo cp 99-openfpgaloader.rules /etc/udev/rules.d/ /lib/systemd/systemd-udevd --daemon # force udev to take new rule sudo udevadm trigger # force udev to take new rule sudo usermod -a $USER -G plugdev # add user to plugdev group ``` ![](https://i.imgur.com/rvYnVO2.png)