sdram 裸机程序

硬件平台 :JZ2440

实现功能:将led闪烁代码从2440的2k sram中拷贝到sdram

start.s      -->   上电初始化,拷贝代码

sdram.c   -->   led代码

start.s 源码:

.equ MENRI_BASE, 0x48000000
.equ SDRAM_BASE, 0x30000000 .text
.global _start
_start:
bl close_watchdog
bl sdram_set
bl copy_sram_to_sdram
ldr pc,=on_sdram
on_sdram:
ldr sp,=0x34000000
bl main
loop1:
b loop1 close_watchdog:
ldr r0,=0x53000000
mov r1,#0x0
str r1,[r0]
mov pc,lr copy_sram_to_sdram:
ldr r0,=SDRAM_BASE
mov r1,#0x0
mov r3,#*
l:
ldr r4,[r1], #
str r4,[r0],#
cmp r1, r3
bne l mov pc,lr sdram_set:
mov r1,#MENRI_BASE
adrl r2,mem_reg_set
add r3,r1,#
m:
ldr r4,[r2],#
str r4,[r1],#
cmp r1,r3
bne m mov pc,lr .align
mem_reg_set:
.long 0x22011110
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00018005
.long 0x00018005
.long 0x008c07a3
.long 0x000000b1
.long 0x00000030
.long 0x00000030

sdram.c 源码:

#define GPFCON (*(unsigned long *)0x56000050)
#define GPFDAT (*(unsigned long *)0x56000054)
#define LED1_ON (1<<8)
#define LED2_ON (1<<10)
#define LED3_ON (1<<12) void delay(unsigned long num)
{
while(--num);
} int main(void)
{
GPFCON=LED1_ON|LED2_ON|LED3_ON;
while()
{
GPFDAT=(<<);
delay();
GPFDAT=(<<);
delay();
GPFDAT=(<<);
delay();
} return ;
}

编译的Makefile:

sdram.bin:start.s sdram.c
arm-linux-gcc -o start.o -c start.s
arm-linux-gcc -o sdram.o -c sdram.c
arm-linux-ld -Ttext 0x3000000 -o sdram_elf start.o sdram.o
arm-linux-objcopy -O binary -S sdram_elf sdram.bin
arm-linux-objdump -D -m arm sdram_elf > sdram.dis
clean:
rm *.o *.dis *.bin sdram_elf

    

上一篇:C# is与as


下一篇:频繁更换ip会影响SEO优化吗?