Archive for the ‘What?!’ Category

The Great Internet Migratory Box Of Electronics Junk: Excavating a box.

Posted on January 29th, 2011 in Electronics, What?! | No Comments »

I recently received a Great Internet Migratory Box of Electronics Junk (man is that hard to say in the proper order).

The rules are simple: Sign up for a box (or start your own), dig through it and document (in some form) what you’ve taken  from the box and what you’re doing with it, and ship it off to the next person in line. I feel bad that I’ve been sitting on this box for longer than I should have (normally no more than 7-14 days)… but with work, other projects, a house, and not enough sleep lately, progress has been a bit slow. (My apologies)

Let’s go digging:

I’ve found some use already with large capacitors and solenoids (and my Electronics Learning lab kit)… and a small handful of other parts are going into an upcoming project that I plan on writing up (that’ll happen soon). Adding  a few items to the box, and off to the post-office on Monday to keep this thing in circulation.

Video Game Creation using Blender, Gimp, and Allegro

Posted on December 11th, 2010 in Allegro, Blender, C, GIMP, What?! | No Comments »

I had an enjoyable assignment in a college course on the C language the other day – using the Allegro libraries, write a game of your choosing.

The assignment coincided with my recent discovery of Blender, the 3D mesh animation and design tool. Out of boredom on a recent weekend afternoon, I found Blender in a series of random Google searches… and dedicated the better part of 3 weeks teaching myself the ins and outs. (Surprisingly EVERYONE I know already knew about it, I’m not sure how Blender eluded my radar).

The entire movie Big Buck Bunny was created in Blender

So many people are familar with Blender  in fact, that there are hundreds of YouTube videos (and even  DVDs) covering practically anything you’re looking to do.

My first job was to model an alien – one similar to one of the enemies in a great game from my childhood – Commander Keen. (Side note: I first got the game from one of the many mail-order shareware companies that were popular before the Internet was in practically every home.)

Simple enough, the Alien is basically 3 spheres and 2 cylinders. After 30 or so iterations, I finally had one I liked.

My inspiration (from Commander Keen)

My Tribute to Commander Keen

Learning to paint took about 2 days of watching video after video trying to figure things out. Part of that time was devoted to me hunting down the cause of  a “bug”, which I later learned was a default setting in vertex paint.

This is not a boog.

With the Painting Mask enabled (the 'F' key)

The freenode #blender channel had plenty of knowledgeable users that convinced me that I wasn’t dealing with a bug in my install

Probably the best thing about Blender is that even I (having no real graphical talents), was able to create a decent looking object with a small amount of effort. And  I could then animate it, using armatures and a tutorial by Ira Krakow.

Citronella is Evil: The Action Editor and Timeline

After creating a few other random objects (some of which looked just plain pathetic), I ended up with a small stable of characters – and thankfully an assignment where they could live.

The Allegro programming library is a well documented, easy to use programming library that handles the tough parts of graphics programming – getting objects onto the screen. As with everything – where does one start?

Having two weeks to start and finish a game, I decided another childhood staple would be the perfect game to write – Jetpack.

Just a fun game.

Jetpack had a lot of great things going for it – fun game, re-playable (especially since it had a built in level editor) , and one of my favorite things – a jetpack. Jetpack could easily be thought of as Lode Runner with the ability to fly.

XScavenger is a fun Linux port of Lode Runner

While digging through Allegro’s online manual and chatting with other users on freenode (trying to  figure out how I could write this thing), my storyline inspiration played on my Last.FM stream – “Let’s save Tony Orlando’s House“, a great song by Yo La Tengo about Frankie Valli setting fire to  Tony Orlando’s house after a dispute over backup singers. The song is so subtle (it could easily be played in an elevator) that I had probably heard it a dozen times before actually realizing this soft song was all about a pretty amusing instance of arson.

So, I had a storyline, I had a borrowed game idea- and I had little time.  My first tasks basically drilled down to these items:

