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系统管理中,压缩与传输工具是数据备份和远程协作的桥梁,而系统监控工具则是保障服务器稳定运行的眼睛,下面小编就来和大家详细介绍一下它... 目录引言一、压缩与解压:数据存储与传输的优化核心1. zip/unzip:通用压缩格式的便捷操作2.

Linux中SSH服务配置的全面指南

《Linux中SSH服务配置的全面指南》作为网络安全工程师,SSH(SecureShell)服务的安全配置是我们日常工作中不可忽视的重要环节,本文将从基础配置到高级安全加固,全面解析SSH服务的各项参... 目录概述基础配置详解端口与监听设置主机密钥配置认证机制强化禁用密码认证禁止root直接登录实现双因素

在Linux终端中统计非二进制文件行数的实现方法

《在Linux终端中统计非二进制文件行数的实现方法》在Linux系统中,有时需要统计非二进制文件(如CSV、TXT文件)的行数,而不希望手动打开文件进行查看,例如,在处理大型日志文件、数据文件时,了解... 目录在linux终端中统计非二进制文件的行数技术背景实现步骤1. 使用wc命令2. 使用grep命令

Linux如何快速检查服务器的硬件配置和性能指标

《Linux如何快速检查服务器的硬件配置和性能指标》在运维和开发工作中,我们经常需要快速检查Linux服务器的硬件配置和性能指标,本文将以CentOS为例,介绍如何通过命令行快速获取这些关键信息,... 目录引言一、查询CPU核心数编程(几C?)1. 使用 nproc(最简单)2. 使用 lscpu(详细信

linux重启命令有哪些? 7个实用的Linux系统重启命令汇总

《linux重启命令有哪些?7个实用的Linux系统重启命令汇总》Linux系统提供了多种重启命令,常用的包括shutdown-r、reboot、init6等,不同命令适用于不同场景,本文将详细... 在管理和维护 linux 服务器时,完成系统更新、故障排查或日常维护后,重启系统往往是必不可少的步骤。本文

基于Linux的ffmpeg python的关键帧抽取

《基于Linux的ffmpegpython的关键帧抽取》本文主要介绍了基于Linux的ffmpegpython的关键帧抽取,实现以按帧或时间间隔抽取关键帧,文中通过示例代码介绍的非常详细,对大家的学... 目录1.FFmpeg的环境配置1) 创建一个虚拟环境envjavascript2) ffmpeg-py

Linux脚本(shell)的使用方式

《Linux脚本(shell)的使用方式》:本文主要介绍Linux脚本(shell)的使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录概述语法详解数学运算表达式Shell变量变量分类环境变量Shell内部变量自定义变量:定义、赋值自定义变量:引用、修改、删

Linux链表操作方式

《Linux链表操作方式》:本文主要介绍Linux链表操作方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、链表基础概念与内核链表优势二、内核链表结构与宏解析三、内核链表的优点四、用户态链表示例五、双向循环链表在内核中的实现优势六、典型应用场景七、调试技巧与

详解Linux中常见环境变量的特点与设置

《详解Linux中常见环境变量的特点与设置》环境变量是操作系统和用户设置的一些动态键值对,为运行的程序提供配置信息,理解环境变量对于系统管理、软件开发都很重要,下面小编就为大家详细介绍一下吧... 目录前言一、环境变量的概念二、常见的环境变量三、环境变量特点及其相关指令3.1 环境变量的全局性3.2、环境变

Linux系统中的firewall-offline-cmd详解(收藏版)

《Linux系统中的firewall-offline-cmd详解(收藏版)》firewall-offline-cmd是firewalld的一个命令行工具,专门设计用于在没有运行firewalld服务的... 目录主要用途基本语法选项1. 状态管理2. 区域管理3. 服务管理4. 端口管理5. ICMP 阻断