EDN首页   博客首页

最新日志

发表于:2008-6-21 15:30:43
标签:无标签

1

u-boot c部分流程

c部分代码分析。

rar

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(4) | 阅读(269)
发表于:2008-6-21 15:26:00
标签:无标签

1

u-boot-120 移植

支持nandflash启动,nandflash操作。

修改go命令,支持kernel的引导。

点击下载

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(278)
发表于:2008-6-21 15:14:44
标签:无标签

1

u-boot 关于代码搬移

对u-boot启动代码start.s(汇编部分)的注解。

需要注意的是代码的搬运过程。

对于从nandflash启动的s3c2410,上电后会自动从nandflash搬移4k代码(肯定包含start.s部分)到0地址的缓存(bootstone)中,然后从0地址开始读取指令并运行。那么这4k的代码必须实现必要的初始化和u-boot代码的搬移(到sdram中),最后u-boot将在sdram中运行。

u-boot默认是从norflash或sdram中启动运行的。原版的start.s对于代码搬移的实现如下:

1,首先读取_start的地址值(相对pc的值,特别注意adr伪指令)和_TEXT_BASE地址处TEXT_BASE的值(在连接脚本中定义的常数),以判别程序从哪里运行,是否需要搬移。

relocate:               /* relocate U-Boot to RAM       */

    adr r0, _start      /* r0 <- current position of code   */

    ldr r1, _TEXT_BASE      /* test if we run from flash or RAM */

    cmp     r0, r1                

    beq     stack_setup

 

2,如果需要,搬移所有整个代码段到sdram(TEXT_BASE地址处)。下面用于计算代码段长度和代码段终止地址。

 

    ldr r2, _armboot_start

    ldr r3, _bss_start

    sub r2, r3, r2      /* r2 <- size of armboot            */

    add r2, r0, r2      /* r2 <- source end address         */

 

3,如果是从nandflash启动,上述实际上只有效搬移了4k的代码到sdram,因为u-boot代码段大部分还在nandflash中。所以需要添加从nandflash拷贝到sdram的代码。这里由copy_myself函数实现,再次搬移了128k,并且覆盖了前次搬移的4k。

 

     bl    copy_myself

 

4,搬移完成后,程序必须跳到sdram中去运行。注意下面的ldr伪指令,得到on_the_ram的绝对地址(连接完成后就是个常数值,位于sdram中),然后赋值给pc。

 

    @ jump to ram

      ldr   r1, =on_the_ram

      add   pc, r1, #0

 

5,跳到start_armboot(),运行第一跳c指令。这里的ldr是普通指令,_start_armboot标号处存储了start_armboot()函数的绝对地址(连接完就是个常数)。到此start.s的工作完成。

    on_the_ram:

    #endif

    /*end add*/

 

        ldr pc, _start_armboot

 

    _start_armboot: .word start_armboot

 

点击下载

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(366)
发表于:2008-6-21 14:15:23
标签:无标签

1

u-boot intro

u-boot简介。

u-boot命令说明。

u-boot添加自定义命令流程。

u-boot启动流程。点击下载

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(364)
发表于:2008-6-12 2:55:35
标签:无标签

2

