TMS320F28335程序烧写FLASH

来源:互联网 发布:笔记本wifi破解软件 编辑:程序博客网 时间:2024/05/21 14:04

DSP TMS320F28335 FLASH烧写

1.检查map文件

在烧写之前,首先检查Debug目录下的.map文件,如果Debug文件下没有,检查其他的文件夹,每个项目中都会有.map文件。

打开.map文件,显示内容如下所示(部分内容,并非map文件所有内容):

...MEMORY CONFIGURATION         name            origin    length      used     unused   attr    fill----------------------  --------  ---------  --------  --------  ----  --------PAGE 0:  RAML0                 00008000   00001000  00000000  00001000  RWIX  RAML1                 00009000   00001000  00000000  00001000  RWIX  RAML2                 0000a000   00001000  00000000  00001000  RWIX  RAML3                 0000b000   00001000  00000000  00001000  RWIX  FLASHH                00300000   00008000  00000000  00008000  RWIX  FLASHG                00308000   00008000  00000000  00008000  RWIX  FLASHF                00310000   00008000  00000000  00008000  RWIX  FLASHE                00318000   00008000  00000000  00008000  RWIX  FLASHD                00320000   00008000  00000000  00008000  RWIX  FLASHC                00328000   00008000  00000000  00008000  RWIX  FLASHB                00330000   00008000  00000102  00007efe  RWIX  FLASHA                00338000   00007f80  00000000  00007f80  RWIX  CSM_RSVD              0033ff80   00000076  00000000  00000076  RWIX  BEGIN                 0033fff6   00000002  00000000  00000002  RWIX  CSM_PWL               0033fff8   00000008  00000000  00000008  RWIX  ADC_CAL               00380080   00000009  00000000  00000009  RWIX  OTP                   00380400   00000400  00000000  00000400  RWIX  IQTABLES              003fe000   00000b50  00000000  00000b50  RWIX  IQTABLES2             003feb50   0000008c  00000000  0000008c  RWIX  FPUTABLES             003febdc   000006a0  00000000  000006a0  RWIX  ROM                   003ff27c   00000d44  00000000  00000d44  RWIX  RESET                 003fffc0   00000002  00000000  00000002  RWIX  VECTORS               003fffc2   0000003e  00000000  0000003e  RWIX....

检查CSM_PWL项:

         name            origin    length      used     unused   attr    fill----------------------  --------  ---------  --------  --------  ----  --------...  CSM_PWL               0033fff8   00000008  00000000  00000008  RWIX...

如果used和unused对应的值分别为00和08,如上,则标识密码区域尚未使用,否则密码区域可能已经被使用,不可以进行烧写,若强行烧写将导致DSP锁死,此时可以自己重新新建工程进行编译。

检查密码区域无误之后可以进行下一步操作。

2.编写CMD文件

项目创建之后,会自动生成一个28335_RAM_lnk.cmd文件,该文件是我们进行仿真调试的时候,将程序放入RAM中运行的CMD文件,如果需要烧写到Flash中,则需要修改对应的地址,因此,可以更改cmd中对应的地址位置或者我们重新创建一个烧写Flash对应的cmd文件。

我们可以从其他项目例程中拷贝一个往Flash中烧写的cmd文件,同一芯片往flash中烧写的cmd文件都相同,因此直接拷贝一个过来(一般名称为F28335.cmd),名称可以自己进行修改,或者自己创建一个xxx.cmd文件,将如下内容拷贝进去:

注意:以下内容只试用于TMS320F28335!

