Software Infrastructure

Purpose

To familiarize you with the software infrastructure used in this course:

Due dates

You must have completed your decrypting tasks, and transmitted the required mail messages, before 8:00 am on Tuesday, September 4. This part of the assignment is worth 5 points.

You must be prepared to discuss your work at the beginning of your laboratory period on Tuesday, September 4, and to demonstrate your program to your TA during that session. This part of the assignment is worth 5 points.

Background

When a computer is used as a component of a larger system, the focus is on the overall system rather than on the component computer. This is in sharp contrast to the situation with a normal desktop or laptop computer system, which is geared to support its processor. For example, the desktop or laptop has a keyboard to enter information, a screen to examine output, and a disc to hold associated software. None of these devices would be associated with (say) the computer controlling a traffic light.

The computer component of a traffic light system comprises a processor and a memory. Part of the memory (ROM) consists of devices whose content is ``burned in'' by the manufacturer, and cannot be altered by the processor. It holds the program and any constant data. The other part (RAM) is used to hold values computed during the system's operation.

Ultimately, the designer of a computer-controlled traffic light control program must deliver an appropriate collection of 0's and 1's to the ROM burner. The obvious strategy is to use normal tools (editor, compiler, assembler) running on a desktop or laptop computer to create a file that will specify the contents of the ROM, and then send that file to the ROM burner. This strategy is sound, but incomplete because it ignores the unpleasant fact that we can never seem to do something right the first time!

Think about the normal development cycle that you've followed in your programming classes: You use an editor to write code, you compile it, and then you execute it on some test data. Usually, the test fails in some way and you go back through the cycle again. Although you may not have thought about it, the fact that you could get through one iteration of this cycle quickly was critical to your ability to get your assignment done. Even if the traffic-light designer had the traffic light hardware available (hardware and software design usually proceed in parallel, so that's not a good assumption), the need to burn a ROM for each iteration would make this approach unacceptably slow.

An even more serious problem is that if there's a mistake in the program, the most probable effect is that the traffic light will do nothing. Thus the programmer will not be able to get any information at all about the error. How do you find out why a program doesn't work? Add statements to print intermediate data? Use a debugger? The traffic light has no printer, no keyboard, and no extra software...

One solution is for the designer to use a two-level development system consisting of a simulator and a processor board with a simple monitor. That is the environment you will be working in this semester. Each station consists of a normal desktop system running Windows 2000 and a single-board computer with a simple monitor program in its ROM. The desktop system (``Dell'') is connected to the internet, and its Z: drive is your account on the ECE server. The single-board computer (``MB5'') communicates with the Dell via the Dell's COM1 port.

A commercial MC68000 development system runs on the Dell. It is used to compile MC68000 programs, and can simulate their execution. The simulator provides interactive debugging facilities. Compiled programs can be downloaded to the MB5, and then executed there. During execution, those programs can read from and write to the Dell's COM1 port.

This assignment will walk you through a ``final'' development cycle, starting with a directory on your Z: drive that contains a correct program. You will translate the program using the Dell's MC68000 compiler, download it to the MB5, and run it with some data. (This is a ``final'' development cycle because the program is correct; it illustrates the last step in the development process.)

Task

Short cryptograms, in which an encoded sentence or quotation is to be decoded, are common pastimes of many recreational puzzle enthusiasts. A paper presenting the ``probable word'' approach to such problems appeared in the Communications of the ACM (To Decode Short Cryptograms, CACM 37, 9 (September, 1994), 102-108). This algorithm has been implemented as a C program.

Your task is to obtain a copy of the directory containing this program, compile it on the Dell, download the compiled program to the MB5, and use it to decrypt a given cryptogram. You will to obtain a test cryptogram via electronic mail, solve that cryptogram on the MB5, and return your solution via electronic mail.

Note any problems you have as they occur, and be prepared to discuss them at your next laboratory session. Also be prepared to demonstrate and explain your use of the development system to your TA during the lab session.

The individual steps are expanded below.

Obtain a cryptogram via electronic mail

