Custom Perl For Chumby

From Chumby Wiki
Revision as of 16:20, 30 May 2008 by Nightmedia (Talk | contribs)

Jump to: navigation, search

These are the instructions for building Perl to work on the Chumby.

Since cross-compiling it would be an extremely tedious task, we found a way to do it on an emulated ARM environment.

Considering that you followed the instructions on the page linked above, and you have now a fully functional ARM emulator, you can build now Perl on it, then pack it and save it on an USB stick, ready to be used on a Chumby.

Building Perl on the emulated ARM platform

For that, create a folder /mnt/usb. This will be the same as the base folder for applications that will run on the device. In that folder create the following full path:

  /mnt/usb/usr/local/bin

The perl version that needs to be compiled for the Chumby is 5.10.0 or later. Get the Perl source from here:

  http://www.perl.com/download.csp

We have to use the 5.10, because the 5.8.8 threading is broken on ANY debian platform (i386, ARM, or otherwise). The error one gets is a version mismatch of threads.pm (with a required version of 16384), but the actual error is somewhere in the libpthreads system library. There is no workaround for this.

Even the 5.10 threading is broken on Debian i386, but for some reason it works fine on the ARM platform. If you are trying to run the automation script on a debian i386, you will get a Segfault exception the first time a socket is being opened in a thread. The error occurs on the manager, when the client is opening a connection.

This segfault does not occur on the emulated ARM platform. Chumby testing is pending, but it should work, since all other low-level perl tests that I have done between the Chumby and the ARM emulator returned similar results.

Memory usage

The Perl 5.10.0 should not use more memory than the 5.8.8 when tested on windows. From the initial tests run on the ARM emulator, the scripts did not use over 7MB of memory at any time.

It is expected that with a real life test payload, an extra MB or two would be used. When writing a test, if you expect to deal with large amounts of data, it is therefore recommended to persist the data to disk (flash), to minimize the RAM memory usage.

Build parameters for Perl 5.10.0 (or later)

In general you can use the defaults, but the following have to be entered as specified:

Hard defined installation path:

  By default, perl5 will be installed in .../../bin
  ...
  Installation prefix to use? (~name ok) [.../..] /mnt/usb/usr/local

Installation prefix for files:

  What installation prefix should I use for installing files? (~name ok)
  [/usr/local] /mnt/usb/usr/local

The perl 5.10 brings a few new things. Among them the relocatable @INC

  Would you like to build Perl so that the installation is relocatable
  ....
  Use relocatable @INC? [n] y
  Installation prefix to use? (~name ok) [.../..] /mnt/usb/usr/local

Build threading Perl:

  Perl can be built to take advantage of threads on some systems.
  ...
  Build a threading Perl? [n] y

Setting the path for public executables:

  Pathname where the public executables will reside? (~name ok)
  [/usr/local/bin] /mnt/usb/usr/local/bin

Extra modules:

  Install any extra modules (y or n)? [n] y
  Extras? Net::Daemon String::CRC32 File::Path File::Copy IO::Handle

Hard path to the perl installed on USB:

  What shall I put after the #! to start up perl ("none" to not use #!)?
  [none] /mnt/usb/usr/local/bin/perl

Other installation paths:

  Where do you keep publicly executable scripts? (~name ok) 
  [.../] /mnt/usb/usr/share
  Pathname where the add-on public executables should be installed? (~name ok)
  [.../../bin] /mnt/usb/usr/bin
  Pathname where add-on public executable scripts should be installed? (~name ok)
  [.../../bin] /mnt/usb/usr/bin
  Pathname where the private library files will reside? (~name ok)
  [.../../lib/perl5/5.10.0]
  Installation prefix to use for add-on modules and utilities? (~name ok)
  [.../..]
  Pathname for the site-specific library files? (~name ok)
  [.../../lib/perl5/site_perl/5.10.0]
  Where do you want to put the public architecture-dependent libraries? (~name ok)
  [.../../lib/perl5/5.10.0/i686-linux-thread-multi]

Extract the compiled Perl

After running make, make test, and make install, you can pack the files under

 /mnt/usb/usr

This is all you need to run custom perl scripts on the chumby.

If you need any extra CPAN modules, you can install them before packing everything, calling perl with the full path to the executable:

 /mnt/usb/usr/local/bin/perl -MCPAN -e shell

This should allow you to compile and install any new CPAN modules directly in the /mnt/usb/usr/local/ path.

Pre-compiled, ready-to-run Perl

You can download here the Perl 5.10 compiled with threads suppport on the ARM emulator. This is the clean Perl install, with NO installed CPAN modules. Currently threading is not completely compatible with the Chumby, since debian uses libc.2.3.6 and the Chumby uses libc.2.4, so avoid using threading, use forking instead.

 media:perl.5.10.threaded.arm.usb.working.tgz

Download here the Perl and the include libraries as they should be installed on a Chumby USB key. They will get unpacked in "usr", which will appear on the Chumby as /mnt/usb/usr. This is the file that will get updated on a regular basis. This build contains some generic CPAN modules that can be useful when writing Perl scripts on the Chumby. Among them are the libwww package and the Mail::Sender package.

 media:Arm.usb.5.10.Chumby.tgz

Download here the packed /lib folder from the QEMU ARM environment.

 media:qemuARMLibs.tgz