Moxa W321-LX [22/80] Compiling hello c

Moxa W341-LX [22/80] Compiling hello c
W321/341 Linux Getting Started
2-14
If there isn’t enough “Available” space for your application, you will need to delete some existing files. To do
this, connect your PC to the W321/341 with the console cable, and then use the console utility to delete the files
from the W321/341’s flash memory. To check the amount of free space available, look at the directories in the
read/write directory
/dev/mtdblock3. Note that the directories /home and /etc are both mounted on the
directory
/dev/mtdblock3.
NOTE
If the flash memory is full, you will need to free up some memory space before saving files to the Flash ROM.
Compiling Hello.c
The package CD contains several example programs. Here we use Hello.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/W321/* /tmp/example
To compile the program, go to the Hello subdirectory and issue the following commands:
#cd example/W321/hello #make
You should receive the following response:
[root@localhost hello]# make
/usr/local/arm-linux/bin/arm-linux-gcc –o hello-release hello.c
/usr/local/arm-linux/bin/arm-linux-strip –s hello-release
/usr/local/arm-linux/bin/arm-linux-gcc –ggdb -o hello-debug hello.c
[root@localhost hello]# _
Next, execute make to generate hello-release and hello-debug, which are described below:
hello-releasean ARM platform execution file (created specifically to run on the W321/341)
hello-debugan ARM platform GDB debug server execution file (see Chapter 5 for details about the GDB
debug tool).
NOTE
Since Moxa’s tool chain places a specially designed
Makefile in the directory /tmp/example/W321/hello
,
be sure to type the
#make command from within that directory. This special Makefile uses the mxscale-
gcc
compiler to compile the hello.c source code for the Xscale environment. If you type the
#make
command from
within any other directory, Linux will use the x86 compiler (for example, cc or gcc).
Refer to Chapter 5 to see a Makefile example.
Uploading and Running the “Hello” Program
Use the following commands to upload hello-release to the W321/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> cd /home
ftp> put hello-release
3. From the W321/341, type:
# chmod +x hello-release
# ./hello-release

Содержание

Похожие устройства

Скачать
Случайные обсуждения