ITPub博客

首页 > IT职业 > IT职场 > 让LED程序在片外SDRAM中运行

让LED程序在片外SDRAM中运行

IT职场 作者:liangyh 时间:2021-09-09 09:39:19 0 删除 编辑

作者:@outs
本文为作者原创,转载请注明出处:https://www.cnblogs.com/outs/p/9385081.html


 

加载SDRAM以及ldr,bl实现跳转的区别

  • 汇编指令-位置无关码(BL)与绝对位置码(LDR)(2)

  • 2. led.c

    #define GPBCON      (*(volatile unsigned long *)0x56000010)#define GPBDAT      (*(volatile unsigned long *)0x56000014)#define GPB5_out    (1 0; dly--);
    }int main(void){    unsigned long i = 5;
        
        GPBCON = GPB5_out|GPB6_out|GPB7_out|GPB8_out;       // 将LED1-4对应的GPB5/6/7/8四个引脚设为输出
    
        while(1){
            wait(30000);
            GPBDAT = (~(1

    以上的main函数,即为led.S中调用的main。其作用为依次点亮4个LED。

    3. makefile

    sdram.bin : head.S  leds.c
        arm-linux-gcc  -c -o head.o head.S
        arm-linux-gcc -c -o leds.o leds.c
        arm-linux-ld -Ttext 0x30000000 head.o leds.o -o sdram_elf
        arm-linux-objcopy -O binary -S sdram_elf sdram.bin
        arm-linux-objdump -D -m arm  sdram_elf > sdram.disclean:
        rm -f   sdram.dis sdram.bin sdram_elf *.o

    以上是makefile的内容,需要注意的一点是,程序的链接地址被指定为0x30000000,它与led.S中的SDRAM_BASE值应一致。

    三、烧录

    将Mini2440通过串口线、USB线与电脑连接,设置为从NandFlash启动(假定NandFlash中已经烧录了supervivi),按住开发板上任意一个按键,然后上电,这时串口会打印出以下信息,提示你输入指令:

    ##### FriendlyARM BIOS for 2440 #####
    [x] bon part 0 320k 2368k
    [v] Download vivi 
    [k] Download linux kernel 
    [y] Download root_yaffs image 
    [a] Absolute User Application
    [n] Download Nboot 
    [l] Download WinCE boot-logo
    [w] Download WinCE NK.bin 
    [d] Download & Run 
    [z] Download zImage into RAM 
    [g] Boot linux from RAM 
    [f] Format the nand flash 
    [b] Boot the system 
    [s] Set the boot parameters 
    [u] Backup NAND Flash to HOST through USB(upload) 
    [r] Restore NAND Flash from HOST through USB 
    [q] Goto shell of vivi 
    [i] Version: 1026-12
    Enter your selection:

    在电脑键盘上敲击a,在dnw中选择由以上3个文件make生成的sdram.bin文件,将其烧录至NandFlash中。
    烧录完成后,重新给开发板上电,可以看到4个LED灯被依次点亮。

    烧录过程中需要注意的是,指令a是将bin文件烧录至Nandflash中,此时dnw中的Download Address是没有作用的。而指令d则是将bin文件烧录至SDRAM中,此时设置的Download Address才起作用。

    如果使用指令d将生成的sdram.bin烧录至sdram中,有可能达不到实验效果。因为在烧录完成后,sdram.bin被执行,它会将0地址即steppingstone处的4K内容拷贝至0x30000000处,而要知道,被拷贝的steppingstone中的4K数据,并不是我们的sdram.bin,而是本次上电时NandFlash前4K的数据。

    原文出处:https://www.cnblogs.com/outs/p/9385081.html

    来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2260/viewspace-2805676/ ,如需转载,请注明出处,否则将追究法律责任。

    请登录后发表评论 登录
    全部评论

    注册时间:2019-04-16

    • 博文量
      86
    • 访问量
      838