Documentation:AVR32 Linux Development/How to build an embedded Erlang
From AVRFreaks Wiki
As of R13B04, an embedded version of Erlang can be built for the NGW100 using buildroot-2.3.0. Full documentation on cross-compiling Erlang can be found in the xcomp/README file inside the source distribution.
Contents |
[edit] Prerequisites
Assuming you've successfully built buildroot-2.3.0 and been able to create a bootable system from it. Next, you'll need a copy of the Erlang sources, available from http://erlang.org/download.html, or by cloning the git repository at http://github.com/erlang/otp.
[edit] Setup
You'll need to set up the following environment variables:
- ERL_TOP: Points to the top of the Erlang source tree
- PATH: Must include the avr32-linux-* commands, in $BUILDROOT/build_avr32/staging_dir/usr/bin
- TARGET_DIR: Desired installation directory on the NGW100, typically /usr/lib/erlang
- TMP_DIR: Temporary directory for creating the Erlang distribution
For example:
$ export ERL_TOP=~/Work/otp_src_R13B04 $ export PATH=$PATH:~/Work/buildroot-avr32-v2.3.0/build_avr32/staging_dir/usr/bin $ export TARGET_DIR=/usr/lib/erlang
[edit] Configuring
There are a number of steps to configure and build Erlang for the NGW100:
$ cd $ERL_TOP $ ./otp_build autoconf $ ./otp_build configure --xcomp-conf=$ERL_TOP/xcomp/erl-xcomp-avr32-atmel-linux-gnu.conf
This will configure a cross compile environment using the settings in the ./xcomp/erl-xcomp-avr32-atmel-linux-gnu.conf file.
[edit] Building
The next step is to build Erlang, this can take a while as it first must build a host-native version in order to compile .erl files, before it can build the avr32 version:
$ ./otp_build boot -a
[edit] Creating a Release
The next step is to create an Erlang release distribution that can be simply untarred on the NGW100:
$ ./otp_build release -a $TMP_DIR $ cd $TMP_DIR $ ./Install -cross -minimal $TARGET_DIR
Note that $TARGET_DIR specifies where on the NGW100 filesystem Erlang will be located, typically /usr/lib/erlang.
$ tar czvf /tmp/erlang-dist.tar.gz *
Will create the tar.gz file in /tmp.
[edit] Installation
Use scp to copy the erlang-dist.tar.gz file to the NGW100; don't copy it to /tmp as it likely won't fit, put it in /home/avr32.
$ scp /tmp/erlang-dist.tar.gz root@ngw.example.net:/home/avr32
Now, log into the NGW100 and type the following commands:
~ # mkdir /usr/lib/erlang ~ # cd /usr/lib/erlang ~ # tar xzvf /home/avr32/erlang-dist.tar.gz
Finally, create links to erl and erlc in /usr/bin:
~ # ln -s /usr/lib/erlang/bin/erl /usr/bin/erl ~ # ln -s /usr/lib/erlang/bin/erlc /usr/bin/erlc
You may also wish to set up links in /usr/bin for dialyzer, typer and escript if you use those.
