OpenRisc-4-ORSoC跑linux实验

引言

光说不练假把式,本小节就用官方的FPGA开发板跑一下linux。

 

4.1,  实验准备

1》  orsoc的工具链环境(gcc,gdbjtag),搭建过程见上一篇blog:

http://blog.csdn.net/rill_zhen/article/details/8443882

2》  ep4ce22FPGA开发板(€:149)

3》  micro-USB连接线

 

4.2,  实验步骤

0》连线。将板子左上方的那个USB口与PC相连。

1》  烧写RTL综合后的电路逻辑文件(也可自己用quartus综合)

$ cd /home/openrisc

$ jtag ./program_fpga.jtag

2》开启gdbdebuggerOR processor间的代理服务

$ /opt/or_debug_proxy/bin/or_debug_proxy –r 55555

3》  (再开一个终端)打开一个串口终端

picocom –b 115200–p n –d 8 –f xon /dev/ttyUSB2

4》  (再开一个终端)开启gdb来下载vmlinux镜像

$ cd ~/soc-design/linux

$ make ARCH=openrisc defconfig

$ make ARCH=openrisc

$ or32-elf-gdb

(gdb) target remote :55555

(gdb) file ./vmlinux

Answer ‘y’

(gdb) load

(gdb) spr npc 0x100

(gdb) c

5》此时,看picocom那个终端,可以看到linux的启动过程:如下图:

6》此时链接网线,设置网卡(eth8)参数,就可以和PC通过网络通信了。

 

 

 

4.3 参考文档

Running_SW_on_FPGA_board.txt:

 

 

