求大佬帮忙看一下哪错了 。。 led灯不亮。。head.S
.text
.global _start
_start:
ldr sp,=4096
bl disable_watch_dog
bl memsetup
bl copy_steppingstone_to_sdram
ldr pc,=on_sdram
on_sdram:
ldr sp,=0x34000000
bl main
halt_loop:
b halt_loop
one_led.c
#define GPFCON (*(volatile unsigned long )0x56000050)
#define GPFDAT ((volatile unsigned long *)0x56000054)
int main()
{
GPFCON = 0x00000100; // 设置GPF4为输出口, 位[9:8]=0b01
GPFDAT = 0x00000000; // GPF4输出0,LED1点亮
return 0;
}
init.c
#define WAT_DOG (*(volatile unsigned long *) 0x53000000)
#define MEM_CTL_BASE 0x48000000
void disable_watch_dog(void)
{
WAT_DOG = 0x0;
}
void memsetup(void)
{
unsigned long const mem_cfg_val[]={
0x22011110,
0x00000700,//0
0x00000700,//1
0x00000700,//2
0x00000700,//3
0x00000700,//4
0x00000700,//5
0x00018005,
0x00018005,
0x008C07A3,
0x000000B1,
0x00000030,
0x00000030,
};
int i=0;
volatile unsigned long p=(volatile unsigned long)MEM_CTL_BASE;
for(;i<13;i++)
p[i]=mem_cfg_val[i];
}
void copy_steppingstone_to_sdram(void)
{
unsigned int *pdwSrc=(unsigned int *)0;
unsigned int *pdwDest=(unsigned int *)0x30000000;
while(pdwSrc<(unsigned int *)4096)
{
*pdwDest=*pdwSrc;
pdwDest++;
pdwSrc++;
}
}
Makefile
sdram.bin:head.S one_led.c init.c
arm-linux-gcc -g -c -o head.o head.S
arm-linux-gcc -g -c -o one_led.o one_led.c
arm-linux-gcc -g -c -o init.o init.c
arm-linux-ld -Ttext 0x30000000 head.o one_led.o init.o -o sdram_elf
arm-linux-objcopy -O binary -S sdram_elf sdram.bin
clean:
rm -f sdram.bin sdram_elf *.o