Archive for the ‘OpenRISC’ Category

October 16th, 2012
OpenRISC Conference Stockholm 2012

The great thing about open source communities is that hundreds of people around the globe can collaborate on fascinating software and hardware projects without ever meeting one another.

An even better thing about such communities is that they can also meet up and discuss their shared fascinations!

Last weekend a part of the openRISC community (including us) did just that, at a fantastic meetup hosted by our main partner – Realtime Embedded – in their office at Sveavägen in central Stockholm. The three of us attended as relative newcomers to the openRISC bunch, some of whom have been out and about for many years now, but I think we managed to arouse much interest with our presentation of eCos as a new addition to the openRISC ecosystem. We were pleased to hear a number of insightful remarks and requests; as one of the never-too-many actively supported OS’s for the openRISC our eCos port got also quite a few mentions during the other presentations.

We have already started putting the suggested changes into life as time permits us – check Peter’s description how to compile a program in eCos in an (insanely) easy way! (Makefile included.) In the nearest future, watch out for new eCos for openRISC notes.

Unfortunately, as Murphy’s Law would have it, our presentation was not recorded due to a technical glitch – damn you, AAA batteries! – but you will soon find the slides on the project meeting website.

As for the other presentations, all of them were very interesting to listen to but one of them, a status report on the (now functional) dynamic linking support for openRISC LLVM by Stefan Kristiansson – was absolutely brilliant. The best moment was when the boring slides ended, and… check out what came later at the extremely cool demo. (The other videos are easily found in the attached playlist.)

Don’t trust Stefan when he says “I don’t know about this stuff for real” :)

The meetup was also a very good forum to talk about our priorities, open source processes in general and other related interesting developments – including Parallella from Adapteva, which we are very excited about. For those of you who don’t know the project, it’s an attempt to raise $750000 (or more) by giving away development platforms (called Parallella) for an already complete 16-64 core (called Epiphany) to as many people as possible for as little as $99. We love the idea, since the guys at Adapteva have from the beginning been very open about their history, process and willingness to actually get people to find the proper applications for the hardware, not the other way around!

See the short pitch I prompted for Parallella at the openRISC meeting, by Jeremy Bennett from Embecosm:

And buy one yourself to get parallel computing out into the open!

June 7th, 2012
SPI driver for OpenRISC eCos

After a short break, this week we are going to deal with SPI support for the OpenRISC eCos port,

To add the driver to the eCos build, the CYGPKG_IO_SPI package has to be added as follows:

1
ecosconfig add CYGPKG_IO_SPI

ECos requires that each device connected to the SPI bus is properly described. Our driver provides a macro for this purpose:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
CYG_DEVS_SPI_OPENCORES_SIMPLE_SPI_DEVICE(
  name,        // handler name of the device
  bus,         // SPI bus, numbering starts at 0
  cs,          // CS line, numbering starts at 0
  polarity,    // polarity (1 or 0)
  phase,       // phase (1 or 0)
  freq,        // maximum SCK frequency measured in hertz
  cs_to_tran,  // minimum delay between CS signal and start
               // of the transmission, measured in microseconds
  tran_to_cs,  // minimum delay between the end of the transmission
               // and the release of CS signal, measured in microseconds
  tran_to_tran // minimum delay between transmission of consecutive
               // bytes, measured in microseconds
);

For example, to add a m25pxx flash memory, fairly common on FPGA boards, connected to bus 0 chip-select 0, we can describe it as follows:

1
2
3
CYG_DEVS_SPI_OPENCORES_SIMPLE_SPI_DEVICE(
  m25pxx_spi, 0, 0, 0, 0, 1000000, 1, 1, 1
);

It is worth noting that eCos already has a driver for this memory type. To use it you have to add the CYGPKG_DEVS_FLASH_SPI_M25PXX package:

1
ecosconfig add CYGPKG_DEVS_FLASH_SPI_M25PXX

And connect the SPI device to it:

1
2
3
CYG_DEVS_FLASH_SPI_M25PXX_DRIVER (
  m25pxx_drv, 0, &m25pxx_spi
);

Note: Get the relevant code from our mirror of eCos-openrisc on Ant Micro’s github account.

The eCos provided by Ant Micro now supports:

  • UART
  • SPI
  • Ethernet
  • SDIO

Stay with us for more updates about OpenRISC, FPGA and open source in embedded systems.

May 14th, 2012
SD controller driver for OpenRISC eCos

[If you are unfamiliar with the OpenRISC architecture or just want some help on setting up your OpenRISC work environment, we recommend the great tutorial from our friend Sven-Åke, working for our partner, Realtime Embedded.]

This week we are going to deal with SD card support for the OpenRISC eCos port, enabling the developer to have easily replacable, persistent storage for the platform, a welcome addition to any system. SD card support is generally scarce for the OpenRISC so this should be a good reference implementation for SD support on other OSs.

