Sunday, April 15, 2012

RROD XBOX-360 Fix Using 5.25 Fan.doc

I added a 5 ¼” fan to the top of my XBOX 360 because it kept getting the RROD.  And I couldn’t find any other way to seemingly permanently fix it.  At the time I did this, I was working under contract for a company in the Philippines, and I couldn’t get a replacement US console to play my US region coded games that I had brought with me.  It’s a lot of work just to fix a console that can be replaced for $150.  But it did produce what appeared to be either a long-term or perhaps permanent fix.  The fix goes beyond just adding a fan.  I shimmed the GPU with a 0.5mm aluminum shim, X-Clamp fixed both the GPU and CPU, reflowed the solder by CAREFULLY overheating the box as detailed below, put the DVD drive outside the case by extending its cables, and then finally, I cut in a 5 ¼” fan over the top of the GPU.


I am on my seventh and eighth X-BOX 360 (I have two working consoles that have never failed, but they are both relatively new models). 

In order to fix this, you have to stop the PCB from flexing, and you need to dissipate the heat somehow.  The GPU and CPU both run very hot—too hot for the thermal characteristics of the case.  The problem is exacerbated by the RHOS compliant non-leaded solder used on the package.  The primary reason that lead is used in solder is to make it more flexible and resistant to cracking. 

The “X-Clamp” fix basically pins the motherboard to the case.  The metal on the bottom of the case is very thick.  This by itself goes a long way towards stopping the constant PCB flexing due to thermal expansion that is largely responsible for eventually breaking the solder connections on the GPU and to a lesser extent CPU packaging.   There are very good articles on how to do the X-Clamp fix here: http://xbox-experts.com/tutorial/team-hybrids-ultimate-xclamp-fix-released/   WARNING::Before you just launch in and repair it this way, you should know I followed this to a T, and it didn’t last.  It’s not sufficient in and of itself to permanently fix an XBOX.  And further, there’s a problem because the GPU and the CPU packages are not the same height off the motherboard.  This article discusses using a shim on the GPU which I strongly recommend:

The X-Clamp fix calls for putting a 2mm stack of washers on top of the motherboard.  The heat sinks sit on the washers.  However, the GPU is only about 1.5mm high.  So this leaves a 0.5mm space between the top of the GPU and the heat sink which relies on the solder paste as a filler.  This is very bad.  And we want to get mechanical pressure on the GPU to keep the solder balls from separating in the event they crack.  So the shim is essential to the fix.

I couldn’t find the aluminum shim anywhere in the Philippines.  I ended up sanding the paint off a soda can and cutting a couple pieces to get the requisite shim height.  I then put down a thin layer of solder paste between the aluminum sheets.  Obviously, I don’t recommend this, but it did seem to work.
Lastly, once you finish the fix, you should follow the directions at Llamma for safely overheating the GPU by pulling the fan shroud and putting the fan directly on the CPU as detailed in these step-by-step instructions:

They make a good argument for using this method, and I agree with it.  And I can attest it does work.  I did it three times before I finished fully modding this box as it kept breaking again every few days until I finally went all out with the shim and the new fan.

In order to add a 12v fan, you need to find a 12v source on the motherboard.  I used the source from here: http://www.llamma.com/xbox360/mods/images/Fan_Mod/360-124.jpg.  That solder joint in the photo looks terrible.  You only need a small amount of solder.  And flux is your friend.

A huge set of Kudos are due to all of these sites for their help fixing this problem.  There are a ton of bogus X-Box repair links out there.  But these are are the gold amongst the slag, and they helped me hugely.

However, even after I finished all these fixes, I still didn’t feel very good about my 360.  I figured that the board is bound to flex due to thermal expansion, and obviously, the GPU balls were already cracked.  I had already RROD’ed three times and supposedly “fixed it” by this time.  So I decided I needed a better way to keep the GPU cool.

After looking the box over for a while, I came to the conclusion that the only way to cool the GPU is to remove the DVD drive.  The DVD drive is sitting right on top of the GPU and almost completely blocking the airflow to it.  Now mind you, this isn’t going to be the world’s most beautiful 360 once it’s finished.  The DVD sitting off to the side isn’t very nice to look at.  But in a pinch, you have to do what you have to do.