How do I make the background of a bitmap image transparent?

Set the transparent portion of the bitmap to #FF00FF (pink), and use masked_blit() or draw_sprite()

Hmm, Allegro didn’t remove all the pink background?

Make sure to disable anti-aliasing, you’re blending #FF00FF with nearby colors

How do I easily generate animations?

Design the models in Blender, use armatures and timelines to create the motion, save them as individual bitmaps (with OSA disabled and with the camera’s background color set to #FF00FF)

What’s the shortcut to add bitmaps to a datfile? Grabber would take forever!

Use the command line interface to datfiles – “dat”. Trust me on this one, I could archive 300 images in a few seconds, doing it by hand would be masochistic, taking hours.

How do I prevent choppiness in animations and movement?

There’s system bitmaps, video bitmaps, and memory bitmaps. Look into them, and the example code that comes with Allegro (especially exupdate) for ideas and examples.

How can I fade in/out?

One method is to place a semi-transparent black rectangle over the screen. Look at set_trans_blender(), drawing_mode(), and rectfill().

With the answers to those questions in tow, I had a decent demo ready in under two weeks; one that supported smooth screen scrolling, had some limited game-physics, and an even more limited level editor.

In the end, I pieced together level backgrounds using GIMP and a few photos from IStockPhoto.com. The game physics could be better, I’ll attribute their current state to my inexperience and the pending deadline. In the end – I think the project turned out fairly well.

GIMP and the first level background

Part of the Title Sequence to the game. Tony Orlando image used without his consent.

I took the following screen capture of the game using Taksi, an open-source, and free capture program in the same vein as Fraps (although Fraps is limited to 30 seconds of capture in the trial version). The screen-capture doesn’t have sound (the game does) and the actual game runs much smoother than the screen-capture..

So basically, you’re a mosquito with no wings (thank you Mr. Orlando) fighting to survive, collecting blood IV’s and gascans to fuel your jetpack. Now, I’ve got another project to dedicate free time to – all made possible with Blender, Allegro, GIMP,  and a little programming.

RadioShack Electronics Learning Lab

Posted on September 25th, 2010 in BrainDeadTip, RF, TI Launchpad, What?! | No Comments »

Recently I was intrigued by a Hack A Day post regarding a low-cost development platform for their MSP430 line of microcontrollers. I’ve long wanted to toy with an Arduino, but with many other projects currently under my belt, I’ve jut not had the time. When I heard the Launchpad was only $4.30, I figured I might as well pick some up for future use.

To make the shipping worthwhile, I ordered 3 of the boards from DigiKey. Unfortunately they were on back-order, but less than a month later – I got my purchase in the mail:

A couple Texas Instruments MSP430/Launchpads.The 3rd I gave to my brother

Each box contains the Launchpad Development board, USB cable, pin headers, a crystal, and two MSP430 chips. The online wiki contains links to a couple IDEs for use in the Windows world – and Hack A Day has a good writeup on using the msp430-gcc compiler in the Linux world.

Acting like an impatient kid, I put schoolwork and other projects on hold for a couple days to dig into the Launchpad. First mission – the basic “RC Car modification”.

Only modify full sized Police Cars.

To disassemble a real police car, first remove a couple tires.

After mapping out the pins on the H-Bridge of the RC Car, I decided to do something I’ve always wanted to do – buy a Radio Shack Electronics Learning Lab and brush up on what little I know.

The RadioShack Electronics Learning Lab. This circuit is a pacemaker for the human heart (from page 32)

This is something I should have had by the time I was in high-school – if not by 5th grade. The Electronics Learning lab contains 2 lab manuals (one covering Basic Electronics, the other Digital Logic), about 20 ICs, a handful of transistors, numerous resistors and capacitors, and jumper wires (among a few other things). The console itself has numerous built in potentiometers, LEDs, a relay, a transformer, a buzzer, speaker, DPDT switch, and many other components ready to use. Each of the built-in components uses springs to make contact. There’s also a built in breadboard.

The two included lab manuals.

Each lab manual contains background information on each of the various components, as well as example circuits that you can build. Each circuit contains a standard schematic, step-by-step instructions, as well as a checklist to help the user build an error-free circuit. The explanations on how many of the circuits work are lacking – requiring the user to do additional searching and reading to get a full understanding of what’s going on. (But seriously, that’s how it should be: You buy the lab to learn, doing additional reading should be encouraged)

If you look closely, you'll see an acrostic poem.

Which circuits you build and in what order you build them is entirely up to the user. Each manual is structured so that learning is incremental: You learn how resistors work, you learn how capacitors work, you learn many different ways in which resistors and capacitors can work together.

My goal is to work through each book page by page (I’m only just over halfway through manual 1). Each manual is about 96 pages long so this can easily be done in a long weekend (or a few in my case).

I really wish my high-school had offered an electronics class. My limited knowledge had been enough to get me by for basic projects, but the labs I’ve done so far have really bolstered what I know. And at $70, this is a real deal.

Next up: After completing all the labs, go back to the RC Car modifications and explore the possibilities of a TI Launchpad.

Fun with Hotlink Spam

Posted on September 22nd, 2010 in BrainDeadTip, Cisco, What?! | No Comments »

I get a lot of hotlink spam to this site, and normally I don’t particularly care. But when Mercado Libre (an online sales forum similar to E-bay) started using the pictures of one of the switches from my CCNA lab for a posting – I decided I’d try my hand as a sales person.

They could have at least resized the image – but here’s a snippet of what the posting looked like (note: since modern browsers cache imagery, you’ll likely have to hold down the shift button and hit refresh when looking at that post):

The actual switch is below the o-scope.

A few quick rewrite rules to tamper with that HTTP Referrer:

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ^.*articulo\.mercadolibre\.com\.ec.*$
RewriteRule \.(gif|jpg|jpeg|png)$ hotlinkers/computer-thermite.jpg [L]

And voila -

The perfect computer for arsonists.

I hope I get a commission off the huge volume of sales this generates.

Engenius EOC-2610 and OpenWRT: Getting Started

Posted on August 8th, 2010 in Engenius, What?!, Wireless | 2 Comments »

I’m looking forward to the upcoming CPLUG presentation: “Unleash your home router’s potential“. As 48 users will now attest, the captive portal I’ve been building has been a pretty big success.

Numerous attempts to fix the EOC-2610 reboot bug have all been in vain. The problem is this: the device reboots fine until the wireless modules are inserted AND the device placed into Master mode (to serve as an access-point). Removing the modules, using GPIO pin 0 instead of 5 to reset, pointing things back to the bootloader at either address 0xbfc00000 or 0xa8000000, and numerous other tests all fail. I cannot seem to locate the source that Engenius uses (which would help in finding the solution), and neither Engenius nor Senao will respond back to emails or Facebook posts. (I’ve spoken to Engenius reps in California that have pointed me to Singapore – I’ve been on hold for almost an hour there to no avail).

Serial Connection or Brain Surgery. Can't see it well enough to say.

But enough complaining, I’ll fix that bug eventually.

Update 8/10/2010: A coworker suggested double-checking voltage and direction on GPIO pin 0, as well as ensuring that AR2315_RESET_GPIO was set correctly this morning. Sure enough, I had a problem. I’ll release a very basic patch shortly. -=Bug squashed=-

Here’s the lowdown on how to build a basic linux kernel and rootfilesystem using OpenWRT and how to install your new firmware via the Redboot bootloader. I’m posting it as a quick introduction.

First off, use subversion to grab the appropriate source. In this instance, I’m using the BackFire port:

svn co svn://svn.openwrt.org/openwrt/branches/backfire

This contains everything you need to get started: toolchain, compiler,  and scripts to pull in the source for the kernel and all packages that will be built. OpenWRT is very well documented, and it’s worth the time to read the README file as well to build and read the contents of the docs/ directory.

Menuconfig is used to determine not only kernel options, but packages that will be built as part of the firmware image.

cd backfire
make menuconfig

Obviously the first thing you want to do is set the appropriate Target System. For the Engenius EOC-2610, you’ll want to use Atheros AR2315:

Menuconfig: Selecting your Target

Next, ensure you select squashfs for the Root filesystem image (under Target Image). Target Profile will only have one option (Default), so no changes are needed there. I generally use the default Global build settings (as they’re ample), but look them over if you want more advanced debugging options and to enable things like IPv6, etc.

The Image Builder option is to allow creation of a firmware image using precompiled binaries. I generally leave this and the other Main build options off..

Base system is exactly as it sounds: it’s a list of base utilities like dropbear, bridging utilities, iptables, mtd, and other items. In fact, all of the remaining options are fairly self-explanatory: Network, Libraries, Kernel Modules – they all mean what they say. If you can’t find an option, use “/” and search for it. Luckily a working firmware (that incorporates wireless) can be built with simply selecting the correct target (Atheros AR2315). You can add more features later.

When you’re ready to roll, a simple make V=99 will cause the OpenWRT system to download all the appropriate tools, compile them, and build your firmware. Obviously the first time you build an image, it will take some time. Subsequent builds focus solely on the kernel and root filesystem, not building the entire toolchain. The images are found under the bin/ directory.

For Future Reference: The Serial Pinouts

Now that you have an image, one has to use the Redboot bootloader to upload it. There’s excellent documentation out there on this as well, but here’s a quick rundown:

Use a crossover cable to connect to the Engenius EOC2610′s Ethernet port. The bootloader defaults to using 192.168.1.1, so configure your IP accordingly (for this example, I’m using 192.168.1.2).

In one terminal, start pinging 192.168.1.1. Plug in the PoE adapter to start the 2610 and upon receiving an ICMP response, telnet to 192.168.1.1, port 9000. (Since you need to send a Ctrl-C to the Redboot bootloader, I have found that using puttytel seems to be the preferred method to connect to it). You may find a blank screen that doesn’t respond – if you do quickly disconnect and reconnect to the device.

The first time you'll lay eyes on Redboot.

When you see the above screen (and have hit Ctrl-C), you’re ready to go.

Ensure that you have a TFTP server on your local machine and that the kernel (openwrt-atheros-vmlinux.lzma) and rootfs (openwrt-atheros-root.squashfs) are in the TFTP root location. Next, configure the bootloader to use your system as a TFTP server (and ensure that it can connect to you):

RedBoot>
RedBoot> ip_address -l 192.168.1.1 -h 192.168.1.2
IP: 192.168.1.1/255.255.255.0, Gateway: 0.0.0.0
Default server: 192.168.1.2
RedBoot> ping -h 192.168.1.2
Network PING – from 192.168.1.1 to 192.168.1.2
PING – received 10 of 10 expected
RedBoot>

Uploading the kernel is easy:

RedBoot> load -r -v -b %{FREEMEMLO} openwrt-atheros-vmlinux.lzma -m tftp
Raw file loaded 0×80041000-0x80110fff, assumed entry at 0×80041000
RedBoot>

Ensure that everything was uploaded ok and that the checksums match:

RedBoot>
RedBoot> cksum
Computing cksum for area 0×80041000-0×80111000
POSIX cksum = 472679704 851968 (0x1c2c8518 0x000d0000)
RedBoot>

me@vonnegut/tftpboot $ cksum openwrt-atheros-vmlinux.lzma
472679704 851968 openwrt-atheros-vmlinux.lzma

If all is well, format the flash and burn the kernel image:

RedBoot> fis init
About to initialize [format] FLASH image system – continue (y/n)? y
*** Initialize FLASH Image System
… Erase from 0xa87e0000-0xa87f0000: .
… Program from 0x80ff0000-0×81000000 at 0xa87e0000:

RedBoot> fis list
Name              FLASH addr  Mem addr    Length      Entry point
RedBoot           0xA8000000  0xA8000000  0×00030000  0×00000000
FIS directory     0xA87E0000  0xA87E0000  0x0000F000  0×00000000
RedBoot config    0xA87EF000  0xA87EF000  0×00001000  0×00000000
RedBoot> fis create -r 0×80041000 -e 0×80041000 vmlinux.bin.l7
… Erase from 0xa8030000-0xa8100000: ………….
… Program from 0×80041000-0×80111000 at 0xa8030000: ………….
… Erase from 0xa87e0000-0xa87f0000: .
… Program from 0x80ff0000-0×81000000 at 0xa87e0000: .
RedBoot>

You can then verify that the kernel is saved to flash:

RedBoot> fis list
Name              FLASH addr  Mem addr    Length      Entry point
RedBoot           0xA8000000  0xA8000000  0×00030000  0×00000000
vmlinux.bin.l7    0xA8030000  0×80041000  0x000D0000  0×80041000
FIS directory     0xA87E0000  0xA87E0000  0x0000F000  0×00000000
RedBoot config    0xA87EF000  0xA87EF000  0×00001000  0×00000000
RedBoot>

Excellent – it is. Next up – the rootfilesystem. It’s loaded into memory via the TFTP  server in the same fashion as the kernel (again, run a checksum to ensure all transferred fine):

RedBoot> load -r -v -b %{FREEMEMLO} openwrt-atheros-root.squashfs -m tftp
Raw file loaded 0×80041000-0x801a0fff, assumed entry at 0×80041000
RedBoot>

RedBoot> cksum
Computing cksum for area 0×80041000-0x801a1000
POSIX cksum = 3009821226 1441792 (0xb3663a2a 0×00160000)
RedBoot>

me@vonnegut/tftpboot $ cksum openwrt-atheros-root.squashfs
3009821226 1441792 openwrt-atheros-root.squashfs

Next, determine how much space is actually free in FLASH. It helps to use bc to calculate this:

RedBoot> fis free
0xA8100000 .. 0xA87E0000
RedBoot>

bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty’.
iscale=16
oscale=16
A87E0000-A8100000
690000

With this information at hand, you can burn in the Root Filesystem, utilizing all the free space:

RedBoot> fis create -l 0x690000 rootfs
… Erase from 0xa8100000-0xa8790000: ……………………………………………………………………………………………
… Program from 0×80041000-0x801a1000 at 0xa8100000: ………………….
… Erase from 0xa87e0000-0xa87f0000: .
… Program from 0x80ff0000-0×81000000 at 0xa87e0000: .
RedBoot>

That’s it – you’ve now uploaded your firmware to the device. Next, lets just double-check and ensure all is well, and finally – let’s boot our new image:

RedBoot>
RedBoot> fis list
Name              FLASH addr  Mem addr    Length      Entry point
RedBoot           0xA8000000  0xA8000000  0×00030000  0×00000000
vmlinux.bin.l7    0xA8030000  0×80041000  0x000D0000  0×80041000
rootfs            0xA8100000  0×80041000  0×00690000  0×80041000
FIS directory     0xA87E0000  0xA87E0000  0x0000F000  0×00000000
RedBoot config    0xA87EF000  0xA87EF000  0×00001000  0×00000000
RedBoot>
RedBoot> fis load -l vmlinux.bin.l7
Image loaded from 0×80041000-0x802a0200
RedBoot> exec

At this point, detach from the telnet session (no output will be seen when the device boots), and once the system has booted – connect using telnet (or SSH if compiled).

The OpenWRT Busybox shell

Next up – customize your firmware image and build your own packages  – and check out the upcoming CPLUG meeting on unleashing your home routers potential.