Python in a FriendlyArm (minicom 2440)

This post was developed as a project of Specialization in Mobile Devices Fatec-Jp subject in Python. We’ll talk over how to cross post the python compiler for ARM platform (FriendlyArm minicom 2440).

First let’s do cross-compile a Hello World in C before porting python to friendlyarm, and so we need to install the cross-compiling toolchains for ARM platform (arm-linux-gcc)

To do this we split the tutorial in a few steps:

Step 1: Install the arm-linux-gcc

To do the cross-compiler used the arm-linux-gcc-4.3.2.tgz, which is available at:                            

Unzip it in /usr/local/armgcc and then add the path in the path like this:
export PATH=/usr/local/armgcc/bin:$PATH

Step 2: Create a sample helloword in C and make the cross-compiler for arm

Create a C program helloworld.c

#include <stdio.h>
printf (“Hello World!\n”);

Make a normal build:                                                                                                                                                                                                                                                                                                                                                                                 gcc helloworld.c -o helloNormal

Then do:
file helloNormal

The output will be the one below, which shows that this file is compiled to processor pc:
helloNormal: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU / Linux 2.6.15, not stripped

With this file is not possible to run at friendlyarm they still did not cross-compiler.

To generate the binary cross-compiled arm to do so:
arm-linux-gcc -s helloworld.c -o helloArm

Now we have a program in C that can run on FriendlyArm, to be sure, let’s check the file:
file helloArm

The output will be the one below, which shows that this file is compiled to FriendlyArm:
helloArm: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, stripped

Okay, now just put the file in helloArm FriendlyArm and run:

As output we get:
Hello World!

Step 3: Porting python to FriendlyArm

We will download the python in
We will use the example version 2.6.5

Once you have downloaded the python will unpack it using tar:

tar -xvzf Python-2.6.5.tgz

The result is the creation of the directory Python-2.6.5, now enter the created directory:

cd Python-2.6.5

Now, execute the following commands to create the components of the host:


make python Parser/pgen

mv hostpython python

mv Parser/Parser pgen/hostpgen

make distclean

The next step is to download the correct patch for your version of python which is located in:

Then we will apply the patch:

patch -p1 < Python-2.6.5-xcompile.patch

Then run the following commands:

CC=ppc_6xx-gcc CXX=ppc_6xx-g++ AR=ppc_6xx-ar RANLIB=ppc_6xx-ranlib ./configure –host=ppc-linux –build=i686-pc-linux-gnu –prefix=/python

make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED=”ppc-linux-gcc -shared” CROSS_COMPILE=ppc_6xx- CROSS_COMPILE_TARGET=yes

make  install HOSTPYTHON=./hostpython BLDSHARED=”ppc-linux-gcc -shared” CROSS_COMPILE=ppc_6xx- CROSS_COMPILE_TARGET=yes prefix=~/Python-2.6.5/_install

This will install the binaries and libs in ~/Python-2.6.5/_install.

Copy the entire _install directory to the device, setup the PATH environment variable to include the location of the Python executable and run:

python lib/Python-2.6/test/

To accelerate the import of Python modules, we recommend creating one. Zip, with that we will not need to copy “all” the files manually.

cd _install/lib/python2.6

zip -r -y .

Copy the _install/bin/python to the /usr/bin directory on the target:

Copy the file to the /usr/lib directory on the target:
Create a directory named python2.6 /usr/lib and copy it to the following directories:




The structure of your directory should be like the one below:

/usr/lib # ls


/python/lib/python2.6 # ls

config  lib-dynload  site-package

Set the environment variable PYTHONHOME para /usr/ and you will already be running python in his FriendlyArm

Further, this process will build only the binary python, So the libraries will not be running.