background image

 

 

1

1

 

 

Chapter 1

 

Introduction 

The MOXA ThinkCore W311/321/341 are RISC-based ready-to-run wireless embedded computers 
with 802.11a/b/g WLAN, one 10/100 Mbps Ethernet port, an internal SD socket, 1/2/4 
RS-232/422/485 serial ports, two USB 2.0 hosts, one relay output channel, and pre-installed Linux 
operating system. The W311/321/341 offer high performance communication and unlimited 
storage in a super compact, palm-size ARM9 box. The ThinkCore W300 Series is the right 
solution for embedded applications that are used in hard-to-wire environments and that require a 
large amount of memory, but that must be housed in a small space without sacrificing 
performance. 

The following topics are covered in this chapter: 

‰

 

Overview 

‰

 

Software Architecture 

¾

 

Journaling Flash File System (JFFS2) 

¾

 

Software Package 

 

Summary of Contents for THINKCORE W311

Page 1: ...re W311 321 341 Linux User s Manual Second Edition March 2007 www moxa com product MOXA Systems Co Ltd Tel 886 2 2910 1230 Fax 886 2 2910 1231 Web www moxa com MOXA Technical Support Worldwide support moxa com ...

Page 2: ...a commitment on the part of MOXA MOXA provides this document as is without warranty of any kind either expressed or implied including but not limited to its particular purpose MOXA reserves the right to make improvements and or changes to this manual or to the products and or the programs described in this manual at any time Information provided in this manual is intended to be accurate and reliab...

Page 3: ...oping Hello c 2 13 Installing the Tool Chain Linux 2 13 Checking the Flash Memory Space 2 13 Compiling Hello c 2 14 Uploading and Running the Hello Program 2 15 Developing Your First Application 2 15 Testing Environment 2 16 Compiling tcps2 c 2 17 Uploading and Running the tcps2 release Program 2 18 Testing Procedure Summary 2 20 Chapter 3 Managing Embedded Linux 3 1 System Version Information 3 2...

Page 4: ...n 5 2 Steps for Installing the Linux Tool Chain 5 2 Compilation for Applications 5 2 On Line Debugging with GDB 5 3 Windows Tool Chain 5 4 System Requirements for Windows Tool Chain 5 4 Steps for Installing Windows Tool Chain 5 4 Using the BASH Shell 5 9 Compilation for Applications 5 10 On Line Debugging with Insight 5 12 Chapter 6 Programmer s Guide 6 1 Flash Memory Map 6 2 Device API 6 2 RTC Re...

Page 5: ... Linux normal command utility collection A 1 File manager A 1 Editor A 1 Network A 1 Process A 2 Other A 2 MOXA special utilities A 2 Appendix B Service Information B 1 MOXA Internet Services B 2 Problem Report Form B 3 Product Return Procedure B 4 ...

Page 6: ...perating system The W311 321 341 offer high performance communication and unlimited storage in a super compact palm size ARM9 box The ThinkCore W300 Series is the right solution for embedded applications that are used in hard to wire environments and that require a large amount of memory but that must be housed in a small space without sacrificing performance The following topics are covered in th...

Page 7: ... for desktop PCs can be easily ported to the computer with a GNU cross compiler without needing to modify the source code The OS device drivers e g serial and buzzer control and your own applications can all be stored in the NOR Flash memory Software Architecture The Linux operating system that is pre installed in the W311 321 341 follows the standard Linux architecture making it easy to accept pr...

Page 8: ...FS2 implements wear leveling to extend the life of the flash disk and stores the flash directory structure in the RAM A log structured file system is maintained at all times The system is always consistent even if it encounters crashes or improper power downs and does not require fsck file system check on boot up JFFS2 is the newest version of JFFS It provides improved wear leveling and garbage co...

Page 9: ...client program ftp FTP client program smtpclient email utility scp Secure file transfer Client Program Daemons pppd dial in out over serial port daemon snmpd snmpd agent daemon telnetd telnet server daemon inetd TCP server manager program ftpd ftp server daemon apache web server daemon sshd secure shell server openvpn virtual private network openssl open SSL Linux Tool Chain Gcc V3 3 2 C C PC Cros...

Page 10: ... Configuring the Ethernet Interface Modifying Network Settings with the Serial Console Modifying Network Settings over the Network Configuring the WLAN IEEE802 11a b g Using WPA_SUPPLICANT to Support WPA and WPA2 SD Socket and USB for Storage Expansion Test Program Developing Hello c Installing the Tool Chain Linux Checking the Flash Memory Space Compiling Hello c Uploading and Running the Hello P...

Page 11: ...operating system is ready ATTENTION This product is intended to be supplied by a Listed Power Unit with output marked LPS and rated for 12 48 VDC 600 mA minimum requirements Connecting the W311 321 341 to a PC There are two ways to connect the W311 321 341 to a PC through the serial console and by Telnet over the network Serial Console The serial console gives users a convenient way of connecting ...

Page 12: ...7 255 255 255 0 Use a cross over Ethernet cable to connect directly from your PC to the W311 321 341 You should first modify your PC s IP address and netmask so that your PC is on the same subnet as one of W311 321 341 s two LAN ports For example if you connect to LAN 1 you can set your PC s IP address to 192 168 3 126 and netmask to 255 255 255 0 If you connect to the WIRLESS LAN you can set your...

