The code is based on that of MER (Spirit and Opportunity), which were based off of their first lander, MPF (Sojourner). It's 3.5 million lines of C (much of it autogenerated), running on a RA50 processor manufactured by BAE and the VxWorks Operating system. Over a million lines were hand coded.
The code is implemented as 150 separate modules, each performing a different function. Highly coupled modules are organized into Components that abstract the modules they contain, and "specify either a specific function, activity, or behavior." These components are futher organized into layers, and there are "no more than 10 top-level components."
Source: Keynote talk by Benjamin Cichy at 2010 Workshop on Spacecraft Flight Software (FSW-10), slides, audio, and video (starts with mission overview, architecture discussion at slide 80).
Someone on Hacker News asked "Not sure what means that most of the C code is auto generated. From what?"
I'm not 100% sure, although there probably is a separate presentation in that year or a different year that describes their auto-generation process. I know that it was a popular topic in general at the FSW-11 conference.
Simulink is a possibility. It's a MATLAB component popular among mechanical engineers, and therefore most navigation & control engineers, and allows them to 'code' and simulate things without thinking they're coding.
Model-based programming is definitely a thing that the industry is slowly becoming aware of, but I don't know how well it's catching on at JPL or if they would have chosen to use it when the project started.
The third and most likely possibility is for the communication code. With all space systems, you need to send commands to the flight software from the ground software, and receive telemetry from the flight software and process it with the ground software. Each command/telemetry packet is a heterogeneous data structure, and is is necessary that both sides are working from the exact same packet definition, and format the packet so it is correctly formatted on the one side, and parsed on the other side. This involves getting a whole lot of things right, including data type, size, and endianness (although the latter is usually a global thing, you could have multiple processors onboard with different endianness).
But that's just the surface. You need lots of repetitive code on both sides to handle things like logging, command/telemetry validation, limit checking, and error handling. And then you can do more sophisticated things. Say you have a command to set a hardware register value, and that value is sent back in telemetry in a particular packet. You could generate ground software that monitors that telemetry point to ensure that when this register value is set, eventually the telemetry changes to reflect the change. And of course, some telemetry points are more important than others (e.g. main bus current), and are designated to come down in multiple packets, which involves extra copying on the flight side and data de-duplication on the ground side.
With all that, it's much easier (in my opinion) to write one collection of static text files (in XML, csv, or some DSL/what-have-you), run them through a perl/python script, and presto! Code!
I do not work at JPL, so I cannot provide any detail that is not in the video, with one exception. I've heard that the autogenerated C code is written by Python scripts, and the amount of autocoding in a project varies greatly depending on who the FSW lead is.
88Why would one assume there is only one language involved in the project. – Rig – 2012-08-06T04:11:13.010
5Good point, sure, it's probably got a breadth of technology associated with it. I want to know more about all of that :) – InfinitiesLoop – 2012-08-06T04:12:30.713
3Which part? The spacecraft? The rover? Instruments? The ground system? As other comments indicate, there are probably several languages used in the different components. It's not out of the question that assembler was used for some of the time critical components. – GreenMatt – 2012-08-06T04:27:44.410
1Since it's a government project I am guessing Forth, MUMPS 2011, and RPG V, with management interfaces built in Object COBOL, and motor control in Postscript. – joshp – 2012-08-06T05:44:05.817
I think Roverbasic, a new language purportedly designed by the JPL, but it will turn out to be actualy written by Microsoft. – Mr Lister – 2012-08-06T05:46:57.493
61To be honest, when I saw the 500kloc figure I caught myself thinking "Only?" It could have been realistic had it been Haskell, but having read a bit about previous projects and their low level languages, this seemed way too low. The 2.5mio loc C code cited below are more believable. – Philip Kamenarsky – 2012-08-06T06:02:38.950
@PhilipK - I think the 500kloc figure might only cover the EDL software. – JohannesD – 2012-08-06T14:43:25.147
Some of the sub-questions you asked were not answered in the other question before. That has been fixed :) – Nate Parsons – 2012-08-06T15:01:47.930
1@Philip K It might be the 500kloc is for the descent software only. The keynotes in the answer of drhorrible divides the MSL into 3 different stages, running different software, 1. the flight (earth to mars) 2. The descent and landing 3. The rover itself, roving around. – nos – 2012-08-06T16:38:47.133
1@PhilipK I'm thinking 500k LOC is with the comments and extra blank lines stripped out - so, 500k functional LOC, but 2.5m lines total in the codebase. ;) – Izkata – 2012-08-06T16:54:24.523
16A more interesting question that "in what language?" is "with what process?". It's the process that make the difference, and NASA has been using a rigorous one for decades now. – dmckee – 2012-08-06T17:07:39.797
It was all written in LISP. Nasa is trusting LISP's backtracking to infer all the correct decisions to make. – JustinDanielson – 2012-08-06T21:16:38.893
2@dmckee: I agree. Why don't you ask that question? – Jim G. – 2012-08-06T22:29:17.543
This overview was really interesting, talking about the tech behind its software and instruments: http://www.extremetech.com/extreme/134041-inside-nasas-curiosity-its-an-apple-airport-extreme-with-wheels
– Matt – 2012-08-08T13:50:02.067I asked a question on ITSec.se regarding the security on the rover: <http://security.stackexchange.com/questions/18225/mars-curiosity-rover-security>
– pasawaya – 2012-10-09T07:27:15.993For an insight into NASA software engineering culture and practices, there's a great article from 1996: http://www.fastcompany.com/28121/they-write-right-stuff
– akatkinson – 2013-10-05T21:35:30.950For sure, there is absolutely no .net code. :D – Samuel – 2015-03-18T10:21:26.207