16.4. Putting It All TogetherNow that we have a reference from which to proceed, we can create the necessary files and functions for our own custom board. We copy the Lite5200 platform files for our baseline and modify them for our custom PowerPC platform. We'll call our new platform PowerDNA. The steps we will perform for this custom port are as follows:
You learned how to add a configuration option to Kconfig in Chapter 4. The configuration option for our new PowerDNA port is detailed in Listing 16-11. Listing 16-11. Configuration Option for PowerDNA
This Kconfig entry is added just below the entry for LITE5200 because they are related.[9] Figure 16-4 illustrates the results when the configuration utility is invoked.
Figure 16-4. Machine type option for PowerDNANotice that when the user selects POWERDNA, two important actions are performed:
The next step is to copy the files closest to our platform as the basis of our new platform-initialization files. We have already decided that the Lite5200 platform fits the bill. Copy lite5200.c to powerdna.c, and lite5200.h to powerdna.h. The difficult part comes next. Using the hardware specifications, schematics, and any other data you have on the hardware platform, edit the new powerdna.* files as appropriate for your hardware. Get the code to compile, and then proceed to boot and debug your new kernel. There is no shortcut here, nor any substitute for experience. It is the hard work of porting, but now at least you know where to start. Many tips and techniques for kernel debugging are presented in Chapter 14, "Kernel Debugging Techniques." To summarize our porting effort, Listing 16-12 details the files that have been added or modified to get Linux running on the PowerDNA board. Listing 16-12. PowerDNA New or Modified Kernel Files
The first file is the default configuration, which enables a quick kernel configuration based on defaults. It is enabled by invoking make as follows: $ make ARCH=ppc CROSS_COMPILE=<cross-prefix> powerdna_defconfig We've already discussed the changes to the Kconfig file. Modification to the makefile is trivialthe purpose is to add support for the new kernel configuration based on CONFIG_POWERDNA. The change consists of adding a single line: obj-$(CONFIG_POWERDNA) += powerdna.o The heart of the changes come in the powerdna.[c|h] files and changes to the FEC (Fast Ethernet Controller) layer. There were minor differences between powerdna.c and lite5200.c, the file from which it was derived. Two primary issues required changes. First, PCI was disabled because it is not used in the PowerDNA design. This required some minor tweaking. Second, the PowerDNA design incorporates an unmanaged Ethernet physical-layer chip that required slight changes in the hardware setup and the FEC layer. This work constituted the majority of the porting effort. The patch file consists of 1120 lines, but the bulk of those lines are the default configuration, which is only a convenience for the developer and is not strictly necessary. Removing that, the patch reduces to 411 lines. 16.4.1. Other ArchitecturesWe examined the details of how a given platform fits into the kernel, and the facilities that exist for porting to a new board. Our reference for this chapter and the discussions within came from the PowerPC architecture branch of the kernel. The other architectures differ in many detailed aspects of how various hardware platforms are incorporated, but the concepts are similar. When you have learned how to navigate a single architecture, you have the knowledge and tools to learn the details of the other architectures. |