Page 13: ...ting to the W311 321 341 over a LAN you must configure your PC s Ethernet IP address to be on the same subnet as the W341 that you wish to contact If you do not get connected on the first try re check the serial and IP settings and then unplug and re plug the power cord SSH Console The W311 321 341 support an SSH Console to provide users with better security options Windows Users Click on the link...

Page 14: ...o continue connection yes no yes_ NOTE SSH provides better security compared to Telnet for accessing the W311 321 341 s console utility over the network Configuring the Ethernet Interface The network settings of the W311 321 341 can be modified with the serial console port or online over the network Modifying Network Settings with the Serial Console In this section we use the serial console to con...

Page 15: ...dhcp 3 After the boot settings of the LAN interface have been modified issue the following command to activate the LAN settings immediately etc init d networking restart NOTE After changing the IP settings use the networking restart command to activate the new IP address Modifying Network Settings over the Network IP settings can be activated over the network but the new settings will not be saved...

Page 16: ...d open wireless WPA and WPA2 MOXA_REPEAT Æ If set to Y load_wlan will call ipriv eth1 set_moxa_repeat to establish ad hoc mode using repeat function If you want to use WPA and WPA2 please refer to the subsection Using WPA_SUPPLICANT to Support WPA and WPA2 on page 2 11 2 Use the command vi etc networking interfaces to open the interfaces configuration file with vi editor and then edit the 802 11g ...

Page 17: ... CountryRegion Sets the channels for your particular country region Using iwpriv eth1 set_Region REGION REGION Explanation 1 USA default Use 802 11g channels 1 to 11 2 Taiwan Europe Use 802 11g channels 1 to 13 3 France Use 802 11g channels 10 to 13 4 Japan Use 802 11g channels 1 to 14 5 Israel Use 802 11g channels 3 to 9 6 Mexico Use 802 11g channels 10 11 WirelessMode Sets the wireless mode Usin...

Page 18: ...ct couldn t set freq 802 11b g Channel and Frequency Table Channel Freqence 1 2412 K 2 2417 K 3 2422 K 4 2427 K 5 2432 K 6 2437 K 7 2442 K 8 2447 K 9 2452 K 10 2457 K 11 2462 K 12 2467 K 13 2472 K 14 2484 K 802 11a Channel and Frequency Table Channel Freqence 36 5180 K 40 5200 K 44 5220 K 48 5240 K 52 5260 K 56 5280 K 60 5300 K 64 5320 K 100 5500 K 104 5520 K 108 5540 K 112 5560 K 116 5580 K 120 5...

Page 19: ...on 0 OPEN 1 SHARED 2 AUTO default KeyStr Sets Key Support string key and hex key EncrypType Just Support NONE WEP64 and WEP128 depend on your key length Using iwpriv eth1 key s KEYVALUE open Î support string key Using iwpriv eth1 key KEYVALUE open Î support hex key RTSThreshold Sets the RTS threshold Using iwpriv eth1 rts Setting Setting 1 to 2347 FragThreshold Sets the fragment threshold Using iw...

Page 20: ...age Expansion The W341 and W321 provide an SD slot for storage expansion MOXA provides an SD flash disk for plug play expansion that allows users to plug in a Secure Digital SD memory card compliant with the SD standard V1 0 for up to 1 GB of additional memory space The following steps show you how to install SD card into the W341 and W321 W321 The SD slot is located on the right side of the W321 ...

Page 21: ... slot press the SD card in slightly with your finger and then remove your finger to cause the card to spring out partially You may now grasp the top of the card with two fingers and pull it out Before removing the SD card remember to type sync to ensure that your data has been written In addition to the SD socket two USB 2 0 ports are located on the W341 s upper panel The USB host is also designed...

Page 22: ...1 341 GNU Tool Chain Fedora core or compatible versions are recommended The Tool Chain requires approximately 100 MB of hard disk space on your PC The W311 321 341 Tool Chain software is located on the W311 321 341 CD To install the Tool Chain insert the CD into your PC and then issue the following commands mount dev cdrom mnt cdrom sh mnt cdrom tool chain linux install sh The Tool Chain will be i...

Page 23: ...lo c as an example to show you how to compile and run your applications Type the following commands from your PC to copy the files used for this example from the CD to your computer s hard drive cd tmp mkdir example cp r mnt cdrom example tmp example To compile the program go to the Hello subdirectory and issue the following commands cd example hello make You should receive the following response ...

Page 24: ...e example Uploading and Running the Hello Program Use the following commands to upload hello release to the W311 321 341 by FTP 1 From the PC type ftp 192 168 3 127 2 Use the bin command to set the transfer mode to Binary mode and then use the put command to initiate the file transfer ftp bin ftp put hello release 3 From the W311 321 341 type chmod x hello release hello release The word Hello will...

Page 25: ... serial and Ethernet ports As illustrated in the following figure the purpose of this application is to transfer data between PC 1 and the W311 321 341 through an RS 232 connection At the remote site data can be transferred between the W311 321 341 s Ethernet port and PC 2 over an Ethernet connection Write data to PC1 Receive LAN data Read serial data Send data to PC2 tcps2 c Serial Rx Buffer LAN ...

Page 26: ...arm linux gcc o tcps2 release tcps2 c usr local arm linux bin arm linux strip s tcps2 release usr local arm linux bin arm linux gcc o tcpsp release tcpsp c usr local arm linux bin arm linux strip s tcpsp release usr local arm linux bin arm linux gcc ggdb o tcps2 debug tcps2 c usr local arm linux bin arm linux gcc ggdb o tcpsp debug tcpsp c root server11 1st_application 11 total 92 rw r r 1 root ro...

