Assembly

My section of Engineering 100 is Microprocessors and Toys, and having started with combinational logic, we progressed to finite state machines, then instruction set architectures, and finally to Assembly. We implemented simple instructions in Verilog, and we are now finally programming on that processor in Assembly. It’s oddly gratifying, although I have many gripes about Assembly. We are using E100: a heavily simplified instruction set without programmer-accessible registers, but even so these difficulties seem basic enough to be widely applicable. So far, the bugs we’ve run into have not been problems with overall logic but with return and jump addresses. An incorrect return address can often restart the program: memory by default holds a value of zero, which is also the address of the start of the program. This makes for an especially baffling form of infinite loop. Using the incorrect destination label for an unconditional branch leads to chunks of code mysteriously remaining unexecuted. I hope we figure out how to do this better, as currently it is often difficult to tell even what the values of variables are because on the emulator they are just one of many hexadecimal values out of several pages of them. Without the emulator it would be even more difficult. I’d rather stare at a page of numbers than have to add wait-for-key loops and hex digit outputs for each breakpoint and value I was interested in.

Gitolite, Lighttpd, and GitPHP

I had some trouble setting up GitPHP running under Lighttpd when using Gitolite. GitPHP is a PHP clone of gitweb, which allows web-browser-based repository viewing, and Gitolite is a very nice Git permissions manager. I needed the webserver to have read access to the repos, so I set the group to www-data, but as Gitolite was managing them, each commit would reset the permissions. I couldn’t get it working by adding www-data to the git group as suggested and would make sense, which I think is a lighttpd issue. The group sticky bit solved this problem by stopping the group owner from changing. I didn’t want the Gitolite configuration repos displayed on GitPHP too, so I pointed GitPHP at a different directory than the one the repos were actually in, and filled that with symbolic links to the repos it should display.

Still alive!

I’m still very happy that I’ve dropped physics. My class load is much more manageable. In Psych we have to do behavioral conditioning to improve something about ourselves, so I’ve chosen to try to reduce the amount of time I spend distracted on Reddit when I’m trying to do schoolwork. For the week before break I kept track of time spend trying to do schoolwork, and what of that time I spend browsing Reddit. This coming week I will record my time usage again, but this time whenever I focus on schoolwork for an hour or more without getting distracted on Reddit, I will give myself a 50% chance of the option to play Minecraft for 15 minutes guilt-free. Let’s hope it works.

I’ve begun to contribute to open source projects that I use. It does require knowledge of source control and communal development procedures, but it’s a great feeling to give back, even though my efforts are relatively small. Also, chmod uses X to give execute/search permissions only if someone else already has them for that file/directory.

Progress

