Alex's Alliterative Adventures

Thoughts on Programming, Life, and Travel

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:

Compiler
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):
binutils-2.14.90.0.8.tar.bz2
newlib-1.12.0.tar.gz
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.

Bochs
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

Posting
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.

Eclipse
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.

11 comments

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

Easter Eggstravaganza

I decided to celebrate the successful return of my luggage by allowing myself the one guilty pleasure I’ve been craving since I got home: laundry. Which, incidentally, also means blog post. And underwear. Sweet, sweet underwear. (My underwear)

Although she probably won’t be posting about Naked Night (she wasn’t home a the time), Pinka’s blog has slowly become a better source for Alex-related updates than mine. She covers the Easter breakfast pretty well, complete with photos if you rummage deep enough. The only significant Alex-update that you won’t get from the fingers of Pinka is Sweden: part 2.

Sweden was absolutely amazing. My concerns melted away the instant I saw Nina waving at me in the airport. I’m still reminiscing about how unimaginably perfect our week was. Getting to spend almost 7 days making up for lost time is not an opportunity I expect to be given again anytime soon, and we damn sure made the best of it.

Now that I’m back on Canadian soil, I’m throwing myself into work, getting ready to move to London’s newest hotspot, and drawing triangles. And rarely, rarely blogging.

2 comments

Blagoblag

As the more astute among you may have noticed, the ol’ blog’s getting a little rusty. A few exciting things have happened recently, like a drunken Guitar Hero fest with a few future housemates, a snowboarding weekend that got rained out, an ass-picnic of dudity, and the shins live at the Kool Haus in Toronto.

The shins were particularly awesome not just because of the lead singer’s incredibly refined voice, but also due to the surprising amount of kickass offered by Viva Voce. The rock duo’s first lyrics, “Hey y’all”, caused me a bit of worry, but they immediately swept it away with a resounding “We do not fuck around”. I felt relieved. I was in the presence of professionals: there was not going to be any more fucking around going on than was absolutely necessary. They proceeded to teach the males in the audience that the hottest thing that a girl can possibly do is to shred lick after lick on her electric guitar. Seriously ladies, if you want to bag that cute guy, forget lingerie, just show him that he should salute you, since you are among those about to rock.

I’ll be leaving my guitar behind when I spend next week in Sweden. I’ll be MIE (Mostly In Europe) from the 21st to the 27th, so drop me a line if you’re in the area. My schedule’s pretty full while I’m over there, but there might be time for a cup of coffee.

There’s a part of me that wishes I wasn’t so busy (read: lazy), because I still have thousands of pictures from the EU to sort through, some of which no human eyes have ever seen. I had awesome plans for a montage, and although I feel slightly inspired whenever I hear that one South Park song, my strength of will usually overcomes a pesky amount of inspiration.

ps. watch heroes it’s awesome

5 comments

Get busy child

It’s been a long time since I’ve used the word “bored” to describe myself. I’m in the middle of rebuilding my server, Fable sits 90% beaten, and I’m desperately trying to walk the treacherous path that leads to graduation. I wouldn’t be surprised if some of the authors of my 60 unanswered emails are starting to get annoyed at my unintentional silent treatment. I often wish that the days were 5 times longer so that I could get more done. In the mean time, just know that I’ll return your emails eventually. Probably.

6 comments

Canadian winter

I like winter way better than I do summer. Snowmen, tobogganing, and hot cocoa all bring a smile to my face. While beaches, shorts, and sunlight are all very nice, the summer heat can be totally unbearable. Winter’s chill can always be forgotten by throwing on another sweater and sliding a bit closer to the fire, but when you’ve already taken 3 icy showers and it’s not even 10am, September just can’t come soon enough.

My weekend in Windsor with Wes reminded me of the downsides of winter. I spent most of the poker game (with Captain Bee) whining about how I forgot to pack a sweater while wearing a winter jacket. Everyone made sure to bundle up tightly before leaving to ensure that they survived the trip home. Although it was only -15°C outside (for the yanks: 3°F), the windchill was down to -30°C (-22°F). I guess we were lucky, though. Tonight Thunder Bay has a windchill warning of -47°C (FUCKING COLD). Our winds were only blowing at around 50km/h, whereas some cities in Northern Ontario had to hold fast against gusts of 110km/h. The cold provided some comfort, though: I was more numb to the pain of my poker loses.

