Wednesday, June 25, 2014

[HOWTO] build and run RTEMS on or1ksim

This post describes how to build, configure RTEMS to run on or1ksim emulator. Installing the tool-chain is a prerequisite before applying the steps in this post; if you have not already installed them, check out the steps here and do it. Once the tool-chain are installed and seen in the executable path, you may proceed with the following steps.

1- Set up the work space.

$ mkdir ~/rtems-dev
$ cd ~/rtems-dev

2- Clone my RTEMS project repo


This is temporary, by the end of the project, all the code at my repo should be upstreamed to RTEMS.

$ git clone git@github.com:heshamelmatary/rtems-gsoc2014.git
$ cd rtems-gsoc2014

3- Switch to or1k branch


I have created a branch for the project to help me with arranging and generating patches against master; meanwhile, keep master branch synchronized with remote.

$ git checkout or1k

4- bootstrap


$ bootstrap -p
$ bootstrap

5- Configuring and building 


$ cd ../
$ mkdir b-rtems
$ cd b-rtems
$ ../rtems-gsoc2014/configure --target=or1k-rtems4.11 --enable-rtemsbsp=or1k_or1ksim --disable-posix --disable-itron --disable-networking --disable-smp

You should get hello and ticker applications in their executable form. Other applications/tests will fail to compile because of other features/implementations that are not supported yet.

Running and debugging hello.exe


1- First you should have an or1ksim configuration script suitable for or1ksim BSP. This is the sim.cfg file I use at this stage of the project. It should be placed at your home directory. Note that as long as more features like: FP, cache manager, MMU manager are added, this file has to be changed to simulate these functionalists on or1ksim.

2- Run hello application on or1ksim.

The configuration file uses RSP (remote protocol) to enable GDB to connect to or1ksim. So, when running or1ksim, it reads configuration script, loads the program into the proper addresses, and waits for GDB to connect.

$ cd $HOME/rtems-dev/b-rtems/or1k-rtems4.11/c/or1k_or1ksim/testsuites/samples/hello/
$ or32-elf-sim -f ~/sim.cfg hello.exe

You should get something similar to the following picture:




3- Run GDB and connect to or1ksim 

From another terminal run GDB and connect to or1ksim

$ or1k-rtems4.11-gdb $HOME/rtems-dev/b-rtems/or1k-rtems4.11/c/or1k_or1ksim/testsuites/samples/hello/hello.exe

From gdb, attach it to or1ksim

(gdb) target remote :50001 
(gdb) continue

UART should emit the string output to or1ksim (and any other channel you provided in configuration script)




References 


8 comments:

  1. ../rtems-gsoc2014/configure: No such file or directory
    I can't configure. where is the configure file? please

    ReplyDelete
    Replies
    1. Make sure that:
      1- You have the rtems-gsoc2014 directory at the specified path.
      2- You run bootstrap -p and bootstrap before you run this command.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. I'm sorry to bother you.
      I already run bootstrap -p and bootstrap before.
      but configure file is not created.
      I followed that order.
      Have you ever used qemu?

      Delete
    4. I have updated my repo, so you can avoid moving between branches (or1k and master), and use master branch only. From there you can run bootstrap commands. Which OS do you use? This post assumes that the development is under linux environment, fedora 20 for me. Using QEMU does not relate to what you are asking about. For now, there is no support for or1k/RTEMS on QEMU, however, you can run bare-metal elf applications there.

      Delete
    5. Regarding building or1ksim, you can follow the instructions there http://opencores.org/or1k/Or1ksim

      Delete
    6. I succeed to build RTEMS.
      Bootstrap did not run properly because the autoconf and automake versions of Ubuntu 12.04 low. So I could fix it by raising the autoconf and automake versions.
      And I fixed RTEMS toolchain build error by modifying $PATH.
      I can run hello application on QEMU. But I can't run hello application on or1ksim. I used the sim.cfg files from "github.com/heshamelmatary/or1k-rtems" and or1ksim.
      Anyway, my goal was to run RTEMS in QEMU. Thank you.

      Delete
  2. Great that you managed to run hello on QEMU. Let me know if you need help with or1ksim.

    ReplyDelete