BozoSort

yet another CS blog

Browsing Posts published in November, 2009

Building RTEMS

1 comment

Overview

The classic way of building RTEMS is to start by building your own tool chain for the specific target architecture for which you wish to build your RTEMS kernel for. This can be a tedious process as there are an abundance of little “gotcha’s” that lead to many failed compiles and hurt feelings.

The simplest way to build RTEMS is with the pre-built tool chains available on the rtems website. They are only available in .rpm format, and require the yum package manager for the easy – easy way of getting RTEMS compiled.

The website does have existing instructions on getting these pre-built tool chains setup, but I found them to be incomplete and confusing. So here is a guide to augment those instructions.

General vs. Example

For the sake of clarity, I’ll be showing general commands in normal code font and example commands in red code font . Since there are many different environments and build targets, the general case will be sort of “fill in the blank”, while following the examples in red will get to a working i386 RTEMS kernel.

Downloading Things

For the example build, I’ll be using i386 RTEMS 4.9.2 and the Fedora 12 32-bit O.S. If you aren’t using either Fedora, CentOS, RedHat, or Suse, these instructions are probably useless to you. You’ll need to either build the toolchain by hand or start using one of the supported operating systems.

*One important thing to note about the RTEMS naming convention is that the toolchain drops the last digit of the version number of the RTEMS version you want to build. For example, if you’re building RTEMS 4.9.2, you use the 4.9 toolchain.

Download

Go to www.rtems.org/ftp/pub/rtems/linux/ and click through the links until you’ve found the page listing rpm packages relevant to your OS and desired RTEMS version. There will be an .rpm (probably at the bottom) in the form:
rtems-BRANCH-yum-conf-VERSION-DISTRO.noarch.rpm
For example,
wget http://www.rtems.org/ftp/pub/rtems/linux/4.9/fedora/12/i386/rtems-4.9-yum-conf-0.20-1.fc12.noarch.rpm
will download the correct file into your current directory.

Load

Load the .rpm into yum with command: sudo rpm -ivh [package] . For example, I did
sudo rpm -ivh rtems4.9-yum-conf-0.20-1.fc12.noarch.rpm
Now reload yum and search for rtems to display all the different toolchain components you can download for all the different available target architectures:
sudo yum update
yum search rtems

Install

Install the toolchain of build target of your choice. There are some things that all targets need, and then there are architecture specific things. First, the general stuff:
sudo yum install rtems-4.9-auto*
Now for the architecture specific stuff:
sudo yum install rtems-4.9-[ARCH]*
Playing along with the i386 example, the command would be:
sudo yum install rtems-4.9-i386-*

Sadly yum fails to completely install our tools. It puts everything in /opt/rtems-[VER]/bin/ which is not a part of your $PATH, so trying to compile will still result in "no compatible cc found" at this point. To correct this, tell the $PATH where the tools are with either a quick:
PATH=/opt/rtems-[VER]/bin:$PATH
(or the following for the i386 example):
PATH=/opt/rtems-4.9/bin:$PATH
or for a better solution, edit your ~/.bashrc and add the above line. If you go this route, the changes will take place after you reboot, and will continue to work after every reboot.

Now verify that the toolchain is available for use with the which command.
which [ARCH]-rtems[VER]-gcc
Or for the i386 example:
which i386-rtems4.9-gcc

If you don't get something along the lines of "/opt/rtems-VER/bin/ARCH-rtemsVER-gcc" as your output, you did something wrong.

Compile RTEMS

Compiling RTEMS is no different than compiling other programs. First call the configure script with the options you want, and then hit the make button. However the make files do seem to ignore the "--prefix=" flag if you try to use it (relevant only during make install), and dumps all the output into /opt/... anyway. In the general case, to compile RTEMS, you want to use a command (from the build directory, where [...] is the location of the source files for RTEMS) is:
[...]/rtemsVER/configure --target=ARCH --[ other options ]
In the i386 example:
[...]/rtems4.9/configure --target=i386-rtems4.9 --enable-tests --enable-networking --enable-posix --enable-rtemsbsp="pc386"

To quickly find the output files (assuming you built the tests) do a simple:
sudo find / -name hello.exe
This will reveal the directory holding all of the sample output files, and you can copy or move those somewhere into your home directory so they're more convenient to use.

Congratulations, you built RTEMS!

To get RTEMS booted in QEMU using GRUB, see my article about that

Hello, Go!