MEMORY{PAGE 0:    /* Program Memory */           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */   RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */   RAML1       : origin = 0x009000, length = 0x001000     /* on-chip RAM block L1 */   RAML2       : origin = 0x00A000, length = 0x001000     /* on-chip RAM block L2 */   RAML3       : origin = 0x00B000, length = 0x001000     /* on-chip RAM block L3 */   FLASHH      : origin = 0x300000, length = 0x008000     /* on-chip FLASH */   FLASHG      : origin = 0x308000, length = 0x008000     /* on-chip FLASH */   FLASHF      : origin = 0x310000, length = 0x008000     /* on-chip FLASH */   FLASHE      : origin = 0x318000, length = 0x008000     /* on-chip FLASH */   FLASHD      : origin = 0x320000, length = 0x008000     /* on-chip FLASH */   FLASHC      : origin = 0x328000, length = 0x008000     /* on-chip FLASH */   FLASHB      : origin = 0x330000, length = 0x008000     /* on-chip FLASH */   FLASHA      : origin = 0x338000, length = 0x007F80     /* on-chip FLASH */   CSM_RSVD    : origin = 0x33FF80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */   BEGIN       : origin = 0x33FFF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */   CSM_PWL     : origin = 0x33FFF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */   OTP         : origin = 0x380400, length = 0x000400     /* on-chip OTP */   ADC_CAL     : origin = 0x380080, length = 0x000009     /* ADC_cal function in Reserved memory */   IQTABLES    : origin = 0x3FE000, length = 0x000b50     /* IQ Math Tables in Boot ROM */   IQTABLES2   : origin = 0x3FEB50, length = 0x00008c     /* IQ Math Tables in Boot ROM */     FPUTABLES   : origin = 0x3FEBDC, length = 0x0006A0     /* FPU Tables in Boot ROM */   ROM         : origin = 0x3FF27C, length = 0x000D44     /* Boot ROM */           RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */PAGE 1 :   /* Data Memory */           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */           /* Registers remain on PAGE1                                                  */   BOOT_RSVD   : origin = 0x000000, length = 0x000050     /* Part of M0, BOOT rom will use this for stack */   RAMM0       : origin = 0x000050, length = 0x0003B0     /* on-chip RAM block M0 */   RAMM1       : origin = 0x000400, length = 0x000400     /* on-chip RAM block M1 */   RAML4       : origin = 0x00C000, length = 0x001000     /* on-chip RAM block L1 */   RAML5       : origin = 0x00D000, length = 0x001000     /* on-chip RAM block L1 */   RAML6       : origin = 0x00E000, length = 0x001000     /* on-chip RAM block L1 */   RAML7       : origin = 0x00F000, length = 0x001000     /* on-chip RAM block L1 */}/* Allocate sections to memory blocks.   Note:         codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code                    execution when booting to flash         ramfuncs  user defined section to store functions that will be copied from Flash into RAM*/ SECTIONS{   /* Allocate program areas: */   .cinit              : > FLASHB      PAGE = 0   .pinit              : > FLASHB      PAGE = 0   .text               : > FLASHB      PAGE = 0   codestart           : > BEGIN       PAGE = 0   ramfuncs            : > FLASHB      PAGE = 0    csmpasswds          : > CSM_PWL     PAGE = 0   csm_rsvd            : > CSM_RSVD    PAGE = 0   /* Allocate uninitalized data sections: */   .stack              : > RAMM1       PAGE = 1   .ebss               : > RAML5       PAGE = 1   .esysmem            : > RAMM1       PAGE = 1   /* Initalized sections go in Flash */   /* For SDFlash to program these, they must be allocated to page 0 */   .econst             : > FLASHB      PAGE = 0   .switch             : > FLASHB      PAGE = 0         /* Allocate IQ math areas: */   IQmathTables     : > IQTABLES,  PAGE = 0, TYPE = NOLOAD    IQmathTables2    : > IQTABLES2, PAGE = 0, TYPE = NOLOAD    FPUmathTables    : > FPUTABLES, PAGE = 0, TYPE = NOLOAD    .reset              : > RESET,      PAGE = 0, TYPE = DSECT   vectors             : > VECTORS     PAGE = 0, TYPE = DSECT   /* Allocate ADC_cal function (pre-programmed by factory into TI reserved memory) */   .adc_cal     : load = ADC_CAL,   PAGE = 0, TYPE = NOLOAD}/*//===========================================================================// End of file.//===========================================================================*/

创建完成cmd文件之后,在CCS6.0中(或之后的版本)右键点击之前的28335_RAM_lnk.cmd文件,选择Exculde from Build命令,则该文件不参与编译,检查烧写所用的cmd文件,如果没有参与编译,则取消勾选Exculde from Build命令,使该文件参与编译。

两个cmd文件只能选择其中一个参与编译,否则编译器有可能无法识别具体的操作空间而出错。

3.增加代码跳转文件

同时我们还需要在原有的调试程序项目中添加跳转代码文件DSP2833x_CodeStartBranch.asm,在处理器完成引导后跳转到用户应用过程入口。

