Troubleshooting a custom computer build

ASUS P8Z77-M Pro MotherboardRecently I decided to take some leftover computer parts and add them to a few new ones to create a small computer I can use for an upcoming projection project and also use later as a home theatre PC. I went to the local computer store and picked out the required items: Z77 motherboard, graphics card and case. It took part of a Saturday afternoon, and by the evening I had Windows 7 booted.

That’s where I ran into trouble.

Intel i5-3330 CPU and thermal pasteThere’s a delicate balance between hardware and software in a computer, and sometimes the two sides fight each other. That’s what started happening to me. After installing the motherboard drivers from the included DVD, I started getting freezes a few minutes after startup that would last anywhere from 30 seconds to 3 minutes. They would repeat again and again, and it was almost impossible to predict. After updating some software, and testing different applications, I had two breakthroughs: first was a blue screen of death that returned an anodlfx.sys error and the second was a taskbar notification that the graphics driver had halted but recovered again. Armed with those data points, I combed Google for information, but came up largely empty. So to find a solution, I began troubleshooting individual components and systems, which are documented below.

Remove/reseat RAM

Computer memory can sometimes cause random software behaviour under certain conditions. To try to pinpoint if any of the chips you’re using have problems, install only one DIMM at a time and boot the computer to check for an error. You have to make sure the slot used is the one the motherboard needs when only one chip is present. I swapped out the two chips I was using at the time, but the problem continued. Installing them both again, I ran MemTest86+ but that came back clean, so memory was not the problem.

Remove the dedicated graphics card

Since the popup warning seemed to indicate a graphics problem, I tried removing the dedicated graphics card. The Z77 chipset motherboard I’m using has support for integrated graphics, should the CPU support them, so I was running Intel HD2500 from the motherboard itself. Unfortunately the problem persisted, so yet again I had to go down a different road.

Change the hard drive

A problematic main storage unit can display problems in unique ways, so one of the things to try is to use a new drive. Originally I was using a 64GB OCZ Vertex 4 SSD, so I substituted in a spare 2.5″ HDD I had in another enclosure. After reinstalling Windows, along with the different hardware drivers, I continued to get the errors, so obviously that couldn’t be it.

Change out the motherboard

The original motherboard I used was an open box, so after going through each of the steps above, I decided that the only logical problem was the one part that had stayed the same throughout: the motherboard. Be warned this is not for the faint of heart, as it involves removing and collecting nearly every piece loaded into the case already. Nevertheless, I put everything into the box and replaced it with a brand new one. Reinstalling it into the case and booting up the same installation of Windows (it doesn’t care if the hardware model doesn’t change), I was rather frustrated to see that same graphics warning after a few minutes of use.

Use different drivers

At that point I decided to change things up completely and reinstall Windows, along with all of the drivers. This time, however, I went directly to the different manufacturer’s websites and downloaded the files directly. Incredibly, after multiple reboots from the installations, I didn’t get a freeze or blue screen. Somehow changing up the driver versions had aligned everything properly and the parts were playing nice together. Since the main errors were about the graphics driver failing, it’s not particularly surprising that changing up the software might fix the issues.

IMG_0824After getting gigabytes of software updates, the system continues to operate properly and I’m pretty happy with it. At this point most of the challenges I’ve experienced with computer setup deal with driver software; this computer POSTed every time. Hopefully by documenting my challenges here, it will help me in the future, and also anyone else who might have a similar problem.

Posted in Windows

Building a bench top power supply with a computer PSU

Electronic tinkering and building have become a bigger hobby for me as I finished my university degree. The Arduino development platform is quite a remarkable system, and the online community of users is growing every day. The problem with many of the projects that I do is that many systems require more power than the 50mA or so the Arduino can provide. You could use different AC-DC wall adapters, but that becomes unwieldy.

The DIY solution, as many Arduino users have discovered, is to repurpose a used computer power supply unit for cheap, regulated 3.3V, 5V and 12V DC power. I decided to build my own based on some other examples, while adding things that I need for my projects. I documented the procedure in an Instructable but thought I would expand on the design and build process here a little more.

Design Requirements

I did lots of planning before cutting any sheet metal because I wanted to follow the engineering procedure. The major requirement for this is to decide what features the final system needs to be successful. I chose the following:

  1. Ability to remove the 24 pin ATX cable to power other projects
  2. Access to all available PSU voltages (3.3V, 5V, 12V)
  3. Different connectors to make powering different components easy
  4. Fuses to prevent powered systems from breaking
  5. Keep some external cables for future expansion
  6. Connectors on the top of the PSU

Bill of Materials

With the requirements in hand, I started browsing for and collecting components. One of the things I noticed right away is that any power supply with a top mounted fan would not useable. This means that my system is limited to about 300W or less, which for desktop projects is completely fine. Older, cheaper and lower power units were the first place I looked, but I quickly discovered another requirement: a 24 pin ATX connector instead of the older 20 pin standard. This limitation meant that I had to build a new one from Newegg instead of on the used market. The cost worked out to be the same.

