NGW100 Package Building Notes

You are here: Andrew Ho > Software > NGW100 > Packages

This page documents some hacks I have had to apply to build packages for the NGW100. For information on setting up the buildroot based cross-compilation environment, see my page on buildroot for NGW100 on CentOS 5.3.

For the rest of the examples on this page, I use $BUILDROOT to represent the buildroot top-level directory, which is the one with the top level makefile; $AVR32 to represent $BUILDROOT/build_avr32/staging_dir, which contains the actual cross-compilation tools; and $NGW100 to represent $BUILDROOT/project_build_avr32/atngw100/root, which contains the actual root filesystem for the NGW100 target.

GNU nano Editor

The NGW100 only ships with a single editor, which is the BusyBox version of vi. A lot of users prefer the non-modal, beginner-friendly GNU nano editor. I built an NGW100 version of nano hacked for bracket matching. In the nano-1.2.5p build directory:

CC="$AVR32/bin/avr32-linux-gcc" \
LDFLAGS="-L$AVR32/lib -static" \
CPPFLAGS="-I$AVR32/include" \
CPP="$AVR32/bin/avr32-linux-cpp" \
./configure --host=avr --build=avr-unknown-none \
--disable-mouse --disable-speller --disable-glibtest --enable-nanorc

The above command results in a breakage on the regular expression library test, I think because we are cross compiling, and hence the test program doesn't work:

checking for regex.h... yes
checking for broken regexec... configure: error: cannot run test program while cross compiling
See `config.log' for more details.

I manually patched configure to unconditionally disable that test:

@@ -5800,6 +5800,7 @@
 echo "${ECHO_T}$ac_cv_header_regex_h" >&6

+cat >> /dev/null << end_regexec_check
 if test $ac_cv_header_regex_h = yes; then
   echo "$as_me:$LINENO: checking for broken regexec" >&5
 echo $ECHO_N "checking for broken regexec... $ECHO_C" >&6
@@ -5852,6 +5853,7 @@


Rerunning the former configure invocation, and then doing a normal make, resulted in a 450KB nano binary, which I installed as /usr/local/bin/nano on the NGW100. Running any ncurses based application also requires a terminfo database, normally located in /usr/share/terminfo. I copied the version from $NGW100/usr/share/terminfo, which contains a fairly minimal set of the most common terminals, to /usr/local/share/terminfo on the NGW100.

Build Verification

After the build, I created a $HOME/.nanorc with the following contents, which makes nano behave a bit more rationally as a Unix programmer's text editor:

set nohelp
set nowrap
set regexp
set suspend
set historylog

I can open and edit files directly on the NGW100, and all expected features, including regex find and replace, file browser, and tab filename completion, seem to work.


Netcat is an indispensible network testing tool. It basically lets you hook up network connections to stdin and stdout of other programs on the Unix command line. I built the original *Hobbit* authored Netcat version 1.10 variant (you can usually search for "nc110.tgz" to find it). To build it, manually edit the Makefile as follows:

@@ -9,12 +9,12 @@
 # pick gcc if you'd rather , and/or do -g instead of -O if debugging
 # debugging
+CFLAGS = -O -I$AVR32/include
 XFLAGS =       # xtra cflags, set by systype targets
-XLIBS =        # xtra libs if necessary?
+XLIBS =        -L$AVR32/lib
 # -Bstatic for sunos,  -static for gcc, etc.  You want this, trust me.
-CC = cc $(CFLAGS)
+CC = $AVR32/bin/avr32-linux-gcc $(CFLAGS)
 LD = $(CC) -s  # linker; defaults to stripped executables
 o = o          # object extension

Then, build with make linux. This results in an error (nice function name!):

/tmp/cclsEtZb.o: In function `gethostpoop':
netcat.c:(.text+0xf6e): undefined reference to `res_init'
collect2: ld returned 1 exit status
make[1]: *** [nc] Error 1
make: *** [linux] Error 2
make -e nc  XFLAGS='-DLINUX' STATIC=-static
make[1]: Entering directory `$NC110_SRC'
$AVR32/bin/avr32-linux-gcc -O -I$AVR32/avr32/include -s -DLINUX -static -o nc netcat.c -L$AVR32/lib
make[1]: Leaving directory `$NC110_SRC'

I found a fix from a comment on the freshmeat netcat page, which is to patch netcat.c as follows:

@@ -73,6 +73,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <fcntl.h>             /* O_WRONLY et al */
+#include <resolv.h>

 /* handy stuff: */
 #define SA struct sockaddr     /* socket overgeneralization braindeath */

Another make linux generates a 45KB nc binary, which I installed as /usr/local/bin/nc on the NGW100.

Build Verification

From the command line on an Internet-connected NGW100, run a command like this to fetch the front page of Google:

(echo 'GET / HTTP/1.1' ; \
 echo 'Host:' ; \
 echo 'Connection: close' ; \
 echo) | nc 80

If successful, you should see an HTTP/1.1 response, including headers, and probably delivered using HTTP/1.1 chunked Transfer-Encoding; with an entity body with the Google front page HTML.

Lua Scripting Language

TODO: add detailed notes. This builds out of the box with buildroot, but I had to manually copy some of the DLLs that it referenced in place.

LuaSocket Networking Library

The LuaSocket library adds general networking support to Lua, as well as specific client libraries, including an HTTP web client. I built LuaSocket 2.0.2.

With some normal makefile hacking, the library builds successfully, and I copied it to the NGW100. You can test the library by running something like lua -lsocket or lua -lsocket.http, which will get you into Lua's read-eval-print loop. However, I discovered that loading -lsocket.http failed, as did loading -lsocket -lmime, -lmime -lsocket, or any other combination where both mime.core and socket.core libraries were being loaded.

It appears that either Lua or μClibc (I would guess the latter) has a bug with loading two DLLs with the same file basename, but LuaSocket includes a socket/ and mime/ The fix is to patch the code and makefiles so that these are renamed to and You can track my detective work on the #lua IRC channel on (I used my old BBS nick of "yohan").

The diff is lengthy, so you can view it separately: LuaSocket diff for NGW100 build (you can also see a colorized version of the LuaSocket diff). Don't forget that the diffs contain $AVR32 references that need to point at your buildroot toolchain directory.

Build Verification

From the command line on an Internet-connected NGW100, run lua -lsocket.http to get to a Lua interactive toplevel prompt, and enter the following:

body = socket.http.request("");

You should see the HTML from the Google front page.

Guile Scheme Interpreter

Building the Guile Scheme interpreter required such package building effort that I have documented it on its own building Guile for the NGW100 page.

Andrew Ho (