操作系统:ubuntu10.04
测试代码:
1,arm汇编程序
-
@******************************************************************************
-
@ File:start.S
-
@ 功能:通过它转入C程序
-
@******************************************************************************
-
-
.text
-
.global _start
-
_start:
-
ldr r0, =0x53000000 @ WATCHDOG 寄存器地址
-
mov r1, #0x0
-
str r1, [r0] @ 写入0,禁止WATCHDOG,否则CPU会不断重启
-
-
ldr sp, =1024*3 @ 设置堆栈,注意:不能大于4k, 因为现在可用的内存只有4K
-
@ nand flash中的代码在复位后会移到内部ram中,此ram只有4K
-
-
bl main @ 调用C程序中的main函数
-
-
loop:
-
b loop
2,C语言程序
-
#define GPFCON (*(volatile unsigned long*)0x56000050)
-
#define GPFDAT (*(volatile unsigned long*)0x56000054)
-
-
-
int main(void)
-
{
-
GPFCON = 0x00001100; // 设置GPF5,6为输出口, 位[11:10]=0b01,[13:12]=0b01
-
GPFDAT = 0x00000000; // GPF5,6输出0,LED2,LED3点亮
-
-
return 0;
-
}
3,makefile 程序
-
###############################################################################
-
#
-
# A smart Makefile template for GNU/LINUX programming
-
#
-
# Author: SR
-
# Date:
-
#
-
# Usage:
-
# $ make Compile and link (or archive)
-
# $ make clean Clean the objectives and target.
-
###############################################################################
-
-
CROSS_COMPILE = arm-linux-
-
OPTIMIZE := -O2
-
WARNINGS := -Wall -Wno-unused -Wno-format
-
DEFS := -DMYDEF=1 -UMYDEF2
-
EXTRA_CFLAGS :=
-
CFLAGS = $(EXTRA_CFLAGS) $(WARNINGS) $(OPTIMIZE) $(DEFS)
-
-
-
GCC := $(CROSS_COMPILE)gcc
-
LD := $(CROSS_COMPILE)ld
-
OBJCOPY := $(CROSS_COMPILE)objcopy
-
OBJDUMP := $(CROSS_COMPILE)objdump
-
-
-
-
led_main.bin : start.S led_main.c
-
$(GCC) -g -c -o start.o start.S
-
$(GCC) -g -c -o led_main.o led_main.c
-
$(LD) -Ttext 0x0001024 -g start.o led_main.o -o led_main_elf
-
$(OBJCOPY) -O binary -S led_main_elf led_main.bin
-
$(OBJDUMP) -D -m arm led_main_elf > led_main.dis
-
-
-
-
-
PHONY = clean
-
-
clean:
-
rm -f led_main.bin led_main_elf *.o *.dis
-
-
.PHONY: $(PHONY)
疑问:为什么不需要设置时钟频率??
答案:
*arm9 S3C2440系统时钟
阅读(1598) | 评论(0) | 转发(0) |