As i had promised ,here comes the tutorial about ATNGW100.This is not a general purpose tutorial, but its a view of ATNGW100 from our perspective,how ,what we learned from our own experience.It explains basically what we did.I hope it will cover some of the questions faced by any newbie using ATNGW100.

Before i begin i shall say thanks to Mr Pramod CE (for much of the contents is borrowed from his own tutorial,and for his special support and guidance)and my groupmates and especially Prasanth PP who did much of the programming work.

ATNGW100

The Developing Environment of ATNGW100

The developing environment for the Atmel Network Gateway can be setup in Linux operating system.The main source of informaton for programming and customizing ATNGW100 can be obtained from the following locations.

1.The onboard stored information from ATNGW100 itself.It can be accessed by the address

http://10.0.0.1 through a standard webbrowser like Mozilla or IE.(details discussed later).

2.The online support forum for AVR32 at http://www.avrfreaks.net/

3.The following URL, http://www.gnuvision.com/freebird/ holds a good information about building robtic applications using ATNGW100, done by Mr. Pramode C E.

Methods for programming ATNGW100

The ATNGW100 has a 32 bit AP7000 processor and comes with preinstalled Linux with Kernel version 2.6.18 patched for ATNGW100 architecture.The kit can be programmed in two ways,either we can program using the Linux or by erasing the Linux and program the AP7000 using assembly level programminig.Two methods has its own advantages and disadvantages.We preferred the first method because it takes care of almost all the things and makes our life much easier.

AVR32 studio is used for programming the AP7000 processor other than using Linux OS.The Linux

programming can be done in different ways dependin on our requirements.The main methods generally used are

  1. Creating an executable file compiled for ATNGW100 in a remote PC and transfer it to the the target and execute it.The executable file is of .elf format and the remote pc can either run AVR toolchain installed under Linux OS or using Cygwin in Windows.The former is generally preferred and currently used in this project.
  2. Using kernel module programming and running the applications as kernel modules.This is used in time critical applications PWM generation for controlling servo motors.The developing environment is surely a Linux OS with a kernel patched and complied for the target application(ATNGW100).

Operating System and Building the Tool chain.

The operating system used in our project development are Ubuntu 6.06 and Debian Etch.The first step is to prepare the system for ATNGW100 and this involves insatalling the AVR tool chain.

After the installation of tool chain we will be able to compile executables for the ATNGW100 board in .elf formats using avr32-gcc compiler.

The Ubuntu version has got the advantage that repositories are easily availble from their network.

