Moxa Technologies UC-7420/7410 Test Program-Developing Hello.c, Installing the Tool Chain Linux

Page 33

UC-7420/7410 User’s Manual

Getting Started

Test Program—Developing Hello.c

In this section, we use the standard “Hello” programming example to illustrate how to develop a program for UC-7420/7410. In general, program development involves the following seven steps.

Step 1:

Connect UC-7420/7410 to a Linux PC.

Step 2:

x

 

Install Tool Chain (GNU Cross Compiler & glibc).

 

Step 3:

 

Set the cross compiler and glibc environment variables.

 

Step 4:

 

Code and compile the program.

 

Step 5:

 

Download the program to UC-7420/7410 Via FTP or

 

NFS.

 

Step 6:

 

Debug the program

 

ÆIf bugs are found, return to Step 4.

ÆIf no bugs are found, continue with Step 7

Step 7:

Back up the user directory (distribute the program to additional UC-7420/7410 units if needed).

Cross

Compiler

Installing the Tool Chain (Linux)

The PC must have the Linux Operating System pre-installed before installing the UC-7420/7410 GNU Tool Chain. Redhat 7.3/8.0, Fedora core, and compatible versions are recommended. The Tool Chain requires about 100 MB of hard disk space on your PC. The UC-7420/7410 Tool Chain software is located on the UC-7420/7410 CD. To install the Tool Chain, insert the CD into your PC and then issue the following commands:

#mount /dev/cdrom /mnt/cdrom

#rpm –ivh /mnt/cdrom/mxscaleeb-3.3.2-1.386.rpm

The Tool Chain will be installed automatically on your Linux PC within a few minutes. Before compiling the program, be sure to set the following path first, since the ToolChain files, including the compiler, link, library, and include files are located in this directory.

PATH=/usr/local/mxscaleb/bin:$PATH

Setting the path allows you to run the compiler from any directory.

NOTE Refer to Appendix B for an introduction to the Windows Tool Chain. In this chapter, we use the Linux tool chain to illustrate the cross compiling process.

Checking the Flash Memory Space

If the flash memory is full, you will not be able to save data to the Flash ROM. Use the following command to calculate the amount of “Available” flash memory:

/>df –h

2-13

