1 # Build instructions for Microwatt
3 TODO WIP integrate from <https://libre-soc.org/irclog/%23libre-soc.2022-01-26.log.html>
7 * <https://codeconstruct.com.au/docs/microwatt-orangecrab/>
8 * <https://shenki.github.io/boot-linux-on-microwatt/>
9 * <https://github.com/gregdavill/OrangeCrab-test-sw>
13 * install verilator: <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=verilator-install;hb=HEAD>
14 * install yosys <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=hdl-tools-yosys;hb=HEAD>
15 * install ghdl-yosys-plugin
17 After installing ghdl-yosys-plugin use schroot to switch environment
19 schroot -c bullseye_ghdl
20 git clone https://git.libre-soc.org/git/microwatt.git
21 git checkout -b verilator_trace
22 export FPGA_TARGET=verilator
23 make microwatt-verilator
25 Then run the resulting binary
27 time ./microwatt-verilator
29 If everything works correcly it will print out an light bulb in ascii art
30 with the message Microwatt, it works. On my ASUS KGPE D16 this takes
36 ## Building the kernel
37 On a POWER9 there is no need to install gcc-powerpc64le-linux-gnu,
38 you can omit CROSS_COMPILE and ARCH in this case
40 apt install gcc-powerpc64le-linux-gnu
41 apt install flex bison lz4
42 git clone -b microwatt-5.7 https://git.kernel.org/pub/scm/linux/kernel/git/joel/microwatt.git
44 wget https://ftp.libre-soc.org/microwatt-linux-5.7.patch
45 patch -p1 < microwatt-linux-5.7.patch
46 wget https://ftp.libre-soc.org/rootfs.cpio
47 CROSS_COMPILE="ccache powerpc64le-linux-gnu-" ARCH=powerpc make -j8 O=microwatt microwatt_defconfig
48 CROSS_COMPILE="ccache powerpc64le-linux-gnu-" ARCH=powerpc make -j8 O=microwatt
50 This will produce a file
51 microwatt/arch/powerpc/boot/dtbImage.microwatt
53 ## Building sdram_init.bin
54 This needs gcc-powerpc64le-linux-gnu if cross compilation is used.
57 cd litedram/gen-src/sdram_init/
60 ## Building microwatt-verilator using the libre-soc core
63 make microwatt_external_core
64 cp external_core_top.v /path/to/microwatt
66 export FPGA_TARGET=verilator
68 make microwatt-verilator
70 ## Running the simulation
72 cp microwatt/arch/powerpc/boot/dtbImage.microwatt
73 ./microwatt-verilator sdram_init.bin dtbImage.microwatt
75 ## Building the bitstring for OrangeCrab
78 export FPGA_TARGET=ORANGE-CRAB
82 ## flashing the bitstring to the OrangeCrab
84 make prog # this will run OpenOCD
90 * https://github.com/shenki/buildroot/commits/microwatt
91 * https://codeconstruct.com.au/docs/microwatt-orangecrab/
95 notes for how to compile for ulx3s
97 git clone https://github.com/kost/fujprog
98 (follow build procedure shown in fujprog README)
99 git clone https://git.libre-soc.org/git/microwatt.git
100 git checkout -b verilator_trace
101 export FPGA_TARGET=ulx3s
103 fujprog microwatt.svf
106 # Notes for nextpnr-xilinx
108 superceded: see page [[nextpnr-xilinx]] and devscript
109 <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=nextpnr-xilinx-install;hb=HEAD>
111 for compiling nextpnr-xilinx and making it useable for nmigen
112 to compile for the digilent arty-a7-100t, requires a little
113 futzing around, using the symbiflow version of prjxray-db
114 instead of the one recommended as a submodule
116 git clone https://github.com/gatecat/nextpnr-xilinx
118 git checkout cd8b15db6ff5c1a7f10a9e
122 mv prjxray-db prjxray-db-no
123 git clone https://github.com/SymbiFlow/prjxray-db
125 git checkout 0a0addedd73e7
126 cp ./artix7/xc7a100t/*.json \
127 ./artix7/xc7a100tcsg324-1
129 cmake -DARCH=xilinx .
132 python3 xilinx/python/bbaexport.py --device xc7a100tcsg324-1 --bba xilinx/xc7a100t.bba
133 ./bbasm --l xilinx/xc7a100t.bba xilinx/xc7a100t.bin
134 mkdir -p /usr/share/nextpnr/xilinx-chipdb
135 cp xilinx/*.bin /usr/share/nextpnr/xilinx-chipdb
136 cp -aux xilinx/external/prjxray-db /usr/share/nextpnr
138 # Additional Useful Info for UART <-> USB Serial Interface Through OrangeCrab's Built-in USB Interface
140 This uses OrangeCrab's built-in USB interface, rather than needing a
141 separate USB-serial adapter. see the following for further details:
143 * <https://github.com/antonblanchard/microwatt/pull/347#issuecomment-1058800570>
144 * <https://github.com/antonblanchard/microwatt/pull/347#issuecomment-1058834790>
146 # running orangecrab-examples before flashing microwatt
148 See <https://github.com/orangecrab-fpga/orangecrab-hardware/blob/main/contrib/10-orangecrab.rules>
150 If the OrangeCrab is running in DFU mode, lsusb will show:
152 1209:5af0 Generic OrangeCrab r0.2 DFU Bootloader v3.1-6-g62e92e2
154 OrangeCrab has two DFU devices:
156 Found DFU: [1209:5af0] ver=0101, devnum=22, cfg=1, intf=0, path="1-4.2", alt=1, name="0x00100000 RISC-V Firmware", serial="UNKNOWN"
157 Found DFU: [1209:5af0] ver=0101, devnum=22, cfg=1, intf=0, path="1-4.2", alt=0, name="0x00080000 Bitstream", serial="UNKNOWN"
159 Then clone and patch orangecrab-examples:
161 git clone https://github.com/orangecrab-fpga/orangecrab-examples
162 patch -p1 < orangecrab-examples.diff
164 To build and flash the example:
166 pushd orangecrab-examples/nmigen
169 sudo dfu-util -D orangecrab-examples/nmigen/build/top.bit -a 0