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-基础知识3

打包和压缩 zip 安装zip软件包 yum -y install zip unzip 压缩打包命令: zip -q -r -d -u 压缩包文件名 目录和文件名列表 -q:不显示命令执行过程-r:递归处理,打包各级子目录和文件-u:把文件增加/替换到压缩包中-d:从压缩包中删除指定的文件 解压:unzip 压缩包名 打包文件 把压缩包从服务器下载到本地 把压缩包上传到服务器(zip

Linux 网络编程 --- 应用层

一、自定义协议和序列化反序列化 代码: 序列化反序列化实现网络版本计算器 二、HTTP协议 1、谈两个简单的预备知识 https://www.baidu.com/ --- 域名 --- 域名解析 --- IP地址 http的端口号为80端口,https的端口号为443 url为统一资源定位符。CSDNhttps://mp.csdn.net/mp_blog/creation/editor

【Python编程】Linux创建虚拟环境并配置与notebook相连接

1.创建 使用 venv 创建虚拟环境。例如,在当前目录下创建一个名为 myenv 的虚拟环境: python3 -m venv myenv 2.激活 激活虚拟环境使其成为当前终端会话的活动环境。运行: source myenv/bin/activate 3.与notebook连接 在虚拟环境中,使用 pip 安装 Jupyter 和 ipykernel: pip instal

Linux_kernel驱动开发11

一、改回nfs方式挂载根文件系统         在产品将要上线之前,需要制作不同类型格式的根文件系统         在产品研发阶段,我们还是需要使用nfs的方式挂载根文件系统         优点:可以直接在上位机中修改文件系统内容,延长EMMC的寿命         【1】重启上位机nfs服务         sudo service nfs-kernel-server resta

【Linux 从基础到进阶】Ansible自动化运维工具使用

Ansible自动化运维工具使用 Ansible 是一款开源的自动化运维工具,采用无代理架构(agentless),基于 SSH 连接进行管理,具有简单易用、灵活强大、可扩展性高等特点。它广泛用于服务器管理、应用部署、配置管理等任务。本文将介绍 Ansible 的安装、基本使用方法及一些实际运维场景中的应用,旨在帮助运维人员快速上手并熟练运用 Ansible。 1. Ansible的核心概念

Linux服务器Java启动脚本

Linux服务器Java启动脚本 1、初版2、优化版本3、常用脚本仓库 本文章介绍了如何在Linux服务器上执行Java并启动jar包, 通常我们会使用nohup直接启动,但是还是需要手动停止然后再次启动, 那如何更优雅的在服务器上启动jar包呢,让我们一起探讨一下吧。 1、初版 第一个版本是常用的做法,直接使用nohup后台启动jar包, 并将日志输出到当前文件夹n

[Linux]:进程(下)

✨✨ 欢迎大家来到贝蒂大讲堂✨✨ 🎈🎈养成好习惯,先赞后看哦~🎈🎈 所属专栏:Linux学习 贝蒂的主页:Betty’s blog 1. 进程终止 1.1 进程退出的场景 进程退出只有以下三种情况: 代码运行完毕,结果正确。代码运行完毕,结果不正确。代码异常终止(进程崩溃)。 1.2 进程退出码 在编程中,我们通常认为main函数是代码的入口,但实际上它只是用户级

【Linux】应用层http协议

一、HTTP协议 1.1 简要介绍一下HTTP        我们在网络的应用层中可以自己定义协议,但是,已经有大佬定义了一些现成的,非常好用的应用层协议,供我们直接使用,HTTP(超文本传输协议)就是其中之一。        在互联网世界中,HTTP(超文本传输协议)是一个至关重要的协议,他定义了客户端(如浏览器)与服务器之间如何进行通信,以交换或者传输超文本(比如HTML文档)。

如何编写Linux PCIe设备驱动器 之二

如何编写Linux PCIe设备驱动器 之二 功能(capability)集功能(capability)APIs通过pci_bus_read_config完成功能存取功能APIs参数pos常量值PCI功能结构 PCI功能IDMSI功能电源功率管理功能 功能(capability)集 功能(capability)APIs int pcie_capability_read_wo