So I salvaged a 5 ¼” fan from a dead PC power supply.  I also cut off the wire harness to give me wire to work with in order to extend the DVD power cable which I had zero chance of finding another of in the Philippines.  The power cable does not carry any frequency dependent information, so it’s perfectly acceptable to lengthen it.  The SATA cable on the other hand is quite short and likely won’t respond well to being messed with.  Luckily, it’s a standard SATA cable.  So you can just replace it with a SATA cable made for a PC which is plenty long.

You also need to drill a hole in the back of the XBOX (in addition to the giant hole you need to make for the fan).  I strongly recommend wrapping the power cable and SATA cable with electrical tape where they pass through the 360 case to prevent abrasion of the wires over time or you can put a grommet in the hole.  I went the tape route.

There is a natural step in the heat shield for the top of the case.  I set my 5 ¼” fan right in this natural flat spot.  But when I put it back into the case, it hit on the heatsink shroud, and I had to cut the shroud and then repair it as best I could with index cards and tape.  So, if you are going to do this, make sure you position your fan far enough forward in the case to miss the X-box fan shroud or realize you are going to have to modify the fan shroud.

You need 12 volts for the 51/4” fan.  I you don’t like the connection point above, there are other places you can get it.  Use a voltmeter and fish around for it.  Or find some other sites with alternate connection points.  BE CAREFUL WHICH WAY YOU CONNECT THE LEADS.  You want the fan to blow down into the case.  If you reverse the leads, it’s going to blow outward.  You want the air to flow down from the top case, over the GPU, and out through the back via the two existing exhaust fans.

I set the DVD drive on the carrier.  Opening the DVD drive becomes a bit of a problem.  The button to open the DVD drive is actually on the main case.  And it relies on a plastic piece that is affixed to the DVD drive.  So you have to replace the button somehow if you still want it.  However, the software method of opening the drive works fine.

I used this 360 for about five months after I made this fix.  I played all the way through Mass Effect as well as a couple other games.  The 360 is still in the Philippines.  I haven’t been back there to test that it is still working, but I expect it is.  But being an engineer, I am not going to say it’s permanently fixed without a much larger sample size.  But it definitely created a much longer term fix than any other solution I tried.

When Microsoft brought out the 360 “slim”, they merged the GPU and CPU onto one chip.  The units made just prior to this had half the power consumption (and half the heat generation) of the original units.  I searched around and bought one of these last two chip units when I realized what MS had done.  Now that they have merged the GPU and CPU, the concentrated heat signature around that single package is the same as the original GPU heat signature.  So it remains to be seen whether the slim units are reliable or not.  Also, they scream like a banshee when the DVD drive is on high speed.  You are almost forced to put the games on the hard drive.

Let me also say that putting your games on your hard drive is a very good idea anyway.  My console number five bit the dust because the DVD stopped working.  I tried to change the resistor setting to increase the laser strength, but it didn’t help in the slightest.  That console still “works”, but it can’t read the DVD’s.  Even before the DVD died, the output was getting flaky. I think the graphics scalar chip is going out.  It only worked reliably via HDMI even before the DVD drive died.

When that unit died, I was forced to buy a MS slim (I have two consoles in the US and one in the Philippines) to replace it.  The first “slim” unit I bought died after about three weeks.  It started freezing up and resetting.  I took it back where I bought it and exchanged it.  The replacement unit is fine…so far. 

At the end of the day, it’s hard to argue that MS knows anything about hardware design.   It’s a software company.  I’ll probably go with Sony here on out.  The only reason I haven’t is I have an immense library of games with double copies of a lot of the network games. 

Saturday, April 7, 2012

Accessing MySQL Using Bash Scripting


Accessing MySQL Using Bash Scripting

We have a spreadsheet in which the first column contains a customer’s email addres.  We want to perform some processing on each customer, but the script that does the processing only recognizes the customerId.  What’s the quickest way to get the information we need?  You are probably thinking we run a query in MySQL and dump the data.  And that would also work.  But we need some kind of bash shell to run the processing against customer’s ID anyway.  So why not just extract the MySQL information we need at the same time.  The following script does just that.

It assumes a five column table, but can be easily modified for more or less:

