本文主要是介绍OpenRisc-4-ORSoC跑linux实验,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
引言
光说不练假把式,本小节就用官方的FPGA开发板跑一下linux。
4.1, 实验准备
1》 orsoc的工具链环境(gcc,gdb,jtag),搭建过程见上一篇blog:
http://blog.csdn.net/rill_zhen/article/details/8443882
2》 ep4ce22的FPGA开发板(€:149)
3》 micro-USB连接线
4.2, 实验步骤
0》连线。将板子左上方的那个USB口与PC相连。
1》 烧写RTL综合后的电路逻辑文件(也可自己用quartus综合)
$ cd /home/openrisc
$ jtag ./program_fpga.jtag
2》开启gdbdebugger和OR 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:
===========================================================
Running Software on Hardware
===========================================================This FPGA development board has been developed specifically
to fit a OpenRISC processor design, with the smallest form-factor
and lowest cost.The board is called: ordb2a-ep4ce22 (OpenRisc Development Board 2A)More detailed information can be found at the link below:
http://opencores.org/or1k/ordb2a-ep4ce22===========================================================
Connecting ORSoC's OpenRISC-FPGA-development-board
===========================================================1. Connect your ordb2a-board to your computer using the USB connector located on the top-left corner on the board.2. The FPGA is programmed with a pre-compiled OpenRISCprocessor SOC-design, with Ethernet, SDHC, UART and SDRAM support. And with a small boot-loader (orpmon) that is stored in the external SPI-flash. The boot-loader should now be loaded and executing by the OpenRISC processor.3. Open up a new terminal and type:$ picocom --b 115200 --p n --d 8 --f xon /dev/ttyUSB2Press "Enter" and you should now see a print-out in your terminal-window showing: ORSoC devboard>You now have a command-prompt "ORSoC devboard>" controlling the orpmon-software.By typing "help", all the diffent commands will be listed. For example you can start a coremark-test (cpu benchmark test), by typing "coremark 30"===============================================================
Program ORSoC's OpenRISC-FPGA-development-board and run Linux
===============================================================1. Connect your ordb2a-board to your computer using the USB connector located on the top-left corner on the board.2. Start a terminal and type:$ cd ~/fpga_dev_board/ordb2a-ep4ce22$ jtag ./program_fpga.jtagThe file "program_fpga.jtag" defines what FPGA programming file that should be used.3. The FPGA is now programmed with a pre-compiled OpenRISCprocessor SOC-design, with the OpenRISC processor, Ethernet, SDHC, UART and SDRAM support. An small boot-loader is stored in the SPI-flash and should now be loaded and executed by the OpenRISC processor.4. Let's now try and download Linux to the SDRAM and then boot iton the OpenRISC SoC design. There are many ways that we can boot Linux, we can use GDB, we can use orpmon and download it using TFTP, or we can program the SPI-flash. We will using GDBin demo. Open up a new terminal tab (shift+ctrl+t) and type:$ /opt/or_debug_proxy/bin/or_debug_proxy -r 55555This starts a program (or_debug_proxy) that controls the USB connection and communication between the GDB debugger and the OpenRISC processor.You should see the follwoing print-out:"Connecting to OR1k via USB debug cableInitialising USB JTAG interfaceJTAG ID = a188a928Stalling OR1K CPU0Read npc = 0001727c ppc = 00017278 r1 = 00031774Waiting for gdb connection on localhost:55555Press CTRL+c to exit."5. Open up a new terminal tab (shift+ctrl+t) and type:$ picocom --b 115200 --p n --d 8 --f xon /dev/ttyUSB2This UART connection will be our Linux-terminal when we boot-up Linux on the OpenRISC SoC-design.6. Open up a new terminal tab (shift+ctrl+t) and type:$ cd ~/soc-design/linux$ make ARCH=openrisc defconfig$ make ARCH=openrisc$ or32-elf-gdbThe GDB-debugger is now started and you need to connect it tothe or_debug_proxy program, by typing:(gdb) target remote :55555GDB is now connected to the OpenRISC processor and are now waiting. Lets now download the Linux-image, by typing:(gdb) file ./vmlinuxAnswer "y" on the questions.(gdb) loadThe actual download of the Linux image is now in progress and this takes some time, since the JTAG interface is not the fastest one. The following load information should appear:"Loading section .text, size 0x22bd34 lma 0x0Loading section .rodata, size 0x49860 lma 0x22c000Loading section __param, size 0x1c0 lma 0x275860Loading section .data, size 0x15760 lma 0x276000Loading section __ex_table, size 0xa50 lma 0x28b760Loading section .head.text, size 0x4000 lma 0x28e000Loading section .init.text, size 0x12348 lma 0x292000Loading section .init.data, size 0x155e54 lma 0x2a4360Start address 0xc0000000, load size 4160160Transfer rate: 86 KB/sec, 4015 bytes/write."Now we want to set the program-counter to start executing from address 0x100, by typing:(gdb) spr npc 0x100Now let's boot up Linux on the FPGA development board, by typing:(gdb) cYou should now see Linux booting in the picocom-terminal-window that was opened earlier. And you should get a prompt where you can play around with the Linux port that is running on the OpenRISC processor system.For example, you can plug in your board into your Ethernet network and get an IP address by typing:# ifup eth0Your network should now provide your board with an IP address (DHCP) and you can test your connection by pinging a known IP address.====================================================================
Program ORSoC's OpenRISC-FPGA-development-board with bare-metal SW
====================================================================1. Connect your ordb2a-board to your computer using the USB connector located on the top-left corner on the board.2. Start a terminal and type:$ cd /home/openrisc$ jtag ./program_fpga.jtagThe file "program_fpga.jtag" defines what FPGA programming file that should be used.3. The FPGA is now programmed with a pre-compiled OpenRISCprocessor SOC-design, with Ethernet, SDHC, UART and SDRAM support. An small boot-loader is stored in the SPI-flash and should now be loaded and executed by the OpenRISC processor.4. Let's now try and download a bare-metal application (hello world) to the board and run it. Open up a new terminal and type:$ /opt/or_debug_proxy/bin/or_debug_proxy -r 55555This starts a program (or_debug_proxy) that controls the USB connection and communication between the GDB debugger and the OpenRISC processor.You should see the following print-out:"Connecting to OR1k via USB debug cableInitialising USB JTAG interfaceJTAG ID = a188a928Stalling OR1K CPU0Read npc = 0001727c ppc = 00017278 r1 = 00031774Waiting for gdb connection on localhost:55555Press CTRL+c to exit."5. Open up a new terminal and type:$ picocom --b 115200 --p n --d 8 --f xon /dev/ttyUSB2This UART connection will be a UART-terminal and will receive the Helloworld application's printf text.6. Open up a new terminal and type:$ cd ~/soc-design/helloworld-or1ksim$ or32-elf-gdbThe GDB debugger is now started and you need to connect it tothe or_debug_proxy program, by typing:(gdb) target remote :55555GDB is now connected to the OpenRISC processor and are now waiting. Lets now download the Linux-image, by typing:(gdb) file ./helloworld_hwAnswer "y" on the questions.(gdb) loadThe actual download of the Helloworld-image is now in progress and this takes some time, since the JTAG interface is not the fastest one. The following load-information should appear:"Loading section .vectors, size 0x2000 lma 0x0Loading section .init, size 0x28 lma 0x2000Loading section .text, size 0x494c lma 0x2028Loading section .fini, size 0x1c lma 0x6974Loading section .rodata, size 0x50 lma 0x6990Loading section .eh_frame, size 0x4 lma 0x69e0Loading section .ctors, size 0x8 lma 0x89e4Loading section .dtors, size 0x8 lma 0x89ecLoading section .jcr, size 0x4 lma 0x89f4Loading section .data, size 0x9b8 lma 0x89f8Start address 0x2028, load size 29616Transfer rate: 42 KB/sec, 1851 bytes/write."Now we want to set the program-counter to start executing from address 0x100, by typing:(gdb) spr npc 0x100Now lets start the Helloworld_hw application on the FPGA development board, by typing:(gdb) cYou should now see the follwoing printout in the picocom terminal window that was opened earlier:"Hello world!!!!"Now you can start developing your own bare-metal applications :-)===========================================================
Programming external SPI-flash
===========================================================
The external SPI flash contains both the FPGA programming file
and a bootloader (orpmon).
Below are information on how to program the SPI with these two files:1. Download an FPGA-programming file that just connects the FTDI JTAG signals to the SPI flash IOs.$ cd ~/program-spi-flash$ jtag ./program_spi.jtag2. Erase the SPI flash before programming it:$ ./spiflash/spiflash-program -e3. Program the SPI flash with an FPGA programming file (rbf-format):$ ./spiflash/spiflash-program -p /home/openrisc/fpga_dev_board/ordb2a-ep4ce22/output_file.rbf4. Program the SPI-flash with OpenRISC SW application (select only one):4a. Program OpenRISC Linux (requires a large SPI flash):$ ./spiflash/spiflash-program -a 0xc0000 -P /home/openrisc/program-spi-flash/vmlinux.sizebin4b. Program OpenRISC bootloader (orpmon)$ ./spiflash/spiflash-program -a 0xc0000 -P /home/openrisc/program-spi-flash/orpmon.or32.sizebinUnplug the board and connect it again to load the new flash contents.Steps 2-4 can also be combined like so (directory paths omitted for brevity):spiflash-program -e -p output_file.rbf -a 0xc0000 -P orpmon.or32.sizebinSizebin files are produced from binary memory dumps using bin2binsizeword:~/soc-design/orpsocv2/sw/utils/bin2binsizeword ~/soc-design/orpmon/orpmon.or32.bin ~/program-spi-flash/orpmon.or32.sizebinGood luck and welcome to the OpenCores OpenRISC community ;-)Delivered by: Marcus.Erlandsson@orsoc.se, Yann.Vernier@orsoc.se
2011-12-15
附:bootloader启动
即ORmon的启动:
烧完RTL综合后的逻辑,内部mem初始化文件就是ORmon。用超级终端(windows)或者picocom(ubuntu)都可以,如下图:
附:也可以用单独linux for openrisc
http://git.openrisc.net/cgit.cgi/jonas/linux/refs/tags
这篇关于OpenRisc-4-ORSoC跑linux实验的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!