The SD Host controller used in ORPSoC is the sdcard_mass_storage_controller project from OpenCores. We have written a driver for the OpenRISC eCos that connects itself to the disk layer and commited it to the main OpenRISC eCos repository.

Thus it is very easy to configure eCos to support a filesystem on the SD card out of the box. In the Open Source eCos version we can choose between two popular filesystems: jffs2 and FAT.

For example, to prepare an eCos build with the FAT filesystem support, the following lines are necessary:

1
2
3
4
5
6
ecosconfig new orpsoc default
ecosconfig add CYGPKG_IO_DISK
ecosconfig add CYGPKG_IO_FILEIO
ecosconfig add CYGPKG_FS_FAT
ecosconfig add CYGPKG_BLOCK_LIB
ecosconfig add CYGPKG_LINUX_COMPAT

Before compilation it might be a good idea to configure some options, especially the name of the disk device, which defaults to /dev/mmcdisk0.

Once we’re ready, just like in last week’s post, we issue:

1
2
ecosconfig tree
make

getting a compiled eCos with SD support. Also here the API is POSIX-compliant, which makes writing programs manipulating filesystems on SD cards easy and straightforward. A good example can be found in: packages/fs/fat/current/tests/fatfs1.c.

Note that in addition to the opencores repository, we’re now mirroring it on our github account for greater availability.

May 9th, 2012
OpenRISC Ethernet driver for eCos RTOS

We have been maintaining the eCos real-time OS for openRISC for some time now, but what has been an obstacle to use it in a wider array of applications was the lack of suitable driver support enabling the construction of a platform featuring a richer set of interfaces.

In a series of posts, we have decided to amend this situation by writing, contributing and showing how to use drivers for some essential peripherals for ORPSoC.

The first peripheral we are going to work with is Ethernet.