Faced with a persistent inability to complete homework to a satisfactory degree, my academic advisor and I decided to drop my physics lecture, which had yielded encouraging increases in available time. I’ve also discovered GitPHP, which works as a PHP equivalent to gitweb and works very nicely. I set up a private git repo (accessible through the user git with everyone’s public keys in authorized_keys for my Engineering 100 class. We’ll use it to coordinate parallel development of an E100-compliant processor and our project, which at this point looks like it’s going to be creating robots which interact with one another through sound.

Learning Through Disaster

Gather ’round children, and I’ll tell you a tale of what happened to a Linux box when its sole filesystem was remounted read-only due to disk errors. This coincided with the backup server being taken offline with an errant circuit breaker.

I first became aware of something rotten in the state of Webserver when the sites hosted on it became messes of PHP errors in place of content. I could ssh in, but after entering my password I was greeted with:

-bash: /etc/profile: Input/output error
-bash: /home/steve/.profile: Input/output error
-bash-3.2$

That was a scary greeting.

lighttpd and ssh continued running, but PHP died, commands other than Bash builtins refused to run, and Bash profiles failed to load. I don’t know if some of this is due to damage or the partition being read-only. I’m pretty sure that commands expect /tmp, /var/run, and /var/lock to be writable. I now have those mounted as tmpfs as per the instructions on the Arch wiki here. The warning about lighttpd seems to not apply in my case. cURL seemed to run at first but died when I tried to do anything with it. I had hoped to POST files over, as scp, ftp, and sftp would not run. su still worked. Tunneling worked too, so I was able to still access other machines behind the firewall through the server even though I couldn’t run ssh from the machine itself. I ended up using cat to copy over text files. For binary files I had to get a great deal more creative. The only way I could interact with the server was over ssh; the server was an hour away and even if I did have physical access, mount refused to run (unable to write to /etc/mtab?) and I was afraid that the files I could access might be only buffered in memory and that rebooting into a LiveCD/USB would lose them. My options were limited. I had to use only Bash builtins to pull binary files off the server in text form. I modified a version of this hexdump script to pull files over ssh using | tee file.log to avoid having to copy-paste. tee takes output from stdout and redirects it to stdout and a file given as an argument. Here’s the script:

exec 3<"$1" while read -s -u 3 -d '' -r -n 1 char do printf "%02x" "'$char" done

I lacked a text editor and couldn't write to anything on the root filesystem. I found a tmpfs mount point (I used /lib/init/rw but /dev/shm would also work.) and stored the file by echoing the script line-by-line. In retrospect, I could have used \n and the -e (interpret backslash escapes) option to do it in one line: echo -e "exec 3<\"\$1\"\nwhile read -s -u 3 -d '' -r -n 1 char\ndo\nprintf \"%02x\" \"'\$char\"\ndone" > scriptfile. I ran it with bash scriptfile target_file.

All of this effort, though fun, ended up being unneeded as I had forgotten about my set-and-forget backups. Hooray rdiff-backup!

I ran mysqldump nightly and let rdiff-backup handle any differences. I restored it on the new machine with source mysql_dump.sql on a mysqladmin prompt, but as it contained users and privileges things got messy as the root and debian-sys-maint accounts were partially overwritten. I used mysqladmin to sort out the root password confusion and phpmyadmin to replace the debian-sys-maint password with the one found (in plaintext?!) in /etc/mysql/debian.cnf.

It was a fun puzzle even though it was ill-timed.

The Wolverine Soft 48-hour game competition revealed to me just how difficult physics engines are to make. I spent two days coding and recoding collision resolution only to get different sets of bizarre, game-breaking glitches. At least collision detection was easy because everything was a circle. It was fun and I'd like to do it again. Maybe I should become familiar with a physics library such as Bullet and ask for it to be approved for use in the competition. The guideline is unless it's an approved library, all code and assets (with exceptions for music and sound effects) must be created primarily on-site within the 48-hours. Next time I'll have to plan to do homework in advance. Ignoring homework for a weekend is inadvisable.

I am currently taking 17 credits, and the time management is very difficult, though has not yet proven to be entirely impossible. I'm considering taking classes at LCC this summer to lighten the load during the next school year. I applied to Camp CAEN to be a counselor, but they emailed back saying camp was ending due to the director retiring. The odd part is their website, as of this writing, has no mention of it that I can find. I'll have to see if I can get an internship over the summer.

Patience

I’ve been getting lessons in the importance of calm patience from various sources.  For instance, when I realized that Windows Backup would require too much effort to function as it should, I expanded my Linux backup partition to fill the entire backup drive, with the intent of adding Windows directories to the backup. To do this, as Truecrypt volumes have no official expansion capability, I moved the backups to my home folder, wiped the partitions, created a new LUKS volume, and moved the backups back. The partition operations were insanely easy with Red Hat’s Palimpsest. I put them in the root of the drive, and Deja Dup kept failing a CRC check and dying. My impulse was to freak out, delete the backups, and start fresh, but I researched it instead and ended up moving them from the root of the drive to a directory, and it appears to have fallen back to what it was supposed to do in the event of a corrupt backup which is make a new full one. I don’t yet know which backup was corrupt, I hope it wasn’t the full that the earlier incremental ones were based on, and I’m dismayed to find errors after copying, but I probably should have used rsync instead of Nautilus.

EDIT: It looks like the backups weren’t actually damaged. It may have been that the lost+found directory in the root of the drive was causing problems.

ADC

The ADC makes more sense now. It turns out Professor Atkins has been waiting as we figured out that the weirdness we’ve run into is due to tremendous electromagnetic interference. My math GSI was incredibly kind and willing to spend about an hour helping me fix the statistics. I don’t know why the corruption I ran into was occurring, but we did establish that what GSL calls total sum of squares is actually variance. I’ve added a real TSS function, as well as an output of absolute value of residual. Here’s the best graphs we got previously, rendered with the latest graphing routine:

ADC3 with latest graphing.

ADC5 with latest graphing.

ADC6 with latest graphing.

I didn’t want to disrupt the servo guy’s work much, so I moved Gumstix over to the power supply and set it back up. I didn’t use the breadboard to ground the unused ADCs, and put them all in the same alligator clip instead. I thought I would calibrate two more channels so that we’d have a usable input for the gyro reference voltage. I was very surprised with the results:

Behold ADC2!

Behold ADC7!

This makes so much more sense for many reasons. As I pointed out yesterday, there was a consistent, significant distortion under 1v. This is nowhere to be found in the new line. It’s actually a line, and there is only a minuscule difference in counts for the same voltages between graphs. This is acceptable as imperfections in the voltages we fed it as in this respect our power supply is… abstract. This line also goes up to 1024 at 2.5v, which is what it should actually do as it’s the maximum count at the maximum voltage. What I find amazing is how huge the effect of electromagnetic interference is! We got completely different information when using the breadboard, and even its imperfections were consistent! Professor Atkins revealed that she had let us spend hours on this fruitless calibration of electromagnetic interference so that we would thoroughly learn the importance of electromagnetically clean wiring. Lesson learned!

Engineering and Minecraft

It’s been a while. I get the feeling that I’m writing to an empty room, which contributes to the lack of content. If this is not the case, please let me know. These are still nice to write sometimes though.

I’ve discovered Minecraft. It’s a sandbox game like no other. The world is a natural landscape generated out of one-meter cubes: hills, mountains, valleys, caves, forests, beaches, deserts, plains, tundra. The fact that’s it’s generated makes it not only different each time, but also incredibly huge: the maximum size of the Minecraft world is limited only by the precision of a 64-bit double. This apparently works out to eight times the surface area of the earth. There’s a lot of exploring to do. However, that’s not all that makes Minecraft different: there’s no goal. There is no objective that the player is pushed to, other than to make their own. I can easily see this being a bad thing for some people, but after playing my fair share of linear games I find it quite refreshing. The player starts out with nothing more than a pair of hands to manipulate the world and works up from there: resources can be gathered to form ever more powerful tools, which can be used to manipulate the world faster. As it’s constructed of blocks, the entire world can be removed block by block, and placed back as seen fit. This allows for the construction of huge castles, tunnels, pits, mines, houses, and highways. There’s a pride in standing inside a shelter built with one’s own virtual hands. I also found Minecraft-Overviewer, which is an application which parses Minecraft maps and renders them into Google Maps tiles so that it can be inspected from above at multiple zoom levels, which sets it apart from single-image renderers such as Cartographer, although Cartographer has many more options. If you’re interested, you can view my world, but I warn that I haven’t built much above ground and it brings the lack of upload bandwidth into sharp focus with its slowness. But it’s there. (EDIT: never mind.) Monsters spawn in the dark: nightfall is terrifying.

In my engineering course I’m part of a small group that elected to automate a small hovercraft instead of relearn programming concepts we’ve already been over multiple times. Instead of learning more coding, we’re focusing on hardware. Our current status is soldering the chips on a board so that we can attach is to the rate table without it flying apart and eventually mount it on the hovercraft. I spent a few hours with gnuplot_i and GNU Scientific Library to make these graphs. I know the value of R^2 is wrong, I’m not quite sure what it is as I’m having trouble with the statistics functions in GSL and have never taken a statistics course. I hope to get it sorted out soon.

Graph of ADC3 calibration

Graph of ADC5 calibration

Graph of ADC6 calibration

What these show is the data we collected for the channels: we fed it known voltages in 0.1v increments and recorded the count given by the ADC, then found a best fit line for each one. They’re similar, but slightly different: I hope the difference isn’t just sampling error. At the very least they all seem to dip down until around 0.4v and float up until around 1v, so we may need to make something more complicated than a straight line to account for that.

Wolverine Soft

It’s not fun when you have to scroll down to see the last link to a required piece of online homework that’s not done. That monotony aside, things are going pretty well. I’ve discovered that Wolverine Soft is great – I hadn’t really realized how much I missed sitting and coding on a game for a day.