Difference between revisions of "Python development"

From ArmadeusWiki
Jump to: navigation, search
m (Links)
(Installation)
Line 2: Line 2:
  
 
==Installation==
 
==Installation==
* Python interpreter and libraries are not installed in the default APF9328 rootfs. Currently it increases the rootfs size by 6 MBytes and so, without cleanup, '''it won't fit in the old APF9328 boards with 8 MBytes FLASH size'''. So for the moment, if you have an 8MB FLASH, you can only use it from a [[Network_Configuration#Boot_from_NFS | NFS]] or [[MultiMediaCard#Booting_from_MMC.2FSD | a MMC/SD rootfs]].<br>
+
* Python interpreter and libraries are not installed in the default APF rootfs:
'''Python''' version installed by Buildroot is '''2.4'''.<br>
+
** Currently it increases the rootfs size by 6 MBytes and so, without cleanup, '''it won't fit in the old APF9328 boards with 8 MBytes FLASH size'''. So for the moment, if you have an 8MB FLASH, you can only use it from a [[Network_Configuration#Boot_from_NFS | NFS]] or [[MultiMediaCard#Booting_from_MMC.2FSD | a MMC/SD rootfs]]. If your are a Python expert you can still delete some files in $ARMADEUS_ROOTFS/usr/lib/python2.4/... and tell us what isn't mandatory and uses a lot of space for nothing.
If your are a Python expert you can still delete some files in $ROOTFS/usr/lib/python2.4/... and tell us what isn't mandatory and uses a lot of space for nothing.
+
** On the APF27, you can activate it without concerning about the FLASH size.
 +
* '''Python''' version installed by Buildroot is '''2.4'''.
  
 
* Launch Buildroot's menuconfig:
 
* Launch Buildroot's menuconfig:
<pre>
+
<pre class="host">
armadeus$ make menuconfig
+
$ make menuconfig
 
</pre>
 
</pre>
 
* In  
 
* In  
[[Image:Menuconfig_package.png]] <br>  
+
[[Image:Menuconfig_package.png]]
and in <br>  
+
<br> <br>  
 
[[Image:Menuconfig_package_scripting.png]] <br>  
 
[[Image:Menuconfig_package_scripting.png]] <br>  
 
choose <br>  
 
choose <br>  
 
[[Image:Menuconfig_package_python.png]] <br>
 
[[Image:Menuconfig_package_python.png]] <br>
* then save your configuration and build your system:
+
* then save your configuration and rebuild your system:
<pre>
+
<pre class="host">
armadeus$ make
+
$ make
 
</pre>
 
</pre>
* copy generated rootfs to your NFS directory or on your MMC/SD: [[Network_Configuration#Boot_from_NFS | Booting from NFS]] or [[MultiMediaCard#Booting_from_MMC.2FSD | Booting from MMC/SD]].
+
* reflash you rootfs or, if needed, copy it to your NFS directory or on your MMC/SD: [[Network_Configuration#Boot_from_NFS | Booting from NFS]] or [[MultiMediaCard#Booting_from_MMC.2FSD | Booting from MMC/SD]].
  
 
==Source code==
 
==Source code==

Revision as of 15:04, 15 July 2009

On this page you will learn how to create your first Python script for your Armadeus board. Python logo.png

Installation

  • Python interpreter and libraries are not installed in the default APF rootfs:
    • Currently it increases the rootfs size by 6 MBytes and so, without cleanup, it won't fit in the old APF9328 boards with 8 MBytes FLASH size. So for the moment, if you have an 8MB FLASH, you can only use it from a NFS or a MMC/SD rootfs. If your are a Python expert you can still delete some files in $ARMADEUS_ROOTFS/usr/lib/python2.4/... and tell us what isn't mandatory and uses a lot of space for nothing.
    • On the APF27, you can activate it without concerning about the FLASH size.
  • Python version installed by Buildroot is 2.4.
  • Launch Buildroot's menuconfig:
$ make menuconfig
  • In

Menuconfig package.png

Menuconfig package scripting.png
choose
Menuconfig package python.png

  • then save your configuration and rebuild your system:
$ make

Source code

  • First take your favorite editor/IDE and create the following script:
import sys
 
    print "APF says: Hello World ! ;-)"
    sys.exit(0)
  • Save it as hello.py

Compilation

Not needed. Transforming python script in executables hasn't been tested yet.

Running

  • Copy your hello.py script on your NFS export directory or on your MMC/SD
  • then on your APF console, launch it:
 # python hello.py
 APF says: Hello World ! ;-)
 #

Now it's up to you ! ;-) But keep in mind that Python is extremely powerful and libraries rich, so if you don't pay attention to memory usage of your scripts, you can easily reach the APF9328 RAM size limit: 16 MBytes.

Advanced usages

Disabling modules

Defaults python modules can be enabled/disabled by Buildroot menuconfig

Menuconfig package python.png

Installing modules

Default python package on buildroot is minimal, for certain usage, it necessary to install more modules. Here a list of module tested on apf9328 :

pyserial

This module is used to communicate through serial port (rs232). The package is really simple to install. Just download the module here [1] and unzip it on card (or on nfs filesystem). Once uncompressed just type :

# python setup.py install

Under the pyserial directory. Once installed, this directory is no longer needed.

Links

Other languages:

English Flag.svg English  •  French Flag.svg Français