同一芯片对应的DSP2833x_CodeStartBranch.asm文件也相同,因此我们可以从其他例程中拷贝或者自己添加该文件,文件内容如下:

注意:以下内容只试用于TMS320F28335!

;// TI File $Revision: /main/1 $;// Checkin $Date: August 18, 2006   13:45:55 $;//###########################################################################;//;// FILE:  DSP2833x_CodeStartBranch.asm ;//;// TITLE: Branch for redirecting code execution after boot. ;//;// For these examples, code_start is the first code that is executed after;// exiting the boot ROM code. ;//;// The codestart section in the linker cmd file is used to physically place;// this code at the correct memory location.  This section should be placed ;// at the location the BOOT ROM will re-direct the code to.  For example, ;// for boot to FLASH this code will be located at 0x3f7ff6. ;//;// In addition, the example DSP2833x projects are setup such that the codegen;// entry point is also set to the code_start label.  This is done by linker ;// option -e in the project build options.  When the debugger loads the code,;// it will automatically set the PC to the "entry point" address indicated by;// the -e linker option.  In this case the debugger is simply assigning the PC, ;// it is not the same as a full reset of the device. ;// ;// The compiler may warn that the entry point for the project is other then;//  _c_init00.  _c_init00 is the C environment setup and is run before ;// main() is entered. The code_start code will re-direct the execution ;// to _c_init00 and thus there is no worry and this warning can be ignored. ;// ;//###########################################################################;// $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $;// $Release Date: August 4, 2009 $;//###########################################################################***********************************************************************WD_DISABLE  .set    1       ;set to 1 to disable WD, else set to 0    .ref _c_int00    .global code_start************************************************************************ 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************************************************************************ Function: wd_disable** Description: Disables the watchdog timer***********************************************************************    .if WD_DISABLE == 1    .textwd_disable:    SETC OBJMODE        ;Set OBJMODE for 28x object code    EALLOW              ;Enable EALLOW protected register access    MOVZ DP, #7029h>>6  ;Set data page for WDCR register    MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD    EDIS                ;Disable EALLOW protected register access    LB _c_int00         ;Branch to start of boot.asm in RTS library    .endif;end wd_disable    .end;//===========================================================================;// End of file.;//===========================================================================

4.生成可执行文件

点击Build Project进行编译(Ctrl+B),编译没有错误之后会在Debug目录下生成.out文件,该文件就是我们往Flash中烧写的文件。

5.烧写(或仿真)可执行文件

之后的过程与仿真时候Debug的过程相同。

以下内容可忽略:

配置TargetConfiguration文件,如果没有,可以右键x项目,选择new->Target Configuration File生成一个,文件名可以自己选取。

点击TargetConfiguration文件,设置connection和Board or Device项分别为我们使用的仿真器,例如XDS100V3和28335,然后右侧点击Save进行保存,同时可以点击Test Connection按钮进行测试是否能够成功连接。

如果我们项目中有另一个该配置文件,且该文件不是我们需要的,与硬件不匹配,在Debug的时候发现使用的仿真器与我们配置的不相同,可以点击View->Target Configurations,在打开的窗口中找到我们的项目,展开可能看到多个xxxconfig.ccxml文件,选择我们需要的文件右击,点击Set As Default,将其设置为默认的配置文件。

同时也可以在项目的config.ccxml文件上直接右键选择Set As Default Target Configuration。

点击Run->Debug选项,程序会直接连接仿真器并下载内容,如果使用的ram的cmd文件,则直接仿真运行,如果使用的是flash的cmd文件,则会先擦除flash中的数据并下载可执行文件到flash中。

如果程序没有自动下载或者连接仿真器,则在Debug窗口中手动进行连接,在Run选项下或者Debug窗口中选择Connect Target,连接仿真器,如果没有自动下载,则在连接仿真器之后,选择Run->Load->Load Program进行程序的下载。

在RAM中运行程序和在Flash中运行程序下载的过程是相同的。

注意:在程序的下载过程中不要进行断电或者拔掉仿真器,否则有可能造成芯片锁死。

6.验证程序是否烧写到FLash中

程序烧写完成之后,给板子断电。通过拨码开关或者其他方式设置GPIO84/85/86/87四个引脚为高电平,则为设置Boot Mod模式为Flash启动,然后重新上电,看程序是否执行。

断电上电如果程序自动运行,则表明往Flash中烧写成功。

原创粉丝点击