|
【TI C2000的使用经验】CMD文件解读&从flash里搬运RAM函数
[复制链接]
首先每个数据段的存放位置,以及运行位置都是在cmd文件里面存放控制的。例如下面一段:
- .cinit : LOAD = FLASHC, PAGE = 0 /* Load section to Flash */
- RUN = RAML6, PAGE = 1 /* Run section from RAM */
- LOAD_START(_cinit_loadstart),
- RUN_START(_cinit_runstart),
- SIZE(_cinit_size)
复制代码我们就可以看到.cinit这个段。存放在flashC段里。运行的会把函数拷贝到RAML6段里来运行。后面的三行表示存储的起始位置,运行的起始位置,以及该函数的长度。
有了这些就够了。如果不能保证DSP在下载程序后不会掉电,那么程序就要烧写在flash里。运行的时候呢。要么就拷贝到RAM里,要么就直接在flash里面跑。拷贝到RAM里又要看你程序会不会比较大,可以只拷贝一部分还是全部都拷进去。
那么本文后半部分就讲全部拷贝的方法。
首先我们来看F2806x_CodeStartBranch.asm这个文件。
- ***********************************************************************
- * Function: codestart section
- *
- * Description: Branch to code starting point
- ***********************************************************************
- .sect "codestart"
- code_start:
- .if WD_DISABLE == 1
- LB wd_disable ;Branch to watchdog disable code
- .else
- LB _c_int00 ;Branch to start of boot.asm in RTS library
- .endif
- ;end codestart section
复制代码controlSUITE默认的文件呢是这个样子的。先关看门狗,然后在跳转到c_int00开始执行。当然这些都是在main执行之前做的事。
那么我们就把这句话改掉。让他跳转到另一个地方去。
- .sect "codestart"
- code_start:
- .if WD_DISABLE == 1
- LB wd_disable ;Branch to watchdog disable code
- .else
- LB copy_sections ;Branch to copy_sections
- .endif
复制代码跳转到哪里去呢?我们就需要另一个文件给我们指示F2806x_SectionCopy_nonBIOS.asm
- ;############################################################################
- ;
- ; FILE: DSP28xxx_SectionCopy_nonBIOS.asm
- ;
- ; DESCRIPTION: Provides functionality for copying intialized sections from
- ; flash to ram at runtime before entering the _c_int00 startup
- ; routine
- ;############################################################################
- ; Author: Tim Love
- ; Release Date: March 2008
- ;############################################################################
- .ref _c_int00
- .global copy_sections
- .global _cinit_loadstart, _cinit_runstart, _cinit_size
- .global _const_loadstart, _const_runstart, _const_size
- .global _econst_loadstart, _econst_runstart, _econst_size
- .global _pinit_loadstart, _pinit_runstart, _pinit_size
- .global _switch_loadstart, _switch_runstart, _switch_size
- .global _text_loadstart, _text_runstart, _text_size
- .global _cla_loadstart, _cla_runstart, _cla_size
-
- ***********************************************************************
- * Function: copy_sections
- *
- * Description: Copies initialized sections from flash to ram
- ***********************************************************************
- .sect "copysections"
- copy_sections:
- MOVL XAR5,#_const_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_const_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_const_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
-
- MOVL XAR5,#_econst_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_econst_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_econst_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
- MOVL XAR5,#_pinit_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_pinit_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_pinit_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
- MOVL XAR5,#_switch_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_switch_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_switch_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
- MOVL XAR5,#_text_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_text_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_text_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
-
- MOVL XAR5,#_cinit_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_cinit_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_cinit_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
- MOVL XAR5,#_cla_size ; Store Section Size in XAR5
- MOVL ACC,@XAR5 ; Move Section Size to ACC
- MOVL XAR6,#_cla_loadstart ; Store Load Starting Address in XAR6
- MOVL XAR7,#_cla_runstart ; Store Run Address in XAR7
- LCR copy ; Branch to Copy
- LB _c_int00 ; Branch to start of boot.asm in RTS library
- copy:
- B return,EQ ; Return if ACC is Zero (No section to copy)
- RPT AL ; Copy Section From Load Address to
- || PWRITE *XAR7, *XAR6++ ; Run Address
- return:
- LRETR ; Return
- .end
-
- ;//===========================================================================
- ;// End of file.
- ;//===========================================================================
复制代码
看到这个文件比较长,但其实是一直在重复。每段里是先把某一个程序段的长度给ACC,然后把存储起始地址,运行起始地址给XAR6,XAR7。然后就是拷贝。
然后所有的数据段都拷贝完了,在跳转会c_int00继续执行。
这样就完成啦。是不是很简单。
|
赞赏
-
1
查看全部赞赏
-
|