Page 27: ...tem type is UNIX Using binary mode to transfer files ftp bin 200 Type set to I ftp put tcps2 release local tcps2 release remote tcps2 release 277 Entering Passive Mode 192 168 3 127 82 253 150 Opening BINARY mode data connection for tcps2 release 226 Transfer complete 4996 bytes sent in 0 00013 seconds 3 9e 04 Kbytes s ftp ls 227 Entering Passive Mode 192 168 3 127 106 196 150 Opening ASCII mode d...

Page 28: ...e this program kill 1 ps ef use this command to check if the program is running 192 168 3 127 PuTTY 1 Running tcps2 release root Moxa ps ef PID Uid VmSize Stat Command 1 root 532 S init 3 2 root SWN ksoftirqd 0 3 root SW events 0 4 root SW khelper 13 root SW kblockd 0 14 root SW khubd 24 root SW pdflush 25 root SW pdflush 27 root SW aio 0 26 root SW kswapd0 604 root SW mtdblockd 609 root SW pccard...

Page 29: ...t you typed on PC1 will appear on PC2 s screen The testing environment is illustrated in the following figure However note that there are limitations to the example program tcps2 c tcps2 c RS 232 LAN PC 2 PC 1 Write data to PC1 Receive LAN data Read serial data Send data to PC2 Serial Rx Buffer LAN Rx Buffer NOTE The tcps2 c application is a simple example designed to give users a basic understand...

Page 30: ...W311 321 341 units The following topics are covered in this chapter System Version Information System Image Backup Upgrading the Firmware Loading Factory Defaults Backing Up the User Directory Deploying the User Directory to Additional W311 321 341 Units Enabling and Disabling Daemons Setting the Run Level Adjusting the System Time Setting the Time Manually NTP Client Updating the Time Automatical...

Page 31: ...load the latest firmware version from Moxa s website and then upgrade the W311 321 341 s hardware System Image Backup Upgrading the Firmware The W311 321 341 s bios kernel and root file system are combined into one firmware file which can be downloaded from Moxa s website www moxa com The name of the file has the form w341 x x x frm with x x x indicating the firmware version To upgrade the firmwar...

Page 32: ... mtdblock3 6 0M 488 0k 5 5M 8 tmp dev mtdblock3 6 0M 488 0k 5 5M 8 home dev mtdblock3 6 0M 488 0k 5 5M 8 etc tmpfs 30 4M 0 30 4M 0 dev shm root Moxa upramdisk root Moxa df h Filesystem Size Used Available Use Mounted on dev mtdblock2 8 0M 6 0M 2 0M 75 dev ram0 499 0k 16 0k 458 0k 3 var dev mtdblock3 6 0M 488 0k 5 5M 8 tmp dev mtdblock3 6 0M 488 0k 5 5M 8 home dev mtdblock3 6 0M 488 0k 5 5M 8 etc t...

Page 33: ...ftp ftp 0 Nov 30 10 03 drw rw rw 1 ftp ftp 0 Nov 30 10 03 rw rw rw 1 ftp ftp 13167772 Nov 29 10 24 w3xx 1 0 frm 226 Transfer complete ftp get w3xx 1 0 frm local ia240 1 0 frm remote w3xx 1 0 frm 200 Port command successful 150 Opening data connection for w3xx 1 0 frm 226 Transfer complete 13167772 bytes received in 2 17 secs 5925 8 kB s ftp 3 Next use the upfirm command to upgrade the kernel and r...

Page 34: ...pe the following command to enable the RAM disk upramdisk Next use the file system backup utility provided by Moxa backupuf mnt ramdisk usrfs backup 2 Once the file system is backed up use FTP to transfer the file usrfs backup to your PC 192 168 3 127 PuTTY root Moxa upramdisk root Moxa cd mnt ramdisk root Moxa mnt ramdisk df h Filesystem Size Used Available Use Mounted on dev mtdblock2 8 0M 6 0M ...

Page 35: ...p 29 2004 rw 1 root root 12288 Jun 15 02 45 lost found rw r r 1 root root 27263140 Jun 15 02 48 usrfs backup root Moxa mnt ramdisk upfirm usrfs backup Moxa ThinkCore w3xx upgrade firmware utility version 1 0 To check source firmware file context The source firmware file conext is OK This step will destroy all your firmware Continue Y N Y Now upgrade the file userdisk Format MTD device dev mtd3 MTD...

Page 36: ...5 root 1176 S bin sh login 690 root 464 S bin snmpd 694 nobody 3012 S usr bin httpd k start d etc apache 695 nobody 3012 S usr bin httpd k start d etc apache 696 nobody 3012 S usr bin httpd k start d etc apache 697 nobody 3012 S usr bin httpd k start d etc apache 698 nobody 3012 S usr bin httpd k start d etc apache 701 root 352 S bin reportip 714 root 1176 S bash 726 root 436 S bin telnetd 727 roo...

Page 37: ...tpd k start d etc apache 696 nobody 3012 S usr bin httpd k start d etc apache 697 nobody 3012 S usr bin httpd k start d etc apache 698 nobody 3012 S usr bin httpd k start d etc apache 701 root 352 S bin reportip 714 root 1176 S bash 726 root 436 S bin telnetd 727 root 1180 S bash 783 root 628 R ps ef root Moxa Setting the Run Level In this section we outline the steps you should take to set the Li...

