Cross Compiling GNU Radio for the Cell ProcessorThis page explains how to compile GNU Radio on an x86 or x86_64 platform, and generate code for the Cell processor. This is most useful when developing for the Sony PS3 which, because of it's small main memory size (256MB), is a poor platform for software development. OverviewThere are several ways one can go about cross compiling anything. There are always at least two machines involved: the build machine where the compilation takes place, and the host machine where the resulting software runs. Oftentimes these machines have differing architectures. In our case, the build machine is an x86 or x86-64 workstation running GNU/Linux, while the host machine is a Cell based machine also running GNU/Linux. (These instructions have been tested using a PS3, but are expected to work on a Cell bladeserver such as the IBM QS21 too.) The strategy described here requires that the build machine have
read-only access via to the root file system of the Cell host, and that both machines have read/write access to a shared NFS file system. PrerequisitesIn order to be concrete, we call the build machine *build* and the host machine *ps3*.
At present the only RPM's available are for x86, x86_64 or Cell/BE machines running Fedora 7. They also work fine on Fedora 8. It should be possible to build the cross toolchain from source on virtually any machine, but that is beyond the scope of this page.
build$ id uid=500(eb) gid=500(eb) groups=3(sys),10(wheel),500(eb),1000(usrp) ps3$ id
$ sudo yum install ntp
DetailsCongratulations on making it this far! _You have handled all the prerequisites described above, right?_ If not, please take care of them now. Google or your local sys admin can provide assistance. To cross compile there is some one-time stuff that needs to be done to set up everything between *build* and *ps3*, and then there's the actual steps for cross compiling GNU Radio. Setting up *build* and *ps3* so that they can talkWe need to arrange for *build* to be able to see the installed packages, includes and libraries on *ps3* so that we can compile and link against them. In addition, so that we can compile the software on *build* but run the QA code (make check) on *ps3*, we must arrange that they see a common file system, with identical path names to the shared file system from the root of each system. (configure hard-codes absolute file names into the generated Makefile's). Export the ps3 root filesystem read-onlyYou'll need to edit or create /etc/exports on *ps3* so that it contains something like this:/ 192.168.64.0/24(ro,all_squash)Use man exports if you've got questions. Then run exportfs
to have it take effect.ps3$ sudo exportfs -a Mount the ps3 root filesystem on buildOn *build* create a mount point named /mnt/cell-root and mount the ps3 root there.build$ sudo mkdir /mnt/cell-root build$ sudo mount -o ro ps3:/ /mnt/cell-rootAt this point you should be able to see the ps3 root filesystem from *build*. (The warnings and question marks are normal. Special files aren't accessible across NFS.) build$ ls -l /mnt/cell-rootIf this doesn't work, check that NFS is running on *ps3* and *build* and that there aren't any firewall rules that might be keeping you from connecting. Look at /var/log/messages on both machines for clues. Once this is working, add a line to /etc/fstab on *build* so that the filesystem is mounted automatically on boot. ps3:/ /mnt/cell-root nfs ro,intr,bg 0 0 Export the shared filesystem and mount it on both systemsNow we need to create the shared directory on *build*, export it, and then mount it on both systems. Find an existing filesystem on *build* that has at least a few gigs free, and create a directory called share there. It should be readable and writable by your regular login. The path isn't critical, just remember what you used. E.g.,build$ mkdir /mnt/misc/shareSet up this directory for export by adding a line similar to this to /etc/exports on *build*: /mnt/misc/share 192.168.64.0/24(rw)Then export it: build$ sudo exportfs -aCreate a mount point called /mnt/share on both machines: build$ sudo mkdir /mnt/share and mount it on both machines: build$ sudo mount build:/mnt/misc/share /mnt/shareYou should be able to create a file from either machine and see it on the other. E.g., build$ date > /mnt/share/foo If this isn't working, take a look at /var/log/messages on both machines. Once this is working, add a line to /etc/fstab on both machines so that themount will happen automatically at boot time: build:/mnt/misc/share /mnt/share nfs rw,intr,bg 0 0 Tweak filesystem on PS3 for cross compilationA few symlinks need to be created on *ps3* and some linker scripts need to be edited. There's a script that will do this for us. The script is contained in the gnuradio trunk. As part of getting ready to do the cross compilation, check out the gnuradio trunk into a directory on /mnt/share.E.g., build$ mkdir /mnt/share/grNow, on *ps3* do this: ps3$ sudo /mnt/share/gr/trunk/dtools/bin/tweak-cell-for-cross-compiling Excellent! All the one-time set up is complete! Do the Cross Compilation (Finally!)Now on to the familar part... To keep life simple we'll specify a *--prefix* that's on /mnt/share. (This isn't required, but start this way. Otherwise, depending on which machine you're on when you type "make install" you'll hose yourself with P(.5) by installing binaries for the wrong architecture into /usr/local). The key difference from native compilation is using the ./configure-cell-cross script instead of ./configure directly. It accepts all the normal configure options. On *build*:build$ cd /mnt/share/gr/trunkAssuming that configure and make completed successfully, we can switch to *ps3* and run make check ps3$ cd /mnt/share/gr/trunkThis should also work fine. When you're happy: ps3$ make installAt this point the installed code should be ready to run. Be sure to set your PYTHONPATH and PATH to point into your prefix: ps3$ export PYTHONPATH=/mnt/share/cell-install/lib/python2.5/site-packagesThen try to run something: ps3$ usrp_fft.py ... Trouble ShootingWhat could possibly go wrong??? 注: Cross Compiling GNU Radio for the Cell Processor(原文出处,翻译整理仅供参考!) |