Building from Source - grisp/otp GitHub Wiki
Prerequisites
grisp/grisp-software
checked out and built according to the READMEgrisp/otp
(this repository) with the branchpeerst/grisp-patches
checked out
Build
-
Change directory to the
otp
checkout$ cd otp
-
Set the
GRISP_TC_ROOT
environment variable to point to the absolute path of the builtgrisp-software
toolchain:$ export GRISP_TC_ROOT=/absolute/path/to/grisp-software/rtems-install/rtems-4.12
-
Set your path to include the toolchain binaries:
$ export PATH=$GRISP_TC_ROOT/bin:$PATH
-
Prepare autoconf
$ ./otp_build autoconf
-
Run configure
$ ./otp_build configure --xcomp-conf=xcomp/erl-xcomp-arm-rtems.conf --disable-threads --prefix=/otp
-
Build the bootstrap system
$ ./otp_build boot -a
-
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 runobjcopy
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
-
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
-
Remove previous build:
$ rm -rf $INSTALLDIR/otp
-
Build OTP to the install directory:
$ make install DESTDIR=$INSTALLDIR
-
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
-
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.
-
Start an Erlang shell in the OTP installation directory:
$ cd $INSTALLDIR/otp/lib $ erl
-
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].