a sample of apologyletter

        前言:真的没想到陈冠希会用全英文做道歉陈述,虽然知道他是CBC(Canadian Born Chinese),但英文水平还是让我佩服。他500多字的道歉信, 用词准确地道,词汇难度较高,包含了50多个考研(雅思)核心词汇,经过改编完全可以成为一篇高质量的考研完形填空,或雅思阅读理解。Edison这小子虽然"猥琐",但英文用词的难度达到了考研英语(国内最变态英语考试)的要求,如果参加雅思考试估计8分以上不成问题。

  推荐理由: 超敬业的同声翻译, 不仅翻译准确及时, 而且激情投入感情充沛,让人感觉就像是自己刚刚拍了艳照被人发现.

  Today I have come back to Hong Kong to stand before you and account for myself. I have never escaped from my responsibility. During the past few weeks, I have been with my mother and my family and my loved ones to show support and care and at the same time to have them support and care for me.

  核心词汇解析

  account for 1) 说明,解释;2) 占…比例

  escape from从…逃脱, 推卸责任

  escape=es(ex=out) + cape(catch)

  I admit that most of the photos being circulated on the Internet were taken by me. But these photos are very private and have not been shown to people and are never intended to be shown to anyone. These photos were stolen from me illegally and distributed without my consent.

  核心词汇解析

  circulate = circul(circle圆圈) + ate v.循环,流通

  intend to v.打算去…

  illegal = il(not) + legal (合法的) + ly adv.违法地

  单词组记: distribute, contribute, attribute, tribute

  distribute = dis(away)+ tribute(give) = give away vt.分发,传播

  contribute = con(fully) + tribute vt.贡献; 投稿 [助记]全部都给了

  attribute to v.归因于

  tribute n.贡品,颂词 [助记] 给国王的礼物

  单词组记:consent, dissent, resent, sentimental

  consent = con(共同)+ sent(=sense情感) n.赞同,同意=agreement

  dissent = dis(not) + sent n.不同意 [助记]不同的情感 = disagreement

  resent = re(against) + sent n.憎恨 [助记] 相对抗的情感= hatred

  sentimental[谐音]三屉馒头,失恋了只吃三屉馒头,所以是---a.多愁善感的

  There is no doubt whoever obtained these photos have them uploaded on the Internet with malicious and deliberate intent. This matter has deteriorated to theextent that society as a whole has been affected by this. In this regard, I am deeply saddened. I would like now to apologize to all the people for all the suffering that has been caused and the problems that have arisen from this. I would like to apologize to all the ladies and to all their families for any harm or hurt that they have been feeling. I am sorry. I would like to also apologize to my mother and my father for the pain and suffering I have caused them
  during the past few weeks. Most importantly, I would like to say sorry to all the people of Hong Kong . I give my apology sincerely to you all, unreservedly and with my heart.

  核心词汇解析

  upload = up + load vt.上传(图片, 文件等)

  download = down + load vt.下载(图片,文件等)

  单词组记: mal-=bad坏

  malice = mal + ice(冰) n.恶意;【律】预谋, 蓄意 [助记]在路上放一块冰,想让陈冠希

  滑倒,这是有预谋的恶意伤害。

  malicious= malice(恶意) + ious(形容词) a.恶意的

  mal-function n.功能紊乱

  mal-nutrition n.营养不良

  maltreat = mal + treat(对待) vt.虐待

  单词组记: libra天平, deliberate, liberate, liberty, libertine, libido

  一直到现在,英国的法院门口还站立着古希腊象征法律精神的正义女神(DICE)的雕像,她左手拿着神圣的天平Libra,象征着权衡和平等;右手拿着宝剑,象征着裁决和力量;眼睛被布蒙着,象征绝对的公正无私。

  deliberate = de(强调) + libera(=libra) + ate a. 深思熟虑的, 故意的 [助记] 把你的想法放在天平上称量,引申为深思熟虑的,深思熟虑的结果当然是故意的

  liberate = liber (自由=libera)+ ate vt.解放(让人民获得自由)

  自由和天平有什么关系呢?

  天平的主要作用就是要让两边重量相等,平等。解放全人类不就是让人民平等吗?人民解放军PLA:People’s Liberation Army liberation的职责就是解放全中国让中国人民平等自由

  liberty n.自由

  libertine这个单词叫"浪荡子",原来就是“特别自由的人”的意思,” 挺(tin)自由(liber)的”

  libido弗洛伊德的著作里面,他造出一个表示“性动力”的单词libido(中文翻译成“利比多”),表达的就是这种本源的不受控制的力量。

  单词组记:deteriorate,interior, exterior, territory

  deteriorate = de(down) + terior(土地) +ate(动词) v.使恶化; 败坏(风俗); 使变坏(品质等) [助记] 品格败坏的人就应该入土活埋。

  interior = in(into) + terior(土地) a.内部的,国内的

  interior design 室内设计专业

  exterior = ex (out)+ terior(土地) a.外部的,国外的

  territory = territ(=terior)+ ory(地方) n.版图,疆土

  to the extent 到了….程度

  in this regard 在这一点上 = in this case

  单词组记: 神奇的-en可以把形容词名词变为你想要的动词

  sadden = sad + d + en vt.使人悲哀

  strengthen = strength(strong的名词) + en vt.加强(力量)

  weaken = weak + en vt.削弱

  lengthen = length(long的名词) + en vt.延长

  shorten = short + en vt.缩短

  tighten = tight + en vt.拉紧

  loosen = loose + en vt.放松

  还有一个超级牛的单词前后都加en

  enlighten= en + light + en vt.启蒙;(用思想)照亮

  intent n.意图,打算

  unreservedly = un + reserved(保留的) + ly(副词) adv.毫无保留地

I know young people in Hong Kong look up to many figures in our society. And in this regard, I have failed. I failed as a role model. However, I wish this matter will teach everyone a lesson. To all the young people in our community, let this be a lesson for you all. This is not an example to be set for you.

  核心词汇解析

  look up to 仰望,尊重= respect

  look down upon/on 鄙视,瞧不起=despise

  role model 榜样

  During my time away, I have made an important decision. I will whole-heartedly fulfill all commitments that I have to date. But after that, I decided to step away from the Hong Kong entertainment industry. I have decided to do this to give myself an opportunity to heal myself and to search my soul. I will dedicate my time to charity and community work within the next few months. I will be away from Hong Kong entertainment industry indefinitely. There is no time frame.

  核心词汇解析

  whole-heatedly 全心全意地; single-mindedly一心一意地

  fulfill one's commitment vt.履行…的诺言

  entertainment industry 娱乐业

  health =heal(恢复健康) +th(名词)

  heal (v.治愈,恢复) 是health的反向构词

  dedicate to 把...奉献给,投身于...

  charity = char(=care关心)+ ity(名词) n.慈善,慈善事业 [助记]关心穷人就是做慈善

  I have been assisting the police since the first day the photos were published and I will continue to assist them. After this press con., I have obligation to help them with their investigation and hope that this case can end soon as everyone I think has the same wish.

  核心词汇解析

  assist = as(to) + sist(stand) vt. (站在一旁来) 协助

  press con. = press conference 新闻发布会

  press free. = press freedom 言论自由

  press 是“压”的意思,怎么会变成“新闻”,“言论”呢?

  因为最初的报纸都是油墨印刷,需要把纸紧紧的压在刻版上才能印刷出字来.所以press有了一个引申意:n.出版业,印刷业. 出版印刷业不就是发布新闻和言论的阵地吗?

  obligation n.义务

  investigation n.调查

  I would like to use this opportunity to thank the police for their hard work on this case. Thank you. I believe everyone’s priority now (and) my priority now is to stop the suffering and pain, for not letting this…we do not want to let this situation become more out of control. We need to protect all the inno cents and all the young from matters like this. In this regard, I have instructed my lawyers to do everything possible within the law to protect all the innocents, victims of this case. I believe that a press statement is being issued
  as we speak on what my lawyers have advised me to do.

  核心词汇解析

  单词组记:prior to, priority

  pri = pre是一个拉丁前缀表示before

  [书面]prior to = [口语]before

  小翻译 : 在你离开之前,请完成这项工作.

  prior to your departure, please complete this task.

  小翻译: 预先警告/通知 prior warning/notice.

  priority = prior + ity(名词) n.优先考虑的事情, 优先权

  单词组忆: victor, victory, victim

  vict中的V象征着胜利,vict-表示征服

  victory n.胜利

  victor =vict + or(人) n.胜利者, 征服者

  victim = vict + im(我是) [助记]我是被征服了,当然就成了n.受害人,牺牲品

  innocent = in + no + cent(一分钱) [助忆]兜里没有一分钱, 所以没有偷窃, 是无辜的

  a. 无辜的, 天真的

  instruct = in + struct(构造) vt.传授,告知 [助记]内心中去构建知识或信息

  Lastly, I would like to thank everyone for coming here today and listening to what I have to say. I would like to also apologize once again to all the ladies and their families, my family and to everyone in Hong Kong and everyone in our society. I am deeply saddened by this. And I apologize to everyone (who) has to go through this. I would like to also thank you for giving me this opportunity to say what I have wanted to say all along in my heart.

  I hope, after today, I can have your forgiveness. With regard to this case, with everything, everything that has happened, I am deeply sorry. I hope you all accept my apology and give me a chance. Thank you.

  [书]with regard to关于= [口]abou

