Skip to content

Building from Source

Adam Lindberg edited this page Jun 14, 2017 · 1 revision

Prerequisites

  • grisp/grisp-software checked out and built according to the README
  • grisp/otp (this repository) with the branch peerst/grisp-patches checked out

Build

  1. Change directory to the otp checkout

    $ cd otp
  2. Set the GRISP_TC_ROOT environment variable to point to the absolute path of the built grisp-software toolchain:

    $ export GRISP_TC_ROOT=/absolute/path/to/grisp-software/rtems-install/rtems-4.12
  3. Set your path to include the toolchain binaries:

    $ export PATH=$GRISP_TC_ROOT/bin:$PATH
  4. Prepare autoconf

    $ ./otp_build autoconf
  5. Run configure

    $ ./otp_build configure --xcomp-conf=xcomp/erl-xcomp-arm-rtems.conf --disable-threads --prefix=/otp
  6. Build the bootstrap system

    $ ./otp_build boot -a
  7. After a successful build, the file bin/arm-unknown-rtems4.12/beam is the elf executable. To get the file to boot from the SD-card one needs to run objcopy to make a raw binary out of the elf file since that is what the bootloader expects:

    $ arm-rtems4.12-objcopy -O binary bin/arm-unknown-rtems4.12/beam /path/to/SDcard/beam.bin
  8. Create and set a temporary install directory (only needed the first time):

    $ mktemp -d
    /var/folders/j2/fl737lzx5y5_3gn97sg_m9r40000gn/T/tmp.GtwzJaJp
    $ export INSTALLDIR=/var/folders/j2/fl737lzx5y5_3gn97sg_m9r40000gn/T/tmp.GtwzJaJp
  9. Remove previous build:

    $ rm -rf $INSTALLDIR/otp
  10. Build OTP to the install directory:

    $ make install DESTDIR=$INSTALLDIR
  11. However this doesn't do the install in a way that makes the paths correct. To fix this, move everything up two levels:

    $ cd $INSTALLDIR/otp
    $ mv lib{,.old}      # move aside since we create a new lib next
    $ mv lib.old/erlang/* .
    $ rm -rf lib.old
  12. Copy the beam files to the SD card.

    $ cd $INSTALLDIR
    $ cp -r otp /path/to/SDcard/

Miscellaneous

Package OTP as EZ Archives

This could be used to speed up access or at least minimize the number of files to be read from the SD-card.

  1. Start an Erlang shell in the OTP installation directory:

    $ cd $INSTALLDIR/otp/lib
    $ erl
  2. List all applications and create Erlang archive files for them:

    1> {ok, D} = file:list_dir(".").
    2> Ez = fun(F) -> zip:create(F ++ ".ez", [F], [{compress, all},{uncompress, [".beam",".app"]}]) end.
    3> [Ez(F) | F <- D].
    
Clone this wiki locally