Run Python with CloudFlash (arm926ej-s)

Preface

CloudFlash is a micro SD card adapter with built-in wireless LAN. It is an SD card that the storage part of Eye-Fi and FlashAir is sold separately. Since Linux is running inside, you can play various things.

Suddenly, I wanted to run a Python script on CloudFlash and automatically upload the captured image to Flickr etc., so I decided to try Python cross compile first.

This is the memorandum.

Python 2.7.2 Build procedure

  1. sorcery codebench or launchpad Get the toolchain from -arm-embedded). Here, I used the latest Sourcery CodeBench Lite 2014.05-29.

  2. Download the Python source code and the patch for cross compile on a suitable Linux PC. The patch is provided by Paul Gibson, a bibliography. Thanks!

    $ wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
    $ wget http://randomsplat.com/wp-content/uploads/2011/10/Python-2.7.2-xcompile.patch
    
  3. First, build Python for the host. The hostpython and hostpgen generated here will be needed for later cross-compilation.

    $ tar xjf Python-2.7.2.tar.bz2  
    $ cd Python-2.7.2  
    $ ./configure
    $ make python Parser/pgen  
    $ mv python hostpython  
    $ mv Parser/pgen hostpgen  
    $ make distclean
    
  4. Apply the patch and reconfigure for arm926ej-s.

    $ patch -p1 < ../Python-2.7.2-xcompile.patch
    $ CC=arm-none-linux-gnueabi-gcc CXX=arm-none-linux-gnueabi-g++ AR=arm-none-linux-gnueabi-ar RANLIB=arm-none-linux-gnueabi-ranlib BASECFLAGS=-mcpu=arm926ej-s ./configure --host=arm-none-linux --build=x86_64-linux-gnu --prefix=/python
    
  5. Make. I get a warning like unrecognized format function type [-W format =], but I don't care.

    $ make HOSTPYTHON=./hostpython HOSTPGEN=./hostpgen
    
  6. Collect the files to be copied to the rootfs of the target (CloudFlash) in _install.

    $ make install HOSTPYTHON=./hostpython CROSS_COMPILE=arm-none-linux-gnueabi- CROSS_COMPILE_TARGET=yes prefix=~/Python-2.7.2/_install
    
  7. Delete unnecessary information by stripping to make it as small as possible.

    $ cp -rf _install _install_stripped
    $ for SO in _install_stripped/lib/python2.7/lib-dynload/*.so; do arm-none-linux-gnueabi-strip ${SO}; done
    $ arm-none-linux-gnueabi-strip _install_stripped/bin/python2.7
    $ rm _install_stripped/bin/python
    $ ln -s python2.7 _install_stripped/bin/python
    

Run Python with Cloud Flash

  1. Copy the entire _install_stripped to your CloudFlash SD card.
  2. Refer to here and telnet to CloudFlash.
  3. If you try cd / mnt / sd / _install_stripped / bin and ./python etc., you can see that it works well. python_on_cloudflash.png

Automatically start some processing with CloudFlash

When I telnet to CloudFlash and take a peek, the startup process is as follows.

/etc/inittab


# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquel

null::sysinit:/bin/mount -o remount,rw /
null::sysinit:/bin/mount -t proc proc /proc
null::sysinit:/bin/mount -t sysfs sysfs /sys

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
console::sysinit:/etc/init.d/rcS

# Start an "askfirst" shell on the console (whatever that may be)
#::askfirst:-/bin/ash
#ttyS0::respawn:-/bin/ash #enter shell automatically
ttyS0::askfirst:-/bin/ash #enter shell needs enter 

/etc/init.d/rcS(Excerpt)


#cp /mtd/dnsd.conf to /etc
cp /mnt/mtd/config/dnsd.conf /etc
#cp /mtd/udhcpd.conf to /etc
cp /mnt/mtd/config/udhcpd.conf /etc
cp /mnt/mtd/config/wsd_backup.conf /etc/wsd_backup.conf

#a2&

# autorun.sh from sd in case need to perform some test mode
if [ -f /mnt/sd/autorun.sh ]
then
	echo "run autorun.sh"
	sleep 1
	chmod 777 /mnt/sd/autorun.sh
	/mnt/sd/autorun.sh&     
fi
echo "rcS done"

If you put ʻautorun.sh` in the root of the SD card, you can do various things.

References

Recommended Posts

Run Python with CloudFlash (arm926ej-s)
Run Python with VBA
Run Blender with python
Run iperf with python
Run python with PyCharm (Windows)
Let's run Excel with Python
Run Label with tkinter [Python]
Run DHT22 with RasPi + Python
Run Rotrics DexArm with python API
Run mruby with Python or Blender
Run XGBoost with Cloud Dataflow (Python)
Run Aprili from Python with Orange
Run python3 Django1.9 with mod_wsgi (deploy)
Until you run python with apache
FizzBuzz with Python3
Scraping with Python
Run servo with Python on ESP32 (Windows)
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Run a Python web application with Docker
Excel with Python
Microcomputer with Python
Cast with python
Python> Run with run-time arguments> Use import argparse
Run VMware vSphere 6 vSphere API with Python script (pyvmomi)
Run Flask on CentOS with python3.4, Gunicorn + Nginx.
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
Sequential search with Python
"Object-oriented" learning with python
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
1.1 Getting Started with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Scraping with Python + PhantomJS
Posting tweets with python