The Debian Etch can be setup using the AVR BSP(Board Support Package) image version 2 supplied from the Atmel website (http://www.atmel.com/dyn/resources/prod_documents/AVR32_Linux_BSP_CD_Image_2.0.0.zip)

You can download , unzip and in the debian directory execute “dpkg -i *.deb” and incase of dependencies problem use the four DVDs of Debian Etch to meet the requirements.

Connecting the ATNGW100 to a Debian based system.

The serial port of the ATNGW100 is connected to the PC serial port and the ethernet cable is connected to the LAN port provided in the board. The board requires a power supply 9V-15V DC, ensure that you are using a good power supply able to meet the current requirements.The LAN port is the most current driving unit and if the supply is not good enough then LAN port may not work properly.

Install a terminal program like ‘minicom’ or ‘GtKterm’ in the pc and set the baud rate to 115200 and the appropriate device eg: /dev/ttyS0 and with no parity or flow control.Open up a Gtkterm window.

Now switching on the powesr supply causes the system to boot up, the booting process can be viewed on the gtkterm window.Once the booting process is over you can find the red LED lights up.

The LAN connection can be setup using the ip address 10.0.0.1 of the NGW100 (Usually 10.0.0.1 for the LAN and 10.11.12.1 for the WAN)

Once you have connected the LAN port to your PC you should be able to access the built in web/ftp/telnet servers. To access the webserver, open Firefox or other selected web browser and type in “10.0.0.1″ in the address bar (you could also type “http://ngw.example.net“). You should be presented with a blue website with four options.

you can establish a telnet connection by

$telnet 10.0.0.1

if you want to login as root the default password is ‘roota’

An ftp connection is opened by the

$ftp 10.0.0.1

file can be transfered from current directory to root directory of NGW100 by

$put ‘filename’

connection can be closed by issuing

$bye

Once you ve transferred the needed file eg: hello.elf you must change its permissions to be able to execute

$chmod +x filename

or

$chmod 755 filename

To execute the file you can give

$./filename.elf

Compiling the files using avr32 gcc

The compling process is similar to normal compiling in Unix environment.The the thread programming method is used in this project.The command used is

$avr32-linux-gcc -pthread -o filename.elf filename.c -Ipthread

Using a Custom Kernel

The preinstalled kernel v 2.6.18 came with only one serial port /dev/ttyS0. Although three serial ports are functional in NGW100 the other two are not enabled in the default kernel.So we compiled another kernel with a slight modification.The procedure is as follows.

Get linux-2.6.22.atmel.3.tar.bz2 from http://www.avr32linux.org/twiki/bin/view/Main/LinuxPatches

We won’t enable UART0 as it conflicts with one of the other on-chip peripherals.

The setup file that configures the NGW100 is arch/avr32/boards/atngw100/setup.c. There are two additions that need to be made to the file to enable the serial port.

Change __init setup_board() to:

void __init setup_board(void)

{

at32_map_usart(1, 0); /* USART 1: /dev/ttyS0, DB9 */

at32_map_usart(2, 1); /* USART 2: /dev/ttyS1 */

at32_map_usart(3, 2); /* USART 3: /dev/ttyS2 */

at32_setup_serial_console(0);

}

and add the following lines to the beginning of atngw100_init():

static int __init atngw100_init(void)

{

unsigned i;

/*

* ATNGW100 uses 16-bit SDRAM interface, so we don’t need to

* reserve any pins for it.

*/

at32_add_system_devices();

at32_add_device_usart(0);

at32_add_device_usart(1);

at32_add_device_usart(2);

Now do

make ARCH=avr32 CROSS_COMPILE=avr32-linux- atngw100_defconfig

Now, you can do a

make ARCH=avr32 CROSS_COMPILE=avr-linux- menuconfig

and tweak some parameters. Be aware that changing certain config values can result in a kernel which doesn’t boot properly. Build the kernel by running:

make ARCH=avr32 CROSS_COMPILE=avr32-linux-

make ARCH=avr32 CROSS_COMPILE=avr32-linux- INSTALL_MOD_PATH=./modules modules_install

You should get a file `uImage’ in the folder arch/avr32/boot/images/.

Installing a tftp server

You can use the `synaptic’ package manager and install the packages `tftp’ and `tftpd’. The TFTP server is configured to look under the folder `/srv/tftp’ in Debian etch. Copy the `uImage’ which you have built into this folder. Now, `uboot’ will be able to load it into memory through the ethernet interface and boot it properly.

Configuring Ethernet Interface

t seems that some programs running in the background like to do bizarre things with the network interface – so it might be better to stop those programs before you try any experiment with the board. You can do this by running:

sh /etc/init.d/dbus stop

You can now assign an IP address for the interface:

ifconfig eth1 10.0.0.99

Configuring Uboot

Reboot the board (keep it connected to the PC using the serial port as well as an ethernet cable – also, keep a terminal program like `minicom’ running) and keep the `space’ key pressed. This will result in `uboot’ (the bootloader) suspending the default boot process and dropping into interactive mode. At the uboot prompt, type the following commands:

setenv tftpip 10.0.0.99

setenv ipaddr 10.0.0.1

setenv bootfile uImage

Now, type:

tftpboot

and `uboot’ will download the `uImage’ from the PC and loads it into memory. Running

bootm

will result in this kernel booting!

Booting from SD card

The `u-boot’ boot loader can boot an image from an SD card. Once at the `u-boot’ prompt, type `mmcinit’ to initialize the card – this should also give you some information regarding the card (like its size). The command

ext2ls mmc 0:1 /

will show you all the files in the root directory of the card. Note that for the above command to work, the first partition on the card should be formatted as ext2.

The following commands will load and boot an image present on the card:

ext2load mmc 0:1 0×90400000 uImage

bootm 0×90400000

Once booting is over, you should see /dev/mmcblk0p1 mounted on /media/mmcblk0p1.

`U-boot’ environment variables

By default, the ATNGW100 boots a kernel which resides on the on-board flash memory. The modified kernel is on an SD card – so we have to make sure that when powered on, the ATNGW100 boots from the SD card. This is done by saving proper `environment’ variables.

setenv tftpip 10.0.0.99

setenv ipaddr 10.0.0.1

setenv bootfile uImage

setenv ethact macb1

setenv bootcmd ‘mmcinit;ext2load mmc 0:1 0×90400000 uImage;bootm’

saveenv

Pinouts of the Expnasion connectors in NGW100

The serial port pins can be identified from the following tables

J5 Pin out

alt. 2

alt. 1

port

pin

pin

port

alt. 1

alt. 2

3.3V

1

2

GND

SSC1 – RX_FRAME

SPI0 – MISO

PA00

3

4

PA01

SPI0 – MOSI

SSC1 – TX_ FRAME

SSC1 – TX_CLOCK

SPI0 – SCK

PA02

5

6

PA03

SPI0 – NPCS0

SSC1 – RX_CLOCK

SSC1 – TX_DATA

SPI0 – NPCS1

PA04

7

8

PA05

SPI0 – NPCS2

SSC1 – RX_DATA

USART0 – RTS

TWI – SDA

PA06

9

10

PA07

TWI – SCL

USART0 – CTS

USART0 – RXD

PSIF – CLOCK0

PA08

11

12

PA09

PSIF – DATA0

USART0 – TXD

PWM – PWM2

SSC0 – RX_FRAME

PA21

13

14

PA22

SSC0 – RX_CLOCK

PWM – PWM3

TIMER1 – A0

SSC0 – TX_CLOCK

PA23

15

16

PA24

SSC0 – TX_FRAME

TIMER1 – A1

TIMER1 – B0

SSC0 – TX_DATA

PA25

17

18

PA26

SSC0 – RX_DATA

TIMER1 – B1

TIMER1 – CLK0

SPI1 – NPCS3

PA27

19

20

PA28

PWM – PWM0

TIMER1 – A2

TIMER1 – B2

PWM -PWM1

PA29

21

22

PA30

SM – GCLK0

TIMER1 – CLK1

TIMER1 – CLK2

SM – GCLK1

PA31

23

24

PB00

ISI – D0

SPI1 – MISO

SPI1 – MOSI

ISI – D1

PB01

25

26

PB02

ISI – D2

SPI1 – NPCS0

SPI1 – NPCS1

ISI – D3

PB03

27

28

PB04

ISI – D4

SPI1 – NPCS2

SPI1 – SCK

ISI – D5

PB05

29

30

PB06

ISI – D6

MMCI – CMD1

USART1 – CTS

SPI0 – NPCS3

PA20

31

32

N.C.

3.3V

33

34

GND

3.3V

35

36

GND

J6 Pin out

alt. 2

alt. 1

port

pin

pin

port

alt. 1

alt. 2

3.3V

1

2

GND

3.3V

3

4

GND

N.C.

5

6

N.C.

MMCI – D4

ISI – D7

PB07

7

8

PB08

ISI – HSYNC

MMCI – D5

MMCI – D6

ISI – VSYNC

PB09

9

10

PB10

ISI – PCLK

MMCI – D7

ISI – D8

PSIF – CLOCK1

PB11

11

12

PB12

PSIF – DATA1

ISI – D9

ISI – D10

SSC2 – TX_DATA

PB13

13

14

PB14

SSC2 – RX_DATA

ISI – D11

USART3 – CTS

SSC2 – TX_CLOCK

PB15

15

16

PB16

SSC2 – TX_FRAME

USART3 – RTS

USART3 – TXD

SSC2 – RX_FRAME

PB17

17

18

PB18

SSC2 – RX_CLOCK

USART3 – RXD

USART3 – CLK

SM – GCLK2

PB19

19

20

PB20

DAC – DATA1

AUDIOC – SDO

AUDIOC – SYNC

DAC – DATA0

PB21

21

22

PB22

DAC – DATAN1

AUDIOC – SCLK

AUDIOC – SDI

DAC – DATAN0

PB23

23

24

PB24

DMAC – DMARQ0

NMI – NMI_N

IRQ – EXTINT0

DMAC – DMARQ1

PB25

25

26

PB26

USART2 – RXD

IRQ – EXTINT1

IRQ – EXTINT2

USART2 – TXD

PB27

27

28

WAKE_N

N.C.

29

30

N.C.

N.C.

31

32

N.C.

3.3V

33

34

GND

3.3V

35

36

GND

J7 Pin out

alt. 2

alt. 1

port

pin

pin

port

alt. 1

alt. 2

EBI – D19

LCD – D0

PE03

1

2

PE04

LCD – D1

EBI – D20

EBI – D21

LCD – D2

PE05

3

4

PE06

LCD – D3

EBI – D22

EBI – D23

LCD – D4

PE07

5

6

PC31

LCD – D5

LCD – D6

PD00

7

8

PD01

LCD – D7

EBI – D24

LCD – D8

PE08

9

10

PE09

LCD – D9

EBI – D25

EBI – D26

LCD – D10

PE10

11

12

PE11

LCD – D11

EBI – D27

EBI – D28

LCD – D12

PE12

13

14

PD07

LCD – D13

LCD – D14

PD08

15

16

PD09

LCD – D15

EBI – D29

LCD – D16

PE13

17

18

PE14

LCD – D17

EBI – D30

EBI – D31

LCD – D18

PE15

19

20

PE16

LCD – D19

EBI – A23

EBI – A24

LCD – D20

PE17

21

22

PE18

LCD – D21

EBI – A25

LCD – D22

PD16

23

24

PD17

LCD – D23

EBI – D17

LCD – DVAL

PE01

25

26

PE02

LCD – MODE

EBI – D18

LCD – HSYNC

PC20

27

28

PC21

LCD – PCLK

LCD – VSYNC

PC22

29

30

N.C.

N.C.

31

32

N.C.

3.3V

33

34

GND

3.3V

35

36

GND