init.s文件:
PRESERVE8
IMPORT main
AREA |C$$code|, CODE, READONLY
global start
start
;/* 硬件相关的设置 */
;/* Peri port setup */
ldr r0, =0x70000000
orr r0, r0, #0x13
mcr p15,0,r0,c15,c2,4 ; //@ 256M(0x70000000-0x7fffffff)
;/* 关看门狗 */
;/* 往WTCON(0x7E004000)写0 */
ldr r0, =0x7E004000
mov r1, #0
str r1, [r0]
;/*堆栈*/
ldr sp,=8*1024 ;//@此时堆栈的大小不能大于8K,SRAM只有8K
bl main
halt
b halt
END
main.c文件:
#define rGPMCON (*(volatile unsigned *)(0x7F008820))
#define rGPMDAT (*(volatile unsigned *)(0x7F008824))
#define rGPMPUD (*(volatile unsigned *)(0x7F008828))
void msDelay(int time)
{
volatile unsigned int i,j;
for(i = 0; i < 20; i++) ;//如果是532M的时钟,应该用2000000
for(j=0; j
void delay()
{
volatile int i = 0x10000;
while (i--);
}
void GPIO_Init(void)
{
rGPMCON = 0x11111;
rGPMPUD = 0x00;
rGPMDAT = 0X1F;
}
void LedTest(void)
{
volatile unsigned int i;
while (1)
{
for(i=0; i<4; i++)
{
rGPMDAT = ~(1< delay();
}
}
}
void main(void)
{
GPIO_Init();
LedTest();
while(1);
}
编译:
RVDS需要进行设置一下
1.target settings->post-linker->arm realview fromELF
2.language settings->arm1176JZF-S
3.language compiler->arm1176JZF-S
4.realview linker->simple->0x50000000
->Image entry point->0x50000000
->init.o
5.realview fromelf->output file name->demo.bin
操作步骤::
首先切换到SD卡的uboot:
1.dnw 50008000
2.把文件通过USB传输进来
3.nand erase 0 100000
4.nand write.uboot 50008000 0 100000
5.切换到nand启动,效果就出来了!!