OpenRisc-4-ORSoC跑linux实验

2023-10-07 09:58
文章标签 linux 实验 openrisc orsoc

本文主要是介绍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:

 

 

===========================================================
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实验的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/157577

相关文章

linux打包解压命令方式

《linux打包解压命令方式》文章介绍了Linux系统中常用的打包和解压命令,包括tar和zip,使用tar命令可以创建和解压tar格式的归档文件,使用zip命令可以创建和解压zip格式的压缩文件,每... 目录Lijavascriptnux 打包和解压命令打包命令解压命令总结linux 打包和解压命令打

linux如何复制文件夹并重命名

《linux如何复制文件夹并重命名》在Linux系统中,复制文件夹并重命名可以通过使用“cp”和“mv”命令来实现,使用“cp-r”命令可以递归复制整个文件夹及其子文件夹和文件,而使用“mv”命令可以... 目录linux复制文件夹并重命名我们需要使用“cp”命令来复制文件夹我们还可以结合使用“mv”命令总

Linux使用cut进行文本提取的操作方法

《Linux使用cut进行文本提取的操作方法》Linux中的cut命令是一个命令行实用程序,用于从文件或标准输入中提取文本行的部分,本文给大家介绍了Linux使用cut进行文本提取的操作方法,文中有详... 目录简介基础语法常用选项范围选择示例用法-f:字段选择-d:分隔符-c:字符选择-b:字节选择--c

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

linux下多个硬盘划分到同一挂载点问题

《linux下多个硬盘划分到同一挂载点问题》在Linux系统中,将多个硬盘划分到同一挂载点需要通过逻辑卷管理(LVM)来实现,首先,需要将物理存储设备(如硬盘分区)创建为物理卷,然后,将这些物理卷组成... 目录linux下多个硬盘划分到同一挂载点需要明确的几个概念硬盘插上默认的是非lvm总结Linux下多

linux进程D状态的解决思路分享

《linux进程D状态的解决思路分享》在Linux系统中,进程在内核模式下等待I/O完成时会进入不间断睡眠状态(D状态),这种状态下,进程无法通过普通方式被杀死,本文通过实验模拟了这种状态,并分析了如... 目录1. 问题描述2. 问题分析3. 实验模拟3.1 使用losetup创建一个卷作为pv的磁盘3.

Linux环境变量&&进程地址空间详解

《Linux环境变量&&进程地址空间详解》本文介绍了Linux环境变量、命令行参数、进程地址空间以及Linux内核进程调度队列的相关知识,环境变量是系统运行环境的参数,命令行参数用于传递给程序的参数,... 目录一、初步认识环境变量1.1常见的环境变量1.2环境变量的基本概念二、命令行参数2.1通过命令编程

Linux之进程状态&&进程优先级详解

《Linux之进程状态&&进程优先级详解》文章介绍了操作系统中进程的状态,包括运行状态、阻塞状态和挂起状态,并详细解释了Linux下进程的具体状态及其管理,此外,文章还讨论了进程的优先级、查看和修改进... 目录一、操作系统的进程状态1.1运行状态1.2阻塞状态1.3挂起二、linux下具体的状态三、进程的