1 comment

Part 1 of my journey with Go! from Google.

Getting the Go! compiler up and running

Following Google’s installation instructions are fairly simple. One thing to keep in mind is that all three architectures are based on different compilers, and each compiler must be built for each architecture you wish to build to. A minor annoyance now, but it may turn out for better or for worse later on. Imagine building something for every architecture. You’d have to have to configure and build an entire compiler for every one of them, as well as deal with the clusterf**k of automake files that’s sure to ensue.

On to building as per Google’s instructions:
One thing to keep in mind, $GOBIN is not clearly explained like the other three env variables. I just set them like this:

export GOROOT=$HOME/go
export GOARCH=386
export GOOS=linux
export GOBIN=/home/[Me]/gobin

where [Me] is my own personal home folder. No, it’s not very clean, but I’m really way too lazy to do it the “proper” way. I’ll just wait for Go! compilers to end up in my distro’s repositories. Also, the above (specifically GOBIN and GOROOT) needs to be re-exported every time you reboot, other wise your computer forgets them and trying to compile your .go programs will result in missing packages and whatnot. So add those lines to your .bashrc or whatever file it is you choose which is run upon boot.

You will also need to add GOBIN to your $PATH, so throw that into your .bashrc (or whatever) at this time as well.

PATH=$PATH:$GOBIN

To make these changes take place without rebooting, do a simple

source ~/.bashrc

In acquiring the source files to build, Google recommends using some easy_install python crap. Just ignore that and install mercurial directly using your favorite package manager, and then use their command:
hg clone -r release https://go.googlecode.com/hg/ $GOROOT

to download the source files.

Making the Go! compiler

Firstly, make sure you have bison gcc libc6-dev ed make all installed using your favorite package manager.

Then, it’s time to build Go!:
Change to the src directory, and then start the build process:

cd $GOROOT/src
./all.bash

Remember, you’re going to be building a cross-compiler (even if you’re on a “native” machine) for the architecture you defined on $GOARCH. If you want different compilers, you have to change all your variables accordingly and build appropriately.

Onward to compiling!

As said before, each architecture uses an entirely different compiler (and linker).

Architecture amd64 i386 arm
Compiler 6g 8g 5g
Linker 6l 8l 5l


In my examples, I’ll be using the 8g, or i386 compiler since my laptop has a dinosaur Pentium cpu.

Before compiling out program, we should probably write it first. You could be cool and just cat the following to a file, or you could be like me and open a favorite text editor (gedit in my case) and make files that way. Here’s the code for the “Hello World” that I used.

package main

import fmt "fmt"

func main()
{
	fmt.Printf("Hi\n");
}

I saved this as Test.go to my working directory. To compile, use:

8g Test.go

And then to link it:

8l -o Test Test.go

The “-o” switch tells the linker to call the output file “Test” rather than the default “8.out” which is how the google guide leaves it. I like properly named output files that can exist in the same directory without being overwritten.

Lastly, we run the program with the familiar:

./Test

As for output, I got the expected:

[Seth@SFedora GoFiles]$ ./Test
Hi

If you use Webmin to manage your server, you will eventually come across upgrades which will seem to ‘break’ your install. After upgrading, you’ll lose the ability to log in, and it seems as though the whole thing is just borked. In reality, you just need to restart the webmin daemon. Since this only happens when you reboot or start it manually, you’ll need to either reboot or start it manually.

At the command line, type (as root):

# /etc/webmin/start

After logging in you can verify the upgrade was successful and make sure that webmin starts upon system boot, just in case.

There are existing instructions on how to connect an Ubuntu (or any Gnome-Network Manager) machine to the University of Texas restricted campus wifi, but they are several years out of date. The interface has changed quite a bit over the past few years, and now no longer provides some default settings that the UT instructions relied on previously.

Here are the proper settings for the “updated” Network Manager:

Wireless Security: WPA & WPA2 Enterprise
Authentication: Tunneled TLS
Anonymous Identity: anonymous
CA Certificate: [the one you downloaded]
Inner Authentication: MSCHAPV2
Username: [your UT EID]
Password: [your corresponding password]

Network Manager UT WiFi

There are also instructions on the UT Helpdesk site for using wpa_supplicant to get yourself connected, but I strongly recommend not using that. I also don’t recommend using KDE’s network manager, as it sucks. hard. I have never tried to use Wicd, but I imagine if you use the same settings it will work just as well.