天嵌 ARM开发社区

 找回密码
 注册
查看: 3478|回复: 0

TQ6410重定位的问题

[复制链接]
xiebo 发表于 2015-7-13 21:15:42 | 显示全部楼层 |阅读模式
我写的重定位代码通过SD卡启动下载到NandFlash中,拨码开关拨到Nand启动,重新上电后发现程序不能运行,但是直接下载到内存就能运行,请天嵌技术支持工作人员给予帮助,谢谢!

下载到Nand 使用的是[1]Download u-boot or STEPLDR.nbl or other bootloader to Nand Flash
下载到SDRAM 使用的是[7]Download Program to SDRAM and Run it




代码和链接脚本如下:
.globl _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]

    bl clock_init
   
/* 为调用C函数准备环境 */
    ldr sp, =0x0C002000
    bl sdram_init

/* 重定位代码 */
/* 把程序的代码段、数据段复制到它的链接地址去 */   
    adr r0, _start      /* _start   获得_start指令当前所在的地址 : 0*/
    ldr r1, =_start  /* _start的链接地址 0x50000000 */
   
    ldr r2, =bss_start      /* bss段的起始链接地址 */
   
    cmp r0,r1
    beq clean_bss
   
copy_loop:
    ldr r3, [r0], #4
    str r3, [r1], #4
    cmp r1, r2
    bne copy_loop   


/* 把BSS段对应的内存清零 */
clean_bss:
    ldr r0, =bss_start
    ldr r1, =bss_end
    mov r3, #0
    cmp r0, r1
    ldreq pc, =on_ddr
clean_loop:
    str r3, [r0], #4
    cmp r0, r1   
    bne clean_loop
    ldr pc, =on_ddr   

on_ddr:
/* 调用C函数 */
    /* ldr sp,=0x50008000 */
    ldr pc, =main  /* pc等于main的链接地址 */


链接脚本:
SECTIONS
{
    . = 0x50000000;
    .text :
    {
        start.o
        * (.text)
    }
   
    . = ALIGN(4);
    .rodata :
    {
        * (.rodata)
    }
   
    . = ALIGN(4);
    .data :
    {
        * (.data)
    }

    . = ALIGN(4);   
   
    bss_start = . ;  /* 0x50000450 */
   
    .bss :
    {
        * (.bss)     /* i */
        * (.common)
    }
   
    bss_end = . ;   /* 0x50000450 */
}



您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-21 22:44 , Processed in 1.031250 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表