[html]  view plain copy print ?
  1. ===========================================================  
  2. Running Software on Hardware  
  3. ===========================================================  
  4.   
  5. This FPGA development board has been developed specifically   
  6. to fit a OpenRISC processor design, with the smallest form-factor   
  7. and lowest cost.  
  8.   
  9. The board is called: ordb2a-ep4ce22 (OpenRisc Development Board 2A)  
  10.   
  11. More detailed information can be found at the link below:  
  12. http://opencores.org/or1k/ordb2a-ep4ce22  
  13.   
  14.   
  15. ===========================================================  
  16. Connecting ORSoC's OpenRISC-FPGA-development-board  
  17. ===========================================================  
  18.   
  19. 1. Connect your ordb2a-board to your computer using the   
  20.    USB connector located on the top-left corner on the board.  
  21.   
  22. 2. The FPGA is programmed with a pre-compiled OpenRISC  
  23.    processor SOC-design, with Ethernet, SDHC, UART and   
  24.    SDRAM support. And with a small boot-loader (orpmon) that is   
  25.    stored in the external SPI-flash. The boot-loader should   
  26.    now be loaded and executing by the OpenRISC processor.  
  27.   
  28. 3. Open up a new terminal and type:  
  29.    $ picocom --b 115200 --p n --d 8 --f xon /dev/ttyUSB2  
  30.   
  31.    Press "Enter" and you should now see a print-out in your   
  32.    terminal-window showing: ORSoC devboard>  
  33.   
  34.    You now have a command-prompt "ORSoC devboard>" controlling   
  35.    the orpmon-software.  
  36.    By typing "help", all the diffent commands will be listed.   
  37.    For example you can start a coremark-test (cpu benchmark test),   
  38.    by typing "coremark 30"  
  39.   
  40.   
  41. ===============================================================  
  42. Program ORSoC's OpenRISC-FPGA-development-board and run Linux  
  43. ===============================================================  
  44.   
  45. 1. Connect your ordb2a-board to your computer using the   
  46.    USB connector located on the top-left corner on the board.  
  47.   
  48. 2. Start a terminal and type:  
  49.    $ cd ~/fpga_dev_board/ordb2a-ep4ce22  
  50.    $ jtag ./program_fpga.jtag  
  51.   
  52.    The file "program_fpga.jtag" defines what FPGA programming file   
  53.    that should be used.  
  54.   
  55. 3. The FPGA is now programmed with a pre-compiled OpenRISC  
  56.    processor SOC-design, with the OpenRISC processor, Ethernet,   
  57.    SDHC, UART and SDRAM support. An small boot-loader is stored   
  58.    in the SPI-flash and should now be loaded and executed   
  59.    by the OpenRISC processor.  
  60.   
  61. 4. Let's now try and download Linux to the SDRAM and then boot it  
  62.    on the OpenRISC SoC design. There are many ways that we can   
  63.    boot Linux, we can use GDB, we can use orpmon and download it   
  64.    using TFTP, or we can program the SPI-flash. We will using GDB  
  65.    in demo. Open up a new terminal tab (shift+ctrl+t) and type:  
  66.    $ /opt/or_debug_proxy/bin/or_debug_proxy -r 55555  
  67.   
  68.    This starts a program (or_debug_proxy) that controls the   
  69.    USB connection and communication between the GDB debugger and   
  70.    the OpenRISC processor.  
  71.    
  72.    You should see the follwoing print-out:  
  73.   
  74.    "  
  75.    Connecting to OR1k via USB debug cable  
  76.    Initialising USB JTAG interface  
  77.    JTAG ID = a188a928  
  78.    Stalling OR1K CPU0  
  79.    Read      npc = 0001727c ppc = 00017278 r1 = 00031774  
  80.    Waiting for gdb connection on localhost:55555  
  81.    Press CTRL+c to exit.  
  82.    "  
  83.   
  84. 5. Open up a new terminal tab (shift+ctrl+t) and type:  
  85.    $ picocom --b 115200 --p n --d 8 --f xon /dev/ttyUSB2  
  86.   
  87.    This UART connection will be our Linux-terminal when we boot-up   
  88.    Linux on the OpenRISC SoC-design.  
  89.   
  90.   
  91. 6. Open up a new terminal tab (shift+ctrl+t) and type:  
  92.    $ cd ~/soc-design/linux  
  93.    $ make ARCH=openrisc defconfig  
  94.    $ make ARCH=openrisc  
  95.    $ or32-elf-gdb  
  96.   
  97.    The GDB-debugger is now started and you need to connect it to  
  98.    the or_debug_proxy program, by typing:  
  99.    (gdb) target remote :55555  
  100.   
  101.    GDB is now connected to the OpenRISC processor and are now   
  102.    waiting. Lets now download the Linux-image, by typing:  
  103.    (gdb) file ./vmlinux  
  104.    Answer "y" on the questions.  
  105.   
  106.    (gdb) load  
  107.   
  108.    The actual download of the Linux image is now in progress and   
  109.    this takes some time, since the JTAG interface is not the   
  110.    fastest one. The following load information should appear:  
  111.   
  112.    "  
  113.    Loading section .text, size 0x22bd34 lma 0x0  
  114.    Loading section .rodata, size 0x49860 lma 0x22c000  
  115.    Loading section __param, size 0x1c0 lma 0x275860  
  116.    Loading section .data, size 0x15760 lma 0x276000  
  117.    Loading section __ex_table, size 0xa50 lma 0x28b760  
  118.    Loading section .head.text, size 0x4000 lma 0x28e000  
  119.    Loading section .init.text, size 0x12348 lma 0x292000  
  120.    Loading section .init.data, size 0x155e54 lma 0x2a4360  
  121.    Start address 0xc0000000, load size 4160160  
  122.    Transfer rate: 86 KB/sec, 4015 bytes/write.  
  123.    "  
  124.   
  125.    Now we want to set the program-counter to start executing   
  126.    from address 0x100, by typing:  
  127.    (gdb) spr npc 0x100  
  128.   
  129.    Now let's boot up Linux on the FPGA development board, by typing:  
  130.    (gdb) c  
  131.   
  132.    You should now see Linux booting in the picocom-terminal-window   
  133.    that was opened earlier. And you should get a prompt where you   
  134.    can play around with the Linux port that is running on the   
  135.    OpenRISC processor system.  
  136.   
  137.    For example, you can plug in your board into your Ethernet network   
  138.    and get an IP address by typing:  
  139.    # ifup eth0  
  140.   
  141.    Your network should now provide your board with an IP address (DHCP)   
  142.    and you can test your connection by pinging a known IP address.  
  143.   
  144.   
  145. ====================================================================  
  146. Program ORSoC's OpenRISC-FPGA-development-board with bare-metal SW  
  147. ====================================================================  
  148.   
  149. 1. Connect your ordb2a-board to your computer using the   
  150.    USB connector located on the top-left corner on the board.  
  151.   
  152. 2. Start a terminal and type:  
  153.    $ cd /home/openrisc  
  154.    $ jtag ./program_fpga.jtag  
  155.   
  156.    The file "program_fpga.jtag" defines what FPGA programming file   
  157.    that should be used.  
  158.   
  159. 3. The FPGA is now programmed with a pre-compiled OpenRISC  
  160.    processor SOC-design, with Ethernet, SDHC, UART and   
  161.    SDRAM support. An small boot-loader is stored in the SPI-flash   
  162.    and should now be loaded and executed by the OpenRISC processor.  
  163.   
  164. 4. Let's now try and download a bare-metal application (hello world) to   
  165.    the board and run it. Open up a new terminal and type:  
  166.    $ /opt/or_debug_proxy/bin/or_debug_proxy -r 55555  
  167.   
  168.    This starts a program (or_debug_proxy) that controls the   
  169.    USB connection and communication between the GDB debugger and   
  170.    the OpenRISC processor.  
  171.    
  172.    You should see the following print-out:  
  173.   
  174.    "  
  175.    Connecting to OR1k via USB debug cable  
  176.    Initialising USB JTAG interface  
  177.    JTAG ID = a188a928  
  178.    Stalling OR1K CPU0  
  179.    Read      npc = 0001727c ppc = 00017278 r1 = 00031774  
  180.    Waiting for gdb connection on localhost:55555  
  181.    Press CTRL+c to exit.  
  182.    "  
  183.   
  184. 5. Open up a new terminal and type:  
  185.    $ picocom --b 115200 --p n --d 8 --f xon /dev/ttyUSB2  
  186.   
  187.    This UART connection will be a UART-terminal and will   
  188.    receive the Helloworld application's printf text.  
  189.   
  190.   
  191. 6. Open up a new terminal and type:  
  192.    $ cd ~/soc-design/helloworld-or1ksim  
  193.    $ or32-elf-gdb  
  194.   
  195.    The GDB debugger is now started and you need to connect it to  
  196.    the or_debug_proxy program, by typing:  
  197.    (gdb) target remote :55555  
  198.   
  199.    GDB is now connected to the OpenRISC processor and are now   
  200.    waiting. Lets now download the Linux-image, by typing:  
  201.    (gdb) file ./helloworld_hw  
  202.    Answer "y" on the questions.  
  203.   
  204.    (gdb) load  
  205.   
  206.    The actual download of the Helloworld-image is now in progress and   
  207.    this takes some time, since the JTAG interface is not the   
  208.    fastest one. The following load-information should appear:  
  209.   
  210.    "  
  211.    Loading section .vectors, size 0x2000 lma 0x0  
  212.    Loading section .init, size 0x28 lma 0x2000  
  213.    Loading section .text, size 0x494c lma 0x2028  
  214.    Loading section .fini, size 0x1c lma 0x6974  
  215.    Loading section .rodata, size 0x50 lma 0x6990  
  216.    Loading section .eh_frame, size 0x4 lma 0x69e0  
  217.    Loading section .ctors, size 0x8 lma 0x89e4  
  218.    Loading section .dtors, size 0x8 lma 0x89ec  
  219.    Loading section .jcr, size 0x4 lma 0x89f4  
  220.    Loading section .data, size 0x9b8 lma 0x89f8  
  221.    Start address 0x2028, load size 29616  
  222.    Transfer rate: 42 KB/sec, 1851 bytes/write.  
  223.    "  
  224.   
  225.    Now we want to set the program-counter to start executing   
  226.    from address 0x100, by typing:  
  227.    (gdb) spr npc 0x100  
  228.   
  229.    Now lets start the Helloworld_hw application on the FPGA   
  230.    development board, by typing:  
  231.    (gdb) c  
  232.   
  233.    You should now see the follwoing printout in the   
  234.    picocom terminal window that was opened earlier:  
  235.   
  236.    "  
  237.    Hello world!!!!  
  238.    "  
  239.   
  240.    Now you can start developing your own   
  241.    bare-metal applications :-)  
  242.   
  243.   
  244. ===========================================================  
  245. Programming external SPI-flash   
  246. ===========================================================  
  247. The external SPI flash contains both the FPGA programming file   
  248. and a bootloader (orpmon).  
  249. Below are information on how to program the SPI with these two files:  
  250.   
  251.   
  252.    1. Download an FPGA-programming file that just connects the   
  253.       FTDI JTAG signals to the SPI flash IOs.  
  254.       $ cd ~/program-spi-flash  
  255.       $ jtag ./program_spi.jtag  
  256.   
  257.    2. Erase the SPI flash before programming it:  
  258.       $ ./spiflash/spiflash-program -e  
  259.   
  260.   
  261.    3. Program the SPI flash with an FPGA programming file (rbf-format):  
  262.       $ ./spiflash/spiflash-program -p /home/openrisc/fpga_dev_board/ordb2a-ep4ce22/output_file.rbf  
  263.   
  264.    4. Program the SPI-flash with OpenRISC SW application (select only one):  
  265.   
  266.       4a. Program OpenRISC Linux (requires a large SPI flash):  
  267.           $ ./spiflash/spiflash-program -a 0xc0000 -P /home/openrisc/program-spi-flash/vmlinux.sizebin  
  268.   
  269.   
  270.       4b. Program OpenRISC bootloader (orpmon)  
  271.           $ ./spiflash/spiflash-program -a 0xc0000 -P /home/openrisc/program-spi-flash/orpmon.or32.sizebin  
  272.   
  273.   
  274. Unplug the board and connect it again to load the new flash contents.  
  275.   
  276.   
  277. Steps 2-4 can also be combined like so (directory paths omitted for brevity):  
  278.    spiflash-program -e -p output_file.rbf -a 0xc0000 -P orpmon.or32.sizebin  
  279.   
  280. Sizebin files are produced from binary memory dumps using bin2binsizeword:  
  281.    ~/soc-design/orpsocv2/sw/utils/bin2binsizeword ~/soc-design/orpmon/orpmon.or32.bin ~/program-spi-flash/orpmon.or32.sizebin  
  282.   
  283.   
  284. Good luck and welcome to the OpenCores OpenRISC community ;-)  
  285.   
  286.   
  287.   
  288. Delivered by: Marcus.Erlandsson@orsoc.se, Yann.Vernier@orsoc.se  
  289. 2011-12-15  


 

附:bootloader启动

即ORmon的启动:

烧完RTL综合后的逻辑,内部mem初始化文件就是ORmon。用超级终端(windows)或者picocom(ubuntu)都可以,如下图:

 

 附:也可以用单独linux for openrisc

http://git.openrisc.net/cgit.cgi/jonas/linux/refs/tags

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值