UC-7101/7110/7112 User’s Manual Eighth Edition, February 2009 www.moxa.com/product © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited.
UC-7101/7110/7112 User’s Manual The software described in this manual is furnished under a license agreement and may be used only in accordance with the terms of that agreement. Copyright Notice Copyright © 2009 Moxa Inc. All rights reserved. Reproduction without permission is prohibited. Trademarks MOXA is a registered trademark of Moxa Inc. All other trademarks or registered marks in this manual belong to their respective manufacturers.
Table of Contents Chapter 1 Introduction ..................................................................................................1-1 Overview.................................................................................................................................. 1-2 Package Checklist .................................................................................................................... 1-2 Product Features .....................................................................
WDT (Watch Dog Timer) ........................................................................................................ 5-3 Appendix A System Commands..................................................................................... A-1 µClinux normal command utility collection ........................................................................... A-1 File manager ................................................................................................................ A-1 Editor .....
1 Chapter 1 Introduction The Moxa UC-7101/7110/7112 Series of mini RISC-based ready-to-run embedded computers are ideal for your embedded applications. The UC-7110 and UC-7112 feature dual 10/100 Mbps Ethernet ports and two RS-232/422/485 serial ports in a built-in µClinux ARM9 box. The UC-7101 features one 10/100 Mbps Ethernet port and one RS-232/422/425 serial port.
UC-7101/7110/7112 Software User’s Manual Introduction Overview The UC-7101/7110/7112 Series of mini RISC-based communication platforms are ideal for your embedded applications. The UC-7101/7110/7112 come with RS-232/422/485 serial ports and 10/100 Mbps Ethernet LAN ports to provide users with a versatile communication platform. The UC-7101/7110/7112 use the ARM9 RISC CPU.
UC-7101/7110/7112 Software User’s Manual Introduction Product Features The UC-7101/7110/7112 embedded computers have the following features: y y y y y y y y y Mini controller with ready-to-run platform for customized applications 32-bit ARM9 RISC microcontroller On-board 16 MB RAM, 8 MB Flash ROM Two RS-232/422/485 serial ports (one RS-232/422/485 serieal port for UC-7101) Dual 10/100 Mbps Ethernet (one 10/100 Mbps ethernet for UC-7101) SD expansion slot for storage expansion (UC-7101/7112 only) µClinux-
UC-7101/7110/7112 Software User’s Manual Introduction 340 mA @ 12 VDC, 4.5W (UC-7110/7112) Operating temperature -10 to 60oC, (14 to 140oF), 5 to 95% RH -20 to 80oC, (-4 to 176oF), 5 to 95% RH Storage temperature Regulatory Approvals EMC: FCC Class A, CE Class A Safety: UL, CUL, TÜV 5 years Warranty Software Specifications Kernel Protocol Stack File System Msh pppd PPPoE snmpd busybox Tinylogin Telnetd telnet inetd ftpd ftp boa ntpdate Linux Tool Chain µClinux Kernel 2.
2 Chapter 2 Getting Started In this chapter, we explain the basic procedure for getting the UC-7101/7110/7112 connected and ready to use. This chapter covers the following topics: Powering on the UC-7101/7110/7112 Connecting the UC-7101/7110/7112 to a PC ¾ Console Port ¾ Telnet Configuring the Ethernet Interface Developing Your Applications ¾ Installing the UC-7101/7110/7112 Tool Chain ¾ Compiling Hello.
UC-7101/7110/7112 Software User’s Manual Getting Started Powering on the UC-7101/7110/7112 Connect the SG wire to the Shielded Contact located on the upper left corner of the UC-7101/7110/7112, and then power on the UC-7101/7110/7112 by connecting the power adaptor. It takes about 16 seconds for the system to boot up. Once the system is ready, the Ready LED will light up.
UC-7101/7110/7112 Software User’s Manual Getting Started Telnet If you know at least one of the two IP addresses and netmasks, then you can use Telnet to connect to the UC-7101/7110/7112’s console. Default IP Address Default Netmask LAN 1 192.168.3.127 255.255.255.0 LAN 2 192.168.4.127 255.255.255.0 Telnet can be used locally by using a crossover Ethernet cable to connect your computer to the UC-7101/7110/7112, or over a LAN or the Internet. The default IP addresses and netmasks are shown above.
UC-7101/7110/7112 Software User’s Manual Getting Started Configuring the Ethernet Interface In this section, we use the serial console to explain how to modify the UC-7101/7110/7112’s network settings. 1. Change directories by issuing the command cd /etc. 2. Type the command vi rc to use VI Editor to edit the configuration file. The IP addresses for the UC-7101/7110/7112’s LAN1 and LAN2 are given as: ifconfig eth0 192.168.3.127 ifconfig eth1 192.168.4.127 as shown in the following figure.
UC-7101/7110/7112 Software User’s Manual 3. Getting Started You may also configure the UC-7101/7110/7112 to request IP addresses from a DHCP server. In this case, use the sharp sign (#) to comment out one or both “ifconfig” lines, and then add the setting about the “dhcpcd” into the rc file as below: dhcpcd -p -a eth0 & dhcpcd -p -a eth1 & Note that the UC-7101/7110/7112 will send out DHCP broadcast packets, and then get the IP addresses from the first DHCP server that responds. 4.
UC-7101/7110/7112 Software User’s Manual Getting Started Developing Your Applications Step 1: Connect the UC-7101/7110/7112 to a Linux PC. Step 2: Install the Tool Chain (GNU Cross Compiler & uClibc). Step 3: Configure the cross compiler and uClibc environment variables. Step 4: Code and compile your program. Step 5: Download the program to the UC-7101/7110/7112 by FTP or NFS. Step 6: Debug the program. If the program is OK, proceed to Step 7. If the program needs to be modified, go back to Step 4.
UC-7101/7110/7112 Software User’s Manual Getting Started Compiling Hello.c The Tool Chain path is: PATH=/usr/local/bin:$PATH The UC-7101/7110/7112 CD includes several example programs. We use Hello.c to illustrate how to compile and run applications. Issue the following commands from your PC to compile Hello.c: # cd /tmp/ # mkdir example # cp –r /mnt/cdrom/example/* /tmp/example Go to the Hello subdirectory, and issue the command #make to compile Hello.c.
UC-7101/7110/7112 Software User’s Manual Getting Started Running “Hello” on the UC-7101/7110/7112 To run the “Hello” program issue the following commands on the UC-7101/7110/7112: # chmod 755 hello #./hello The words “hello world” will be printed on the screen.
UC-7101/7110/7112 Software User’s Manual Getting Started ATTENTION Be sure to calculate the amount of Flash Memory used by the User File System in the Flash ROM. Use one of the following two commands to determine the amount of memory being used: # df –k or # df If the flash memory is full, you will no longer be able to save data in Flash ROM. To free up some memory, use the console cable to connect to the UC-7101/7110/7112’s serial console terminal, and then delete files from the Flash ROM.
UC-7101/7110/7112 Software User’s Manual Getting Started LIBS = CFLAGS = # Change these if necessary CC = arm-elf-gcc CPP = arm-elf-gcc -E all: hello hello: $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(LIBS) $@.c clean: rm -f $(OBJS) hello core *.
3 Chapter 3 Software Package This chapter includes information about the software that is used with the UC-7101/7110/7112 Series of embedded computers.
UC-7101/7110/7112 Software User’s Manual Software Package UC-7101/7110/7112 Software Architecture The pre-installed µClinux operating system used by the UC-7101/7110/7112 follows the standard µClinux architecture, making programs that follow the POSIX standard easily ported to the UC-7101/7110/7112 by using the GNU Tool Chain provided by www.uClinux.org. In addition to the Standard POSIX API, device drivers for the buzzer, and UART for the serial ports are also included.
UC-7101/7110/7112 Software User’s Manual Software Package The partition sizes are hard coded into the kernel binary. You must rebuild the kernel to change the partition sizes. The flash memory map is shown in the following table.
UC-7101/7110/7112 Software User’s Manual Software Package UC-7101/7110/7112 Software Package bin upkernel passwd -> tinylogin login -> tinylogin tinylogin telnetd snmpd mail sh routed netstat arp chat pppd portmap ntpdate necid eraseall kversion init expand inetd hwclock ftpd ftp mke2fs e2fsck discard dhcpcd cpu busybox boa downramdisk upramdisk dev ptype ptypd ptypc ptypb ptypa ptyp9 ptyp8 ptyp7 ptyp6 ptyp5 ptyp4 ptyp3 ptyp2 ptyp1 ptyp0 ppp pio rtc ram1 ram0 null kmem mem cua0 console tty mtdblock1 mtd
4 Chapter 4 Configuring UC-7101/7110/7112 In this chapter, we describe how to configure the UC-7101/7110/7112 embedded computers.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 Enabling and Disabling Daemons The following daemons are enabled when the UC-7101/7110/7112 boot up for the first time. y y y y y SNMP Agent daemon: Telnet Server / Client daemon: Internet Daemons: FTP Server / Client daemon: WWW Server daemon: snmpd telnetd inetd ftpd boa ATTENTION How to enable/disable telnet/ftp server a. b. Edit the file ‘/etc/inetd.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 Adding a Web Page Default Home Page address: /home/httpd/index.html You may change the default home page directory by editing the web server’s configuration file, located at: /etc/boa.conf. Type the following command to edit the boa.conf file: /etc>vi boa.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 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. If one host can connect to the Internet, then other computers that connect to this host can connect to the Internet when the computer does not have an actual IP address.
UC-7101/7110/7112 Software User’s Manual NOTE Configuring UC-7101/7110/7112 The UC-7101/7110/7112 do NOT support IPV6 and ipchains. IPTABLES supports packet filtering or NAT. Take care when setting up the IPTABLES rules. If the rules are not correct, remote hosts that connect via a LAN or PPP may be denied access. We recommend using the Serial Console to set up IPTABLES. Click on the following links for more information about iptables. http://www.linuxguruz.com/iptables/ http://www.netfilter.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 #iptables –t nat –P PREROUTING ACCEPT #iptables –t nat –P OUTPUT ACCEPT #iptables -t nat –P POSTROUTING ACCEPT In this example, the policy accepts outgoing packets and denies incoming packets. Append or delete rules: Usage: # iptables [-t table] [-AI] [INPUT, OUTPUT, FORWARD] [-io interface] [-p tcp, udp, icmp, all] [-s IP/network] [--sport ports] [-d IP/network] [--dport ports] –j [ACCEPT.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 NAT Example The IP addresses of all packets leaving LAN1 are changed to 192.168.3.127 (you will need to load the module ipt_MASQUERADE): IP/Netmask: 192.168.3.100/24 Gateway: 192.168.3.127 PC1 (Linux or Windows) LAN1 LAN1:eth0 192.168.3.127/24 LAN2:eth1 192.168.4.127/24 UC-7110 LAN2 PC2 (Linux or Windows) IP/Netmask: 192.168.4.100/24 Gateway: 192.168.4.127 NAT Area / Private IP 1. #echo 1 > /proc/sys/net/ipv4/ip_forward 2.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 Enabling NAT at Bootup In most real world situations, you should use a simple shell script to enable NAT when the UC-7101/7110/7112 boot up, as indicated by the following: 1. 2. 3. 4. 5. setting iptables iptables-save > /home/xxx.file (xxx.file is the user defined file name) vi /etc/rc Append echo 1 > /proc/sys/net/ipv4/ip_forward Append iptables-restore /home/xxx.file (xxx.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 Configuring PPPoE PPPoE relies on two widely accepted standards: PPP and Ethernet, which permit the use of PPPoE(Point-to-Point Over Ethernet). PPPoE is a specification for connecting users on an Ethernet to the Internet through a common broadband medium, such as a single DSL line, wireless device or cable modem, used by many ADSL service providers.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 For example, to unload the UART driver, type the following command: />rmmod mxser For the UC-7110, the factory default is to load the UART driver “mxser.ko”. The additional driver module to control the SD/MMC memory card is loaded for the UC-7112. Please see the information below for the locations and file names of these driver modules. UART: /lib/modules/2.6.9-MoXaRt/kernel/drivers/char/mxser.ko SD/MMC: /lib/modules/2.6.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 Use the upkernel command to upgrade the kernel and root file system. /ramdisk>upkernel uc7110-3.x.bin /ramdisk>reboot Upgrading the Root File System & User Directory The UC-7101/7110/7112 uses JFFS2 for the root file system and user directory. By default, the root file system is pre-set to READ only. The UC-7101/7110/7112 provides a read/write user’s directory in the JFFS2 file system.
UC-7101/7110/7112 Software User’s Manual Configuring UC-7101/7110/7112 You will also need to restore factory defaults to load the new settings. To do this, either press the RESET button for more than 5 seconds, or input the command “stdef” from the Telnet console. Loading Factory Defaults The easiest way to “Load Factory Defaults” is with the “Upgrade User directory” operation. Refer to the previous section Upgrading the Root File Sysem & User Directory for an introduction.
5 Chapter 5 UC-7101/7110/7112 Device API In this chapter, we discuss the Device API for the UC-7101/7110/7112 Series.
UC-7101/7110/7112 Software User’s Manual UC-7101/7110/7112 Device API RTC (Real Time Clock) The device node is located at /dev/rtc. The UC-7101/7110/7112 support µClinux standard simple RTC control. You must include to use these functions. 1. Function: RTC_RD_TIME int ioctl(fd, RTC_RD_TIME, struct rtc_time *time); Description: Reads time information from RTC. 2. Function: RTC_SET_TIME int ioctl(fd, RTC_SET_TIME, struct rtc_time *time); Description: Sets RTC time.
UC-7101/7110/7112 Software User’s Manual UC-7101/7110/7112 Device API WDT (Watch Dog Timer) 1. Introduction 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.
UC-7101/7110/7112 Software User’s Manual UC-7101/7110/7112 Device API Output 0 (zero) for no error. Any other number indicates an error. You can get the error code from errno(). int swtd_disable (int fd) Description Disable the application to ack sWatchDog. The kernel will auto ack it. Users does not to do it periodically. Input int fd—the file handle from swtd_open() return value. Output 0 (zero) for no error. Any other number indicates an error. You can get the error code from errno().
UC-7101/7110/7112 Software User’s Manual UC-7101/7110/7112 Device API 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 to reboot again and again. 5.
UC-7101/7110/7112 Software User’s Manual struct timeval UC-7101/7110/7112 Device API time; time.tv_sec = msec / 1000; time.
A Appendix A System Commands µClinux normal command utility collection File manager cp ls ln mount rm chmod chown chgrp sync mv pwd df du mkdir rmdir head tail touch copy file list file make symbolic link file mount and check file system delete file change file owner & group & user change file owner change file group sync file system; save system file buffer to hardware move file display active file directly list active file system space estimate file space usage make new directory delete directory prin
UC-7101/7110/7112 Software User’s Manual System Commands Network ping route netstat ifconfig tftp telnet ftp iptables ping to test network routing table manager display network status set network IP address tftp protocol user interface to TELNET protocol file transfer protocol iptables command kill killall ps sleep kill process kill process by name report process status suspend command on time dmesg stty mknod free date env clear reboot halt gzip, gunzip, zcat hostname tar dump kernel log message set
B Appendix B SNMP Agent with MIB II & RS-232 Like Group The UC-7101/7110/7112 has a built-in SNMP (Simple Network Management Protocol) agent that supports RFC1317 RS-232 like group and RFC 1213 MIB-II. The following table lists the variable implementation for the UC-7101/7110/7112. The full SNMP object ID of the UC-7101/7110/7112 is .iso.3.6.1.4.1.8691.12.7112 and .iso.3.6.1.4.1.8691.12.7110. Note that the UC-7101/7110/7112 does not support SNMP trap.
UC-7101/7110/7112 Software User’s Manual ip MIB ipForwarding ipDefaultTTL ipInReceives ipInHdrErrors ipInAddrErrors ipForwDatagrams ipInUnknownProtos ipInDiscards ipInDelivers ipOutRequests ipOutDiscards ipOutNoRoutes ipReasmTimeout ipReasmReqds ipReasmFails ipFragOKs ipFragFails ipFragCreates ipAddrTable ipAdEntAddr ipAdEntIfIndex ipAdEntNetMask ipAdEntBcastAddr ipAdEntReasmMaxSize ipRouteTable ipRouteDest ipRouteIfIndex ipRouteMetric1 ipRouteMetric2 ipRouteMetric3 ipRouteMetric4 ipRouteNextHop ipRouteType
UC-7101/7110/7112 Software User’s Manual SNMP Agent snmp MIB snmpInPkts snmpOutPkts snmpInBadVersions snmpInBadCommunityNames snmpInBadCommunityUses snmpInASNParseErrs snmpInTooBigs snmpInNoSuchNames snmpInBadValues snmpInReadOnlys snmpInGenErrs snmpInTotalReqVars snmpInTotalSetVars snmpInGetRequests snmpInGetNexts snmpInSetRequests snmpInGetResponses snmpInTraps snmpOutTooBigs snmpOutNoSuchNames snmpOutBadValues snmpOutGenErrs snmpOutGetRequests snmpOutGetNexts snmpOutSetRequests snmpOutTraps snmpEnableA
C Appendix C FAQ FAQ 1 Why am I only able to use vfork ( ),and cannot use fork ( )? Answer 1 μClinux only supports vfork ( ). It does not support fork ( ). Note that when using vfork ( ), the parent process will hang until the child process calls an exec group API, or exits.