world leader in high performance signal processing
Trace: » building-rpms

Building The Blackfin Toolchain From RPM Source Tarballs

The recommend procedure is still to use the Toolchain Build Script, but for the sake of completeness, this document covers how to build up the toolchain from the source rpms found in each release.

Building .src.rpm Directly

You may be able to cheat and just build up the .src.rpm directly without any modification. First fetch the relevant .src.rpm and place it in /usr/src/rpm/SRPMS/. Here we will use the 2007R1.1 release as an example.

Then compile it:

# cd /usr/src/rpm/SRPMS
# rpmbuild --rebuild blackfin-toolchain-07r1.1-3.src.rpm

You should also review the build output from `rpmbuild` to make sure there weren't any significant problems. Since it can be quite verbose, you may want to redirect it to a log file by appending >& log to the above command.

Once it is finished compiling, you should be left with the binary rpm's in /usr/src/rpm/RPMS/<arch>/. The <arch> field will obviously differ according to the architecture you're compiling on.

Testing The RPMs

You should now test the binary to make sure they were built properly. First clean out the installed files from the build:

# rm -rf /opt/uClinux/

Then install the new binary rpms:

# cd /usr/src/rpm/RPMS/<arch>/
# rpm -i blackfin-toolchain-07r1.1-3.<arch>.rpm

Finally give a quick compile/link test to catch any obvious problems. Note that the `file` output may differ slightly on your host.

# cd ~
# echo 'int main(){}' > test.c
# /opt/uClinux/bfin-uclinux/bin/bfin-uclinux-gcc test.c -o test
# file ./test
./test: ELF 32-bit LSB executable, version 1 (SYSV), statically linked, not stripped
# /opt/uClinux/bfin-uclinux/bin/bfin-uclinux-gcc test.c -o test -Wl,-elf2flt
# file ./test
./test: BFLT executable - version 4 ram
# /opt/uClinux/bfin-linux-uclibc/bin/bfin-linux-uclibc-gcc test.c -o test
# file ./test
./test: ELF 32-bit LSB executable, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

If you get weird errors from the toolchain about unrecognized objects, then you will have to go down to the next section about building from the .spec file.

Building From The .spec

Some rpm implementations have generic install hooks that force the host strip program to be run on all files in the compiled path. Often times, this destroys the cross-compiler libraries and objects that are designed to be run on the Blackfin processor rather than your build host. In this case, we need to install the .src.rpm, tweak the .spec file, and then build the binary rpms from the .spec.

Installing The .src.rpm

Fetch the relevant .src.rpm and place it in /usr/src/rpm/SRPMS/. Here we will use the 2007R1.1 release as an example. Then simply install it:

# rpm -i blackfin-toolchain-07r1.1-3.src.rpm

This will unpack the .src.rpm and all of its files into the proper subdirectories in /usr/src/rpm/.

Tweak The .spec

This part is largely dependent on the version of rpm you have installed as well as your distribution. Often times, the custom strip targets are part of __os_install_post, so simply adding this one line to the .spec file should be sufficient. You can find the .spec file at /usr/src/rpm/SPECS/blackfin-toolchain.spec.

// Anywhere in the beginning of the .spec
%define __os_install_post %{nil}

You may also be able to get by with any one of these instead:

// Anywhere in the beginning of the .spec
%define __strip /bin/true
// Anywhere in the beginning of the .spec
%define debug_package %{nil}
// As the first line of %install
export DONT_STRIP=1

Again, this is largely dependent on your distribution/setup. The first example (tweaking __os_install_post) is known to work on Debian systems.

Building The .spec

The last (and longest) part is to build up the toolchain with our new modified .spec file.

# cd /usr/src/rpm/SPECS
# rpmbuild -bb blackfin-toolchain.spec

After this, it is the same as building up from a .src.rpm. You should review the output of the rpmbuild command for any problems (redirect the output to a file by appending >& log) and then run the quick test as shown in the .src.rpm section up above. If you still get errors from the host strip destroying the Blackfin objects, you'll have to dig into your rpm setup and figure out how to disable the automatic stripping steps.

Debian chroot

For those of us who do not use a rpm based distribution, or need a relatively older setup, we'll show you how to use quickly get things rolling with Debian. A Debian chroot is used here as it provides stable setups with older versions of glibc which tend to be a helpful thing when making binary packages.

  1. create the chroot using the debootstrap package.
    # debootstrap etch /path/to/debian/chroot/
  2. Once that finishes, you should setup the critical mount points.
    # mount --bind /dev     /path/to/debian/chroot/dev
    # mount --bind /dev/pts /path/to/debian/chroot/dev/pts
    # mount --bind /proc    /path/to/debian/chroot/proc
    # mount --bind /sys     /path/to/debian/chroot/sys
  3. Then enter the chroot.
    # chroot /path/to/debian/chroot/
  4. Install the relevant development packages.
  5. RPM insists on executing /usr/bin/bzip2, so you need to make a link:
    // RPM insists on executing /usr/bin/bzip2
    # ln -s /bin/bzip2 /usr/bin/bzip2

Now you have a usable setup to build up some RPMs. Follow the steps above for building from a .spec file.