.text .globl _start _start: ldr r0, =0x70000000 orr r0, r0, #0x13 mcr p15, 0, r0, c15, c2, 4 ldr r0, =0x7e004000 mov r1, #0 str r1, [r0] ldr sp, =8*1024 bl xxxx b .
start.S文件代碼; linux
void delay () { int i; for (i = 0; i < 100000; i++) ; } int xxxx (void) { volatile unsigned long *gpmcon = (volatile unsigned long *)0x7f008820; volatile unsigned long *gpmdat = (volatile unsigned long *)0x7f008824; int i; for (i = 1; i <= 4; i++){ if (1 == i){ *gpmcon &= ~0xffff; *gpmcon |= 0x1; }else if (2 == i){ *gpmcon &= ~0xffff; *gpmcon |= 0x10; }else if (3 == i){ *gpmcon &= ~0xffff; *gpmcon |= 0x100; }else if (4 == i){ *gpmcon &= ~0xffff; *gpmcon |= 0x1000; i = 0; } *gpmdat = 0; delay(); } return 0; }
led.c 文件代碼; code
all:start.o led.o arm-linux-ld -Ttext 0 -o led.elf start.o led.o arm-linux-objcopy -O binary led.elf led.bin arm-linux-objdump -D led.elf > led.dis cp led.bin /tftpboot/led.bin start.o: arm-linux-gcc -c start.S -o start.o led.o: arm-linux-gcc -c -o led.o led.c clean: rm -rf *.o *.elf *.dis *.bin /tftpboot/*.bin
Makefile文件代碼; class