- Timestamp:
-
12/11/14 03:06:21 (9 years ago)
- Author:
-
Chris Johns
- Comment:
-
--
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v1
|
v2
|
|
4 | 4 | |
5 | 5 | |
6 | | Python is a programming language that can be embedded in user programs giving them the added functionality of a fully featured scripting language. You can find out more about Python by visting its web site - |
| 6 | Python is a programming language that can be embedded in user programs giving them the added functionality of a fully featured scripting language. You can find out more about Python by visiting its web site - |
7 | 7 | |
8 | 8 | http://www.python.org/ |
… |
… |
|
10 | 10 | |
11 | 11 | |
12 | | Python and RTEMS are a great combination. RTEMS provides you with a stable, scalable real-time operating system on which you build your applications. It also allows you to run low priority threads for monitoring and managment functions. SNMP and a webserver are examples of typical services and interfaces you find on embedded devices. These days with more internet integration in embedded real-time products the number of complex protocols grows. Python has an extensive protocol library that can be used by your application to meet these demands. For example you could send an email using SMTP, fetch configuration data from a POP or IMAP email account, or via the HTTP protocol from a web server. |
| 12 | Python and RTEMS are a great combination. RTEMS provides you with a stable, scalable real-time operating system on which you build your applications. It also allows you to run low priority threads for monitoring and management functions. SNMP and a webserver are examples of typical services and interfaces you find on embedded devices. These days with more internet integration in embedded real-time products the number of complex protocols grows. Python has an extensive protocol library that can be used by your application to meet these demands. For example you could send an email using SMTP, fetch configuration data from a POP or IMAP email account, or via the HTTP protocol from a web server. |
13 | 13 | |
14 | 14 | So far I have used on RTEMS the following modules - |
15 | 15 | |
16 | | #The httplib (requires some minor, see Sourceforge Bug #1229646) to read web pages from a number of web servers. |
17 | | #The imaplib to open and read my email INBOX. |
18 | | #The smtplib to send email. I sent email to Joel to say hi. This uses the email package that can handle generating and parsing email. |
19 | | #The os module. I was able to list, change and make directories. |
| 16 | 1. The httplib (requires some minor, see Sourceforge Bug !#1229646) to read web pages from a number of web servers. |
| 17 | 1. The imaplib to open and read my email INBOX. |
| 18 | 1. The smtplib to send email. I sent email to Joel to say hi. This uses the email package that can handle generating and parsing email. |
| 19 | 1. The os module. I was able to list, change and make directories. |
20 | 20 | |
21 | 21 | If you use C++ in your application you can use PyCXX to integrate your C++ code to Python. The PyCXX project can be found at http://cxx.sourceforge.net/. |
… |
… |
|
27 | 27 | RTEMS version is 4.6 but 4.7 will be even easier to support thanks to Ralf's excellent work in cleaning up the RTEMS header files. The RTEMS build is multilib therefore the multilib library install paths are used. |
28 | 28 | |
29 | | Python running on most modern machines makes use of dynmanic loading of code. On Unix this is shared libraries and on Windows this is a DLL. On RTEMS we do not support dynamic loading so we need to build and include in the Python library required modules. Python normally handles this by running a Python program in the new Python intepreter. This program performs a range of checks and determines the modules the platform requires. We cannot do this for RTEMS so we have a list of modules and add them to the generated Makefile. |
| 29 | Python running on most modern machines makes use of dynamic loading of code. On Unix this is shared libraries and on Windows this is a DLL. On RTEMS we do not support dynamic loading so we need to build and include in the Python library required modules. Python normally handles this by running a Python program in the new Python interpreter. This program performs a range of checks and determines the modules the platform requires. We cannot do this for RTEMS so we have a list of modules and add them to the generated Makefile. |
30 | 30 | |
31 | 31 | The build machine is running Fedora Core 3 with a working RTEMS tool set. |
… |
… |
|
34 | 34 | * Fetch the Python patch from the RTEMS web site (ftp://ftp.rtems.org/pub/rtems/4.6.99.2/contrib/python). |
35 | 35 | * Unpack the Python source. |
36 | | * Perform a native build for the build machine outside the Python source tree. We need to create a local program call ''pgen''. Python does not cross-compile out of the box and so a simple work around is to build Python for the local machine first and reference it. The ''pgen'' program is not used in the cross-compile for RTEMS but no reference results in it tring to be cross-compiled and run which will not succeed. |
| 36 | * Perform a native build for the build machine outside the Python source tree. We need to create a local program call ''pgen''. Python does not cross-compile out of the box and so a simple work around is to build Python for the local machine first and reference it. The ''pgen'' program is not used in the cross-compile for RTEMS but no reference results in it trying to be cross-compiled and run which will not succeed. |
37 | 37 | |
38 | 38 | $ tar jxf Python-2.4.1.tar.bz2 |
… |
… |
|
50 | 50 | |
51 | 51 | |
52 | | You will end up wuth a Python library and Python header files ready for your application. |
| 52 | You will end up with a Python library and Python header files ready for your application. |
53 | 53 | = RTEMS Python Application = |
54 | 54 | |
… |
… |
|
88 | 88 | The build script in the example directory - |
89 | 89 | |
90 | | #Builds 3 C files |
91 | | #Run the local Python 2.4 interpreter to compile all the python code. We only need the compiled python code. |
92 | | #Creates a tar file of the compiled Python library code. |
93 | | #Link the example. |
94 | | #Convert to a binary image. |
95 | | #Compress the image. The Cybertec Microcore boot monitor accept gzip and 7zip files. |
96 | | = RTEMS Python Build Script#[wiki:Script script] = |
| 90 | 1. Builds 3 C files |
| 91 | 1. Run the local Python 2.4 interpreter to compile all the python code. We only need the compiled python code. |
| 92 | 1. Creates a tar file of the compiled Python library code. |
| 93 | 1. Link the example. |
| 94 | 1. Convert to a binary image. |
| 95 | 1. Compress the image. The Cybertec Microcore boot monitor accept gzip and 7zip files. |
| 96 | = RTEMS Python Build Script = |
97 | 97 | |
98 | 98 | |
99 | 99 | The script requires you supply 4 options. The options are not checked. You can down the script with the example. See the RTEMS Python Application section. |
100 | 100 | |
101 | | #The RTEMS target. For example ''m68k'' for ''m68k-rtems''. |
102 | | #The CPU or BSP label. This is the directory the library and headers are installed into under the RTEMS prefix. |
103 | | #The compiler flags for the CPU. For example the Coldfire 5272 is m5200. This is separared from the CPU name so the processors such the i386 family can be supported. |
104 | | #The prefix is the path the installed RTEMS. |
| 101 | 1. The RTEMS target. For example ''m68k'' for ''m68k-rtems''. |
| 102 | 1. The CPU or BSP label. This is the directory the library and headers are installed into under the RTEMS prefix. |
| 103 | 1. The compiler flags for the CPU. For example the Coldfire 5272 is m5200. This is separared from the CPU name so the processors such the i386 family can be supported. |
| 104 | 1. The prefix is the path the installed RTEMS. |
105 | 105 | |
106 | 106 | The script does not build in unicode support into Python. If you require unicode support you need remove ''--disable-unicode'' from the configure command line and place the unicode modules into the Modules list the script contains. Unicode is disabled as it contains a number of large 64K byte tables. These are not correctly declared as ''const'' so end up in the executable and then in the data space. |