Company Products/Technology Services News/Events Support Spacer Contact Partners Customers
English    日本語
Products Photo

Product Documentation for
Devicescape Universal Wireless Platform

Documentation Home for Devicescape Universal Wireless Platform | Developer Guide

Developer GuidePreviousNextIndex

 


Building the Packages

Building a Userspace Package from a Source RPM

If you want to modify the source for one of the packages provided with the platform, you must re-build the source RPM as a package after making the modifications. Similarly if you want to add a custom feature for which you have source code available, you must build the source file(s) into a package for including in the root file system (RFS) image. In either case, you must step through this build process to get a binary version of the new or modified feature.

To build a userspace package from a source RPM, follow these steps in the Devicescape Studio.

  1. Select File > Import to open the import dialog. Then select the "Source RPM as Workspace Project" option.

  2. For "Choose source package", choose the SRPM file you want to import into the project.
  3. The SRPM files for the toolchain set are installed in: /opt/devicescape/linux/2.0/<Architecture>-bbdyn-linux/packages/core/SRPMS.

    For "Build source RPM using:",select "rpmbuild" as the method used to build the SRPM.

  4. Type in a name for the project. (The project name will show up in the navigator pane on the IDE and will also be the directory name in the workspace).

  5. Open the top level Makefile in the editor. (Double click "Makefile" in the navigator window after opening the new project).

  6. Replace all but the first two lines of the Makefile with this:
  7. TSRPM = tsrpm --target=$(ARCH)-uclibc
    export PATH := /opt/devicescape/toolchains/$(ARCH)-linux/bin:$(PATH)
    all: build
    .PHONY: build all clean
    build:
    	$(TSRPM) --build $(SPECFILE)
    	$(TSRPM) --repackage=targetipkg $(PROJDIR)/$(ARCH)-uclibc/RPMS/*.rpm
    clean:
    	rm -rf $(ARCH)-uclibc

    (Remember to use tabs in front of the rules and not spaces.)

  8. Open the Properties for the project (Project > Properties) and select the "C/C++ Make Project" panel. In the "Build command" box, uncheck the "Use default" and change the build command to reflect the architecture name of your target device (in this example, armv5b):
  9. make ARCH=armv5b

    Click OK to save this change. (For other architectures, substitute the correct name for the 'armv5b' in the example above.)

  10. Build the project (menu option Project > Build Project.).
    Note
    If the "Build Project" option is grayed out, make sure the "Project > Build Automatically" option is not checked.


Building a Pre-Packaged Kernel

The kernel provided with the platform can be used as-is on the target device. However, if you want to reconfigure the kernel or build any of the kernel modules (which require a pre-built kernel tree be available during compile time), you must re-build the kernel after making modifications.

To build the kernel with pre-packaged source, follow these steps in the Devicescape Studio.

  1. Select the menu option File > New > Project and choose the "Pre-Packaged Kernel"' option. When the first step of the wizard appears, enter a name for the project and click Next.

  2. Type in a name for the project and click Next. (The project name will show up in the navigator pane on the IDE and will also be the directory name in the workspace)

  3. Select the SDK that matches the target board for which you are building the kernel. In this example we choose the ixdpg425. The toolchain should be selected automatically to reflect the chosen board.

  4. Check the "Copy kernel sources into project" option (if you have write access to the installed location you can use link, but we would recommend making a copy anyway to keep the installed source tree "clean" as a starting point for any future projects you want to create with different settings.

  5. Click Finish and the wizard will create the project. With the copy option checked this can take a little while as it copies the full kernel source tree into your project workspace. A progress bar will indicate the status of the copy operation.

  6. Once the project has been created, you can double-click on the .kfg file in the navigator pane to open the kernel configuration tool. Make any changes you need here and save the configuration.

  7. Remember to use the "Save and Exit" option when finished to make sure that your new configuration is saved, then simply rebuild the project to get the new image.

  8. Select Project > Build Project to build the new kernel. If it builds successfully you should find the appropriate kernel image (normally a zImage file) in the navigator pane, and also have a set of build logs in the buildlogs directory. Check these for any errors.

Creating a Custom Kernel Project Linked to External Sources

The kernel provided with the platform can be used as-is on the target device. However, you may want to create a customized kernel with fewer or additional features than the one provided.

To create a custom kernel project linked to external sources:

  1. Select the menu option File > New > Project and choose the "Custom Kernel Project"' option.

  2. Enter a name for the project. The project name you provide will be displayed in the workspace. In this example, the project name is "kernel-linked".

  3. Browse to, or type in the path to the external kernel source tree. Ideally, the tree should already have a .config file that matches the board you plan to use it on.

  4. Make sure the 'Link to kernel sources' option is checked, then click Next.

    Note
    You must have write access to this directory as it will still be used to build the kernel. The act of linking just avoids having to copy the kernel source tree into the workspace, which saves time and disk space, but perhaps more importantly allows you to point at an external source tree that is kept in a version control system such as CVS or Perforce.

  5. Choose the correct toolchain and architecture name (as used by the kernel). The "Image Name" and "Target Name" should populate automatically when the architecture name is selected.

  6. Click Finish to create the project.

    Once created, the project will show a link from the workspace to the external kernel sources.

  7. Select Project > Build project to build the project.
  8. As with all kernel projects, the logs for the different phases of the kernel build can be found in the "buildlogs" directory under the project.

  9. Double-click on the .kfg file in the project to open the kernel configuration tool. For a Linux 2.4 kernel, such as the one being used in this example, this will start the kernel's "make xconfig" process and open the TK based graphical kernel configuration tool.

  10. Remember to use the "Save and Exit" option when finished to make sure that your new configuration is saved, then rebuild the project to get the new image.

Building a Kernel Module from a Source RPM

To build a kernel module from a source RPM, do the following.

  1. Select File > Import and then choose "Source RPM as Workspace Project" from the list of available import options.

  2. Enter the path to the Source RPM to import. The SRPMs that come with the distribution can be found at: /opt/devicescape/linux/2.0/<arch>-bbdyn-uclibc/packages/SRPMS

  3. Make sure the "rpmbuild" option is checked.

  4. Enter a name for the new project and click Finish to create the new project.

  5. Open the properties for the new project (menu option: Project > Properties) and open the "C/C++ Make Project" pane. Under "Build command" uncheck the "Use default" option and add ARCH=<Architecture> to the build command, where <Architecture> matches the architecture you are building for (for example, armv5b in the example).

  6. Open the Makefile and replace all but the first two lines with the following:
  7. TSRPM = tsrpm --target=$(ARCH)-uclibc
    export PATH := /opt/devicescape/toolchains/$(ARCH)-linux/bin:$(PATH)
    all: build
    .PHONY: build all clean
    build:
    	$(TSRPM) --build $(SPECFILE)
    	$(TSRPM) --repackage=targetipkg \
                      $(PROJDIR)/$(ARCH)-uclibc/RPMS/*.rpm
    clean:
    	rm -rf $(ARCH)-uclib

    (Remember to use tabs in front of the rules and not spaces.)

  8. Add a new file, client_bridge.tshint, to the project (menu option: New > File).

  9. Add a single line to this new file that points at the top level directory of the kernel source tree for your system. For example, assuming that you have a pre-packaged kernel project called kernel in your workspace at /home/user/workspaces, the line would look like this:
  10. export LINUX_SOURCE=/home/user/workspaces/kernel/kernel
 
 
  • Select "Project > Build Project" to build the project. The new binary packages can be found under the <Architecture>-uclibc/RPMS and <Architecture>-uclibc/IPKG directories.

  • Using Command Line Tools to Build Packages (tsrpm)

    tsrpm is a wrapper for rpmbuild that supports cross-compilation of SRPMs, in most cases without any need to modify the original package. In cases where you prefer to use a command line interface rather than the Devicescape Studio, you can use tsrpm to build packages from the command line. The following sections describe how to build packages from the command line using tsrpm:

    Building a Userspace Package from the Command Line

    To build a target package, obtain the source RPM for the package you want to build. Devicescape source RPMs are in installed in the following directory when you install the Devicescape Wireless Infrastructure Platform:

    /opt/devicescape/linux/2.0/<Architecture>-bbdyn-linux/packages/core/SRPMS .

    Devicescape source RPMs are known to build using tsrpm. Other source RPM sources such as Fedora (http://download.fedora.redhat.com/pub/fedora/linux/core/) can give you a starting point if you need a package not supported by Devicescape. Source RPMs from an external source such as Fedora may require patches before they can be cross-compiled by tsrpm.

    For example to build the hello package distributed by Devicescape for an "arm" target:

    1. Create and enter a build directory then extract the source package.
    2. $ tsrpm --extract hello-1.0-1ds7.src.rpm 
    3. Then invoke tsrpm again to build the package.
    4. $ tsrpm --target=armv5b-uclibc \
      	--build rpm-sources/hello-1.0-1ds7/hello.spec 

      The --target flag indicates the target hardware for which the binary should be built. The following table shows the mapping between the tsrpm target and Devicescape supported platforms.

      Model
      Board String
      tsrpm Target
      D-Link dwl-2210ap
      ar531x
      mips-uclibc
      Linksys wrt54g
      bcm947xx
      mipsel-uclibc
      Monte Jade
      ixdpg425
      armv5b-uclibc
      Intel PC
      x86pc
      i686-uclibc

    5. When the build is complete, tsrpm writes the RPM and source RPM to a target subdirectory. You can check this by doing an "ls" of the target subdirectories:
    6. $ ls armv5b-uclibc/RPMS/ armv5b-uclibc/SRPMS/
      armv5b-uclibc/RPMS/:
      hello-1.0-1ds7.armv5b-uclibc.rpm
      armv5b-uclibc/SRPMS/:
      hello-1.0-1ds7.src.rpm
      $
    7. To convert to ipkg invoke tsrpm again.
    8. $ tsrpm --repackage=targetipkg --target=armv5b-uclibc armv5b-uclibc/RPMS/hello-1.0-
      1ds7.armv5b-uclibc.rpm

    Building a Target Library

    Building a target library involves an additional step to convert the package into a form suitable for installation on the host build machine. For example, to build 'zlib' follow the procedure outlined above for building any package:

    1. Extract the source package.
    2. $ tsrpm --extract zlib-1.2.1.1-2.1.src.rpm 
      $ tsrpm --target=armv5b-uclibc \
      	--build rpm-sources/zlib-1.2.1.1-2.1/zlib.spec
      . . .
      Wrote: /usr/src/armv5b-uclibc/RPMS/zlib-1.2.1.1-2.1.armv5b-uclibc.rpm
      Wrote: /usr/src/armv5b-uclibc/RPMS/zlib-devel-1.2.1.1-2.1.armv5b-uclibc.rpm
      . . .
      $

      The build creates two packages. The first, zlib-1.2.1.1-2.1.armv5b-uclibc.rpm, contains the shared library and is meant to be installed on the target. The second, zlib-devel-1.2.1.1-2.1.armv5b-uclibc.rpm, contains library header files. This second package will not be installed on the target. The second package is only used as input to the tsrpm invocation described next.

    3. Invoke tsrpm again to convert the target packages into host format.
    4. $ tsrpm --target=armv5b-uclibc --convert-to-host \
      	armv5b-uclibc/RPMS/zlib-1.2.1.1-2.1.armv5b-uclibc.rpm
      . . .
      Wrote: /usr/src/i386-x-armv5b-uclibc/RPMS/zlib-armv5b-uclibc-1.2.1.1-2.1.i386.rpm
      $ tsrpm --target=armv5b-uclibc --convert-to-host \
      	armv5b-uclibc/RPMS/zlib-devel-1.2.1.1-2.1.armv5b-uclibc.rpm
      . . .
      Wrote: \
      	/usr/src/i386-x-armv5b-uclibc/RPMS/zlib-devel-armv5b-uclibc-1.2.1.1-2.1.i386.rpm
      $
    5. Install the host target library packages:
    6. $ sudo rpm -i --nodeps --force \
      	i386-x-armv5b-uclibc/RPMS/zlib-devel-armv5b-uclibc-1.2.1.1-2.1.i386.rpm \
      	i386-x-armv5b-uclibc/RPMS/zlib-armv5b-uclibc-1.2.1.1-2.1.i386.rpm
      $

      At this point the zlib headers and libraries are in the toolchain's search path. Applications that use zlib can now be built.

    Building Driver Packages

    Many Linux driver packages require a built kernel tree for part of the build process. The driver packages expect the kernel tree in a known location. The following steps outline how to build a kernel tree in the location the modules packages expect. The kernel build starts like all the other builds that use tsrpm:

    1. Extract the source RPM.
    2. $ tsrpm --extract kernel-arm-ixdpg425-2.4-devicescape.1.src.rpm

      To prevent the package build from cleaning the kernel tree after the build, you can specify the '-bc' option be passed to tsrpm.

      $ tsrpm --target=armv5b-uclibc -bc \
      	rpm-sources/kernel-arm-ixdpg425-2.4-devicescape.1/kernel-arm-ixdpg425.spec
    3. Create a link so the drivers build can find the kernel.
    4. $ ln -s `pwd`/armv5b-uclibc/BUILD/kernel-arm-ixdpg425-2.4/linux-2.4.27-uc1/ \
      	armv5b-uclibc/linux

      After the built kernel tree is setup as described above driver packages can be built just like any other package.

      $ tsrpm --extract ieee80211-0.1-1ds7.src.rpm 
      $ tsrpm --target=armv5b-uclibc --build rpm-sources/ieee80211-0.1-1ds7/ieee80211.spec

    Making Changes to a Package

    To modify a package:

    1. Extract the srpm (this is the same as the step above).
    2. $ tsrpm --extract strace-4.5.3-1.src.rpm
    3. To make changes to the source of a package first run only the "prep" stage of build. This typically involves extracting the tarball and applying any patches:
    4. $ tsrpm --target=armv5b-uclibc -bp rpm-sources/strace-4.5.3-1/strace.spec
    5. Now make a copy of the original build directory. You will use this to generate a patch that includes your changes :
    6. $ cp -a armv5b-uclibc/BUILD/strace-4.5.3 armv5b-uclibc/BUILD/strace-4.5.3.orig
    7. Build the package:
    8. $tsrpm --cust=devicescape --target=armv5b-uclibc \
      --build rpm-sources/strace-4.5.3-1/strace.spec
    9. If you are debugging a build it can be helpful to interact with the package in the cross shell environment. To do this, execute a shell and enter the build directory. Execute build commands via this shell while testing the changes you made to the package. For example:
    10. $ tsrpm --target=armv5b-uclibc --run-tool /bin/sh
      + eval /bin/sh
      ++ /bin/sh
      sh-2.05b$ cd armv5b-uclibc/BUILD/strace-4.5.3/ sh-2.05b$ make 
      make  all-am
      make[1]: Entering directory `/usr/src/armv5b-uclibc/BUILD/strace-4.5.3'
      if armv5b-uclibc-gcc -DHAVE_CONFIG_H -I. -I. -I. \
      	-Ilinux/arm -I./linux/arm -Ilinux -I./linux   \
      	-Wall -D_GNU_SOURCE -O2 -g -pipe -MT mem.o -MD -MP -MF ".deps/mem.Tpo" \
      	-c -o mem.o `test -f 'mem.c' || echo './'`mem.c; \ 
      	then mv -f ".deps/mem.Tpo" ".deps/mem.Po"; \ 
      	else rm -f ".deps/mem.Tpo"; exit 1; \ 
      	fi armv5b-uclibc-gcc -Wall -D_GNU_SOURCE -O2 -g -pipe   \
      	-o strace  strace.o syscall.o util.o desc.o file.o ipc.o io.o \
      	ioctl.o mem.o net.o process.o bjm.o resource.o signal.o sock.o \
      	system.o term.o time.o proc.o stream.o  
      make[1]: Leaving directory \
      	`/usr/src/armv5b-uclibc/BUILD/strace-4.5.3'
      sh-2.05b$ 

      The shell entered above has a set of environment variables specifically for cross building so some tools may not work as expected. Specifically, you may find that your editor does not work when invoked from this shell. Therefore, only execute build commands (commands that typically appear in a specfile such as 'configure' or 'make') within the cross shell described above. Make your source changes (run your editor) in a non-cross shell.

    11. Once your source changes are complete, generate a patch:
    12. $ diff -urN armv5b-uclibc/BUILD/strace-4.5.3.orig/ \
      	armv5b-uclibc/BUILD/strace-4.5.3 > rpm-sources/strace-4.5.3-1/statfs64.patch
    13. Look through the diff and delete any changes you did not want to make, any auto-generated files, etc. Your patch might then look something like the following:
    14. diff -urN armv5b-uclibc/BUILD/strace-4.5.3.orig/config.h.in \
      	armv5b-uclibc/BUILD/strace-4.5.3/config.h.in
      --- armv5b-uclibc/BUILD/strace-4.5.3.orig/config.h.in									\
      	2004-04-16 15:29:49.000000000 -0700
      +++ armv5b-uclibc/BUILD/strace-4.5.3/config.h.in									\
      	2005-03-03 15:37:23.786755720 -0800
      @@ -176,6 +176,9 @@
       /* Define to 1 if `sin6_scope_id' is member of `struct sockaddr_in6'. */  
      #undef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID
       
      +/* Define to 1 if the system has the type `struct statfs64'. */ 
      #undef 
      +HAVE_STRUCT_STATFS64
      +
       /* Define to 1 if `st_aclcnt' is member of `struct stat'. */  
      #undef HAVE_STRUCT_STAT_ST_ACLCNT
       
      diff -urN armv5b-uclibc/BUILD/strace-4.5.3.orig/configure.ac \
      	armv5b-uclibc/BUILD/strace-4.5.3/configure.ac
      --- armv5b-uclibc/BUILD/strace-4.5.3.orig/configure.ac										\
      	2004-04-16 15:22:19.000000000 -0700
      +++ armv5b-uclibc/BUILD/strace-4.5.3/configure.ac									\
      	2005-03-03 15:37:23.786755720 -0800
      @@ -165,6 +165,7 @@
       		  struct stat.st_level,
       		  struct stat.st_rdev])
       AC_STAT64
      +AC_CHECK_TYPES([struct statfs64],,, [#include <sys/statfs.h>])
       
       AC_TYPE_SIGNAL
       AC_TYPE_UID_T
      diff -urN armv5b-uclibc/BUILD/strace-4.5.3.orig/file.c \
      	armv5b-uclibc/BUILD/strace-4.5.3/file.c
      --- armv5b-uclibc/BUILD/strace-4.5.3.orig/file.c									\
      	2004-01-13 02:16:47.000000000 -0800
      +++ armv5b-uclibc/BUILD/strace-4.5.3/file.c								\
      	2005-03-03 15:37:23.787755568 -0800
      @@ -1437,6 +1437,7 @@
       }
       
       #ifdef LINUX
      +#ifdef HAVE_STRUCT_STATFS64
       static void
       printstatfs64(tcp, addr)
       struct tcb *tcp;
      @@ -1479,11 +1480,13 @@
       #endif
       	tprintf("}");
       }
      +#endif
       
       int
       sys_statfs64(tcp)
       struct tcb *tcp;
       {
      +#ifdef HAVE_STRUCT_STATFS64
       	if (entering(tcp)) {
       		printpath(tcp, tcp->u_arg[0]);
       		tprintf(", %lu, ", tcp->u_arg[1]);
      @@ -1494,12 +1497,16 @@
       			tprintf("{???}");
       	}
       	return 0;
      +#else
      +	return printargs(tcp);
      +#endif
       }
       
       int
       sys_fstatfs64(tcp)
       struct tcb *tcp;
       {
      +#ifdef HAVE_STRUCT_STATFS64
       	if (entering(tcp)) {
       		tprintf("%lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
       	} else {
      @@ -1509,6 +1516,9 @@
       			tprintf("{???}");
       	}
       	return 0;
      +#else
      +	return printargs(tcp);
      +#endif
       }
       #endif
       
      @@ -2067,6 +2077,13 @@
       	free(buf);
       	return 0;
       }
      +#else
      +int
      +sys_getdents64(tcp)
      +struct tcb *tcp;
      +{
      +	printargs(tcp);
      +}
       #endif
       
       #ifdef FREEBSD
    15. Add the patch to the specfile, and increment the version number :
    16. --- rpm-sources/strace-4.5.3-1.orig/strace.spec
      +++ rpm-sources/strace-4.5.3-1/strace.spec
      @@ -1,11 +1,12 @@
       Summary: Tracks and displays system calls associated with a running process.
       Name: strace
       Version: 4.5.3
      -Release: 1
      +Release: 1.1
       License: BSD
       Group: Development/Debuggers
       URL: http://sourceforge.net/projects/strace/
       Source0: %{name}-%{version}.tar.bz2
      +Patch0: statfs64.patch
       BuildRoot: %{_tmppath}/%{name}-root
       
       %define strace64_arches ppc64
      @@ -41,6 +42,7 @@
       
       %prep
       %setup -q
      +%patch0 -p3
       
       %build
       %configure
      Then build the new package:
      $ tsrpm --target=armv5b-uclibc --build rpm-sources/strace-4.5.3-1/strace.spec
      The new source rpm is available under the target subdir :
      $ ls armv5b-uclibc/SRPMS/
      armv5b-uclibc/SRPMS/strace-4.5.3-1.1.src.rpm
      $ 
    Developer GuidePreviousNextIndex