If you think it's tough to keep your computer or smartphone's software updated, try keeping a space robot updated from about 160 million miles away.

Last Tuesday the team at NASA's Mars Science Laboratory finished what amounted to a complete overhaul of the Curiosity Rover's software. Asked why this was necessary, Ben Cichy, Curiosity's chief software engineer, explains that the software required to help Curiosity land on the surface of Mars and the software it needs to drive around and avoid obstacles is completely different. But as we've reported, Curiosity's hardware is pretty modest. Cichy says it didn't have enough memory to hold the software for both the landing mission and the surface mission, so the software had to be swapped out remotely after landing.

The process took four days. "We had to be really, really careful, we didn't want to 'brick' the rover and end up not being able to communicate with it anymore," says Cichy. "We were very methodical."

Curiosity takes photos during the day when the light is best. At night it goes into a low-power state that Cichy compares to a laptop's hibernation mode. During this time the on-board radioisotope thermoelectric generator (translation: a nuclear power plant) recharges Curiosity's batteries so that it's ready for the morning. Heaters remain on during hibernation, as does a system that wakes Curiosity up in the morning and reboots its computer.

On the first day of the software update, the team deployed a temporary version of the new software to the rover's primary computer. This version was only held in RAM so that the computer would revert back to the previous version when it restarted. This gave the team a chance to make sure everything was functioning properly.

On the second day the team deployed a more permanent version of the update to the computer's file system. On the third day they deployed the temporary version to the backup computer and on the fourth day they deployed the permanent version to the backup computer.

Cichy explains that it took so long because every interaction takes about 30 minutes: 14 minutes to send a signal to the rover in space, 14 minutes to get a response. That means even though it only took a few minutes for the software to actually install, each step of the process of making it happen was painfully slow.

But it all came together in the end and Cichy says there were no problems with the update. Around 160 million miles and not one glitch. Bet you wish iTunes updates were that smooth. Then again, at least they don't take four days.

Correction: The original version of this story identified the distance of the patch as being over 350 million miles. This was incorrect. Although according to NASA the Curiosity Rover has traveled over 350 million miles since launch, the distance from Earth to Mars is currently approximately 160 million miles according to Real-time Distance Calculator from the Department of Physics at Emory University. According to Space.com, the maximum distance from Earth to Mars is approximately 401 million km, or about 250 million miles.

Image: A mosaic made from images captured by the Curiosity Rover on Aug. 7. Photo: NASA/JPL-Caltech