After waiting a few weeks for delivery, the following parts were on my table:

The ATX breakout board handles the operation of the PSU by properly shorting the on/off wire and providing indicator LEDs. It also breaks out each of the voltages on the cable to a useful screw terminal pad. If you choose to use a different method, turning the power supply on is as easy as shorting the green wire with a common ground. The other parts I found on eBay or various electronics retailers on the internet (try Adafruit, RobotShop, Sparkfun or OddWires).

Design Process

My first step was to measure and replicate each part as accurately as possible using a 3D CAD package. If you’re looking to do something similar, take a look at Solidworks, Autodesk Inventor, SketchUp or Pro/Engineer and decide which to learn. They all perform the same functions, although SketchUp is less about dimensions and more about sculpting 3D objects.

With the components in my system, I was able to lay out all of the holes on the PSU shell to confirm space. I was able to fit 5 2.1mm DC barrel jack connectors, the power distribution block and ATX board on the top surface, with the fuses moved to the side. The software made it very easy to print templates for the hole locations on each surface.

One of the things I needed to look out for was preventing interference between the barrel jacks on top and the internal heat sinks. That meant modelling additional components inside the shell, but doing that extra step prevented numerous hangups further down the process.

As a quick note, please keep in mind that this is a record of my procedure and by no means a complete step-by-step instruction manual for hacking power supplies. These units produce an evil amount of electricity and can be dangerous when misused. Remember that before breaking open the tool box and realize that it’s entirely your choice to void the warranty.

Drilling and installing the components

Cutting into the sheet metal container can’t be done by hand, of course, so here’s a list of tools I used:

  • Power drill
  • Assorted drill bits
  • Step drill (with 3/16″, 3/8″ and 1/2″ sizes)
  • Round file
  • Dremel deburring tool
  • Assorted screw drivers
  • Wire stripper
  • Diagonal cutters
  • Multimeter

If or when I build another unit, I’ll add a center punch to that list in order to accurately dent the material to start drilling. Without it, I needed a finishing nail and hammer, which reduced accuracy somewhat.

Start by ignoring the warranty labels and cracking open the PSU shell.

Inside you’ll find a semi-organized collection of wires, circuit boards, capacitors, MOSFETs and heat sinks.

Now is a good time to tape the hole template paper to the shell, if you’ve prepared one. For the most part the holes aren’t for accuracy relative to the shell, but more for proper spacing between the individual holes.

Drill the 1/2″ holes for the fuses with the step drill. The thin sheet metal will produce burrs on the underside that you’ll need to clean up for the fuse holder to sit flat.

Do the same for the 3/8″ holes for the DC barrel jacks. Both of those components can then be loaded into their respective locations because they’ll need to be installed in order to solder the wires.

Wiring and soldering the connections

Routing the cables from the bottom PCB to the fuses and on to the barrel jacks was somewhat of a challenge because of the arrangement of the heat sinks and bottom components. I cut the external connectors and passed the wires inside to test for length. The overall path for the positive cable of each voltage would be PCB – Fuse – barrel jack and the associated ground wire went directly to the barrel jack. Be careful not to pull too hard on the PCB because tracing the wire back to the soldering pad can be a real pain.

Generally the fuse to barrel jack wire was soldered first, because it was the easiest to trim and arrange. The fuse holder only has two pads, but the barrel jack has three, which means before soldering anything you’ll have to learn the pinout configuration. The most common barrel pinout is center positive, so that’s what I used. Finding which pad was which meant connecting a wire to the jack and checking continuity with a multimeter. Not difficult by any means, but it can be time consuming.

After reinstalling the shell, I soldered on the screw terminals to the ATX board and connected the 24 ATX cable. The brass standoffs are used on the ATX board to raise it from the metal shell, so those were installed next.

Testing the entire unit was a simple matter of connecting the multimeter to the screw terminals and barrel jacks.

After testing, how you use the power supply is completely up to you. The easiest way to incorporate the power is to feed lines from the screw terminals to a branch on a solderless breadboard. Saving the cut off internal wires is a great way to wire them together.

This was a great project for me to test design principles and following through with a project from start to finish. It now opens the doors to building systems with motors, thermoelectric coolers or any number of other sensors.

Posted in Hardware Tagged with: , , ,

Compiling C Programs on OS X 10.7+

One of the first posts I wrote for this blog, back in 2007, was about how to write and compile C programs using Mac OS X. That post was a result of me doing C programming in my first year of university, and since then plenty of things have changed. Not only have I finished university, but the basic procedure for installing Xcode has changed as well.