For this assignment, each student, individually, must send an e-mail message to ecen2120@schof.colorado.edu. The subject line of that message must consist of your official university e-mail address (for example, Prof. Waite would use William.Waite@Colorado.edu), a space, and the word hw1 (the letters ``hw'' followed by the digit ``1''); the body of the message will be ignored, and may be empty. You will be sent a cryptogram as a reply to that message. Thus the cryptogram will be sent to the account from which your request was made, not to the address in the subject line, and it is your responsibility to ensure that the cryptogram can be delivered to you via the account you used to make the request. It's a good idea to request your cryptogram before going to the lab, so that it will be available when you need it.

Log onto a Dell

When you press Ctrl+Alt+Delete on one of the Dell, a Windows Log On window will appear. Fill in your user name and password, and select METAVERSE in the Log on to pane before clicking OK.

Set up your environment

All of your compilations on the Dell will use a command-line interface. There are two possibilities: Cygwin (which provides a Unix interface) and the Windows command line interface. Icons for both of these programs are on the Dell desktop, and it is your choice which you use. In either case, when you open the window the shell will be in your home directory on the ECE server (the Z: drive of the Dell). For the remainder of the course, we will refer to this directory simply as ``your home directory''. We strongly recommend that you do all of your work in this directory and directories descended from it, rather than moving to another drive.

If you use the Cygwin interface, you will get an error message when the window first opens:


CMD.EXE was started with '\\blacksun\arp\Windows Folders\Desktop' as the current
directory path.  UNC paths
are not supported.  Defaulting to Windows directory.
Your group is currently "mkpasswd".  This indicates that
the /etc/passwd (and possibly /etc/group) files should be rebuilt.
See the man pages for mkpasswd and mkgroup then, for example, run
mkpasswd -l [-d] > /etc/passwd
mkgroup  -l [-d] > /etc/group
Note that the -d switch is necessary for domain users.

You are a ``domain user'', because you are working in your home directory on the ECE server rather than being logged on to the particular Dell you're sitting at. Simply ignore this message.

If you use the Cygwin interface, you will need to add the MC68000 development system binary directory to your path. Edit file .bashrc in your home directory adding the following line to the end of the file:

PATH=$PATH:/cygdrive/c/MGC/embedded/bin

We recommend the vi editor for use in this course. It is a capable editor that is available on a variety of platforms. You can run it as a Cygwin command, or you can double-click the gVim 6.3 icon on your desktop. There is also a vimtutor icon on the desktop; double-clicking it will put you into an excellent tutorial.

Obtain the decryption program

Start Internet Explorer on one of the Dells in the laboratory, and point it to this assignment. Click here to get a zip file containing the source code for the decryption program and an appropriate Makefile. The browser will pop up a ``File Download'' window asking you what to do with the file; click Open: to invoke WinZip. Click the middle button in the bottom row (I Agree) of the license window, and when the WinZip control window appears click the Extract icon. An ``Extract'' window will pop up.

Select a directory on your Z: drive, either by using the browse area of the ``Extract'' window or by typing the full path name into the Extract to: area in the upper left. Click the Extract button in the upper right after you have selected the directory. WinZip will create a hw1 subdirectory of the selected directory, and this subdirectory will contain all of the source files and the Makefile needed to create the decryption program. After this operation is complete, you can dismiss the WinZip window.

Compile the program

Obtain a command-line window by double-clicking on either the Cygwin icon or the Command Prompt icon. In your command-line window, cd to the hw1 subdirectory that you extracted, and execute the command make. This will cause the computer to carry out a sequence of compilations, translating the source files into machine code, followed by a linking step that combines them.

The linking step may produce a warning message:

(W) #A0347-D Command Ignored: Output is S
Ignore this warning.

The linker has produced a file called driver.abs, which contains the MC68000 program in a form (``Motorola S-Records'') that can be downloaded to the MB5.

Download the program to the MB5

Double-click on the Tera Term icon on the desktop, or use the Windows Start menu to start Tera Term Pro. Select the Serial connection via COM1, and click OK.

Turn on the MB5 board, using the switch on the left side (all descriptions of the MB5 assume that the keypad is ``right side up'' as you look at it). All of the LEDs should be lit. If the board is already on, press the red reset button on the left side below the red LED.

