Historical EuphoriaAndRaspberryPi, Revision 4
The following is an introduction to building Euphoria (and other software) for your Raspberry Pi. The steps used here should work for other ARM devices as well, including the Nokia N900, B&N Nook Color, etc. This wiki page will not detail how to get started using your Pi, since there are already some excellent tutorials out there. Check out the official Raspberry Pi wiki at http://elinux.org/RPi_Hub and also the forums at http://www.raspberrypi.org/phpBB3/index.php for some good guides. I will try to give explicit details and examples for all aspects concerning Euphoria.
Thanks,
Ira
Download Links
Soft-float compatible (Debian,etc..) -> eubin-arm-cortex-a8-2012-01-13-ee49c6b8a340.tar.gz
Hard-float compatible (Raspbian,Arch,etc..) -> eubin-armv6hf.tar.gz
Getting Started
To get started, we first need to choose a specific distribution to use on the Pi since they have some key differences. This tutorial is based on the Raspbian distribution, since it is currently the officially recommended distribution. Other options include Debian Wheezy, Arch Linux, Fedora, QTonPi, and several more; a complete list is given here. Whichever your preference, it is important to note if the distribution uses the hard-float (-mfloat-abi=hard) or soft (-mfloat-abi=soft) ABI (Application Binary Interface). The hard-float distributions take advantage of the FPU hardware on the Pi for floating point calculations, making software that use extensive floating point calculations significantly faster. Soft float distributions perform these calculations in software, as the name implies. There is also the soft-fp (-mfloat-abi=softfp) convention, which uses FPU hardware but remains compatible with the soft ABI. A decent explanation is given here and here.
Now the easiest way to get Euphoria is to take pre-built binaries which are targeted for your distribution choice, either hard or soft. Currently, soft-float compatible Euphoria binaries are available here. Hard float may be available in the future (will check with Admins). It is recommended to not mix the binaries (things will usually just break), but the exception is that some soft-float binaries may work fine on a hard-float distribution if the binaries are self-contained and do not depend on any external libraries. The current soft-float binaries do not always work correctly on Raspbian.
To get started, boot up your PI and login. You can either work in the initial terminal presented or start a graphical sessison (type 'startx') and pull up LXTerminal inside LXDE (your desktop environment).
-- Download ARM eubins - This link is for the soft-float version! pi@raspberrypi ~/tutorial $ wget http://openeuphoria.org/eubins/linux/4.1.0/arm-32-bit/eubin-arm-cortex-a8-2012-01-13-ee49c6b8a340.tar.gz -- Unzip pi@raspberrypi ~/tutorial $ gunzip eubin-arm-cortex-a8-2012-01-13-ee49c6b8a340.tar.gz pi@raspberrypi ~/tutorial $ tar -xvf eubin-arm-cortex-a8-2012-01-13-ee49c6b8a340.tar -- Make a new euphoria directory pi@raspberrypi ~/tutorial $ sudo mkdir -p /usr/share/euphoria/bin -- Change ownership of the euphoria directory to normal users pi@raspberrypi ~/tutorial $ sudo chown -R pi.users /usr/share/euphoria/ -- Copy binary files into euphoria pi@raspberrypi ~/tutorial $ mv *.tar ../. pi@raspberrypi ~/tutorial $ cp * /usr/share/euphoria/bin/. -- Check current path and add the euphoria bin directory pi@raspberrypi ~/tutorial $ echo $PATH -> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games pi@raspberrypi ~/tutorial $ nano ~/.bashrc -- Add these lines to the end of .bashrc PATH=$PATH:/usr/share/euphoria/bin export PATH -- End of lines to add to .bashrc -- Update your path so you can use it now pi@raspberrypi ~/tutorial $ source ~/.bashrc pi@raspberrypi ~/tutorial $ echo $PATH -> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/share/euphoria/bin -- Check that Euphoria is working pi@raspberrypi ~/tutorial $ eui -v -> Euphoria Interpreter v4.1.0 development -> 32-bit Linux, Using System Memory -> Revision Date: 2012-01-07 12:54:32, Id: 5455:ee49c6b8a340 -- Now lets get the source files so we have includes,demos,tests,etc.. pi@raspberrypi ~/tutorial $ mkdir src pi@raspberrypi ~/tutorial $ cd src/ pi@raspberrypi ~/tutorial/src $ wget http://sourceforge.net/projects/rapideuphoria/files/Euphoria/4.0.5/euphoria-LINUX-4.0.5-src.tar.gz pi@raspberrypi ~/tutorial/src $ cp -r euphoria-LINUX-4.0.5/* /usr/share/euphoria/.
So remember that on Raspbian, the soft-float euphoria binaries will not work correctly when floating points are involved. First, lets show that the binary we have is indeed soft-float and then do an example of why it doesn't work! Code compiled with hard-float will always have the following line in the 'readelf -A' output: "Tag_ABI_VFP_args: VFP registers"
-- Check eui pi@raspberrypi ~/tutorial $ readelf -A /usr/share/euphoria/bin/eui Attribute Section: aeabi File Attributes Tag_CPU_name: "6" Tag_CPU_arch: v6 Tag_ARM_ISA_use: Yes Tag_THUMB_ISA_use: Thumb-1 Tag_FP_arch: VFPv2 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte Tag_ABI_enum_size: int Tag_ABI_HardFP_use: SP and DP -- Check a random binary on your system which is hard float pi@raspberrypi ~/tutorial $ readelf -A /usr/bin/curl Attribute Section: aeabi File Attributes Tag_CPU_name: "6" Tag_CPU_arch: v6 Tag_ARM_ISA_use: Yes Tag_THUMB_ISA_use: Thumb-1 Tag_FP_arch: VFPv2 Tag_ABI_PCS_wchar_t: 4 Tag_ABI_FP_denormal: Needed Tag_ABI_FP_exceptions: Needed Tag_ABI_FP_number_model: IEEE 754 Tag_ABI_align_needed: 8-byte Tag_ABI_align_preserved: 8-byte, except leaf SP Tag_ABI_enum_size: int Tag_ABI_HardFP_use: SP and DP Tag_ABI_VFP_args: VFP registers Tag_DIV_use: Not allowed
Ok, so lets prove to ourselves that this soft-float eui does not always work correctly when dealing with atoms!
pi@raspberrypi ~/tutorial $ touch cos.ex pi@raspberrypi ~/tutorial $ nano cos.ex -- Lines to add include std/io.e include std/math.e include std/convert.e atom angle, degreesToRadians = 3.14159/180.0 sequence params = command_line() if length(params) = 3 then angle = to_number(params[3]) else abort(0) end if printf(1,"The cos of %0.2f degrees is %0.6f \n",{angle,cos(angle*degreesToRadians)}) -- End of lines to add pi@raspberrypi ~/tutorial $ eui cos.ex 45 The cos of 45.00 degrees is 6.864136 -- The answer should be: The cos of 45.00 degrees is "0.707107"
Cross-compiling Euphoria
First, cross-compiling is the process of compiling software for another architecture on your host system. For example on my Ubuntu Linux desktop, I can compile software for my Windoze 7 laptop or my Armv7 Nokia phone. This tutorial will walk through the steps necessary to cross-compile Euphoria for your Raspberry Pi but will also work for general software to any other architecture. I prefer using Scratchbox 2; a cross-compiliation engine which neatly handles the cross-compiling process and is very flexible. More info about the project here. I performed these steps on Ubuntu 12.04 but they should work on most major linux distributions by using your distribution's package manager (apt-get, pacman, yum, etc..).
[ira ~/Code/sbox2] $ sudo apt-get install scratchbox2 qemu-user qemu-system [ira ~/Code/sbox2] $ mkdir images && cd images [ira ~/Code/sbox2/images] $ wget http://files.velocix.com/c1410/images/raspbian/2012-12-16-wheezy-raspbian/2012-12-16-wheezy-raspbian.zip [ira ~/Code/sbox2/images] $ sha1sum 2012-12-16-wheezy-raspbian.zip
- diff to current revision, view current revision history, backlinks
- Last modified Dec 24, 2012 by Jerome