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

相关文章

kali linux 无法登录root的问题及解决方法

《kalilinux无法登录root的问题及解决方法》:本文主要介绍kalilinux无法登录root的问题及解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,... 目录kali linux 无法登录root1、问题描述1.1、本地登录root1.2、ssh远程登录root2、

Linux ls命令操作详解

《Linuxls命令操作详解》通过ls命令,我们可以查看指定目录下的文件和子目录,并结合不同的选项获取详细的文件信息,如权限、大小、修改时间等,:本文主要介绍Linuxls命令详解,需要的朋友可... 目录1. 命令简介2. 命令的基本语法和用法2.1 语法格式2.2 使用示例2.2.1 列出当前目录下的文

Linux中的计划任务(crontab)使用方式

《Linux中的计划任务(crontab)使用方式》:本文主要介绍Linux中的计划任务(crontab)使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、前言1、linux的起源与发展2、什么是计划任务(crontab)二、crontab基础1、cro

Linux换行符的使用方法详解

《Linux换行符的使用方法详解》本文介绍了Linux中常用的换行符LF及其在文件中的表示,展示了如何使用sed命令替换换行符,并列举了与换行符处理相关的Linux命令,通过代码讲解的非常详细,需要的... 目录简介检测文件中的换行符使用 cat -A 查看换行符使用 od -c 检查字符换行符格式转换将

Linux系统配置NAT网络模式的详细步骤(附图文)

《Linux系统配置NAT网络模式的详细步骤(附图文)》本文详细指导如何在VMware环境下配置NAT网络模式,包括设置主机和虚拟机的IP地址、网关,以及针对Linux和Windows系统的具体步骤,... 目录一、配置NAT网络模式二、设置虚拟机交换机网关2.1 打开虚拟机2.2 管理员授权2.3 设置子

Linux系统中卸载与安装JDK的详细教程

《Linux系统中卸载与安装JDK的详细教程》本文详细介绍了如何在Linux系统中通过Xshell和Xftp工具连接与传输文件,然后进行JDK的安装与卸载,安装步骤包括连接Linux、传输JDK安装包... 目录1、卸载1.1 linux删除自带的JDK1.2 Linux上卸载自己安装的JDK2、安装2.1

Linux卸载自带jdk并安装新jdk版本的图文教程

《Linux卸载自带jdk并安装新jdk版本的图文教程》在Linux系统中,有时需要卸载预装的OpenJDK并安装特定版本的JDK,例如JDK1.8,所以本文给大家详细介绍了Linux卸载自带jdk并... 目录Ⅰ、卸载自带jdkⅡ、安装新版jdkⅠ、卸载自带jdk1、输入命令查看旧jdkrpm -qa

Linux samba共享慢的原因及解决方案

《Linuxsamba共享慢的原因及解决方案》:本文主要介绍Linuxsamba共享慢的原因及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux samba共享慢原因及解决问题表现原因解决办法总结Linandroidux samba共享慢原因及解决

新特性抢先看! Ubuntu 25.04 Beta 发布:Linux 6.14 内核

《新特性抢先看!Ubuntu25.04Beta发布:Linux6.14内核》Canonical公司近日发布了Ubuntu25.04Beta版,这一版本被赋予了一个活泼的代号——“Plu... Canonical 昨日(3 月 27 日)放出了 Beta 版 Ubuntu 25.04 系统镜像,代号“Pluc

Linux安装MySQL的教程

《Linux安装MySQL的教程》:本文主要介绍Linux安装MySQL的教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录linux安装mysql1.Mysql官网2.我的存放路径3.解压mysql文件到当前目录4.重命名一下5.创建mysql用户组和用户并修