In the Tera Term window, you will see text describing the five single-letter commands, A through F, implemented by MooseLoad (the MB5's ROM monitor). You want to download a program from the Dell, so type an upper-case A on the Dell's keyboard.

MooseLoad should now request that you send your code. From Tera Term's File menu, select Send file.... This will produce a normal Windows explorer pop-up window to allow you to select the file. Initially, this window is positioned in the TTERMPRO directory. Click the downward-pointing arrow at the right end of the Look in: pane and select the Z: drive. Navigate to the hw1 directory you created earlier, and open file driver.abs.

A Send file progress window containing a running count of the bytes transferred will now appear, and text will be written into the main Tera Term window. The downloading process for this program will take about three and a half minutes. When it is complete, the progress window will disappear and MooseLoad will write its command list to the main TeraTerm window.

Run the program

MooseLoad writes the starting address of the downloaded program just above its command list. Copy the last six characters of this starting address onto a piece of paper. You'll need it to run the program.

Type an upper-case B on the Dell's keyboard to begin execution. MooseLoad will then ask you for the address at which to start running. Since you want to run the program from the beginning, type the six characters of the program's starting address, followed by Enter. The case of the letters is irrelevant here.

MooseLoad prints Executing..... and goes to a new line. At this point, the program is awaiting input. You might expect to be able to type in the text of the cryptogram to be solved, correcting any mistakes you made by simply backspacing over them. Unfortunately, the program does not understand backspaces. Thus the best strategy is either to paste that text from the mail message containing the cryptogram, or to create a file with the cryptogram text.

You can invoke Explorer or Mozilla to get web mail. If your e-mail server can be accessed via SSH, you can log onto it from the Dell as follows:

  1. Double-click the SSH Secure Shell Client icon on the desktop.
  2. Click the Quick Connect button on the second toolbar of the SSH window.
  3. Fill in the name of the host and your user name in the pop-up form and click Connect.
  4. Type your normal password in the next pop-up and click OK.
You can then go to the e-mail containing the cryptogram, select the text, and use Ctrl+Insert or the Copy item in the Edit menu to pick it up. Drop it into the Tera Term window either by using Alt+v or the Paste item in TeraTerm's Edit menu.

If you create a file containing the cryptogram, download it in exactly the same way that you downloaded the program.

After you have either pasted or downloaded the cryptogram, type the character # on the Dell's keyboard. This tells the program that the cryptogram has been completely read, and that it should be solved.

The program outputs partial solutions to the Tera Term window. Each partial solution shows the supposed plaintext, with * indicating letters that the program has not yet decided upon. A partial solution will only be output if it gets a higher ``score'' than the previous best solution. Thus the program may pump out text for a while, and then think for a long time before another output. When it is finished, it returns control to MooseLoad and MooseLoad displays its list of commands.

When the program is trying to find a higher-scoring partial solution, it does not provide any indication that it is still alive. You must have faith that the program is correct, and will eventually terminate (some cryptograms may force the program to run for up to 10 minutes). Imagine the quandry of a developer -- is the program stuck, or is it just taking longer than expected? As the semester progresses, you will experience these doubts for yourself!

It may be that the program cannot solve the cryptogram completely by the probable word technique. In that case, some *'s will remain in the program's final output. It is also possible for the program to end up with a complete solution that is slightly wrong. Since you must solve the cryptogram completely, use whatever technique you are comfortable with to fill in the missing letters or correct the program's errors. (Scrolling back over the last few partial solutions usually makes the solution obvious.) You are not being tested on your knowledge of cryptography, and the missing letters should not present much of a problem.

Submit your solution

When you have solved the cryptogram, use electronic mail to send your solution to ecen2120@schof.colorado.edu. The subject line of that message must consist of your official university e-mail address, a space, and the word sol1 (the letters ``sol'' followed by the digit ``1''); the body of the message must be your solution. Your solution will be acknowledged by a reply to your mail. Again, this means that the acknowledgment will be sent to you at the account from which the solution was sent rather than the account given in the subject line.

Log off of the Dell

When you are finished with the assignment, log off of the Dell by selecting Shut Down... from the Windows Start menu. Select ``Log off xxxx'' (where ``xxxx'' is your username) in the What do you want the computer to do? pane of the Shut Down window, and click OK. (That selection will persist in subsequent sessions.)
Instructor Revision $Revision: 1.28 $ ($Date: 2007/08/27 00:15:43 $)