If you read this book straight through, by the time you’re done with it you’ll be quite tired of the Minicom program. I use it in several examples. The great thing about Minicom is that it doesn’t require the test bed machine to have any more hardware than a regular off-the-shelf PC—it just needs a serial port. And it actually does something useful!
The preceding section walked you through the installation of the Embedded Linux Workshop. In this section, I’ll give you a step-by-step procedure to build a bootable floppy disk that will directly run Minicom.
1. | Change to the directory where you want your new project to live: cd ∼yourhome/projects
|
2. | Use the elw command installed earlier to create the new project. Several directories and files are created within the new minicom directory. elw --newproject minicom |
3. | Change to the src directory: cd minicom/arch/i386/src |
4. | Create a minicom subdirectory to store the source for Minicom: mkdir minicom |
5. | Change to the new minicom directory. cd minicom |
6. | Download Minicom from http://www.pp.clinet.fi/∼walker/minicom.html. If it’s not there, try http://www.freshmeat.net to find it. If you have trouble downloading it, use http://ftpsearch.lycos.com to search for the filename, and then choose a site near you from which to download. At the time of this writing, the latest version was 1.83.1. |
7. | Untar minicom (if you want to see the files that are created, change xzf in the command to xvzf): tar xzf minicom-1.83.1.src.tar.gz |
8. | Create a symbolic link named minicom that points to the file minicom-1.83.1:
ln -s minicom-1.83.1 minicom This symbolic link will be used in the opt/minicom/Makefile. If you decide to upgrade to a later version of Minicom, you can just change the symbolic link to point to the new version. |
9. | Change to the minicom source directory: cd minicom/src We have to make a small change to the Minicom source code to make sure that it works properly in our mini-environment. We’ll do this by removing a Minicom security feature that’s unnecessary in our embedded application. |
10. | In minicom.c, search for the following line: if (real_uid == 0 && dosetup == 0) { Now delete about 61 lines—up to, but not including the following line: buf[0] == 0; If these lines are not removed, Minicom will bail out at this point. Since we don’t have to be concerned with permissions and correct users in our embedded environment, it’s safe to just skip this code. Save your changes. |
11. | Make the minicom executable file: make |
12. | Change to the kernel source directory: cd ../../../kernel |
13. | Download the current production Linux kernel from ftp://ftp.kernel.org/pub/linux/kernel. At the time of this writing, the latest version was 2.2.15. It shouldn’t really matter which version of the kernel you use for this exercise. Anything from version 2.0 through 2.4+ should work just fine. However, the binary-only DiskOnChip driver may have trouble with some kernels. It’s best to use the kernel on which the DiskOnChip driver is compiled. That may be difficult to do until you try it with one kernel and it complains. |
14. | Untar the kernel: tar xzf linux-2.2.15.tar.gz When you’re done, there will be a new directory named linux. Normally, as soon as I untar a kernel I rename it to linux-x.y.z and create a symbolic link named linux back to it, so I’ll know what this file is later on. Be very careful not to blow away your current sources if you already have a linux directory. |
15. | Change to the kernel directory: cd linux |
16. | Configure the kernel using the make menuconfig command: make menuconfig The following options are based on a 2.2.15 Intel kernel—your kernel configuration may differ. Turn on these options with an asterisk (not an M); everything else should be turned off to save space. You’ll have to go into each of the top-level menus, even those not listed here, to make sure that they’re off. Processor Type and features 386 processor family 1G Maximum Physical Memory Loadable module support Enable loadable module support General Setup Kernel support for ELF binaries Block Devices Normal PC floppy disk support RAM disk support Initial RAM disk (initrd) support Character devices Virtual Terminal Support for console on virtual terminal Standard/generic (dumb) serial support Filesystems DOS FAT fs support MSDOS fs support VFAT (Windows-95) fs support /proc filesystem support Second extended fs support Console Drivers VGA text console |
17. | Build the kernel dependencies and then the kernel itself. We don’t need to make any modules for this kernel, but if we did, we would add the word modules to the command line (make dep bzImage modules): make dep bzImage |
18. | Change back to the root directory of your project: cd ∼yourname/projects/minicom
|
19. | Create the Minicom package directories: mkdir -p opt/minicom/bin opt/minicom/etc/rc |
20. |
In the Embedded Linux Workshop, each opt package can have a Makefile. The Makefile has three targets: everytime, binaries, and dependencies.The everytime target is normally not used.The binaries target is used to rebuild any binaries whose source has changed since the last build and then move those binaries into the opt package. Once in the package, the binaries are then stripped. Finally, the dependencies target lists any dependencies for the opt package. For instance, the minicom executable depends on the ncurses library. Obviously, you don’t have to use the cat command to build the Makefile: it’s just the most convenient method. Here’s the set of commands; note that the indented lines are indented with a single tab: cat > opt/minicom/Makefile everytime: binaries: @(cd ../../src/minicom/minicom/src @amp;@amp; make) @cp -f ../../src/minicom/minicom/src/minicom bin @strip bin/minicom @strip --remove-section=.note --remove-section=.comment bin/minicom dependencies: @echo "libncurses" Press Ctrl+D here. |
21. | The Embedded Linux Workshop comes complete with a set of startup scripts that work similarly to the Red Hat startup scripts. Each script in the /etc/rc directory that begins with the letter S is executed in increasing sort order. Naming a script S99{
something} implies that it should be the last script to run and that it may not return to the caller. Here’s the set of commands: cat > opt/minicom/etc/rc/S99minicom #!/bin/sh echo "Press a key for minicom..." read x minicom -s Press Ctrl+D here. We use the -s option so Minicom will go directly into setup mode. It defaults to COM2; change that setting if necessary. In a real device, you would create a minicom configuration file and let it start directly.You also wouldn’t force the user to press a key to start, but this way you can see any bootup error messages before Minicom erases them. |
22. | Now make the script executable: chmod a+x opt/minicom/etc/rc/S99minicom |
23. | Create the terminfo for the console. This file contains the definitions of escape sequences for the console for operations such as clearing the screen and drawing lines: cp -P /usr/share/terminfo/l/linux opt/minicom |
24. | Run the elw command: elw |
25. |
Choose the Build Binaries option to build the binaries. Unless you take the time to download all the source files for the Embedded Linux Workshop, most of the binaries will fail to build. That’s okay; the binaries that ship will work. You must rerun this option each time you make a change. |
26. | Choose the Build Image option to build the Linux files and image. |
27. | Insert a blank, formatted floppy into your 3½-inch drive and choose the Build Floppy option to build the bootable floppy. |
28. |
When the build is complete, move the floppy from your build machine to the test machine and boot it. If all goes well, you’ll get the following message: Press a key for minicom... |
29. |
18.227.161.132