Page 38: ...ve the daemon remove the run file from the etc rc d rc3 d directory by using the following command rm f etc rc d rc3 d S60tcps2 Adjusting the System Time Setting the Time Manually The W311 321 341 have two time settings One is the system time and the other is the RTC Real Time Clock time kept by the W311 321 341 s hardware Use the date command to query the current system time or set a new system t...

Page 39: ...941 seconds root Moxa ntpdate time stdtion gov tw 9 Dec 10 58 53 ntpdate 207 step time server 220 130 158 52 offset 155905087 9 84256 sec root Moxa hwclock w root Moxa date hwclock Thu Dec 9 10 59 11 CST 2004 Thu Dec 9 10 59 12 2004 0 844076 seconds root Moxa NOTE Before using the NTP client utility check your IP and DNS settings to make sure that an Internet connection is available Refer to Chapt...

Page 40: ... in that minute When executing commands output is mailed to the owner of the crontab or to the user named in the MAILTO environment variable in the crontab if such a user exists Modify the file etc cron d crontab to set up your scheduled applications Crontab files have the following format mm h dom mon dow user command min hour date month week user command 0 59 0 23 1 31 1 12 0 6 0 is Sunday The f...

Page 41: ...us communication functions The following topics are covered in this chapter Telnet FTP DNS Web Service Apache Installing PHP for Apache Web Service IPTABLES NAT NAT Example Enabling NAT at Bootup Dial up Service PPP PPPoE NFS Network File System Setting up the W311 321 341 as an NFS Client Mail SNMP OpenVPN ...

Page 42: ...eads to resolve the host name and IP address etc resolv conf This is the most important file that you need to edit when using DNS for the other programs For example before you use ntpdate time nist goc to update the system time you will need to add the DNS server address to the file Ask your network administrator which DNS server address you should use The DNS server s IP address is specified with...

Page 43: ...nternet Explorer or Mozilla Firefox from your PC to test if the Apache Web Server is working Type the LAN1 IP address in the browser s address box to open the homepage E g if the default IP address is still active type http 192 168 3 127 in the address box To open the default CGI page type http 192 168 3 127 cgi bin test cgi in your browser s address box ...

Page 44: ...oot root 757 Aug 24 1999 test cgi root Moxa home httpd cgi bin Installing PHP for Apache Web Server This embedded computer supports the PHP option However since the PHP file is 3 MB it is not installed by default To install it yourself first make sure there is enough free space at least 3 MB on your embedded flash ROM Step 1 Check that you have enough free space 192 168 3 127 PuTTY root Moxa bin d...

Page 45: ...130 220 vsFTPd 2 0 1 Name 192 168 27 130 root root 331 Please specify the password Password 230 Login successful Remote system type is UNIX Using binary mode to transfer files ftp cd tmp 250 Directory successfully changed ftp bin 200 Switching to Binary mode ftp get php tar gz local php tar gz remote php tar gz 200 PORT command successful Consider using PASV 150 Opening BINARY mode data connection...

Page 46: ... mnt ramdisk install sh Press the number 1 Install PHP package 2 Uninstall PHP package 3 Exit 1 Start to install PHP Please wait Starting web server apache PHP install sucess root Moxa mnt ramdisk Step 6 Test it Use the browser to access http 192 168 3 127 phpinfo php If you want to uninstall PHP follow steps 2 to 5 but select the uninstall option ...

Page 47: ...s PREROUTING chain transfers the destination IP address DNAT POSTROUTING chain works after the routing process and before the Ethernet device process to transfer the source IP address SNAT OUTPUT chain produces local packets sub tables Source NAT SNAT changes the first source packet IP address Destination NAT DNAT changes the first destination packet IP address MASQUERADE a special form for SNAT I...

Page 48: ...CT ipt_limit ipt_ttl ip_nat_irc ipt_REJECT ipt_mac ipt_unclean ip_nat_snmp_basic ipt_TCPMSS ipt_mark ip_queue ipt_TOS ipt_multiport ipt_LOG ipt_ULOG ipt_owner Incoming Packets Mangle Table PREROUTING Chain NAT Table PREROUTING Chain NAT Table POSTROUTING Chain Outgoing Packets Other Host Packets Mangle Table FORWARD Chain Filter Table FORWARD Chain Mangle Table POSTROUTING Chain Local Host Packets...

Page 49: ...http www linuxguruz com iptables http www netfilter org documentation HOWTO packet filtering HOWTO html Since the IPTABLES command is very complex to illustrate the IPTABLES syntax we have divided our discussion of the various rules into three categories Observe and erase chain rules Define policy rules and Append or delete rules Observe and erase chain rules Usage iptables t tables L n t tables T...

Page 50: ...ert one or more rules in the selected chain as the given rule number i Name of an interface via which a packet is going to be received o Name of an interface via which a packet is going to be sent p The protocol of the rule or of the packet to check s Source address network name host name network IP address or plain IP address sport Source port number d Destination address dport Destination port n...

Page 51: ...ddresses and un maps the global IP addresses on incoming packets back into local IP addresses NOTE Click on the following link for more information about iptables and NAT http www netfilter org documentation HOWTO NAT HOWTO html NAT Example The IP address of LAN1 is changed to 192 168 3 127 you will need to load the module ipt_MASQUERADE Embedded Computer PC1 Linux or Windows IP Netmask Gateway 19...

