pypy / pypy / doc / arm.rst

 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 Armin Rigo 2f2bb35 2012-09-29 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 David Schneider 23bf2d6 2012-09-04 David Schneider ab7edc9 2011-05-09 Armin Rigo 2f2bb35 2012-09-29  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 ========================= Cross-translating for ARM ========================= Here we describe the setup required and the steps needed to follow to translate an interpreter using the RPython translator to target ARM using a cross compilation toolchain. To translate an RPython program for ARM we can either translate directly on an ARM device following the normal translation steps. Unfortunately this is not really feasible on most ARM machines. The alternative is to cross-translate using a cross-compilation toolchain. To cross-translate we run the translation on a more powerful (usually x86) machine and generate a binary for ARM using a cross-compiler to compile the generated C code. There are several constraints when doing this. In particular we currently only support Linux as translation host and target platforms (tested on Ubuntu). Also we need a 32-bit environment to run the translation. This can be done either on a 32bit host or in 32bit chroot. Requirements ------------ The tools required to cross translate from a Linux based host to an ARM based Linux target are: - A checkout of PyPy (default branch). - The GCC ARM cross compiler (on Ubuntu it is the gcc-arm-linux-gnueabi package) but other toolchains should also work. - Scratchbox 2, a cross-compilation engine (scratchbox2 Ubuntu package). - A 32-bit PyPy or Python. - And the following (or corresponding) packages need to be installed to create an ARM based chroot: * debootstrap * schroot * binfmt-support * qemu-system * qemu-user-static Creating a Qemu based ARM chroot -------------------------------- First we will need to create a rootfs containing the packages and dependencies required in order to translate PyPy or other interpreters. We are going to assume, that the files will be placed in /srv/chroot/precise_arm. Create the rootfs by calling: :: mkdir -p /srv/chroot/precise_arm qemu-debootstrap --variant=buildd --arch=armel precise /srv/chroot/precise_arm/ http://ports.ubuntu.com/ubuntu-ports/ Next, copy the qemu-arm-static binary to the rootfs. :: cp /usr/bin/qemu-arm-static /srv/chroot/precise_arm/usr/bin/qemu-arm-static For easier configuration and management we will create a schroot pointing to the rootfs. We need to add a configuration block (like the one below) to the schroot configuration file in /etc/schroot/schroot.conf. :: [precise_arm] directory=/srv/chroot/precise_arm users=USERNAME root-users=USERNAME groups=users aliases=default type=directory To verify that everything is working in the chroot, running schroot -c precise_arm should start a shell running in the schroot environment using qemu-arm to execute the ARM binaries. Running uname -m in the chroot should yeild a result like armv7l. Showing that we are emulating an ARM system. Start the schroot as the user root in order to configure the apt sources and to install the following packages: :: schroot -c precise_arm -u root echo "deb http://ports.ubuntu.com/ubuntu-ports/ precise main universe restricted" > /etc/apt/sources.list apt-get update apt-get install libffi-dev libgc-dev python-dev build-essential libncurses5-dev libbz2-dev Now all dependencies should be in place and we can exit the schroot environment. Configuring scratchbox2 ----------------------- To configure the scratchbox we need to cd into the root directory of the rootfs we created before. From there we can call the sb2 configuration tools which will take the current directory as the base directory for the scratchbox2 environment. :: cd /srv/chroot/precise_arm sb2-init -c which qemu-arm ARM which arm-linux-gnueabi-gcc This will create a scratchbox2 based environment called ARM that maps calls to gcc done within the scratchbox to the arm-linux-gnueabi-gcc outside the scratchbox. Now we should have a working cross compilation toolchain in place and can start cross-translating programs for ARM. Translation ----------- Having performed all the preliminary steps we should now be able to cross translate a program for ARM. You can use this_ minimal target to test your setup before applying it to a larger project. Before starting the translator we need to set two environment variables, so the translator knows how to use the scratchbox environment. We need to set the **SB2** environment variable to point to the rootfs and the **SB2OPT** should contain the command line options for the sb2 command. If our rootfs is in the folder /srv/chroot/precise_arm and the scratchbox environment is called "ARM", the variables would be defined as follows. :: export SB2=/srv/chroot/precise_arm export SB2OPT='-t ARM' Once this is set, you can call the translator :: pypy ~/path_to_pypy_checkout/pypy/translator/goal/translate.py -O1 --platform=arm target.py If everything worked correctly this should yield an ARM binary. Running this binary in the ARM chroot or on an ARM device should produce the output "Hello World". .. _this: :: def main(args): print "Hello World" return 0 def target(*args): return main, None 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.