We have written drivers to support OpenCores ethmac Ethernet controller (http://opencores.org/project,ethmac). It is already commited to main OpenRISC eCos repository which we’re maintaining.

The driver for the Ethernet controller will be automatically added to the eCos build if we select any network stack. We can pick from the following:

– TCP/IP stack from OpenBSD
– TCP/IP stack from FreeBSD (including KAME IPv6)
– Lightweight TCP/IP stack: lwIP (note: originally created by Adam Dunkels at the Center for Networked Systems at SICS, with whom we cooperate)

For example, in order to build eCos with the FreeBSD stack, the following steps have to be taken:

1
2
3
4
5
ecosconfig new orpsoc default
ecosconfig add CYGPKG_NET
ecosconfig add CYGPKG_NET_FREEBSD_STACK
ecosconfig add CYGPKG_IO_FILEIO
ecosconfig add CYGPKG_IO_ETH_DRIVERS

Before we proceed to compilation, we need to do some additional configuration of the driver and the network stack. The most important configuration options are of course the MAC address of the Ethernet controller itself as well as the IP address (either static or dynamically allocated via DHCP) of the device. The configuration can be done in two ways: either using the GUI program, configtool, or via editing ecos.ecc.

When we are done, we should issue:

1
2
ecosconfig tree
make

which results in a compiled eCos with Ethernet and TCP/IP support. The nice thing is that the network services API in eCos is POSIX-compliant, so the networking programs look and work just like Linux ones. It is best to look at some examples, residing in the packages/net/common/current/tests/ directory – especially ping_test.c and server_test.c are worth noting.

Note: the code described in this post is available here.

March 23rd, 2012
eCos-3.0 port to OpenRISC tracking mainline

Recently we have ported eCos-3.0 for the openRISC, and in other posts described how to reset the ordb2 board and how to build programs for it in the eCos.

We are hoping that this will be a solid piece of help for those who want to work with OpenRISC with a real-time operating system, and for those who want to use the new devboard from opencores.

Now the port has been updated to track the eCos mainline, thoroughly tested – passing all tests on the ordb2 board – and is hosted on OpenCores SVN.

Detailed instructions on using the port are published on the official wiki page.

March 13th, 2012
Running eCos on the OpenRISC ordb2 board

UPDATE: the eCos for OpenRISC is now tracking mainline eCos and more configurations are tested, so the whole procedure was a bit simplified!

Downloading the new version of eCos will be described in a new note and linked to here.

Ant Micro is maintaining and developing the eCos port for OpenRISC – you can find the wiki page of the port at the opencores server.

So far, the port was being tested in the or1ksim simulator which is considered a golden model of the OpenRISC1000 architecture. However, it’s always best to see how a port performs on real hardware.

Recently, ORSoC shared the new ordb2 development board with us. The board is based on Altera Cyclone IV E FPGA chip and is equipped with all popular interfaces.

To verify that everything works fine, we tested the eCos port on the board by running a set of eCos tests and simple multi-threaded programs.

Below are the instructions how to run eCos programs on ordb2 board. UPDATE: Not all configuration options are yet supported, but the default configuration is well tested and stable, so the .ecc file provided previously is no longer needed.

In order to build eCos for ordb2, follow these instructions:

1
2
3
4
5
6
mkdir ecos_openrisc
cd ecos_openrisc
ecosconfig new orpsoc
ecosconfig tree
make
make tests

After issuing these commands tt is possible to run eCos tests on the board. In order to upload the binaries using GDB, the or_debug_proxy program is needed.

Please note that FT4232 support was added to or_debug_proxy on 16th september 2011 – older builds will not work.

To establish a connection with board, issue the following command:

1
or_debug_proxy -r 50001

This will open a tcp port for the GDB RSP connection.

It is now possible to open a UART connection. Please note, that it is better to open the UART connection after starting or_debug_proxy. It is because or_debug_proxy causes the system to reorder USB devices when connected to the FTDI chip.

The configuration file assumes that the UART is running at a 115200 baud rate.

To open a UART device using picocom, issue the following command:

1
picocom -b 115200 /dev/ttyUSB1

The number next to ttyUSB may be different across systems.

Everything is ready to upload a test binary. We will use GDB and connect to or_debug_proxy.

1
2
3
4
5
or32-elf-gdb [test binary]
target remote :50001
load
spr npc 0x100
c

Now that we know how to connect to the board, let’s make a simple hello world application. A minimal eCos hello world program looks pretty standard:

1
2
3
4
5
#include <stdio.h>
int main(void) {
  printf("hello world\n");
  return 0;
}

To build the program, use the following flags with or32-elf-gcc:

1
2
3
4
5
6
7
or32-elf-gcc \
   -g \
   -Iecos_openrisc/install/include \
   -Lecos_openrisc/install/lib \
   -nostdlib \
   -Tecos_openrisc/install/lib/target.ld \\
   main.c

It is now possible to upload the resulting binary file the same way described above. Have fun programming for eCos on the openRISC devboard!

March 9th, 2012
System reset in OpenRISC ordb2 board

The new OpenRISC ordb2 from ORSoC is a very nice devboard to have, especially with its support of multiple services like FPGA JTAG, OpenRISC JTAG and UART with a single USB cable. Our sincere thanks go to ORSoC for making a copy available to us.

For all its ease of use, the one thing that turned out to be a bit problematic was resetting the board, as no reset button is provided. The reset pin is routed to the expansion connector, but that’s not particularly helpful.

The reset line is also connected to the FT4232 controller. It is therefore possible to perform a system reset using the USB connection. Unfortunately, or_debug_proxy does not provide such functionality.

We have come up with a simple way of resetting the board using the USB connection based on the UrJTAG project, and we’d like to share it for the convenience of everyone who is getting a bit frustrated with unplugging the board time and again.

UrJTAG is a universal tool for comunicating over JTAG. It is used to program the Altera FPGA chip, as instructed in the Running_SW_on_FPGA_board.txt document (delivered inside the VirtualBox image). We shall use this tool, with a slight modification, to reset the board.

The scripts included in the VirtualBox image use a generic ft2232 cable driver. This driver does not support TRST ans SRST signals. We have written a small patch that adds a new cable called ordb2. This new cable is based on a generic ft2232 cable, except that a SRST line is added.

Below are the instructions how to enable the reset functionality in UrJTAG:

First download the UrJTAG project and two attachments of this post – the patch and the UrJTAG script.

Extract the project and apply our patch.

1
2
3
tar -xvjpf urjtag-0.10.tar.bz2
cd urjtag-0.10
patch -p1 < ../urjtag-0.10-ordb2-antmicro.patch

Now build the project and copy the configuration script:

1
2
3
./configure
make
cp ../ordb2_reset.cmd ./

It is now possible to reset the board, by issuing the following command (in the current directory):

1
./src/jtag ordb2_reset.cmd

How convenient!

Attached .patch file: urjtag-0.10-ordb2-antmicro.patch

Attached .cmd file: ordb2_reset.cmd

October 31st, 2011
eCos-3.0 port for OpenRISC

During our work with the OpenRISC platform we were missing our favourite real-time operating system – eCos. Although some porting work had been performed earlier, the eCos port was no longer supported. With the development of the OpenRISC project, as a result of toolchain and other changes, it had stopped working.

Also, it was based on the now obsolete 2.0 version of eCos.

We decided that a freshly updated eCos port could be useful both in our work and for the OpenRISC community, and here it is!

On http://opencores.org/or1k/ECos you will find the associated wiki page and from there you can download the code, of which Piotr Skrzypek is the maintainer.

 

Copyright © 2009 - 2013 ant micro. All rights reserved. | Design: Duind.com