Page 52: ... iptables P INPUT ACCEPT bin iptables P OUTPUT ACCEPT bin iptables P FORWARD ACCEPT bin iptables t nat P PREROUTING ACCEPT bin iptables t nat P POSTROUTING ACCEPT bin iptables t nat P OUTPUT ACCEPT Step 3 Enable IP masquerade Dial up Service PPP PPP Point to Point Protocol is used to run IP Internet Protocol and other network protocols over a serial link PPP can be used for direct serial connectio...

Page 53: ...de a space after the second quotation mark ATDT5551212 Dial the modem and then CONNECT Wait for an answer Send a return null text followed by the usual return ogin username word password Log in with username and password Refer to the chat man page chat 8 for more information about the chat utility dev Specify the callout serial port 115200 The baudrate debug Log status in syslog crtscts Use hardwa...

Page 54: ...t P address or point to point address the address of your server Here s what it looks like on one machine lo Link encap Local Loopback inet addr 127 0 0 1 Bcast 127 255 255 255 Mask 255 0 0 0 UP LOOPBACK RUNNING MTU 2000 Metric 1 RX packets 0 errors 0 dropped 0 overrun 0 ppp0 Link encap Point to Point Protocol inet addr 192 76 32 3 P t P 129 67 1 165 Mask 255 255 255 0 UP POINTOPOINT RUNNING MTU 1...

Page 55: ...irst example applies to using a modem and requiring authorization with a username and password pppd dev ttyM0 115200 crtscts modem 192 168 16 1 192 168 16 2 login auth You should also add the following line to the file etc ppp pap secrets The first star lets everyone login The second star lets every host connect The pair of double quotation marks is to use the file etc passwd to check the password...

Page 56: ...ile etc ppp pap secrets and add the following username hinet net password username hinet net is the username obtained from the ISP to log in to the ISP account password is the corresponding password for the account 5 Edit the file etc ppp options and add the following line plugin pppoe ...

Page 57: ...rver ip_addr_of_second_dns_server For example nameserver 168 95 1 1 nameserver 139 175 10 20 8 Use the following command to create a pppoe connection pppd eth0 The eth0 is what is connected to the ADSL modem LAN port The example above uses LAN1 To use LAN2 type pppd eth1 9 Type ifconfig ppp0 to check if the connection is OK or has failed If the connection is OK you will see information about the p...

Page 58: ...OTE Click on the following link for more information about smtpclient http www engelschall com sw smtpclient To send an email message use the smtpclient utility which uses SMTP protocol Type smtpclient help to see the help message Example smtpclient s test f sender company com S IP_address receiver company com mail body message s The mail subject f Sender s mail address S SMTP server IP address Th...

Page 59: ... 36 ifSpeed 4 gauge 38400 37 ifSpeed 5 gauge 38400 38 ifSpeed 6 gauge 38400 39 ifPhysAddress 1 octet string 00 90 E8 10 02 41 hex 40 ifPhysAddress 2 octet string 00 90 E8 10 02 40 hex 41 ifPhysAddress 3 octet string 00 hex 42 ifPhysAddress 4 octet string 00 hex 43 ifPhysAddress 5 octet string 00 hex 44 ifPhysAddress 6 octet string 00 hex 45 ifAdminStatus 1 integer up 1 46 ifAdminStatus 2 integer u...

Page 60: ...nter 51987 100 ifOutOctets 2 counter 3832 101 ifOutOctets 3 counter 0 102 ifOutOctets 4 counter 0 103 ifOutOctets 5 counter 0 104 ifOutOctets 6 counter 0 105 ifOutUcastPkts 1 counter 506 106 ifOutUcastPkts 2 counter 42 107 ifOutUcastPkts 3 counter 0 108 ifOutUcastPkts 4 counter 0 109 ifOutUcastPkts 5 counter 0 110 ifOutUcastPkts 6 counter 0 111 ifOutNUcastPkts 1 counter 0 112 ifOutNUcastPkts 2 cou...

Page 61: ...ipAdEntNetMask 192 168 27 139 ipaddress 255 255 255 0 171 ipAdEntNetMask 192 168 4 127 ipaddress 255 255 255 0 172 ipAdEntBcastAddr 192 168 27 139 integer 1 173 ipAdEntBcastAddr 192 168 4 127 integer 1 174 ipAdEntReasmMaxSize 192 168 27 139 integer 65535 175 ipAdEntReasmMaxSize 192 168 4 127 integer 65535 176 ipRouteDest 192 168 4 0 ipaddress 192 168 4 0 177 ipRouteDest 192 168 27 0 ipaddress 192 ...

Page 62: ... tcpMaxConn 0 integer 1 241 tcpActiveOpens 0 counter 0 242 tcpPassiveOpens 0 counter 0 243 tcpAttemptFails 0 counter 0 244 tcpEstabResets 0 counter 0 245 tcpCurrEstab 0 gauge 0 246 tcpInSegs 0 counter 0 247 tcpOutSegs 0 counter 0 248 tcpRetransSegs 0 counter 0 249 tcpConnState 192 168 27 139 1024 0 0 0 0 0 integer listen 2 250 tcpConnState 192 168 4 127 1024 0 0 0 0 0 integer listen 2 251 tcpConnS...