点击此处查看原文 >>

系统分类: 专业英语   |    用户分类:    |    来源: 转贴

评论(0) | 阅读(260)
发表于:2008-6-12 2:39:25
标签:无标签

2

what Sharon Stone said

Well you know it was very interesting because at first, you know, I am not happy about the ways the Chinese were treating the Tibetans because I don’t think anyone should be unkind to anyone else. And so I have been very concerned about how to think and what to do about that because I don’t like that. And I had been this, you know, concerned about, oh how should we deal with the Olympics because they are not being nice to the Dalai Lama, who is a good  of mine. And all these earthquake and stuff happened and I thought: Is that karma, when you are not nice that bad things happen to you? And then I got a letter, from the Tibetan Foundation that they want to go and be helpful. And that made me cry. And they ask me if I would write a quote about that and I said, “I would.” And it was a big lesson to me, that some times you have to learn to put your head down and be of service even to people who are not nice to you. And that’s a big lesson for me...

点击此处查看原文 >>

系统分类: 专业英语   |    用户分类:    |    来源: 整理

评论(0) | 阅读(168)
发表于:2008-6-12 2:31:59
标签:无标签

1

s3c2410 init code with NAND boot

;=========================================
; NAME: 2410INIT.S
; DESC: C start up codes
; Initialize C-variables
;=========================================

 GET option.inc
 GET memcfg.inc
 GET 2410addr.inc

BIT_SELFREFRESH EQU (1<<22)

;Pre-defined constants
USERMODE    EQU  0x10
FIQMODE     EQU  0x11
IRQMODE     EQU  0x12
SVCMODE     EQU  0x13
ABORTMODE   EQU  0x17
UNDEFMODE   EQU  0x1b
MODEMASK    EQU  0x1f
NOINT       EQU  0xc0

;The location of stacks
UserStack EQU (_STACK_BASEADDRESS-0x3800) ;0x33ff4800 ~
SVCStack    EQU (_STACK_BASEADDRESS-0x2800) ;0x33ff5800 ~
UndefStack EQU (_STACK_BASEADDRESS-0x2400) ;0x33ff5c00 ~
AbortStack EQU (_STACK_BASEADDRESS-0x2000) ;0x33ff6000 ~
IRQStack    EQU (_STACK_BASEADDRESS-0x1000) ;0x33ff7000 ~
FIQStack EQU (_STACK_BASEADDRESS-0x0) ;0x33ff8000 ~

;Check if tasm.exe(armasm -16 ...@ADS 1.0) is used.
 GBLL    THUMBCODE
     [ {CONFIG} = 16
THUMBCODE SETL  {TRUE}
     CODE32
     |  
THUMBCODE SETL  {FALSE}
     ]

  MACRO
 MOV_PC_LR
     [ THUMBCODE
            bx lr
     |
            mov pc,lr
     ]
  MEND

  MACRO
 MOVEQ_PC_LR
     [ THUMBCODE
         bxeq lr
     |
            moveq pc,lr
     ]
  MEND

  MACRO