CSV Data format:
------------------------------------------------------------------------------
Email, First Name, Last Name, Address, Birthdate
------------------------------------------------------------------------------
whoever@wherever.com, Ming, Nguyen, wherever, 4/6/1958
someoneelse@someother.com, John, Doe, somewhere, 4/6/1981
------------------------------------------------------------------------------

#!/bin/bash

# Processes customer Id’s via a CLI PHP Script
# 120406

PHP_DIR=/usr/bin
CLI_DIR=/home/user/site/public
AQCOMMAND=cli.queue-add.message
TQCOMMAND=cli.queue-run.listener
QUEUE_NAME=blog-test-queue
MTYPE=sendCustomerEmail
MESSAGE=customerId
USER=Your_MySQL_User
PASSWORD=Your_MySQL_Password

# Store file name

file="$1"
# make sure file exist and readable
if [ ! -f $file ]; then
   echo "$file : does not exist"
   exit 1
elif [ ! -r $file ]; then
   echo "$file: not readable"
   exit 2
fi

# read one line of file into $line variable
while read -r line
do
   # set the field separator to a “,” character
   # and read in five fields assigning each field
   # to $f1, $f2, $f3, etc for five fields  
   IFS=, read -r f1 f2 f3 f4 f5 <<<"$line"
   
     # execute a mysql select using $f1 (customer email)
     # to get the customer ID and assign it to $result
     # The “-N –r –B” prevents MYSQL from outputting header
     # information that we would have to strip out anyway
    result=$(
        mysql -N -r -B -u $USER –p$PASSWORD db_name << eof
           select customer_id from customer WHERE 
           email = '$f1'
        eof
    )
    # let’s echo it just so we can see our progress
    echo $result
       someCommand argument=$result;
    sleep 3

done <"$file"
exit 0

This method can be used to perform any kind of query against the database.  I have some examples of doing something similar from within a DOS batch file here.


Activating Zend Debugger via Mule


Mule can provide translation services between applications while acting as a common Enterprise Service Bus.   It’s very useful, but it’s also aptly named.  It’s stubborn, and it has the worst documentation, bar none, of any tool I have ever used.  

But all griping aside, the fact is, it’s sitting between two applications I need to communicate with each other.  And I want to debug the receiving application.  So how can I cause the receiving application to trigger Zend Debugger when it receives the data from Mule?  

The original mule configuration looks like this:

<http:outbound-endpoint
   host="receiving-application"
   port="80"
   path="index.php/catalog/updatePrice"
   contentType="text/xml"
   mimeType="text/plain"
   exchange-pattern="one-way"
/> 


We simply add the cookies into the header using a <properties> statement.  Note that a lot of the time, you will see endpoints defined as <http:outbound-endpoint host port etc/> with no closing tag because the "/" at the end of the tag closed it already.  In that case, just remove the trailing "/" and put a </http:outbound-endpoint> tag at the end as I have done here.

<http:outbound-endpoint
   host="receiving-application"
   port="80"
   path="index.php/catalog/updatePrice"
   contentType="text/xml"
   mimeType="text/plain"
   exchange-pattern="one-way"
> 
   <properties>
      <spring:entry key="cookies">
         <spring:map>
            <spring:entry key="start_debug" value="1" />
            <spring:entry key="debug_fastfile" value="1" />
            <spring:entry key="debug_host" value="127.0.0.1" />
            <spring:entry key="use_remote" value="1" />
            <spring:entry key="debug_port" value="10137" />
            <spring:entry key="original_url" value="http://receiving_application" />
            <spring:entry key="debug_stop" value="1" />
            <spring:entry key="debug_session_id" value="1005" />             
         </spring:map>
      </spring:entry>
   </properties
</http:outbound-endpoint>


Don’t forget to include the spring definitions at the top of the file:
xmlns:spring="http://www.springframework.org/schema/beans"

and:
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  
If you need help setting up remote debugging in general, see my blog here: http://www.klugedeforce.com/2012/02/remote-debugging-cli-over-ssh-tunnel-in.html

I particularly like this method because it doesn’t require modification of the outgoing data in the sending application.  I have had problems with Mule stripping out the cookie information.  I am sure there is a way to convince Mule not to strip the cookies, but I haven't invested any serious effort in figuring it out because this method is generally easier.  And even if you were say polling an FTP server for a file and then posting the results as PHP, you can still intercept the incoming transaction this way.  So it's more universally applicable as well.