Page 63: ... 0 0 integer 111 301 tcpConnLocalPort 192 168 27 139 80 0 0 0 0 0 integer 80 302 tcpConnLocalPort 192 168 4 127 80 0 0 0 0 0 integer 80 303 tcpConnLocalPort 192 168 27 139 21 0 0 0 0 0 integer 21 304 tcpConnLocalPort 192 168 4 127 21 0 0 0 0 0 integer 21 305 tcpConnLocalPort 192 168 27 139 22 0 0 0 0 0 integer 22 306 tcpConnLocalPort 192 168 4 127 22 0 0 0 0 0 integer 22 307 tcpConnLocalPort 192 1...

Page 64: ...ddress 192 168 4 127 161 ipaddress 192 168 4 127 367 udpLocalAddress 192 168 27 139 4800 ipaddress 192 168 27 139 368 udpLocalAddress 192 168 4 127 4800 ipaddress 192 168 4 127 369 udpLocalAddress 192 168 27 139 854 ipaddress 192 168 27 139 370 udpLocalAddress 192 168 4 127 854 ipaddress 192 168 4 127 371 udpLocalAddress 192 168 27 139 111 ipaddress 192 168 27 139 372 udpLocalAddress 192 168 4 127...

Page 65: ...ger 3 3 435 rs232InSigPortIndex 4 2 integer 4 4 436 rs232InSigPortIndex 1 3 integer 1 1 437 rs232InSigPortIndex 2 3 integer 2 2 438 rs232InSigPortIndex 3 3 integer 3 3 439 rs232InSigPortIndex 4 3 integer 4 4 440 rs232InSigPortIndex 1 6 integer 1 1 441 rs232InSigPortIndex 2 6 integer 2 2 442 rs232InSigPortIndex 3 6 integer 3 3 443 rs232InSigPortIndex 4 6 integer 4 4 444 rs232InSigName 1 2 integer c...

Page 66: ... 494 snmpInBadVersions 0 counter 0 495 snmpInBadCommunityNames 0 counter 0 496 snmpInBadCommunityUses 0 counter 0 497 snmpInASNParseErrs 0 counter 0 498 snmpInTooBigs 0 counter 0 499 snmpInNoSuchNames 0 counter 0 500 snmpInBadValues 0 counter 0 501 snmpInReadOnlys 0 counter 0 502 snmpInGenErrs 0 counter 0 503 snmpInTotalReqVars 0 counter 503 504 snmpInTotalSetVars 0 counter 0 505 snmpInGetRequests...

Page 67: ...ent Subnets 1 Set up four machines as shown in the following diagram OpenVPN A OpenVPN B Host A LAN1 192 168 2 171 Host B LAN1 192 168 4 172 LAN1 192 168 8 174 LAN1 192 168 2 173 local net local net Internet Internet LAN2 192 168 4 174 LAN2 192 168 8 173 Host A B represents one of the machines that belongs to OpenVPN A B The two remote subnets are configured for a different range of IP addresses W...

Page 68: ...expr i 1 read f1 f2 case f1 in address IPADDR f2 netmask NETMASK f2 broadcast BROADCAST f2 esac done break fi done etc network interfaces get the ip address of the specified interface mname module_up oIFS IFS IFS FOUND no for LINE in lsmod do TOK echo LINE cut d f1 if TOK mname then FOUND yes break fi done IFS oIFS if FOUND no then modprobe mname fi start ifcfg_vpn if d dev net then mkdir dev net ...

Page 69: ... 0 0 0 promisc up i expr i 1 if i ge maxtap then break fi done null ip address of internal interface ifconfig iface 0 0 0 0 promisc up enable bridge ip ifconfig br0 IPADDR netmask NETMASK broadcast BROADCAST ipf proc sys net ipv4 ip_forward enable IP forwarding echo 1 ipf echo ip forwarding enabled to cat ipf stop echo shutdown openvpn bridge ifcfg_vpn i expr 0 while do disconnect tap device from ...

Page 70: ...ute add net 192 168 4 0 netmask 255 255 255 0 dev br0 end Create a configuration file named B tap0 br conf and an executable script file named B tap0 br sh on OpenVPN B point to the peer remote 192 168 8 173 dev tap0 secret etc openvpn secrouter key cipher DES EDE3 CBC auth MD5 tun mtu 1500 tun mtu extra 64 ping 40 up etc openvpn B tap0 br sh Start bin sh value after net is the subnet behind the r...

Page 71: ...n to Host B from Host A you need to add the following routing item route add net 192 168 4 0 netmask 255 255 255 0 dev eth0 To create an indirect connection to Host A from Host B you need to add the following routing item route add net 192 168 2 0 netmask 255 255 255 0 dev eth0 Now ping Host B from Host A by typing ping 192 168 4 174 A successful ping indicates that you have created a VPN system t...

Page 72: ...68 8 173 2 Create a configuration file named A tun conf and an executable script file named A tun sh point to the peer remote 192 168 8 174 dev tun secret etc openvpn secrouter key cipher DES EDE3 CBC auth MD5 tun mtu 1500 tun mtu extra 64 ping 40 ifconfig 192 168 2 173 192 168 4 174 up etc openvpn A tun sh Start bin sh value after net is the subnet behind the remote peer route add net 192 168 4 0...

Page 73: ...internal interface at the remote peer Note that 5 is the argument that the OpenVPN program passes to the script file Its value is the second argument of ifconfig in the configuration file 3 Check the routing table after you run the OpenVPN programs by typing the command route Destination Gateway Genmsk Flags Metric Ref Use Iface 192 168 4 174 255 255 255 255 UH 0 0 0 tun0 192 168 4 0 192 168 4 174...

