1. 實驗環境:
(1).在Embedded Linux 2.6 OS上run.
(2).PC OS:Ubuntu 8.10.
(3).實驗平台:ADP-XC5FF676 v1.1(Andes core N12).
2.範例程式_Hello:
http://cid-b01cb9ac20175eaa.skydrive.live.com/self.aspx/hello/hello.zip(1).hello.c
-----------------------------------------------------------------------------
#include "stdio.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcnt.h"
int main(void)
{
int fd; char ch;
printf("\nHello World!\n");
sleep(1);
return 0;
}-----------------------------------------------------------------------------
(2)Makefile
-----------------------------------------------------------------------------
###########################################
# Copyright (C) 2006-2007 Andes Technology, Inc.
#
# Abstract:
#
# Makefile Experiment.
#
# Revision History:
#
# 2007-09-01 First created by Andestech
###########################################
# CROSS Tools
#CROSS=$(PREFIX)/bin/nds32-elf-
CROSS=nds32-elf-
CC = $(CROSS)gcc
AS = $(CROSS)as
AR = $(CROSS)ar
LD = $(CROSS)ld
NM = $(CROSS)nm
OBJCOPY = $(CROSS)objcopy
OBJDUMP = $(CROSS)objdump
READELF = $(CROSS)readelf
# FLAG
CFLAGS = -g3 -O0 -c -mlib=glibc -EL
#CFLAGS = -g3 -O0 -Wall -c
LDFLAGS = -static -mlib=glibc -EL
#ASMFLAGS = -g3 -O0 -Wall -S
#ASFLAGS = -g3
.PHONY: all clean test
OBJECT = hello
CEXE = $(OBJECT).adx
RM := rm -f
OBJECTS = hello.o
# Rules
all: $(OBJECTS)
$(CC) $(LDFLAGS) -o $(CEXE) $(OBJECTS)
@echo 'Finished building.'
hello.o: hello.c
#$(CC) $(CFLAGS) hello.c -o hello.o
$(CC) $(CFLAGS) $< -o $@ clean: $(RM) $(OBJECTS) $(CEXE) @echo 'Finished cleaned.'-----------------------------------------------------------------------------
3. 將上述的Makefile與hello.c放在同一個目錄下.
4. 使用"Terminal"輸入"
make all",會產生下列訊息.
-----------------------------------------------------------------------------
nds32-elf-gcc -g3 -O0 -c -mlib=glibc -EL hello.c -o
hello.onds32-elf-gcc -static -mlib=glibc -EL -o hello.adx hello.o
Finished building.
-----------------------------------------------------------------------------
5. 之後產生hello.o與hello.adx檔.
6. 將hello.adx存在SD卡內,並裝上ADP-XC5FF676 V1.1實驗板上,並接上URAT與電腦連接後,開啟電源,按
SW2->
SW4.
7. 使用"超級終端機",輸入"
91"進入Embedded Linux.
8. 在Embedded Linux下鍵入:
(1)"
mount -o mand /dev/cf /tmp" ,掛載SD卡.
(2)"
cd tmp"進入SD卡位置.
(3) 在存放程式的目錄內輸入
"./hello.adx"
9.在"超級終端機"顯示結果如下所示:
*SD卡卸載輸入"
umount /tmp"