Python ported to the arm platform

Publisher:脑洞狂想Latest update time:2016-07-07 Source: eefocusKeywords:python Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Cross-compile Python

  见Cross Compiling Python for Embedded Linux

CC=arm-linux-gcc CXX=arm-linux-g++ AR=arm-linux-ar RANLIB=arm-linux-ranlib ./configure --host=arm-linux --build=x86_64-linux-gnu --prefix=/root/tftpboot/Python-2.7.3

make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen BLDSHARED="arm-linux-gcc -shared" CROSS_COMPILE=arm-linux- CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=x86_64-linux-gnu

make install HOSTPYTHON=./hostpython BLDSHARED="arm-linux-gcc -shared" CROSS_COMPILE=arm-linux- CROSS_COMPILE_TARGET=yes prefix=/root/tftpboot/Python-2.7.3

2. File transfer between PC and development board

  tftp: tftp -l path/to/filename -r filename -g 192.168.*.*

3. File copy

  •   cp /your/path/bin/python2.7 /bin/python     

  or export PATH=/your/path/bin/:$PATH # OK210 development board will report an error

  •        Copy serial, Django and other Python libraries to the /lib/python2.7/site-packages/ directory.

4. Set Python related environment variables

  Take Python 2.7.x as an example.

export PYTHONHOME=/your/path/
#export PYTHONPATH=$PYTHONHOME:$PYTHONHOME/lib/python2.7:$PYTHONHOME/lib:$PYTHONHOME/lib/python2.7/site-packages
#export PATH=$PATH:$PYTHONHOME:$PYTHONPATH

5. sqlite3

Building SQLLite and other dependancies

Thanks to Lothsahn’s 2.7.3 patch, it is now possible to build sqlite3, bz2, gz, ssl and ctypes.  Lothsahn provides the following instructions:

To do the compilation, the dependencies must be in the include and lib folder one path up from the python install.   For example:

/include <– header files go here

/lib <– shared object files go here

/Python-2.7.3 <—Python sources go here during compile

Dependencies include libffi, sqlite, openssl, bzip2, zlib, etc.

1. Follow the Cross Compiling Python for Embedded Linux  given by Paul Gibson above , but import sqlite3 will report an error, the reason is not clear yet.

I tried some solutions but failed. It might be a problem with the lib_dir path:

  •   Removing other search paths from the setup.py, but the one i had the ARM compiled library in, made it work. 测试也未通过。

http://stackoverflow.com/questions/12385634/shared-library-sqlite3-so-not-found-when-importing-sqlite3-on-python-2-6-6

  •   http://stackoverflow.com/questions/10654707/no-module-named-zlib-found
  •   http://stackoverflow.com/questions/6171210/building-python-and-more-on-missing-modules

3. Debian platform is successful. http://www.friendlyarm.net/forum/topic/2731

reference:

1. cross compile python, busybox, flex, bash and so on, ARM cross-compiling howto

2. A powerful example on the Internet, python-2.6.6:

Click and run python cross compiling for Embedded ARM Linux

3. Use python in the Friendly Arm Linux system  http://112.124.9.243/?p=285

4. Porting python3 to the OK6410 development board of the ARM platform  http://www.51bigfool.com/%E7%A7%BB%E6%A4%8Dpython3%E5%88%B0arm%E5%B9%B3%E5%8F%B0%E7%9A%84ok6410%E5%BC%80%E5%8F%91%E6%9D%BF.html

Attachment:

  •  After stripping, the debugging information will be removed and the executable file size will be much smaller. The command is as follows:
    # arm-linux-strip  file
    Where file is a binary file compiled by arm-liunux-gcc.
  •    ./configure --host=arm-linux CC=arm-linux-gcc AR=arm-linux-ar STRIP=arm-linux-strip RANLIB=arm-linux-ranlib
  •    Cross-compile of sqlite3
    •   # CC=arm-linux-gcc ./configure --prefix=/your/path/sqlite-3.7.14 --host=arm-linux --disable-tcl

        #make && make install


Keywords:python Reference address:Python ported to the arm platform

Previous article:ffmpeg ported to arm s3c2410
Next article:LOG4C porting to ARM platform process

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号