$HandlerLabel HANDLER $HandleLabel
$HandlerLabel
 sub     sp,sp,#4        ;decrement sp(to store jump address)
 stmfd sp!,{r0}        ;PUSH the work register to stack(lr does't push because it return to original address)
 ldr     r0,=$HandleLabel;load the address of HandleXXX to r0
 ldr     r0,[r0]         ;load the contents(service routine start address) of HandleXXX
 str     r0,[sp,#4]      ;store the contents(ISR) of HandleXXX to stack
 ldmfd   sp!,{r0,pc}     ;POP the work register and pc(jump to ISR)
  MEND
 
 IMPORT  |Image$$RO$$Base| ; Base of ROM code
 IMPORT  |Image$$RO$$Limit|  ; End of ROM code (=start of ROM data) ?
 IMPORT  |Image$$RW$$Base|   ; Base of RAM to initialise
 IMPORT  |Image$$ZI$$Base|   ; Base and limit of area
 IMPORT  |Image$$ZI$$Limit|  ; to zero initialise
 
 IMPORT  Main    ; The main entry of mon program
 
 AREA    Init,CODE,READONLY

ENTRY
 
 EXPORT __ENTRY
__ENTRY
 ;1)The code, which converts to Big-endian, should be in little endian code.
 ;2)The following little endian code will be compiled in Big-Endian mode.
 ;  The code byte order should be changed as the memory bus width.
 ;3)The pseudo instruction,DCD can't be used here because the linker generates error.
 ASSERT :DEF:ENDIAN_CHANGE
 [ ENDIAN_CHANGE
     ASSERT  :DEF:ENTRY_BUS_WIDTH
     [ ENTRY_BUS_WIDTH=32
  b ChangeBigEndian     ;DCD 0xea000007
     ]
    
     [ ENTRY_BUS_WIDTH=16
  andeq r14,r7,r0,lsl #20   ;DCD 0x0007ea00
     ]
    
     [ ENTRY_BUS_WIDTH=8
  streq r0,[r0,-r10,ror #1] ;DCD 0x070000ea
        ]
 |
  b ResetHandler 
    ]
   
 b HandlerUndef ;handler for Undefined mode
 b HandlerSWI     ;handler for SWI interrupt
 b HandlerPabort ;handler for PAbort
 b HandlerDabort ;handler for DAbort
 b .          ;reserved
 b HandlerIRQ     ;handler for IRQ interrupt
 b HandlerFIQ     ;handler for FIQ interrupt

;@0x20
 b EnterPWDN
ChangeBigEndian
;@0x24
 [ ENTRY_BUS_WIDTH=32
     DCD 0xee110f10 ;0xee110f10 => mrc p15,0,r0,c1,c0,0
     DCD 0xe3800080 ;0xe3800080 => orr r0,r0,#0x80;  //Big-endian
     DCD 0xee010f10 ;0xee010f10 => mcr p15,0,r0,c1,c0,0
 ]
 [ ENTRY_BUS_WIDTH=16
     DCD 0x0f10ee11
     DCD 0x0080e380 
     DCD 0x0f10ee01 
 ]
 [ ENTRY_BUS_WIDTH=8
     DCD 0x100f11ee 
     DCD 0x800080e3 
     DCD 0x100f01ee 
    ]
   
 DCD 0xffffffff  ;swinv 0xffffff is similar with NOP and run well in both endian mode.
 DCD 0xffffffff
 DCD 0xffffffff
 DCD 0xffffffff
 DCD 0xffffffff
 b ResetHandler
 
;Function for entering power down mode
; 1. SDRAM should be in self-refresh mode.
; 2. All interrupt should be maksked for SDRAM/DRAM self-refresh.
; 3. LCD controller should be disabled for SDRAM/DRAM self-refresh.
; 4. The I-cache may have to be turned on.
; 5. The location of the following code may have not to be changed.

;void EnterPWDN(int CLKCON);
EnterPWDN   
 mov r2,r0  ;r2=rCLKCON
 tst r0,#0x8  ;POWER_OFF mode?
 bne ENTER_POWER_OFF

ENTER_STOP 
 ldr r0,=REFRESH  
 ldr r3,[r0]  ;r3=rREFRESH 
 mov r1, r3
 orr r1, r1, #BIT_SELFREFRESH
 str r1, [r0] ;Enable SDRAM self-refresh

 mov r1,#16     ;wait until self-refresh is issued. may not be needed.
0 subs r1,r1,#1
 bne %B0

 ldr r0,=CLKCON ;enter STOP mode.
 str r2,[r0]   

 mov r1,#32
0 subs r1,r1,#1 ;1) wait until the STOP mode is in effect.
 bne %B0   ;2) Or wait here until the CPU&Peripherals will be turned-off
     ;Entering POWER_OFF mode, only the reset by wake-up is available.

 ldr r0,=REFRESH ;exit from SDRAM self refresh mode.
 str r3,[r0]
 
 MOV_PC_LR

ENTER_POWER_OFF 
 ;NOTE.
 ;1) rGSTATUS3 should have the return address after wake-up from POWER_OFF mode.
 
 ldr r0,=REFRESH  
 ldr r1,[r0]  ;r1=rREFRESH 
 orr r1, r1, #BIT_SELFREFRESH
 str r1, [r0]  ;Enable SDRAM self-refresh

 mov r1,#16     ;Wait until self-refresh is issued,which may not be needed.
0 subs r1,r1,#1
 bne %B0

 ldr  r1,=MISCCR
 ldr r0,[r1]
 orr r0,r0,#(7<<17)  ;Make sure that SCLK0:SCLK->0, SCLK1:SCLK->0, SCKE="L" during boot-up
 str r0,[r1]

 ldr r0,=CLKCON
 str r2,[r0]   

 b .   ;CPU will die here.
 

WAKEUP_POWER_OFF
 ;Release SCLKn after wake-up from the POWER_OFF mode.

 ldr r1,=MISCCR
 ldr r0,[r1]
 bic r0,r0,#(7<<17)  ;SCLK0:0->SCLK, SCLK1:0->SCLK, SCKE:L->H
 str r0,[r1]

 ;Set memory control registers
    ldr r0,=SMRDATA
 ldr r1,=BWSCON ;BWSCON Address
 add r2, r0, #52 ;End address of SMRDATA
0      
 ldr r3, [r0], #4   
 str r3, [r1], #4   
 cmp r2, r0  
 bne %B0
0
 mov r1,#256
 subs r1,r1,#1     ;1) wait until the SelfRefresh is released.
 bne %B0  
 
 ldr r1,=GSTATUS3  ;GSTATUS3 has the start address just after POWER_OFF wake-up
 ldr r0,[r1]
 mov pc,r0

 LTORG  
