[erlang-questions] inet_gethost fails with enomem on AVR32 (R14B03)

Winston Smith <>
Thu Aug 18 06:22:11 CEST 2011

I am trying to update my AVR32 system (an Atmel NGW100 development
board) to use OTP R14B03 and a reltool (via "rebar generate") based
release -- previous releases were hand-built.  However, I'm having
problems getting the node to start up.  I have built R14B03 using
Atmel's buildroot-v3.0.0 for NGW100 and aside from a couple of issues
(avr32-linux-gcc internal errors due to -O3, fixed by specifying -O
and a missing implementation of finite() in uclibc, fixed by passing
-Dfinite=__finite in CFLAGS), I have been able to fire up the erlang
prompt via the erl command.  I am using the
erl-xcomp-avr32-atmel-linux-gnu.conf xcomp file I supplied a while
back and is included in the otp releases.

Using the "reltool via rebar generate" to create an AVR32 based
release of my app, I first ran into issues with the following error on
the NGW100 platform:

# bin/mynode console
Exec: /home/avr32/mynode/erts-5.8.4/bin/erlexec -boot
/home/avr32/mynode/releases/1/mynode -mode embedded -config
/home/avr32/mynode/etc/app.config -args_file
/home/avr32/mynode/etc/vm.args -- console
Root: /home/avr32/mynode
(no error logger present) error: "Error in process <0.2.0> with exit
value: {badarg,[{erl_prim_loader,check_file_result,3},{init,patch_dir,2},{init,'-patch_path/2-lc$^0/1-0-',2},{init,eval_script,8},{init,do_boot,3}]}
{"init terminating in

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

I couldn't figure out this error (or the "no error logger present"
since sasl is included in the release), but I was able to work around
this by commenting out "+K true" and "+A 5" in the vm.args file, as

## Enable kernel poll and a few async threads
## +K true
## +A 5

So now, I get a bit further, but it fails trying to run inet_gethost
with an enomem error which I'm now stuck at:

# bin/mynode console
Exec: /home/avr32/mynode/erts-5.8.4/bin/erlexec -boot
/home/avr32/mynode/releases/1/mynode -mode embedded -config
/home/avr32/mynode/etc/app.config -args_file
/home/avr32/mynode/etc/vm.args -- console
Root: /home/avr32/mynode
{error_logger,{{2011,8,17},{23,43,58}},"~s~n",["Error in process
<0.16.0> with exit value:
{enomem,[{erlang,open_port,[{spawn,\"inet_gethost 4
Segmentation fault

A wild guess would be that there's some kind of problem with the
packet sizes being passed into inet_gethost from
inet_gethost_native.erl is causing a memory allocation error ... I
suppose it's also possible that my AVR32 system just doesn't have
enough memory to run everything (the NGW100 seems to have about ~30MB
of memory available when running Linux), but I'm not sure this is the
case; I think there's a xcomp bug here.

So my question(s) are:

1) Has anyone seen anything like this when cross compiling erlang? (or
otherwise got any ideas!)
2) How do I build otp with debug mode enabled?  In inet_gethost.c, I
found the ERL_INET_GETHOST_DEBUG environment variable, but setting it
to say 5 doesn't seem to do anything!
3) Is there a way to configure or disable the use of inet_gethost
(i.e. is it even necessary?)

I had to hack rebar to add a new reltool.config setting "root_dir"
which is passed into reltool:eval_target_spec() as the 2nd argument,
this lets me point "rebar generate" at the cross compiled OTP instance
for AVR32.  I'm still working on adding something to allow rebar to
cross compile the port driver!

It's tricky trying to debug this on an embedded platform, so any help
is greatly appreciated!



More information about the erlang-questions mailing list