Image 33
Contents Third Edition, June UC-7420/7410 User’s ManualCopyright Notice TrademarksDisclaimer Table of Contents Chapter UC Finder Appendix B Windows Tool Chain Introduction ‰ Hardware Introduction IntroductionProduct Features Package ChecklistOverview UC-7410-LXProduct Hardware Specifications Appearance and Dimensions Hardware IntroductionAppearance Dimensions Hardware Block Diagram LED IndicatorsLED Name Color Meaning Reset Button Reset-type ButtonsReset to default Button Real Time ClockWall or Cabinet Placement OptionsWiring Requirements Hardware Connection DescriptionDIN-Rail Mounting Connecting to the Network Connecting the PowerPin Signal Grounding UC-7420/7410Connecting to the Console Port Connecting to a Serial DeviceCompactFlash Pin RS-232 RS-422 RS-485Software Architecture Software IntroductionSoftware Package Journaling Flash File System JFFS2Software Version Comparison Table Directory Change Protocol stacks and utilitiesGetting Started ‰ Configuring the Ethernet InterfacePowering on UC-7420/7410 Connecting UC-7420/7410 to a PCSerial Console Telnet Console Default IP Address Netmask192.168.3.127 255.255.255.0 192.168.4.127 255.255.255.0Windows Users SSH ConsoleModifying Network Settings with the Serial Console Configuring the Ethernet InterfaceLinux Users Static IP addressesDynamic IP addresses Modifying Network Settings over the Network Configuring the Wlan via the Pcmcia InterfaceDefault IP address is 192.168.5.127, netmask IEEE802.11b#vi /etc/wlan/wlancfg-any IEEE802.11g Setting Setting ExplanationKey1Str, Key2Str, Key3Str, Key4Str-Sets strings Key1 to Key4 TurboRate-Enables or disables TurboRate Test Program-Developing Hello.c Installing the Tool Chain LinuxChecking the Flash Memory Space StepYou should receive the following response Compiling Hello.cTesting Environment Developing Your First ApplicationUploading Hello to UC-7420/7410 and Running the Program #mount -t iso9660 /dev/cdrom /mnt/cdrom Compiling tcps2.cPuTTY Uploading tcps2-release and Running the Program#jobs // use this command to check if the program is running UC-7420/7410 User’s Manual Testing Procedure SummaryUC-7420/7410 User’s Manual Managing Embedded Linux ‰ System Version Information ‰ System Image BackupSystem Version Information System Image BackupUpgrading the Firmware Upgrading the firmware will erase all data on the Flash ROM#upramdisk #cd /mnt/ramdisk Loading Factory Defaults Backing Up the User File System Firmware versions earlier than V1.5 not includingFirmware version V1.5 and later versions Enabling and Disabling Daemons UC-7420/7410 User’s Manual Managing Embedded Linux Setting the Run-Level Setting the Time Manually Adjusting the System TimeExample shell script to update the system time periodically NTP ClientUpdating the Time Automatically Change mode of fixtime.sh Cron-daemon to Execute Scheduled CommandsEnable the cron daemon manually Enable cron when the system boots upConnecting Peripherals USB Mass StorageCF Mass Storage ‰ Iptables ‰ NAT Managing CommunicationsTelnet / FTP Web Service-ApacheEnabling the Telnet/ftp server Disabling the Telnet/ftp serverUsr/www/cgi-bin Saving a Web Page to the CF Card Use the following commands to restart the Apache web server Iptables Local Host Packets Define policy for chain rules Observe and erase chain rulesUsage ExamplesIptmac Append or delete rulesNAT Example Enabling NAT at BootupDial-up Service-PPP Example 2 Connecting to a PPP server over a hard-wired link UP Loopback Running How to check the connectionSetting up a Machine for Incoming PPP Connections Setting up UC-7420/7410 as an NFS ServerNFS Network File System #vi /etc/exportsSetting up UC-7420/7410 as an NFS Client Steps 2 MailOpen VPN Internet IFS=‘ Create link symbols to enable this script at boot time Destination Gateway Genmsk Flags Metric Use Iface Now ping Host B from Host a by typing Setup 3 Routed IP Destination Gateway Genmsk Flags Metric Use Iface Programmer’s Guide Address Size Contents Flash Memory MapLinux Tool Chain Introduction Obtaining help Debugging with GDBCross Compiling Applications and Libraries Tools Available in the Host EnvironmentDevice API RTC Real Time ClockBuzzer WDT Watch Dog Timer Input Int fd File handle from swtdopen return value Output User application example Example Special NoteSwtddisableswtdfd Int mainint argc, char *argv Pidt sonpid Example to get the baud rate Example to set the baud rateBaud rate inaccuracy KeyPadSpecial Note ExamplesMake File Example UC Finder Windows UC Finder Installing the SoftwareUC-7420/7410 User’s Manual UC Finder Broadcast Search Linux ucfinder Busybox V0.60.4 Linux normal command utility collection System CommandsFile manager EditorProcess OtherMoxa special utilities Windows Tool Chain Introduction Introduction Select the Root Directory Installation ProcedureUC-7420/7410 User’s Manual Windows Tool Chain Introduction UC-7420/7410 User’s Manual Windows Tool Chain Introduction Using the Bash Shell UC-7420/7410 User’s Manual Windows Tool Chain Introduction GDB debug tool-InsightUC-7420/7410 User’s Manual Windows Tool Chain Introduction Service Information Following services are provided Moxa Internet ServicesMoxa Product † UC-7410-LX † UC-7420-LX Serial Number Problem Report FormProduct Return Procedure