Page 74: ...g are also introduced For clarity the W311 321 341 embedded computer is called a target computer The following functions are covered in this chapter Linux Tool Chain Steps for Installing the Linux Tool Chain Compilation for Applications On Line Debugging with GDB Windows Tool Chain System Requirements for Windows Tool Chain Steps for Installing Windows Tool Chain Using the BASH Shell Compilation f...

Page 75: ... installation process to complete This should take a few minutes 3 Add the directory usr local arm linux bin to your path You can do this for the current login by issuing the following commands export PATH usr local arm linux bin PATH Alternatively you can add the same commands to HOME bash_profile to make it effective for all login sessions Compilation for Applications To compile a simple C appli...

Page 76: ...s installed in the host computer We ll asuumne that you have uploaded a program named hello debug to the target computer and strat to debug the program 1 Log on to the target computer and run the debugging server program gdbserver 192 168 4 142 2000 hello debug Process hello debug created pid 38 The debugging server listens for connections at network port 2000 from the network interface 192 168 4 ...

Page 77: ...an 10 19 48 lib rwxr xr x 1 stephen_ mkpasswd 53 Jan 10 22 03 moxa bat rw r r 1 stephen_ mkpasswd 3262 Jan 10 22 03 moxa ico drwxr xr x 2 stephen_ mkpasswd 0 Jan 10 19 48 tmp drwxr xr x 14 stephen_ mkpasswd 0 Jan 10 19 48 usr drwxr xr x 6 stephen_ mkpasswd 0 Jan 10 18 12 var stephen_lin abc 06d82fcbf1a _ System Requirements for Windows Tool Chain Your Windows OS must satisfy the following requirem...

Page 78: ...ory where you prefer to set the root directory for the tool chain Options of All Users and Unix are recommended Then choose Next If you have installed a tool chain before its root directory would show up in the Root Directory text field If you continue the installation the new tool chain in a previous root directory would override the old one Choose a different directory to keep both tool chains ...

Page 79: ...l chain windows Choose Next to proceed It may take anywhere from 5 to 20 minutes to check the packages in the CD ROM 4 All packages are selected by default Choose Next to continue yCategory column Shows a hierarchical display of packages with category name highest and package name lowest Click the plus sign next to a category name to open the category and see the packages within that category ...

Page 80: ...fault named packages are installed yInstall If the package was not previously installed select this option to install the package now yReinstall If the package was previously installed select this option to install it again This will overwrite the previous installation yUninstall If the package was previously installed select this option if you do NOT want to make any changes ySkip Ignores a packa...

Page 81: ... Linux User s Manual Tool Chains for Application Development 5 8 6 Checkmark Create icon on Desktop to place a Moxa BASH Shell icon on your desktop and then click on Finish 7 Click on OK to complete the installation process ...

Page 82: ...en for example ru mkpasswd l d etc passwd mkpasswd l d etc group Note that the d switch is necessary for domain users stephen_lin abc 06d82fcbf1a ls al total 9 drwxr xr x 8 stephen_ mkpasswd 0 Jan 10 17 24 drwxr xr x 8 stephen_ mkpasswd 0 Jan 10 17 24 drwxr xr x 2 stephen_ mkpasswd 0 Jan 10 19 48 bin drwxr xr x 7 stephen_ mkpasswd 0 Jan 10 19 24 etc rw r r 1 stephen_ mkpasswd 3262 Jan 10 22 03 ins...

Page 83: ... of the Windows tool chain Check the root directory where you can find the hello directory Mkpasswd l d etc passwd Mkgroup l d etc group Note that the d switch is necessary for domain users Jared_Wu Jared_Wu cd Jared_Wu Jared_Wu ls al total 9 drwxrwx 9 Jared_Wu 4294967295 0 Nov 4 18 11 drwxrwx 9 Jared_Wu 4294967295 0 Nov 4 18 11 drwxrwx 2 Jared_Wu 4294967295 0 Nov 4 11 10 bin drwxrwx 7 Jared_Wu 42...

Page 84: ...release hello c usr local mxscaleb bin mxscaleb strip s hello release usr local mxscaleb bin mxscaleb gcc ggdb o hello debug hello c Jared_Wu Jared_Wu hello ls Makefile README hello debug hello release hello c Jared_Wu Jared_Wu hello After that use FTP to upload the executable file to the UC and then run the executable hello ftp bye Jared_Wu Jared_Wu hello ftp 192 168 14 9 Connected to 192 168 14 ...

Page 85: ...ccompanies GDB the GNU Debugger was written in Tcl Tk by people working at Red Hat Inc and Cygnus Solutions Red Hat was generous enough to make Insight available for public use and continues to maintain the program Click on http sources redhat com insight for more information about using Insight or click on Help Topics under the Help menu to read the user manual ...

Page 86: ... Programmer s Guide This chapter includes important information for programmers The following functions are covered in this chapter Flash Memory Map Device API RTC Real Time Clock Buzzer WDT Watch Dog Timer UART DO ...

Page 87: ...lete directories and files including source code and executable files as needed 3 Users can create the user file system on the PC host or target platform and then copy it to the W311 321 341 4 To improve system performance we strongly recommend that you install your application programs on the on board flash However since the on board flash has a fixed amount of free memory space you must not over...

Page 88: ...tion The WDT works like a watch dog function You can enable it or disable it When the user enables WDT but the application does not acknowledge it the system will reboot You can set the ack time from a minimum of 50 msec to a maximum of 60 seconds 2 How the WDT works The sWatchDog is disabled when the system boots up The user application can also enable ack When the user does not ack it will let t...

