OpenCores

Linux

From OR1K

Contents

Introduction

This section of the project contains information on using the Linux kernel port for the OpenRISC 1000 family.

Information about Linux on OpenRISC as well as updated toolchains can be found at http://openrisc.net

Features are:

•Free, open source code with no royalty
•UNIX class operating system
•Upstream
•gdbserver for OpenRISC 
•Process protection through use of the Memory Management Unit
•Multitasking, preemptive scheduling
•Interprocess communication and synchronization
•TCP/IP networking and numerous other network protocols
•File systems NFS, ext2, MS-DOS, FAT16/32 and others
•PS2 Keyboard

Status

OpenRISC is officially supported in the Linux kernel since version 3.1 and can be downloaded from https://www.kernel.org. We do however recommend that you use one of the kernels from https://github.com/openrisc/linux/ as they contain some convenient features such as a built-in initramfs and extra board configurations for OpenRISC not found in the upstream kernel.

A gdbserver is now available in SVN for use when debugging applications under Or1ksim Linux. gdbserver acts as a GDB remote serial protocol server for a Linux application, allowing the program to be debugged remotely using GDB.

Supported Boards

Only DE0 Nano and a configuration for or1ksim are officially supported in the kernel sources. See below for how to add support for additional boards. Device trees and configuration files for other boards can be found in the orpsoc-cores collection (e.g. https://github.com/openrisc/orpsoc-cores/blob/master/systems/neek/data/sw/neek.dts)

Initial preparations

To obtain a copy of the kernel tree source with OpenRISC support, ensure git is installed and run

 git clone https://github.com/openrisc/linux

The environment variables `ARCH` and `CROSS_COMPILE` must be set prior to running any `make` command. The `CROSS_COMPILE` command can be set to any toolchain capable of building an OpenRISC Linux kernel (e.g. or1k-linux-musl-)

export ARCH=openrisc
export CROSS_COMPILE=or1k-elf-

Setup a generic default configuration for OpenRISC targets. This will likely generate a bunch of questions for options that are not set in the default configuration file. Choose values that seem appropriate for these options.

make defconfig

Optionally select other options you want to enable or disable

make menuconfig


linux-3.0 menuconf Photo

Build

make

After `make` is complete, there will be a file called `vmlinux` in the kernel root directory. This is the built Linux Kernel in the form of an `ELF` file that can be run in or1ksim, or uploaded to a running OpenRISC Instance with OpenOCD or GDB, or be converted to a `bin` file that can be programmed to a Flash memory

Run on or1ksim

The following commands will run a kernel on the OpenRISC architectural simulator. This is a good way to test if your kernel will boot up before you try it on hardware

or1k-elf-sim -f arch/openrisc/or1ksim.cfg vmlinux


linux-3.0 xterm Photo

By default, or1ksim configured to use TCP port 10084 for standard input/output once the kernel has booted. This means that output to terminal where or1ksim was launched will stop after printing out "Configuring loopback device". At this point, you should launch a new terminal and connect with e.g. "telnet localhost 10084" to interact with the system

Run on FPGA target

Start a serial console that is connected to the UART on the OpenRISC system. There are many different serial consoles and physical UART connections to choose from. Below is a common example using screen and an USB-to-UART adapter

screen /dev/ttyUSB0 115200

Start OpenOCD in a new terminal window with the correct OpenOCD configuration files. Detailed instructions for how to build and set up OpenOCD can be found here Debugging physical targets (FPGA/ASIC). Below is an example for how to connect to an OpenRISC system using the Altera Virtual JTAG TAP and Advanced Debug Interface

openocd -f tcl/interface/altera-usb-blaster.cfg -f tcl/board/or1k_generic.cfg

Start a third terminal and connect to the running OpenOCD proxy. More advanced usage with GDB is described in Debugging physical targets (FPGA/ASIC). Adjust the path to vmlinux if necessary. The default path is relative to the directory from where OpenOCD was started

telnet localhost 4444
halt; load_image vmlinux; reg npc 0x100; reset

The Linux kernel should now be seen booting up in the serial console. After it has booted up, press enter to start using Linux

linux-3.0 ML501 Photo

If you wish to debug applications running under Linux, you should use gdbserver instead.

Adapt to a new board

Make changes to built-in filesystem

© copyright 1999-2017 OpenCores.org, equivalent to ORSoC AB, all rights reserved. OpenCores®, registered trademark.