Section 16.4. Putting It All Together


16.4. Putting It All Together

Now 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:

1.

Add a new configuration option to ...arch/ppc/Kconfig.

2.

Copy lite5200.* to powerdna.* as a baseline.

3.

Edit new powerdna.* files as appropriate for our platform.

4.

Edit .../arch/ppc/Makefile to conditionally include powerdna.o.

5.

Compile, load, and debug!

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

config POWERDNA        bool "United Electronics Industries PowerDNA"        select PPC_MPC52xx        help          Support for the UEI PowerDNA board

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.

[9] To preserve space, we temporarily removed many machine types in Figure 16-4 prior to LITE5200.

Figure 16-4. Machine type option for PowerDNA


Notice that when the user selects POWERDNA, two important actions are performed:

1.

The CONFIG_PPC_MPC52xx configuration option is automatically selected. This is accomplished by the select keyword in Listing 16-11.

2.

A new configuration option, CONFIG_POWERDNA, is defined that will drive the configuration for our build.

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

linux-2.6.14/arch/ppc/configs/powerdna_defconfig linux-2.6.14/arch/ppc/Kconfig linux-2.6.14/arch/ppc/platforms/Makefile linux-2.6.14/arch/ppc/platforms/powerdna.c linux-2.6.14/arch/ppc/platforms/powerdna.h linux-2.6.14/drivers/net/fec_mpc52xx/fec.c linux-2.6.14/drivers/net/fec_mpc52xx/fec.h linux-2.6.14/drivers/net/fec_mpc52xx/fec_phy.h linux-2.6.14/include/asm-ppc/mpc52xx.h

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 Architectures

We 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.



Embedded Linux Primer(c) A Practical Real-World Approach
Embedded Linux Primer: A Practical Real-World Approach
ISBN: 0131679848
EAN: 2147483647
Year: 2007
Pages: 167

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net