Alex's Alliterative Adventures

Thoughts on Programming, Life, and Travel

Archive for June, 2008

Making an ELF in a bochs

My partner and I just spent far too many hours getting the toolchain for Waterloo’s CS452 (Real-Time Programming, aka the trains course) working on Linux. A few tears and a lot of grumbling later, we’re compiling like a bat out of hell, running bochs natively, and posting to the Eos remotely. Here’s how we did it:

1) Using your package manager, install the “flex” and “bison” packages. (We’re not sure about this step, but it can’t hurt)

2) If you don’t already have it, use your package manager to download and install gcc 3.x. (We couldn’t compile everything with gcc 4.x) You’ll also need libc6-dev.

3) Download the following 3 files from some random website (try google):
gcc-3.3.3.tar.bz2 (We used 3.3.3 instead of the recommended 3.3.4, since the school machines run 3.3.3)

4) Open up a terminal window and set the CC environment variable to point to gcc 3.x (which you just installed)

5) Use gcc 3.x to follow the steps at the course toolchain setup guide.

1) Download the bochs source, bochs-2.3.tar.gz

2) Download X Windows libraries, xorg-dev

3) Configure bochs with whatever options you want.
If you want your installation to match the school’s, this is my current best guess:
./configure --enable-debugger --enable-disasm --enable-apic --enable-cpu-level=6 --enable-sse=2 --enable-sep --enable-guest2host-tlb --enable-repeat-speedups --enable-icache --enable-fast-function-calls --enable-ne2000 --enable-vbe --enable-usb --enable-pci --enable-readline --enable-show-ips
(I did this on a fresh ubuntu install, so I had to grab a copy of g++ to do this)

4) Compile bochs.

5) Modify 452mkemu and 452postemu so all of the directories are pointing to the right place on your machine. Our files now set different directories based on whether you’re running linux and which user is logged in. You’ll also need to copy any files these scripts reference (like grub.img, or the bochs BIOS) to your machine somewhere and point the scripts at them
EDIT June 13 14:58: After wasting a lot of time, we figured that bochs would start panicking once we checked our BIOS into CVS. This was, of course, because CVS decided that our BIOS was too big, and it graciously decided to take off two bytes for us. Solution: they’re not in CVS anymore! Thanks, CVS.

5) Run 452mkemu. You’ll need to change any directories in the file to match your machine’s setup, and you’ll also need to install mtools.

6) Emulate to your heart’s content. If you get a message saying that menu.lst is not found, just rebuild your kernel.

Symbolic debugging
I can’t stress enough how useful the bochs debugger becomes once you get symbolic debugging working.
We followed the instructions to generate a symbol file for bochs,  and now our makefile generates a bochs symbols file whenever it posts. I had to install gawk to make this work on linux. Here’s the secret ingredient:
nm -n $1 | grep -v '\( [aUw] \)\|\(__crc_\)\|\( \$[adt]\)' | awk '{print $1, $3}' > $2

The 452post script needs to lock a file on the school servers, and since my Linux-fu is weak, I don’t know how to make that happen remotely. I do know how to copy files to the school servers, though, and execute commands remotely. A few lines of script later, your linux install will post to the Eos machines.

That’s right, I went there. Sort of. Earlier today I set up an eclipse CDT project that compiled our code, start to finish. There were a few hitches: Eclipse thought that having to generate dependency files was a critical error. There were a few other similar snags. I hope we’ll be able to get it working soon so we  have a real IDE to code in, but it can still be a useful tool as a souped up text editor and CVS GUI.
EDIT June 13 15:33: Eclipse works. It’s beautiful.

The only thing that’s even mildly annoying with this whole process is that with my current setup, I’m prompted to enter my password every time I connect to the school machines, which happens 5 times when I post. If the rumours are true, I can tell SSH to connect with a stored key instead of a prompted password, which will be icing on the sweet, sweet cake.
EDIT June 13 11:41: I don’t have to enter my password anymore.

If there are more cool tricks to make coding a kernel a little bit easier, please leave a comment.


Math you can use

If you’re reading this on facebook, you’re missing out on the pretty pictures. Click “View original post” at the bottom of the page.

I’m taking CS370 this term. It covers lots of useful stuff, including interpolation with natural cubic splines, which is the math nerd’s game of connect the dots.

You start with an image:

Pick the dots you want to connect:

And let the math do its magic:

I’ve been comfortable with being a computer geek for years, but a math nerd? This will take some getting used to…

No comments

Pool 3 – Squirrels 1

Or maybe it’s a chipmunk. Whatever it is, I’m glad it grabbed my makeshift lifesaver.

Keep fighting the good fight, little guy.

1 comment

« Previous Page