<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rui Zhang on Medium]]></title>
        <description><![CDATA[Stories by Rui Zhang on Medium]]></description>
        <link>https://medium.com/@rz2285?source=rss-12b08d24d35------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aLk4r9e1t3AxnMuuYxEWdA.png</url>
            <title>Stories by Rui Zhang on Medium</title>
            <link>https://medium.com/@rz2285?source=rss-12b08d24d35------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 22:15:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rz2285/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Write an LLVM Pass]]></title>
            <link>https://medium.com/@rz2285/write-an-llvm-pass-d541471fb73e?source=rss-12b08d24d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/d541471fb73e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[llvm]]></category>
            <dc:creator><![CDATA[Rui Zhang]]></dc:creator>
            <pubDate>Wed, 01 Mar 2017 05:21:00 GMT</pubDate>
            <atom:updated>2017-03-01T05:21:00.032Z</atom:updated>
            <content:encoded><![CDATA[<p>Here, I summarize how I write an LLVM pass. I will also share how I solve some common problems which are not addressed in LLVM documents and tutorials. Note that I will show how to write a new pass, not a Hello pass in most LLVM tutorials.</p><p><strong>Part 0: Install LLVM</strong></p><blockquote>mkdir llvm-source</blockquote><p>Version matters in LLVM. Make sure you download the same version of LLVM and Clang, and also read the tutorials and documents for that particular version. Do not download directly from the svn repository unless you are LLVM developers. If you are just using LLVM, download the stable releases will save you lots of effort. Download the LLVM and Clang from this link: <a href="http://releases.llvm.org/download.html">http://releases.llvm.org/download.html</a>.</p><p>To install LLVM and Clang (I use 3.4.2 as an example, other versions should be similar):</p><blockquote>tar xvzf llvm-3.4.2.src.tar.gz<em><br></em>mv llvm-3.4.2.src src<em><br></em>tar xvzf cfe-3.4.2.src.tar.gz<em><br></em>mv cfe-3.4.2.src src/tools/clang</blockquote><p>Then install LLVM:</p><blockquote><em>cd llvm-source<br>mkdir build<br>cd build<br>./../src/configure<br>make</em></blockquote><p>Done!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2nJhteFJMijacTYL35ENpg.jpeg" /></figure><p><strong>Part 1: Write a New Pass</strong></p><p>First, I will show you how to write a Candy pass.</p><blockquote><em>cd llvm-source/build/lib/Transforms<br></em>mkdir Candy<em><br>vim Candy.cpp</em></blockquote><p>Copy the following lines into Candy.cpp:</p><pre>#include &quot;llvm/Pass.h&quot;<br>#include &quot;llvm/IR/Function.h&quot;<br>#include &quot;llvm/Support/raw_ostream.h&quot;<br><br><strong>using</strong> <strong>namespace</strong> llvm;<br><br><strong>namespace</strong> {<br>  <strong>struct</strong> Candy : <strong>public</strong> FunctionPass {<br>    <strong>static</strong> char ID;<br>    Candy() : FunctionPass(ID) {}<br><br>    <strong>virtual</strong> bool runOnFunction(Function &amp;F) {<br>      errs() &lt;&lt; &quot;Candy: &quot;;<br>      errs().write_escaped(F.getName()) &lt;&lt; &#39;\n&#39;;<br>      <strong>return</strong> false;<br>    }<br>  };<br>}<br><br>char Candy::ID = 0;<br><strong>static</strong> RegisterPass&lt;Candy&gt; X(&quot;candy&quot;, &quot;Candy Pass&quot;, false, false);</pre><p>Then copy the following lines into Makefile:</p><pre><em># Makefile for candy pass</em><br><br><em># Path to top level of LLVM hierarchy</em><br>LEVEL = ../../..<br><br><em># Name of the library to build</em><br>LIBRARYNAME = Candy<br><br><em># Make the shared library become a loadable module so the tools can</em><br><em># dlopen/dlsym on the resulting library.</em><br>LOADABLE_MODULE = 1<br><br><em># Include the makefile implementation stuff</em><br>include $(LEVEL)/Makefile.common</pre><p>If you write a new pass (instead of Hello), for example Candy, by following the tutorials above, you will probably run into the following error:</p><blockquote>make: *** No rule to make target ‘/path/to/llvm-source/src/lib/Transforms/Candy/Makefile’, needed by ‘Makefile’. Stop.</blockquote><p>This is because you write your new path in the <em>build/</em> directory, and LLVM cannot find it in the <em>src/</em> directory. Here is what you need to do to solve it.</p><blockquote><em>cd llvm-source/src/lib/Transforms<br>mkdir Candy<br>cd Candy<br>vim Candy.cpp (save and exit, you don’t need to write anything in the file)<br>vim Makefile (copy the above Makefile into this one)<br>cd ..<br>vim CMakeLists.txt</em></blockquote><p>Add the following line into <em>llvm-source/src/lib/Transforms/CMakeLists.txt</em>:</p><blockquote>add_subdirectory(Candy)</blockquote><p>Add one more file <em>llvm-source/src/lib/Transforms/Candy/CMakeLists.txt </em>with following lines:</p><pre><em>add_llvm_loadable_module(LLVMCandy</em></pre><pre>  Candy.cpp</pre><pre><em>)</em></pre><p>Then build LLVM again:</p><blockquote><em>cd llvm-source/build<br>./../src/configure<br>make -j8</em></blockquote><p>Then go to Candy and make again, the error message will disappear.</p><p>Write a program that you would like to run the candy analysis, and compile it into bitcode file:</p><blockquote><em>cd llvm-source<br>mkdir projects<br>cd projects<br>vim test.cpp (write a program that you would like to run the analysis)<br>clang -O0 -emit-llvm -c test.cpp -o test.bc</em></blockquote><p>Then run the following command to analyze it:</p><blockquote>../../build/Release+Asserts/bin/opt -load ../../build/Release+Asserts/bin/Candy.so -candy &lt; test.bc &gt; /dev/null</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxPTZ9ULq2EpV4Y-A_xiAg.jpeg" /></figure><p>Part 2: Write a Pass with Multiple Files</p><p>In this part, I will show you how to include a Sweet.cpp and Sweet.h into your Candy pass.</p><blockquote>cd llvm-source/build/lib/Transforms/Candy<em><br>mkdir include<br>mkdir src<br>cd include<br>vim Sweet.h (write your Sweet.h and save it)<br>cd ../src<br>mkdir Sweet<br>cd Sweet<br>vim Sweet.cpp (write your Sweet.cpp and save it)<br>vim Makefile</em></blockquote><p>Copy the following into your <em>/llvm-source/build/lib/Transforms/Candy/src/Sweet/Makefile</em></p><pre><em># Path to top level of LLVM hierarchy</em><br>LEVEL = ../../../../..<br><br><em># Name of the library to build</em><br>LIBRARYNAME = Sweet<br><br>BUILD_ARCHIVE = 1<br><br><em># Include the makefile implementation stuff</em><br>include $(LEVEL)/Makefile.common</pre><p>Copy the following into your <em>/llvm-source/build/lib/Transforms/Candy/src/Makefile</em></p><pre><em># Path to top level of LLVM hierarchy</em><br>LEVEL = ../../../..<br><br>DIRS = Sweet<br><br><em># Include the makefile implementation stuff</em><br>include $(LEVEL)/Makefile.common</pre><p>Modify your <em>/llvm-source/build/lib/Transforms/Candy/Makefile</em></p><pre><em># Makefile for candy pass</em><br><br><em># Path to top level of LLVM hierarchy</em><br>LEVEL = ../../..<br><br><em># Name of the library to build</em><br>LIBRARYNAME = Candy<br><br><em># Make the shared library become a loadable module so the tools can</em><br><em># dlopen/dlsym on the resulting library.</em><br>LOADABLE_MODULE = 1</pre><pre>DIRS = src<br>EXTRA_DIST = include</pre><pre><em># Include the makefile implementation stuff</em><br>include $(LEVEL)/Makefile.common</pre><p>Add the corresponding files to your <em>/llvm-source/src/lib/Transforms/Candy</em></p><blockquote>cd llvm-source/src/lib/Transforms/Candy<em><br>mkdir include<br>mkdir src<br>cd include<br>vim Sweet.h (an empty file is okay)<br>cd ../src<br>mkdir Sweet<br>cd Sweet<br>vim Sweet.cpp (an empty file is okay)</em></blockquote><p>Add the three Makefile above to the corresponding directory. Also modify the /llvm-source/src/lib/Transforms/Candy/CMakeLists.txt</p><pre><em>add_llvm_loadable_module(LLVMCandy</em></pre><pre>Candy.cpp<br>src/Sweet/Sweet.cpp</pre><pre><em>)</em></pre><p>Build LLVM again:</p><blockquote>cd llvm-source/build<em><br>./../src/configure<br>make -j8</em></blockquote><p>Then go to your Candy pass, you will be able to make your Candy pass with Sweet.cpp.</p><blockquote>cd llvm-source/build/lib/Transforms/Candy<em><br>make</em></blockquote><p>However, when you try to run your pass with your test files, you will probably run into the following error:</p><blockquote>../../build/Release+Asserts/bin/opt: symbol lookup error: ../../build/Release+Asserts/lib/Candy.so: undefined symbol: _Z21runSweetRN4llvm8FunctionE</blockquote><p>To solve this problem, you need to modify your <em>/llvm-source/build/lib/Transforms/Candy/Makefile. </em>Add the following line into your Makefile:</p><blockquote>USEDLIBS = Sweet.a</blockquote><p>Try to make and run the analysis again. You will not see the error!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d541471fb73e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running ORPSoC on DE0 Nano]]></title>
            <link>https://medium.com/@rz2285/running-orpsoc-on-de0-nano-3aaf43826ecb?source=rss-12b08d24d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aaf43826ecb</guid>
            <category><![CDATA[openrisc]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[fpga]]></category>
            <dc:creator><![CDATA[Rui Zhang]]></dc:creator>
            <pubDate>Wed, 24 Feb 2016 01:54:08 GMT</pubDate>
            <atom:updated>2016-02-26T02:31:22.481Z</atom:updated>
            <content:encoded><![CDATA[<p>Step 0: OpenRISC GNU Toolchain Installation</p><p>See my previous article about how to compile and install OpenRISC GNU toolchain <a href="https://medium.com/@rz2285/running-openrisc-on-redhat-bde7641d35d#.b88oju8d8">here</a>.</p><p>Step 1: Altera Quartus Installation</p><p>Download <em>Quartus-web-13.0.1.232-linux.tar</em> from <a href="http://download.altera.com/akdlm/software/acdsinst/13.0sp1/232/ib_tar/Quartus-web-13.0.1.232-linux.tar">here</a>.</p><p>Add <em>/path-to/quartus/bin</em> directory to the end of your <em>$PATH</em> variable in your <em>.bashrc</em> file. For example:</p><blockquote>export ALTERA_PATH=/path-to/altera/13.0sp1<br>export PATH=$PATH:$ALTERA_PATH/quartus/bin</blockquote><p>Step 2: OpenOCD Installation</p><p>Download and install OpenOCD:</p><blockquote>git clone git://repo.or.cz/openocd.git<br>./bootstrap<br>./configure --enable-ftdi --enable-usb_blaster_libftdi --enable-maintainer-mode<br>make<br>make install<br>cd ..</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AfqpbL9FD5E6ZTrWVPtgXg.jpeg" /></figure><p>Troubleshooting:</p><ol><li>Missing packages. You should install these packages: autoconf, pkg-config, automake, libtool, libusb-1.0–0-dev, libtclcl1-dev, libftdi-dev.</li><li>TCL error message during configuration. If you have already installed the <em>Altera Quartus suite</em> and its <em>quartus/bin</em> directory is in your <em>$PATH</em> then remove it while you configure and build OpenOCD.</li></ol><p>Step 3: Programming the FPGA</p><p>Plug the DE0 Nano FPGA board into your PC via the USB cable.</p><blockquote>quartus_pgm --mode=jtag -o p\;/path-to/de0_nano_orconf2013.sof</blockquote><p>It works if you see the following messages:</p><blockquote>Info (209017): Device 1 contains JTAG ID code 0x020F30DD<br>Info (209007): Configuration succeeded -- 1 device(s) configured<br>Info (209011): Successfully performed operation(s)</blockquote><p>Troubleshooting:</p><ol><li>If you get an error message about the sof file being corrupted, it is very likely that you are using the wrong version of Quartus. You should use version <em>13.0sp1</em>.</li><li>If you get an error message: <em>Can’t scan JTAG chain. Error code 89. </em>You should do the following:</li></ol><blockquote>sudo killall jtagd<br>which jtagd<br>sudo `which jtagd`</blockquote><p>And try to program again.</p><p>Step 4: Attach the Debug Proxy</p><p>Go to the OpenOCD directory in which everything was compiled and run:</p><blockquote>sudo ./src/openocd -s ./tcl -f ./tcl/interface/altera-usb-blaster.cfg -f ./tcl/board/or1k_generic.cfg</blockquote><p>It works if you see the following messages:</p><blockquote>Info : only one transport option; autoselect &#39;jtag&#39;<br>Info : vjtag tap selected<br>Info : adv debug unit selected<br>Info : Option 1 is passed to adv debug unit adapter speed: 3000 kHz<br>Info : No lowlevel driver configured, will try them all<br>Info : usb blaster interface using libftdi<br>Info : This adapter doesn&#39;t support configurable speed<br>Info : JTAG tap: or1200.cpu tap/device found: 0x020f30dd (mfg: 0x06e, part: 0x20f3, ver: 0x0)<br>Info : adv debug unit is configured with option ADBG_USE_HISPEED<br>Halting processor<br>Chip is or1200.cpu, Endian: big, type: or1k<br>Target ready...</blockquote><p>Troubleshooting:</p><ol><li>If you get the error message: JTAG tap: or1200.cpu expected 1 of 1: 0x020b30dd. You can open the following file from the OpenOCD tree: <em>tcl/board/or1k_generic.cfg</em>. And change this line: <em>set FPGATAPID 0x020b30dd</em> to <em>set FPGATAPID 0x020f30dd</em>.</li></ol><p>Step 5: Physically Attach the UART</p><p>Attach the UART as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHSqP3iJ4SSYrAWk7ba3cg.jpeg" /></figure><p>Open a second terminal:</p><blockquote>sudo chmod a+rwx /dev/ttyUSB0<br>screen /dev/ttyUSB0 115200</blockquote><p>Step 6: Download Demo Bare-Metal Software</p><p>Download the pre-compiled demo bare-metal software <em>timerled</em> from <a href="https://www.dropbox.com/s/8em2rzuzvn136pd/timerled">here</a>.</p><p>Step 7: Download and Run OpenRISC Software on SoC</p><p>Open a third terminal and use telnet to connect to OpenOCD:</p><blockquote>telnet localhost 4444</blockquote><p>Download and run the demo program:</p><blockquote>halt; load_image /&lt;path to your&gt;/orconf2013/sw/timer/timer; reg npc 0x100; resume</blockquote><p>It may be required to reset the board once the software has been downloaded:</p><blockquote>reset<br>resume</blockquote><p>Step 8: Run Linux</p><p>Download the pre-compiled Linux kernel from <a href="https://www.dropbox.com/s/bi5vx8kmqnjdldx/vmlinux-de0_nano">here</a>. And Load it with the following method via telnet:</p><blockquote>halt; load_image /work/orpsoc-build/vmlinux-de0_nano; reset</blockquote><p>Hopefully, you will see Linux booting up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9e-NfeDuV8fe9iXZ8KIwfQ.jpeg" /></figure><p>Instead of OpenOCD, GDB can also be used in step 7 and 8. Open a third terminal:</p><blockquote>or1k-elf-gdb<br>(gdb) target remote localhost:3333<br>(gdb) file /path-to/vmlinux-de0_nano<br>(gdb) load<br>(gdb) jump *0x100</blockquote><p>Hopefully again, you will see linux booting up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aaf43826ecb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing VNC Server on CentOS 6]]></title>
            <link>https://medium.com/@rz2285/installing-vnc-server-on-centos-6-6f76ed52c2b5?source=rss-12b08d24d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f76ed52c2b5</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[vnc]]></category>
            <dc:creator><![CDATA[Rui Zhang]]></dc:creator>
            <pubDate>Sun, 21 Feb 2016 06:30:26 GMT</pubDate>
            <atom:updated>2016-02-21T07:25:26.011Z</atom:updated>
            <content:encoded><![CDATA[<p>This recipe works for me, though slightly different from those tutorials online. I summarized all steps here for future reference and for those who might need it.</p><p>To run the VNC Server on CentOS, these required packages need to be installed first.</p><blockquote>sudo yum groupinstall Desktop<br>sudo yum install tigervnc-server<br>sudo yum install xorg-x11-fonts-Type1<br>sudo yum install vnc</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZwhCrRxyusjnr5dQFuguUg.jpeg" /></figure><p>To start VNC Server on boot:</p><blockquote>sudo chkconfig vncserver on</blockquote><p>To setup users’ VNC password:</p><blockquote>su username<br>vncpasswd<br>exit</blockquote><p>Edit the <em>/etc/sysconfig/vncservers</em> file:</p><blockquote>sudo vim /etc/sysconfig/vncservers</blockquote><p>Add the following to the end of the file:</p><blockquote>VNCSERVERS=“1:username”<br>VNCSERVERARGS[1]=“-geometry 1024x600”</blockquote><p>The iptables rules need to be amended to open the VNC ports:</p><blockquote>sudo iptables -I INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT<br>sudo service iptables save<br>sudo service iptables restart</blockquote><p>Restart the VNC Server:</p><blockquote>vncserver</blockquote><p>To kill VNC Servers:</p><blockquote>vncserver -kill :1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSrAG7cvA4iBiNVfocTGPw.jpeg" /></figure><p>Open a new terminal, and type:</p><blockquote>ssh -L 5901:127.0.0.1:5901 -N -f -l username ipaddress</blockquote><p>Open VNC Viewer, and type <em>localhost:5901</em> in <em>VNC Server</em>. Then click <em>connect</em>. Then type the password you set after <em>vncpasswd</em> command.</p><p>Now you can see the screen! Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f76ed52c2b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RTL Simulation of C-Program on Bare-metal OR1200]]></title>
            <link>https://medium.com/@rz2285/simulating-c-program-on-bare-metal-or1200-af67e2886fb8?source=rss-12b08d24d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/af67e2886fb8</guid>
            <category><![CDATA[openrisc]]></category>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[hello-world]]></category>
            <dc:creator><![CDATA[Rui Zhang]]></dc:creator>
            <pubDate>Sat, 20 Feb 2016 00:22:05 GMT</pubDate>
            <atom:updated>2016-02-20T01:52:28.263Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide shows you how to simulate hello-world c-program on bare-metal or1200. I try to make everything as simple as possible.</p><p>First of all, use <em>bash</em>.</p><blockquote>bash</blockquote><p>In order to simulate c-program on bare-metal or1200, the following steps need to be done first. Since auto-tools doesn’t know about or1k, run the last command to replace <em>or32</em> with <em>or1k</em>.</p><blockquote>cd /path-to/orpsocv2/sw/utils/<br>make<br>cd /path-to/orpsocv2/sim/<br>mkdir out<br>cd /path-to/orpsocv2<br>find ./ -type f -name ‘*’ -print | xargs sed -i ‘s/or32/or1k/’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d6DUWs0Vqx67i1NMAy7ekg.jpeg" /></figure><p>You can run a simple test to see if the simulation of ORPSoC RTL works.</p><blockquote>cd /path-to/orpsocv2/sim/run<br>make rtl-test</blockquote><p>If succeed, you will see the following few lines on screen.</p><blockquote>\t### Launching simulation ###</blockquote><blockquote>* Starting simulation of ORPSoC RTL.<br>* Test: or1200-simple</blockquote><blockquote>Or1200 IC enabled at 137230.00 ns<br>Or1200 DC enabled at 175370.00 ns<br>report(0x8000000d);<br>exit(0)</blockquote><p>Create <em>hello.c</em> file.</p><blockquote>mkdir hello<br>cd hello<br>vim hello.c</blockquote><p>Change the content of <em>hello.c</em> to the following:</p><blockquote>#include &lt;stdio.h&gt;<br>int main()<br>{<br> printf(“hello world\n”);<br>}</blockquote><p>Compile the c-program using <em>or1k-elf</em>:</p><blockquote>or1k-elf-gcc hello.c -o hello.elf</blockquote><p>Generate an assembly listing:</p><blockquote>or1k-elf-objdump -d hello.elf &gt; hello.asm</blockquote><p>Convert the compiled code to <em>binary</em> format:</p><blockquote>or1k-elf-objcopy -O binary hello.elf hello.bin</blockquote><p>Convert the <em>binary</em> format to <em>vmem</em> format:</p><blockquote>/path-to/orpsocv2/sw/utils/bin2vmem hello.bin &gt; hello.vmem</blockquote><p>Now you are ready to run the simulation!</p><blockquote>cd /path-to/orpsocv2/sim/run/<br>make distclean<br>make rtl-test USER_VMEM=~/hello/hello.vmem VCD=1</blockquote><p>If succeed, you will see <em>“hello world”</em> on the screen several seconds after running the simulation!</p><blockquote>\t### Launching simulation ###</blockquote><blockquote>* Starting simulation of ORPSoC RTL.<br>* Test: hello</blockquote><blockquote>VCD info: dumpfile ../out/hello.vcd opened for output.<br>Or1200 IC enabled at 136870.00 ns<br>Or1200 DC enabled at 175130.00 ns<br>hello world</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*uIIwfC0DIFcQ9vigP07cXg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af67e2886fb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running OpenRISC on RedHat]]></title>
            <link>https://medium.com/@rz2285/running-openrisc-on-redhat-bde7641d35d?source=rss-12b08d24d35------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde7641d35d</guid>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[openrisc]]></category>
            <dc:creator><![CDATA[Rui Zhang]]></dc:creator>
            <pubDate>Fri, 19 Feb 2016 22:58:38 GMT</pubDate>
            <atom:updated>2016-02-19T23:16:43.253Z</atom:updated>
            <content:encoded><![CDATA[<p>I spent several hours last night to set up OpenRISC on the new server and summarized all steps. The following is a quick guide to help you get OpenRISC running on a RedHat server. Most of the contents are based on OpenRISC website, but minor changes have been made in this guide for RedHat. The RedHat release I am dealing with is <em>Red Hat Enterprise Linux Server release 6.7 (Santiago).</em> Hope this guide can help people who need to run OpenRISC on a RedHat server like me. Enjoy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bP2lGIzfHXcTCEcq0epolQ.jpeg" /></figure><p><strong>Part 0: Installing gcc 4.8 on CentOS 6</strong></p><p>The GCC distributed with CentOS 6 is 4.4.7, which is pretty outdated. So first of all, gcc 4.8+ needs to be installed. If you have a later version of gcc, you can skip this part. To install gcc 4.8+, follow the guide in this link: <a href="https://gist.github.com/stephenturner/e3bc5cfacc2dc67eca8b">https://gist.github.com/stephenturner/e3bc5cfacc2dc67eca8b</a></p><p><strong>Part 1: OpenRISC GNU Toolchain Installation</strong></p><p>Make sure you are using <em>bash</em> and you have your gcc 4.8+ environment variables enabled.</p><blockquote>scl enable devtoolset-2 bash</blockquote><p>Install all required libraries to compile the GNU tools.</p><blockquote>sudo yum install build-essential make gcc g++ flex bison patch texinfo ncurses-devel libmpfr-devel libgmp3-devel libmpc-devel libzip-devel</blockquote><p>Download and extract all the necessary tools.</p><blockquote>wget <a href="http://ftp.gnu.org/gnu/binutils/binutils-2.25.tar.bz2">http://ftp.gnu.org/gnu/binutils/binutils-2.25.tar.bz2</a><br>tar xjvf binutils-2.25.tar.bz2<br>git clone git://github.com/openrisc/or1k-gcc.git<br>git clone git://github.com/openrisc/or1k-src.git<br>git clone git://sourceware.org/git/newlib.git</blockquote><p>Set up environment variables.</p><blockquote>export PREFIX=/opt/or1k-elf<br>export PATH=$PATH:$PREFIX/bin<br>sudo mkdir $PREFIX</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vBjXu5NT6FFuy678yyjLA.jpeg" /></figure><p>Build binutils:</p><blockquote>mkdir build-binutils; cd build-binutils<br>../binutils-2.25/configure --target=or1k-elf --prefix=$PREFIX --enable-shared --disable-itcl --disable-tk --disable-tcl --disable-winsup --disable-gdbtk --disable-libgui --disable-rda --disable-sid --disable-sim --with-sysroot<br>make<br>make install<br>cd ..</blockquote><p>Build gcc stage1:</p><blockquote>mkdir build-gcc-stage1; cd build-gcc-stage1<br>../or1k-gcc/configure --target=or1k-elf --prefix=$PREFIX --enable-languages=c --disable-shared --disable-libssp<br>make<br>make install<br>cd ..</blockquote><p>Build newlib:</p><blockquote>mkdir build-newlib; cd build-newlib<br>../newlib-2.2.0.20150225/configure --target=or1k-elf --prefix=$PREFIX<br>make<br>make install<br>cd ..</blockquote><p>Build gcc stage2:</p><blockquote>mkdir build-gcc-stage2; cd build-gcc-stage2<br>../or1k-gcc/configure --target=or1k-elf --prefix=$PREFIX --enable-languages=c,c++ --disable-shared --disable-libssp --with-newlib<br>make<br>make install<br>cd ..</blockquote><p>Build gdb:</p><blockquote>mkdir build-gdb; cd build-gdb<br>../or1k-src/configure --target=or1k-elf --prefix=$PREFIX --enable-shared --disable-itcl --disable-tk --disable-tcl --disable-winsup --disable-gdbtk --disable-libgui --disable-rda --disable-sid --enable-sim --disable-or1ksim --enable-gdb --with-sysroot --disable-newlib --disable-libgloss<br>make<br>make install<br>cd ..</blockquote><p>Finally, don’t forget to add the following line to your <em>~/.bashrc</em> file.</p><blockquote>export PATH=$PATH:/opt/or1k-elf/bin</blockquote><p><strong>Part 2: ORPSoCv2 Installation</strong></p><p>Download ORPSoCv2:</p><blockquote>git clone <a href="https://github.com/lab305itep/orpsocv2.git">https://github.com/lab305itep/orpsocv2.git</a></blockquote><p>Install Icarus Verilog:</p><blockquote>yum install iverilog</blockquote><p>Install the SystemC library: Download the <em>Core SystemC Language and Examples</em> from <a href="http://www.accellera.org/downloads/standards/systemc">http://www.accellera.org/downloads/standards/systemc</a>. Then extract the file and install it:</p><blockquote>tar zxvf systemc-2.3.1.tgz<br>cd systemc-2.3.1<br>mkdir objdir<br>cd objdir<br>export CXX=g++<br>../configure<br>make<br>sudo make install</blockquote><p>Add export SYSTEMC=/OpenRISC/system-2.3.1 to ~/.bashrc</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7P_3wlWbWxAtAo6-_lnWyA.jpeg" /></figure><p>Install the Verilog-Perl library: Download the <em>Verilog-Perl-3.418</em> from <a href="http://search.cpan.org/~wsnyder/">http://search.cpan.org/~wsnyder/</a>. Then extract the file and install it:</p><blockquote>tar xvzf InstlPkgs/Verilog-Perl-3.418.tar.gz<br>cd Verilog-Perl-3.418<br>perl Makefile.PL<br>make<br>make test<br>sudo make install</blockquote><p>Install the System-Perl library: Download the <em>SystemPerl-1.344</em> from <a href="http://search.cpan.org/~wsnyder/">http://search.cpan.org/~wsnyder/</a>. Then extract the file and install it:</p><blockquote>tar xvzf InstlPkgs/SystemPerl-1.344.tar.gz<br>cd SystemPerl-1.344<br>perl Makefile.PL<br>make<br>sudo make install</blockquote><p>Installing the Verilator library:</p><blockquote>git clone <a href="http://git.veripool.org/git/verilator">http://git.veripool.org/git/verilator</a><br>cd verilator<br>autoconf<br>./configure<br>make<br>sudo make install</blockquote><p>You are all set!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde7641d35d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>