I also had my first glimpse of Vista this weekend. While the translucent borders were cool and the spotli– er, Instant Search seemed snappy, I can only review the one feature I spent enough time with to make my comments valid: the games. Inkball is a hybrid of jezzball, pool, and (for the mac fans) breakout. It could be cool if playing the game didn’t amount to an experience similar to playing mspaint. I can only presume that Purble Place is Microsoft’s attempt at offering family-friendly fun, but if I had a 4-year old that found amusement in baking cakes, they wouldn’t be getting a Vista upgrade, they’d be getting a quick lesson in operating an oven, a little praise, and a book full of recipes for daddy’s favourite pastries.

13 comments

Well, now I’m just pissed

I just spent the past 15 minutes blogging, only to have my efforts thwarted by the sand-solid palm operating system. Stable, my ass-mar. The post I had started to write was about the writer’s block my presently awesome life was giving me, but now the words are just flowing, aren’t they, palm treo. AREN’T THEY. I’M NOT MAKING A SCENE, YOU’RE MAKING A SCENE. I’m sorry, honey, you’re right. I’m taking my anger at realplayer out on you.

A buddy of mine sent his laptop in for repairs today. Since this is effectively the only computer he owns, the repair estimate of 3-5 days is understandably causing him a bit of stress. I can’t even begin to imagine the pain he must be going through right now. They might as well have told him to hold his breath until he gets it back. It would take the pain away sooner. His suffering made me think: I would be totally unable to live productively in the real world without touching a computer of any kind. Between PCs, laptops, cell phones, and miscellaneouses, a vast majority of my life hinges on these powerful toys. If I want to socialize or plan, I turn to msn. TV and movies, selected from various avi files, are watched with VLC or the xbox. My day job involves sitting in front of a computer to write code. I keep people updated with my blog, which I write on my cell more and more often. Need a doctor? Better google map it first. Low on groceries? Online delivery adds less than $10, which is nice considering my lack of wheels. Wikipedia always scratches the itch of random questions. Transportation is planned, checked, and booked with a few clicks of the interblag.

I’ve read a few articles touting the dangers of internet addiction, stating horrifying statistics about people that find it difficult to go for more than a few days without plugging in. I definitely fall into that category. Then again, I also find it difficult to go more than a few days without opening my eyes. I hope I don’t read about the dangers of vision addiction any time soon. One self-diagnosed crippling addiction is all I need right now.

Observation of the day: eating while running is surprisingly hard, considering the deceptive ease of walking while chewing gum.

Also, this is spectacular.

4 comments

Number 4 town in all Kazakhstan

From what I’ve seen so far, London is the friendliest town in Ontario. People exchange smiles when they pass each other on the street. Conversation flows easily between strangers who are passing time. A couple of weeks ago, I had a chat with a hotdog vendor while eating his delicious meat (no brokeback) that was followed up by a random dude asking me how the hotdog was. Today a random in shopper’s asked me if I was a drummer, at which point I noticed that I had been busting out a flurry of funky finger beats on my legs. The random then invited me to play drums in his church’s band. I’ve also swapped stories with bus randoms, one of whom invited to the bar that he owns so, of all reasons, I could join the staff in a game of D&D. This town might be a flashback to a time when the people that surrounded you were your neighbours and friends instead of thieves and rapists. If not, it’s full of a bunch of fucking psychos who are startlingly charismatic in their attempts to kidnap, rape, and kill me.

Random note: a laundromats are surprisingly conducive for blogging.

6 comments

Starting the santa list early

Sometimes I wish for my own personal camera crew to follow me wherever I go. I mean, it would be awesome. My alzheimeric memory would be a thing of the past. I would finally be justified in randomly bursting out in song and the occasional smattering of loosely choreographed breakdancing. If I got tired, I would carry a whip and make them carry me while fanning me with palm leaves. But best of all, when I wipe out for the second time on the icey-slick death trap that is my front steps and end a fabulous display of futile tap-dancing by helping a week’s worth of dirt laundry the exhilerating feeling of being airborne, I could finally achieve my dream of having America’s funniest home video.

I also wish for a rocket-powered ninja pirate. With lasers. That is also a robot. But I’m not picky.

2 comments

« Previous PageNext Page »