Page 89: ...escription Disable the application to ack sWatchDog And the kernel will be auto ack it User does not to do it at periodic Input int fd the file handle from swtd_open return value Output OK will be zero The other has some error to get error code from errno int swtd_get int fd int mode unsigned long time Description Get current setting values mode 1 for user application enable sWatchDog need to do a...

Page 90: ... to get error code from errno 4 Special Note When you kill the application with 9 or kill without option or Ctrl c the kernel will change to auto ack the sWatchDog When your application enables the sWatchDog and does not ack your application may have a logical error or your application has made a core dump The kernel will not change to auto ack This can cause a serious problem causing your system ...

Page 91: ...timeval time time tv_sec msec 1000 time tv_usec msec 1000 1000 select 1 NULL NULL NULL time static int swtdfd static int stopflag 0 static void stop_swatchdog stopflag 1 static void do_swatchdog void swtd_enable swtdfd 500 while stopflag 0 mydelay 250 swtd_ack swtdfd swtd_disable swtdfd int main int argc char argv pid_t sonpid signal SIGUSR1 stop_swatchdog swtdfd swtd_open if swtdfd 0 printf Open ...

Page 92: ... fd MOXA_GET_OP_MODE mode Description Get the interface mode Argument 3 mode will return the interface mode There are two Moxa private ioctl commands for setting up special baudrates Function MOXA_SET_SPECIAL_BAUD_RATE Function MOXA_GET_SPECIAL_BAUD_RATE If you use this ioctl to set a special baudrate the termios cflag will be B4000000 in which case the B4000000 define will be different If the bau...

Page 93: ...r 1 ENUM 7 Inaccuracy 1 7 The Inaccuracy should less than 2 for work reliably Special Note 1 If the target baudrate is not a special baudrate e g 50 75 110 134 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 57600 115200 230400 460800 921600 the termios cflag will be set to the same flag 2 If you use stty to get the serial information you will get speed equal to 0 DO Using Dout pin 22 to cont...

Page 94: ... it in the target computer by a pre utility program setkey setkey ABigKey Note set an empty string to clear the encryption key in the target computer by setkey 2 Develop and compile your program in the development PC 3 In the development PC run the utility program binencryptor to encrypt your program with an encryption key binencryptor yourProgram ABigKey 4 Upload the encrypted program file to the...

Page 95: ...tility works by sending a broadcast message over the LAN to search for IP addresses of target computers Two versions of UC Finder are provided The GUI version works in Windows environments and the command line utility works in Linux environments The following topics are covered in this chapter Windows UC Finder Installing the Software Broadcast Search Linux ucfinder ...

Page 96: ...er The UC Finder utility is used to search the LAN or intranet for Moxa embedded computers Installing the Software 1 Once the Setup program starts running click on Next to proceed 2 Click on Next when the Select Additional Tools window opens to proceed with the installation ...

Page 97: ...lete the installation of UC Finder Broadcast Search The Broadcast Search function is used to locate all W311 321 341 units that are connected to the same LAN as your Windows computer Since the Broadcast Search function searches by MAC address and not IP address all W311 321 341 s connected to the LAN will be found regardless of whether or not they are on the same subnet as the host ...

Page 98: ...mine the IP addresses of all UC units connected to the same LAN the host that is running UC Finder To configure UC s IP addresses or other configuration parameters use Telnet over the network or connect directly to the serial Console port to access the W311 321 341 s Console utility Linux ucfinder Copy ucfinder from the Documentation and Software CD to your Linux PC and then use the following comm...

Page 99: ...move file 11 pwd display now file directly 12 df list now file system space 13 mkdir make new directory 14 rmdir delete directory Editor 1 vi text editor 2 cat dump file context 3 zcat compress or expand files 4 grep search string on file 5 cut get string on file 6 find find file where are there 7 more dump file by one page 8 test test file exist or not 9 sleep sleep seconds 10 echo echo string Ne...

Page 100: ...date and time 7 env run a program in a modified environment 8 clear clear the terminal screen 9 reboot reboot power off on the server 10 halt halt the server 11 du estimate file space usage 12 gzip gunzip compress or expand files 13 hostname show system s host name MOXA special utilities 1 backupfs backup file system user directory 2 bf built the file system user directory 3 kversion show kernel v...

Page 101: ... This appendix shows you how to contact Moxa for information about this and other products and how to report problems The following topics are covered in this appendix MOXA Internet Services Problem Report Form Product Return Procedure ...

Page 102: ... to ensure that customers receive the full benefit of our products Moxa Internet Services has been set up to provide technical support driver updates product information and user s manual updates The following services are provided E mail for technical support support moxa com World Wide Web WWW Site for product information http www moxa com ...

Page 103: ...il Date 1 Moxa Product ThinkCore W311 ThinkCore W321 ThinkCore W341 2 Serial Number _________________ Problem Description Please describe the symptoms of the problem as clearly as possible including any error messages you see A clearly written description of the problem will allow us to reproduce the symptoms and expedite the repair of your product ...

Page 104: ...eement PRA from the sales representative or dealer Fill out the Problem Report Form PRF Include as much detail as possible for a shorter product repair time Carefully pack the product in an anti static package and send it pre paid to the dealer The PRA should be visible on the outside of the package and include a description of the problem along with the return address and telephone number of a te...

Reviews: