Last active
April 2, 2021 07:42
-
-
Save sam210723/394e4b1d0d0dd834d1f61e3daf0af9dd to your computer and use it in GitHub Desktop.
Install IceStorm + Yosys + NextPNR + RISC-V toolchain + TinyFPGA PicoSoC Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install deps | |
sudo apt-get update | |
sudo apt-get install autoconf automake autotools-dev build-essential clang bison \ | |
flex libreadline-dev gawk tcl-dev libffi-dev cmake curl git graphviz xdot \ | |
pkg-config python python3 python3-dev mercurial libboost-system-dev \ | |
libboost-python-dev libboost-filesystem-dev libboost-all-dev libeigen3-dev \ | |
zlib1g-dev libmpc-dev libftdi-dev libmpfr-dev libgmp-dev gawk texinfo gperf \ | |
libtool patchutils bc libexpat-dev qt5-default | |
# Install IceStorm | |
git clone https://github.com/YosysHQ/icestorm | |
cd icestorm | |
make -j$(nproc) | |
sudo make install | |
cd .. | |
# Setup Yosys | |
git clone https://github.com/YosysHQ/yosys | |
cd yosys | |
make | |
sudo make install | |
cd .. | |
# Setup nextpnr | |
git clone --recurse-submodules https://github.com/YosysHQ/nextpnr | |
cd nextpnr | |
mkdir build | |
cd build | |
cmake .. -DARCH=ice40 | |
make -j$(nproc) | |
sudo make install | |
cd ../.. | |
# Setup RISC-V build toolchain | |
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain riscv-gnu-toolchain-rv32i | |
cd riscv-gnu-toolchain-rv32i | |
./configure --prefix=/opt/riscv --with-arch=rv32i --with-abi=ilp32 | |
export PATH="$PATH:/opt/riscv/bin" | |
sudo make | |
cd .. | |
# Clone TinyFPGA PicoSoC example | |
git clone https://github.com/tinyfpga/TinyFPGA-BX | |
cd TinyFPGA-BX/examples/picosoc | |
rm Makefile | |
wget https://gist.githubusercontent.com/sam210723/394e4b1d0d0dd834d1f61e3daf0af9dd/raw/5907f3b06c7fd42c9c61706c76da45ea41c90e08/Makefile | |
make upload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upload: hardware.bin firmware.bin | |
tinyprog -p hardware.bin -u firmware.bin | |
build: hardware.bin firmware.bin | |
echo "Complete" | |
hardware.blif: hardware.v spimemio.v simpleuart.v picosoc.v picorv32.v | |
yosys -ql hardware.log -p 'synth_ice40 -top hardware -json hardware.json' $^ | |
hardware.asc: hardware.pcf hardware.blif | |
nextpnr-ice40 --lp8k --package cm81 --json hardware.json --asc hardware.asc --pcf hardware.pcf | |
hardware.bin: hardware.asc | |
icetime -d lp8k -c 12 -mtr hardware.rpt hardware.asc | |
icepack hardware.asc hardware.bin | |
firmware.elf: sections.lds start.S firmware.c | |
riscv32-unknown-elf-gcc -march=rv32imc -nostartfiles -Wl,-Bstatic,-T,sections.lds,--strip-debug,-Map=firmware.map,--cref -ffreestanding -nostdlib -o firmware.elf start.S firmware.c | |
firmware.bin: firmware.elf | |
riscv32-unknown-elf-objcopy -O binary firmware.elf /dev/stdout > firmware.bin | |
clean: | |
rm -f firmware.elf firmware.hex firmware.bin firmware.o firmware.map \ | |
hardware.blif hardware.log hardware.asc hardware.rpt hardware.bin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment