The Computer Corner Take II (#6) by Bill Kibler

To see more Computer Corner articles look here: CCII page or check out the Home Page .

Atmel NGW100 as an embedded server

The new project and what is needed

Last year I worked on several embedded projects, one of which used SiLabs 8051 boards and chips. I liked the use of the developer boards for the project, because they provided an inexpensive way to get a project on line quickly and cheaply. These "Target/Prototyping" boards come in many flavors and cost from $35 to over $100. Their fully featured F120 board runs about $50 and has plenty of connectors for hooking up other devices.

At one point we decided it would have been nice to have ethernet support and I checked out a few options. We used the SiLabs AB4 ethernet development board ($35) which worked using the closed C code libraries. Some of the options needed a $1500 compiler package and as such I found the overall package a bit combersome to use. Our next option was a WizNet chip, these $25 chips are designed for 8-bit cpus and need no fancy networking stack as did the SiLabs part. I did some test code using our MyForth and my co-developers expansion board, that showed very little coding was needed to get the ethernet support.

The co-developer is still working on a project using the WizNet chip and a smaller SiLabs device under MyForth. I personally found the experience a little too limiting and have struck out on my own to find a better solution. You see I have several possible projects that need a low-cost, off the shelf, web host and embedded controller. Part of the projects are designed to become articles and as such the boards need to be mass produced and available from general supply houses. The SiLabs boards are that, but require too much embedded programming skills for a more general audience. I also didn't want to re-create the networking stack or programming languages - simply put I wanted linux on board.

The first step on the project was defining the design limits and needs. Since I have some ideas about finial design and costing for a few of the projects, the criteria seemed pretty straight forward to set out. The criteria I selected was this:

Not much of a list and pretty much open ended as far as cpu type or memory. A few prime considerations, such as cost and no fan really drop lots of normal options like a stock PC or laptop from the selection process. However I did discover several ITX sized motherboards running Intel's ATOM or AMD's GEODE that might work with costs in the mid $50s. However most of these cheap boards needed ram and ATX power supplies which adds back another $50 to $100 on to the cost. So it is pretty questionable getting these stock boards under $200 as a finished product. However from a development standpoint they have lots of good features and we know most versions of linux would run without problems or special coding.

Alternatives to stock PC/x86 motherboards

My first thought was looking at ARM devices. There has been considerable activity of late on using ARM chips as low cost options to x86 devices. OLPC uses a cheap x86 but has been considering changing to ARM in order to get the overal cost down. Maybe ARM might be just what I need. I hunted down lots of web sites advertising ARM embedded controllers or systems and got pretty frustrated. There are not many for under $200 in single units and only a few that in lots of 100 drop below the $100 limit. Atmel make a cheap ARM chip, but all their prototype boards run over $700, as they don't sell only the boards. However I did notice they have a "Reference Design" board for about $90. I checked that out and found the design was for a linux powered gateway card using their 32 bit AP7000. The more I checked, the better the board looked and the more web sites I found supporting it.

I looked at more ARM boards, but kept coming back to Atmel's NGW100, and thus ended up buying one from Digikey as they had the lowest price at the time. Within a week I had the small card in my hand and nothing else. I can't be 100% sure as I never found any documentation to say exactly what comes in the box, but all that was in mine was the board itself and one very small paper basically pointing me at the Atmel web sites. On the regular dev boards, you get a DVD of stuff, but not with the NGW100 - however you can download images of the DVD from one site, although I was never able to get more than the limited version (680M), as the full DVD version always failed before completion. There are no BiTorrent sites available which is the only way I can get very large files on my system.

After some checking, I discovered the only item missing from the limited version, is the VMware debian image with all the tools already installed properly. Since I have a VMware license and use it for some of my develoment work, I was a bit disappionted not to have the image, but you can do the install on your own linux system. Supposedly the boards come loaded with a running linux gateway system, so using the official tools is not necessary to test out the system.

Never that simple...

As I said earlier, I am not sure my unit was not used or missing parts as it did not boot up as stated. I believe the docs all say it should boot from the on board flash when direct from the factory, but mine tried instead to boot from TFTP server at IP 172.24.41.2. That is a private IP address typical of a personal subnet. This required some digging around to find out what a "normal" boot command might be, and thus I got my first introduction to this products major problem - very bad documentation. You see - there is no place on any of the three web sites that documents factory settings, or what comes in the box. After some digging you can fine some startup help files, but most assume your using some other board in their developers packages. I guess the idea goes something like this - buy the developer package at $700, and after you figure it all out, then buy the reference design to play with. I must say however that based on the questions posted, most users of the board just buy it like I did.

So I spent about a week reading all the information and how-to's on the three sites that support Atmel products, as well as the information in the appnotes and documentation section of the DVD information. My overall feeling is their documention is some of the worst I have come accross in recent time. That done by Atmel staff has the feeling it was done by someone who picked the short straw and didn't get to go drinking. To say some of the topics covered make no sense or explain nothing would be giving them more credit than they deserve. The NGW100 is treated as - " oh yes, we do need to cover it at some point later, maybe...".

By going through all the sources, I eventually found the commands for the boot loader and was able to get it to boot correctly. You need to use the WAN ethernet port and have a DHCP server on it. After booting it will present a web page you can use that has on-line docs and help files that are the same as in the DVD package - which are pretty useless for the NGW100. I will be writing another article that covers using the NGW100 to help other new users understand all those missing docs they really need. I ran several tests and all seemed to work as noted, although I still know very little about the product.

The learning curve starts

Now that it was working and I was starting to understand a few things, it was time to try and venture off a little. The device can boot from SD ram devices or TFTP sites, which gives you a few alternatives to play with. I bought the unit with the idea of using the SD ram option and thus started to try that next. Problems a plenty popped up, it can only use 2GB rams and then only by partitoning them such that the boot partition is small, I used both 64 and 32MB sizes. It seems the boot code doesn't know anything about extended SD ram formats (above 2GB sizes), while once linux is loaded it does. I will cover this in greater details in the other article. For now just understand it works well with small SD rams and can be made to work on larger ones.

In order to use the SD ram however required getting the binary files to load on to the SD. This too will be another article, as I discovered they use BuildRoot to generate the whole linux filesystem. I tried the BuildRoot on the DVD, but it didn't work, and thus I went web surfing again. On the atmel.no site there are newer binaries and buildroots which do work. I found the buildroot V2.3.0 will compile and produce a usable binary. You can also get the zipped up version of what you need there as well. I unzipped the 2.3 version and untarred on to a 64MB SD card and was able to boot it successfully.

I said there is another article pending for buildroot, as I could see the options presented in the atmel version didn't fit any of my needs, and changing those options, is very dificult. Your given five options - atngw100, base, extended, and two for using LCD screens if attached. My intention for the project is to do web serving with perl and other dev tools loaded so a logged in user can code apps on the board. The whole idea is to be able to work remotely and make changes as the need arrises. I think there might be such an option already, but there is no real information on what is provided. I had to guess and do considerable digging to find out what some of the settings did, only to find the code base broken and unable to build. A quick tip is use "make -k" which skips over failed build components and produces a usable system if the kernel and most of the components build ok - other wise it will stop building on the first error it encounters.

I really like buildroot and find it a great tool for putting linux on systems. It gives you the control and ease to build just the system you need. The biggest problem is knowing what you need. There are so many tools with names that mean nothing, and thus I found myself searching the web to see what they are. BuildRoot does try and group the tools in categories that might help, but knowing that dropbear is a ssh client server package is not in my previous experience. The list of such unrelated names is very long and will cause considerable trouble for the new user.

Let me say for now, just use one of the supplied option builds, such as "base" as a starting point. Do "make atngw100-base_defconfig" and it will set all the config files for a "base" build. Try "make source" and it will download all the source files into the "dl" directory. Now do "make -k" and a hour or so later you should have a tar file in the "binary/atngw100-base" directory ready for your SD ram. If you have the boot env settings for a SD right, it should boot from the new binary - mine did. After that worked, I set up a TFTP and NFS server that pointed to a directory that I untarred the binary to. The TFTP needs to point at the uImage and NFS points at the root. I stumbled a few times but got mine going(see CCII #7 for details).

Will it work as planned?

We are skipping over tons of steps and data that needs to be in an article devoted to just the ngw100 itself, as well as buildroot specific features. This article brings you up to speed on the ideas and problems I ran into. At this point in the discussion I have a running system, can use buildroot to make changes, and need to focus now on the projects in mind. One possible project would be using the unit for solar control of batteries and overall montioring of the system. Currently I use serial based temp sensors, and USB based voltage and current sensors (phidgits). The ngw100 has a single RS232 interface broughtout and used for console - it is how I talk to it now. I can free the single serial port by talking to the system using ssh/telnet. There are three other serial ports that should be available on the un-populated headers on the board.

In my currnt setup, I use USB to serial adapters and since the ngw100 has a USB port, I figured I better see how it works, as it could possibly handle all my needs with an existing port. I tried a few USB devices to no avail, rebuilt the system to inculde a few USB utilites, still nothing. After checking all the config files and options, I was still not seeing anything about USB supoort. So I went checking the AP7000 specs, only to discover the device is "USB client" support only - you need the AP7200 series if you want "USB host" support. Big problem and goof on my part. It seems the AP7000 is intended to be a "device" or "gadget" as they call it. It can only talk to host, not be one. That means I can use the USB port to talk to a laptop for setting things up, but not to collect data. Bummer!

At this point I figured I better do a review of I/O since I clearly missed the USB port. In short order my project falls apart as devices turn out to be useless for me. What I thought was an ADC audio input, turns out to be digital audio data stream - no ADC to be had at all. Well there is three I/O headers that on closer examination are setup for LCD displays and some alternate functions. I think serial 2 and 3 are ok, looks like most of PE port is ok to use, might be a SPI still open, but overall not ideal. It might be possible to create a daughter board that plugs into the headers and provides the needed RS232, ADC, or isolated input and outputs. It is "iffy" and far from what I was looking for but not hopeless.

At this point in time, I have stopped playing with the board and started focusing on writing up what I learned. I see how I took for granted the USB port being a host when it wasn't and figuring the I/O was ok, while it is aimed at other purposes. The AP7000 is really intended for PDA type use - where it has few inputs and mostly outputs. The use as a gateway clearly ignores most of it's abilities since they are not needed or wanted. I have seen this problem with other devices, where the multifunction pins get consumed by other devices, that you end up unable to use parts of the device. Oh well - I know better now.

Final thoughts

In looking back at this project, I can see some errors right from the start, such as the criteria list being a bit too simple. The price is good, I am ok with one ethernet port, and using linux on the NGW100 proves my idea is valid, while using buildroot is the key to that aspect. The low power was fine, about 300ma at 12v is great, and it was fanless and has an SD socket built in. So really the only criteria I missed was the I/O and as I know now, can be the make or break option. Atmel uses the USB device or USB host terms which I must say are new to me. I thought USB was USB, but in thinking about it, there really must be some differences between clients and hosts and I need to keep those in mind. For my applications, it must be both options if possible. The final products will need some ADC and might even need a DAC, however those could be handled using a SPI port, although I would rather they be part of the system and not an addon.

I really enjoyed playing with the NGW100. It showed me using buildroot was just the needed tool, and using linux can be done and effective on small systems. The Atmel web server is a great show-me tool with the cgi program that can trigger the leds from the home web page. That really helps get the idea accross about how simple using linux can be without major programming. I like the idea of using my regular linux tools, such as perl, to give the web pages and my tasks some extra features that would be hard to do on a 8051.

Although the documentation is poor, once you start playing with it all, the little information you do get does eventually make sense and you will find it all works, and in fact rather well at that. I can recommend it for embedded projects not needing a USB host port, or as a learning tool, and as a limited project board it should be great. There is a source file that can turn the board into an ethernet serial host and I could see it even as the host interface to an embedded project. Lots of uses and options, just not the one I had in mind.

Some links

Atmel home page - the place to get chip information.
Atmel buildroot support pages - where to download the latest code.
Atmel AVR32 Document pages - great how-to's and tutorials.
AVR32 developer support pages - the support page for AVR32 linux in general.
Buildroot home pages - buildroot with links to packages used.
Mediama Technology home pages - makes daughter board for NGW100.


Kibler Electronics, PO Box 535, Lincoln, CA 95648-0535, USA.
Email: bill@kiblerelectronics.com
Copyright © 2011, Kibler Electronics