HandlerFIQ      HANDLER HandleFIQ
HandlerIRQ      HANDLER HandleIRQ
HandlerUndef    HANDLER HandleUndef
HandlerSWI      HANDLER HandleSWI
HandlerDabort   HANDLER HandleDabort
HandlerPabort   HANDLER HandlePabort

IsrIRQ 
 sub     sp,sp,#4       ;reserved for PC
 stmfd sp!,{r8-r9}  
 
 ldr     r9,=INTOFFSET
 ldr     r9,[r9]
 ldr     r8,=HandleEINT0
 add     r8,r8,r9,lsl #2
 ldr     r8,[r8]
 str     r8,[sp,#8]
 ldmfd sp!,{r8-r9,pc}

;=======
; ENTRY 
;=======
ResetHandler
 ldr r0,=WTCON       ;watch dog disable=========================================1
 ldr r1,=0x0        
 str r1,[r0]

 ldr r0,=INTMSK
 ldr r1,=0xffffffff  ;all interrupt disable=====================================2
 str r1,[r0]

 ldr r0,=INTSUBMSK
 ldr r1,=0x3ff  ;all sub interrupt disable
 str r1,[r0]

 [ {FALSE}   ;Led_Display:light on GPF6
 ldr r0,=GPFCON
 ldr r1,=0x5000  
 str r1,[r0]
 ldr r0,=GPFDAT
 ldr r1,=~0x40
 str r1,[r0]
 ]
 
 ;To reduce PLL lock time, adjust the LOCKTIME register.
 ldr r0,=LOCKTIME
 ldr r1,=0xffffff
 str r1,[r0]
       
    [ PLL_ON_START
 ;Configure MPLL
 ldr r0,=MPLLCON         
 ldr r1,=((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV)  ;Fin=12MHz,Fout=50MHz===============3
 str r1,[r0]
 ]

; ;Check if the boot is caused by the wake-up from POWER_OFF mode.
; ldr r1,=GSTATUS2
; ldr r0,[r1]
; tst r0,#0x2
;       ;In case of the wake-up from POWER_OFF mode, go to POWER_OFF_WAKEUP handler.
; bne WAKEUP_POWER_OFF

 EXPORT StartPointAfterPowerOffWakeUp
StartPointAfterPowerOffWakeUp

 ;Set memory control registers==================================================4
    adr r0,SMRDATA ;can't use ldr r0, =xxxx important!!!
 ldr r1,=BWSCON ;BWSCON Address
 add r2, r0, #52 ;End address of SMRDATA
0      
 ldr r3, [r0], #4   
 str r3, [r1], #4   
 cmp r2, r0  
 bne %B0

    ;Initialize stacks=============================================================5
 bl InitStacks
 
   ; Setup IRQ handler============================================================6
 ldr r0,=HandleIRQ       ;This routine is needed
 ldr r1,=IsrIRQ          ;if there isn't 'subs pc,lr,#4' at 0x18, 0x1c
 str r1,[r0]
 
 ;copy self and relocate========================================================7
 ldr r0, =BWSCON
 ldr r0, [r0]
 ands r0, r0, #6  ;OM[1:0] != 0, NOR FLash boot;OM[1:0] == 0, NAND FLash boot
 bne EntryToRO    ;NOR FLash boot;don't read nand flash
 adr r0, __ENTRY     ;real addr, depend on where to download the program
 cmp r0, #0    ;check if code has been in Ram, not copy from NandFlash to Ram;if boot from NandFlash addr 0x0, copy
 bne EntryToRO   ;when code has been in Ram
;===========================================================
;copy NandFlash to SDRAM,size=128kb
NandToRO    
 mov r5, #NFCONF
 ;enable nand flash control, initilize ecc, chip disable,
 ldr r0, =(1<<15)|(1<<12)|(1<<11)|(7<<8)|(7<<4)|(7)
 str r0, [r5]
 
 bl ReadNandID          ;r5 stores ID
 mov r6, #0    ;r6 stores NandAddr
 ldr r0, =0xec73
 cmp r5, r0
 beq %F1
 ldr r0, =0xec75
 cmp r5, r0
 beq %F1
 mov r6, #1              ;NandAddr = 1

 bl ReadNandStatus  ;r1 = RdNFDat();
 
 mov r8, #0              ;r8 for source
 ldr r9, BaseOfRO        ;r9 for des,

 ands r0, r8, #0x1f  
 bne  %F3
 mov  r0, r8   
 bl  CheckBadBlk
 cmp  r0, #0          ;r0 indicate whether is BadBlk
 addne r8, r8, #32     ;if is BadBlk,jump to copy next Blk
 bne  %F4

 mov r0, r8    ;r0 stores source addr
 mov r1, r9     ;r1 stores des addr,=ResetEntry
 bl ReadNandPage        ;read 512 bytes
 add r9, r9, #512
 add r8, r8, #1   ;page addr++

 cmp r8, #256            ;loop number:256,copy 128kb
 bcc %B2
 
 mov r5, #NFCONF   ;DsNandFlash
 ldr r0, [r5]
 and r0, r0, #~0x8000
 str r0, [r5]
 
 ldr r0, EndOfRO 
 ldr pc, =RelocateRW
;===========================================================
;boot from NorFlash Or code has been in ram when Debugging
EntryToRO
 adr r0, __ENTRY      ;0x0 or 0x30400000
 ldr r1, BaseOfRO  ;some where higher
 cmp r0, r1  
 ldreq r0, EndOfRO  ;if need copy
 beq RelocateRW   ;when Entry = BaseOfRO
 ldr r3, EndOfRO  

 ldmia r0!, {r4-r7} ;from Entry
 stmia r1!, {r4-r7} ;to   RO
 cmp r1, r3
 bcc %B0

 sub r1, r1, r3;
 sub r0, r0, r1;   ;important! r0=Entry+EndOfRO-BaseOfRO
;===========================================================   
RelocateRW
 ;Copy and paste RW data/zero initialized data
 ldr r1, BaseOfRW
 ldr r3, BaseOfZI 
 
 ;Zero init base => top of initialised data
 cmp r0, r1      ; Check that they are different
 beq CleanZI
1      
 cmp r1, r3      ; Copy init data
 ldrcc r2, [r0], #4    ;--> LDRCC r2, [r0] + ADD r0, r0, #4        
 strcc r2, [r1], #4    ;--> STRCC r2, [r1] + ADD r1, r1, #4
 bcc %B1
CleanZI     
 ldr r1, EndOfZI ;
 mov r2, #0
2      
 cmp r3, r1      ; Zero init
 strcc r2, [r3], #4
 bcc %B2

;=========================================================== 
;send reset status to main function================================================8
 ldr r1, =GSTATUS2
 ldr r0, [r1]
 str r0, [r1] ;clear reset status
 
    [ :LNOT:THUMBCODE
     ldr pc, pMain ;must use abosulute addr which is a const==================9
     b .                      
    ]

    [ THUMBCODE         ;for start-up code for Thumb mode
     orr lr,pc,#1
     bx lr
     CODE16
     ldr pc, pMain ;bl Main;Don't use main() because of the addr range
     b .
     CODE32
    ]

;===========================================================
;function not used
 EXPORT disable_irq
disable_irq
 mrs r0, cpsr    ;enter svc mode and disable irq,fiq
 orr r0, r0, #0xc0
 msr cpsr_c, r0
 mov pc, lr
;===========================================================
;funtions for NandFlash 
ReadNandID
 mov   r7,#NFCONF 
 ldr      r0,[r7,#0]  ;NFChipEn();
 bic      r0,r0,#0x800
 str      r0,[r7,#0] 
 mov      r0,#0x90  ;WrNFCmd(RdIDCMD);
 strb     r0,[r7,#4] 
 mov      r4,#0   ;WrNFAddr(0);
 strb     r4,[r7,#8] 
1       ;while(NFIsBusy());
 ldr      r0,[r7,#0x10] 
 tst      r0,#1
 beq      %B1
 ldrb     r0,[r7,#0xc] ;id  = RdNFDat()<<8;
 mov      r0,r0,lsl #8 
 ldrb     r1,[r7,#0xc] ;id |= RdNFDat();
 orr      r5,r1,r0 
 ldr      r0,[r7,#0]  ;NFChipDs();
 orr      r0,r0,#0x800
 str      r0,[r7,#0] 
 mov   pc,lr 
 
ReadNandStatus
 mov   r7,#NFCONF
 ldr      r0,[r7,#0]  ;NFChipEn();
 bic      r0,r0,#0x800
 str      r0,[r7,#0]
 mov      r0,#0x70  ;WrNFCmd(QUERYCMD);
 strb     r0,[r7,#4] 
 ldrb     r1,[r7,#0xc] ;r1 = RdNFDat();
 ldr      r0,[r7,#0]  ;NFChipDs();
 orr      r0,r0,#0x800
 str      r0,[r7,#0]
 mov   pc,lr

WaitNandBusy
 mov      r0,#0x70  ;WrNFCmd(QUERYCMD);
 mov      r1,#NFCONF
 strb     r0,[r1,#4]
1       ;while(!(RdNFDat()&0x40)); 
 ldrb     r0,[r1,#0xc]
 tst      r0,#0x40
 beq   %B1
 mov      r0,#0   ;WrNFCmd(READCMD0);
 strb     r0,[r1,#4]
 mov      pc,lr

CheckBadBlk
 mov  r7, lr
 mov  r5, #NFCONF
 
 bic  r0, r0, #0x1f ;addr &= ~0x1f;
 ldr      r1,[r5,#0]  ;NFChipEn()
 bic      r1,r1,#0x800
 str      r1,[r5,#0] 

 mov      r1,#0x50  ;WrNFCmd(READCMD2)
 strb     r1,[r5,#4] 
 mov  r1, #6
 strb     r1,[r5,#8]  ;WrNFAddr(6)
 strb     r0,[r5,#8]  ;WrNFAddr(addr)
 mov      r1,r0,lsr #8 ;WrNFAddr(addr>>8)
 strb     r1,[r5,#8] 
 cmp      r6,#0   ;if(NandAddr)  
 movne    r0,r0,lsr #16 ;WrNFAddr(addr>>16)
 strneb   r0,[r5,#8]
 
 bl  WaitNandBusy ;WaitNFBusy()

 ldrb r0, [r5,#0xc] ;RdNFDat()
 sub  r0, r0, #0xff ;return (dat!=0xff),where dat="r0"
 
 mov      r1,#0   ;WrNFCmd(READCMD0)
 strb     r1,[r5,#4] 
 
 ldr      r1,[r5,#0]  ;NFChipDs()
 orr      r1,r1,#0x800
 str      r1,[r5,#0]
 
 mov  pc, r7
 
ReadNandPage
 mov   r7,lr
 mov      r4,r1
 mov      r5,#NFCONF

 ldr      r1,[r5,#0]  ;NFChipEn()
 bic      r1,r1,#0x800
 str      r1,[r5,#0] 

 mov      r1,#0   ;WrNFCmd(READCMD0)
 strb     r1,[r5,#4] 
 strb     r1,[r5,#8]  ;WrNFAddr(0)
 strb     r0,[r5,#8]  ;WrNFAddr(addr)
 mov      r1,r0,lsr #8 ;WrNFAddr(addr>>8)
 strb     r1,[r5,#8] 
 cmp      r6,#0   ;if(NandAddr)  
 movne    r0,r0,lsr #16 ;WrNFAddr(addr>>16)
 strneb   r0,[r5,#8]
 
 ldr      r0,[r5,#0]  ;InitEcc()
 orr      r0,r0,#0x1000
 str      r0,[r5,#0] 
 
 bl       WaitNandBusy ;WaitNFBusy()
 
 mov      r0,#0   ;for(i=0; i<512; i++)
1
 ldrb     r1,[r5,#0xc] ;buf[i] = RdNFDat()
 strb     r1,[r4,r0]
 add      r0,r0,#1
 bic      r0,r0,#0x10000
 cmp      r0,#0x200      ;512
 bcc      %B1
 
 ldr      r0,[r5,#0]  ;NFChipDs()
 orr      r0,r0,#0x800
 str      r0,[r5,#0]
  
 mov   pc,r7

;===========================================================
;function initializing stacks
InitStacks
 ;Don't use DRAM,such as stmfd,ldmfd......
 ;SVCstack is initialized before
 ;Under toolkit ver 2.5, 'msr cpsr,r1' can be used instead of 'msr cpsr_cxsf,r1'
 mrs r0,cpsr
 bic r0,r0,#MODEMASK
 orr r1,r0,#UNDEFMODE|NOINT
 msr cpsr_cxsf,r1  ;UndefMode
 ldr sp,=UndefStack
 
 orr r1,r0,#ABORTMODE|NOINT
 msr cpsr_cxsf,r1  ;AbortMode
 ldr sp,=AbortStack

 orr r1,r0,#IRQMODE|NOINT
 msr cpsr_cxsf,r1  ;IRQMode
 ldr sp,=IRQStack
   
 orr r1,r0,#FIQMODE|NOINT
 msr cpsr_cxsf,r1  ;FIQMode
 ldr sp,=FIQStack

 bic r0,r0,#MODEMASK|NOINT
 orr r1,r0,#SVCMODE
 msr cpsr_cxsf,r1  ;SVCMode
 ldr sp,=SVCStack
 
 ;USER mode has not be initialized.
 
 mov pc,lr
 ;The LR register won't be valid if the current mode is not SVC mode.
 

 LTORG

SMRDATA DATA
; Memory configuration should be optimized for best performance
; The following parameter is not optimized.                    
; Memory access cycle parameter strategy
; 1) The memory settings is  safe parameters even at HCLK="75Mhz".
; 2) SDRAM refresh period is for HCLK="75Mhz".
   
 DCD (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28))
 DCD ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC))   ;GCS0
 DCD ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC))   ;GCS1
 DCD ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC))   ;GCS2
 DCD ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC))   ;GCS3
 DCD ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC))   ;GCS4
 DCD ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC))   ;GCS5
 DCD ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN))    ;GCS6
 DCD ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN))    ;GCS7
 DCD ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)   


 DCD 0x32            ;SCLK power saving mode, BANKSIZE 128M/128M

 DCD 0x30            ;MRSR6 CL="3clk"
 DCD 0x30            ;MRSR7
;   DCD 0x20            ;MRSR6 CL="2clk"
;   DCD 0x20            ;MRSR7

BaseOfRO DCD |Image$$RO$$Base|
EndOfRO  DCD |Image$$RO$$Limit|
BaseOfRW DCD |Image$$RW$$Base|
BaseOfZI DCD |Image$$ZI$$Base|
EndOfZI  DCD |Image$$ZI$$Limit|

 GBLS str_main
str_main SETS "Main"  
pMain DCD $str_main  ;DCD 0x301049c4; this was decided when link, the addr to "Main" is const inspite of PC

 ALIGN


 AREA RamData, DATA, READWRITE

    ^    _ISR_STARTADDRESS
       
HandleReset  #   4
HandleUndef  #   4
HandleSWI    #   4
HandlePabort    #   4
HandleDabort    #   4
HandleReserved  #   4
HandleIRQ    #   4
HandleFIQ    #   4

;Don't use the label 'IntVectorTable',
;The value of IntVectorTable is different with the address you think it may be.
;IntVectorTable
HandleEINT0    #   4
HandleEINT1    #   4
HandleEINT2    #   4
HandleEINT3    #   4
HandleEINT4_7 #   4
HandleEINT8_23 #   4
HandleRSV6 #   4
HandleBATFLT    #   4
HandleTICK    #   4
HandleWDT #   4
HandleTIMER0  #   4
HandleTIMER1  #   4
HandleTIMER2  #   4
HandleTIMER3  #   4
HandleTIMER4  #   4
HandleUART2   #   4
HandleLCD  #   4
HandleDMA0 #   4
HandleDMA1 #   4
HandleDMA2 #   4
HandleDMA3 #   4
HandleMMC #   4
HandleSPI0 #   4
HandleUART1 #   4
HandleRSV24 #   4
HandleUSBD #   4
HandleUSBH #   4
HandleIIC    #   4
HandleUART0  #   4
HandleSPI1  #   4
HandleRTC  #   4
HandleADC  #   4

        END

点击此处查看原文 >>

系统分类: ARM   |    用户分类:    |    来源: 原创

评论(0) | 阅读(230)
发表于:2008-6-12 2:13:28
标签:无标签

1

carrier track in matlab

%================= by G.S @ 607 08.05.08 ====================
clear all;
close all;
clc;
%==================================================
pi=3.1416;                      % PI
MHz=1000000;
KHz=1000;                       % kilo

%========freq vars====================
fs=4*KHz;                      % freq of sample

fc_base=0*KHz;                 % 基准频率
fc_local=0*KHz;                % now freq of local carrier
%=========global vars==================
N=fs*0.001;                           % data Length once in cycle: 1 ms

mod_track=10;
mod_rotate=10;

p_track=0;
p_rotate=0;

%==========loop filter parameters===========
K0=2^(-3);                 
K1=2^(-7);                     

%==========track var==================
d_cic_track=0;
Ri_track=zeros(1,2);              
Rq_track=zeros(1,2);
delta_phase=zeros(1,2);         % input of input of the loop filter
LF_out=zeros(1,2);              % output of the loop filter

fc_local_test=[];

%=========phase var==============
phase_local=0;
ROT=exp(-j*(phase_local));

d_cic_rotate=0;
Ri_rotate=0;              
Rq_rotate=0;

x_phy=zeros(1,2);
y_phy=0;

x_phy_test=[];

%========= NCO init============
n=0:N-1;
NCO=exp(-j*(2*pi*fc_local*n/fs));
last_phase_carrier = mod(2*pi*fc_local*(N-1)/fs,2*pi);
first_phase_carrier = last_phase_carrier + 2*pi*fc_local/fs;

%============data init============
delta_f=30;
snr=-6;
time=3;
[signal_noise,fc_in] = signal_gen(delta_f,snr,time);
%========== global switch

track_en=1;         %是否跟踪
rotate_en=1;        %是否纠相
%================================
cycle_close=length(signal_noise)/N;
for cycle="1:cycle"_close
    %=== 跟踪150ms后,频率锁定 =====================
    if(cycle*N/fs*1000 >= 500)% && track_en == 1)
        track_en = 0;
        fc_local=30+20*rand(1)-10;
    end

    %======================= get data =========================
    din = signal_noise( (cycle-1)*N+1 : cycle*N );
   
    %======================= ddc, rotate =========================
    dout_ddc = din.*NCO;

    dout_rot = dout_ddc.*ROT;
   
    %============================ freq_track 

    if(track_en==1)  
        p_track = p_track + 1;
        d_cic_track = d_cic_track + sum(dout_ddc);   

        %========================track========================
        if( p_track==mod_track )
            p_track = 0;  
            Ri_track(2) = real(d_cic_track);
            Rq_track(2) = imag(d_cic_track);
           
            %==============叉积鉴频=======
            delta_phase(2) = atan2(Ri_track(1)*Rq_track(2)-Ri_track(2)*Rq_track(1), Ri_track(1)*Ri_track(2)+Rq_track(1)*Rq_track(2))*fs/(2*pi*(N*mod_track));
            %==============环路滤波器===============================      
            LF_out(2) = (K0+K1)*delta_phase(2) - K0*delta_phase(1) + LF_out(1);
            %==============update vars=============================
            LF_out(1) = LF_out(2);
            delta_phase(1) = delta_phase(2);
            Ri_track(1) = Ri_track(2);     
            Rq_track(1) = Rq_track(2);
            d_cic_track = 0;
            %==============freq of output of the NCO===============
            fc_local = fc_local + LF_out(2);
            NCO="exp"(-j*(2*pi*fc_local*n/fs + first_phase_carrier));
            last_phase_carrier = mod(2*pi*fc_local*(N-1)/fs + first_phase_carrier, 2*pi);
            first_phase_carrier = last_phase_carrier + 2*pi*fc_local/fs;
        else
            NCO="exp"(-j*(2*pi*fc_local*n/fs + first_phase_carrier));
            last_phase_carrier = mod(2*pi*fc_local*(N-1)/fs + first_phase_carrier, 2*pi);
            first_phase_carrier = last_phase_carrier + 2*pi*fc_local/fs;
        end
    else %=== ( track_en==0 )
        NCO="exp"(-j*(2*pi*fc_local*n/fs + first_phase_carrier));
        last_phase_carrier = mod(2*pi*fc_local*(N-1)/fs + first_phase_carrier, 2*pi);
        first_phase_carrier = last_phase_carrier + 2*pi*fc_local/fs;
    end 


    if(rotate_en==1)
        p_rotate = p_rotate + 1;
        d_cic_rotate = d_cic_rotate + sum(dout_rot);
        if( p_rotate==mod_rotate )
            p_rotate = 0;
            Ri_rotate = real(d_cic_rotate);              
            Rq_rotate = imag(d_cic_rotate);
            d_cic_rotate = 0;
            %=============================
            x_phy(2) = atan2(Rq_rotate, Ri_rotate); 
            y_phy = (x_phy(1) + x_phy(2))/8;
            x_phy(1) = x_phy(2);

            phase_local = phase_local + y_phy;
            ROT = exp(-j*(phase_local));
        end
    end
    %================record NCO freq==========================               
    fc_local_test = [fc_local_test fc_local];
    x_phy_test = [x_phy_test x_phy(2)];
end

t=(1:length(fc_local_test))*N/fs*1000;
figure;
subplot(3,1,1);
plot(t,fc_local_test-fc_base,'.-b');grid on;
subplot(3,1,2);
plot(fc_in(1:4:end)-fc_local_test,'.-r');grid on;
subplot(3,1,3);
plot(t,x_phy_test*180/pi,'.-r');grid on;

点击此处查看原文 >>

系统分类: DSP   |    用户分类:    |    来源: 原创

评论(2) | 阅读(117)
总共 , 当前 /