I thought I’d write a new tutorial updated for the more recent versions of OS X.

  1. Install Xcode from the Mac App Store
  2. Install the extra Command Line Tools from within Xcode by navigating to Xcode > Preferences > Downloads
  3. Create a new Xcode project by navigation to File > New > Project
  4. From the template list, under OS X, select Command Line Tool and choose Next
  5. Fill out the required forms, and under Type choose C
  6. Save the project to your computer
  7. Open main.c and write!

It’s possible that by default the toolbar won’t be shown to click Compile + Run, so you can press Cmd+R to do that directly.

The method in the original post continue to work, as long as Xcode installed as described above. Comments on that post provide additional information, like this one from mvdhoef:

instead of resorting to the default a.out you can use gcc the way it was meant to be used!!!
…………………….
gcc -o -Wall name file.c
…………………….
where name is the name of the program gcc will create,
file.c is the file and perhaps extension of the code you have created.

-o is to open new/rewrite in this case name (*if name already existed, it would overwrite without a second thought)
-Wall is another option which tells gcc to show all errors it encounters during compiling. (*this is optional)

Don’t forget to slack off while your code is compiling.

Posted in Macs Tagged with: , ,

Fix missing media info and thumbnails in WordPress 3.4.x

Does your WordPress media library look like this photo? Maybe you don’t have the same affinity for the BMW 1M that I do, but if you’re missing thumbnails, I might be able to help.

After upgrading an important installation to WordPress 3.4, I suddenly noticed that many thumbnails had disappeared, specifically the earlier uploads. After posting to WP support forum and WP StackExchange group and receiving minimal response, I decided to take a look at the database myself.

I ended up finding the problem in the wp_postmeta table. It turns out that prior versions of WordPress didn’t insert the _wp_attached_file meta key when uploading a photo, and the latest version requires it. Since this key doesn’t exist for some uploads, the system defaults to showing the media icon, and refuses to display resized images in other posts.

The solution is to run through the list of attachments and insert this meta key where it doesn’t exist. I wrote code to do so, and it worked for me, but when another user requested it in a more useable format, I wrapped it in a basic WordPress plugin.

Download it here

I can’t provide much in the way of support for it, but if it fixes your problem, leave a comment.

Posted in Wordpress Tagged with: , , ,

Tracking Login Attempts


I’m an inquisitive person. Maybe it’s because I’m an engineer, but I like learning about new things, whether they’re related to cars, computers or technology in general. So recently when looking through the logs of my Ubuntu server, I discovered many, many failed login attempts for users that didn’t exist. Since my system is accessible via the internet through SSH port 22, I get lots of attempts from bots, or less likely, real people.

In the past I’ve looked up the recorded IP address on the internet and found the offending location (or at least an approximation) but now, with my recent affinity for Python, I decided to automate the process and start a log. Using the free API service from IPInfoDB.com, I wrote a Python script that runs hourly and parses the log file, looks up the location online, then stores everything in a MySQL database. Then I wrote a small PHP page to output the data to a browser in the form of the pretty maps and charts you see on this page. Now I can check the site occasionally and see where the activity is.

What does it all mean?

By looking at the map at the top, you’ll notice that most of the logins are centralized in the United States and eastern Asia. I can’t really say I’m that surprised.

The sample is made up of 352 attempts since February 2nd. You’ll see in the chart that the top 5 countries are:

  • China – 126
  • United States – 77
  • Republic of Korea – 32
  • Turkey – 18
  • India – 13

It’s an interesting list, and I’m curious to see how the numbers will change over time.

Additionally, here is a chart of the top usernames that the attempts had. Not really a surprise here, either. Obviously “attackers”, for lack of a better word, want to gain full access to a machine by using the root username, and most of the other names are for services that typical servers have running (eg. Oracle, mysql, postgres, etc.). What I found most interesting are the one-off attempts: brian, richard, fluffy, stud, gnats and taylour to name a few (really!). Top 5 once again are:

  • root – 255
  • bin – 21
  • nagios – 14
  • oracle – 9
  • test – 4

So what can you do?

If you must have an open SSH connection to the internet, there are a few things you can do to protect your system. There are lots of websites that describe the steps in more details (like this one, or this one or even this one. All of those sites share a few simple tips:

  1. Disable root access
  2. Use keys to access the system instead of passwords
  3. Drop the connection after x login attempts
  4. Use a non-standard port for SSH
  5. Enforce secure passwords

I follow a few of those, mostly because my system isn’t important enough to warrant super hardened measures. Even by disabling root access, you remove 99% of the threats, and requiring a key to log in removes the remaining 1%. I”m not particularly worried about users actually accessing my computer, and by following some of the measures above, that possibility is basically elimininated.

Update — September 23, 2012
A commenter requested the source code for the above system, so I’ve attached it as a zip file. It contains the Python script and web front end. I’ve written instructions as best I can, but please remember it’s a bit of a hack and therefore I can’t provide much support. Follow the readme and it should make sense.

Posted in Thoughts Tagged with: , , ,