C6455flash 烧写文档

更新时间:2023-09-12 06:20:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

西安光机所技术总结

——C6455flash自启动的实现

一、flash烧写步骤

1、 将C6455_flashburn\\hex2image\\pjt_use 文件目录下的bootload.asm 添加到自己工程中,

将c6455.cmd 替代自己工程中的CMD文件,编译。

2、 将自己工程中生成的***.out 文件改名为flash.out.复制到C6455_flashburn\\hex2image文

件目录下

3、 运行test2.bat(双击)

4、 将C6455_flashburn\\hex2image目录下的TI_ARR.C文件复制到上一目录C6455_flashburn

替代此目录下的TI_ARR.C文件

5、 在CCS中加载C6455_flashburn\\ Flashburn.pjt工程重新编译工程,将编译生成的

C6455_flashburn\\Debug\\ Flashburn.out下载到DSP中运行。当显示WRITE DONE!!时烧写结束并成功。 二、选择加载模式

C6455DSP芯片的加载模式分为硬件加载和软件加载,(DSP自动加载技术是指在系统刚刚上电或者复位时,DSP将一段存储在外部的非易失性存储器的用户程序搬移到片内的高速存储器单元中执行)对于DSP芯片,其内部中固化了一段代码,而这段代码的功能就是搬移操作。

C6455DSP芯片是根据复位时BOOTMODE[3:0]上四个引脚的高低电平来选择不同的引导模式,主要包括:

1、无引导加载(BOOTMODE[3:0]=0000b)

即上电复位后CPU直接从2M—Byte L2级存储器的地址O处开始执行代码 2、主机接口引导(BOOTMODE[3:0] = 0001b and BOOTMODE[3:0] = 0111b)

CPU上电复位后。YO部分将处于激活状态.可以进行正常的通信.但DSP的内核仍处于复位状态,一直等待主机向HPI控制寄存器中的DSPNT位置l 这样在引导过程中.外部主机通过主机接口访问DSP的整个存储空间,对它们进行初始化。主机完成初始化工作以后.向接口控制寄存器的DSPINT位写1.引导过程结束 然后CPU退出复位状态.开始执行地址0处的代码。

3、EMIFA 8比特外部ROM引导(BOOTMODE[3:0]=0100b)

位于外部CE3空间的ROM中的一部分程序首先通过EDMA被搬人到2M—Byte L2级存储器的地址0处.但是依靠EDMA仅从CE3空间中拷贝从起始地址处开始的1KB个字节来实现。用户可以指定外部加载ROM的存储宽度 这种引导方式可以保证DSP在脱机情况下进行.但由于DSP自带的Boot Loader载入的代码量太少f只有1KB).因此需要用户自己编写二次引导代码.本文也将介绍这种引导方式。

4、I2C主引导(BOOTMODE[3:0]=l01b)

当在I2C主引导模式运行时.DSP作为主设备来控制I2C总线.并从外部I2C EEPROM或者其他从设备处将用户代码拷贝进来。为了能正确地将代码从外部存储器搬移至DSP内部,用户程序需要将数据按照一定格式存储在E2ROM中.按照这些格式存储的数据便是自举表(Boot table) 自举表是Boot Loader程序能正常运行的保证.只有将数据按照自举表的要求存储。用户程序才能被搬移到DSP内部正常运行。在自举表中除了用户数据外还需要一些Boot Loader控制数据.

例如程序入口地址、程序的长度和寄存器配置等信息。 5、I2C从引导(BOOTMODE[3:01=01 10b)

当在I2C从引导模式运行时.DSP作为从设备放弃对I2C总线的控制.而只是简单地接收

以一定的格式传过来的数据。在此种模式中,一个ARM或者其他器件来充当主设备用来向其他I2C总线上的所有从DSP设备传递自举表中的数据.故它可用于多DSP的同时引导 二、bootload.asm文件编写与注释

Bootloader的作用:大多数情况下,1K大小的代码量无法满足系统需要,要达到DSP的高速运算,又不能将大量代码放在外部Flash中运行。因此,当用户代码长度大于1K时,需要使用二次引导加载。即专门编写一段长度为1K的二次加载程序,在初始化时被加载到DSP.而这段程序的功能是从Flash的某个地址处将1K以外的全部用户程序和数据拷贝到其运行地址处。

//××××××××××××× bootloader ××××××××××××××××××× .title \ .option D,T .length 102 .width 140

COPY_TABLE .equ 0xb0000400

.sect \ .global _boot

_boot:

;************************************************************************ ;* Debug Loop - Comment out B for Normal Operation

;************************************************************************

zero B1

_myloop: ; [!B1] B _myloop nop 5 _myloopend: nop

;****************************************************************************

;* Copy code sections

;****************************************************************************

mvkl COPY_TABLE, a3 ; load table pointer mvkh COPY_TABLE, a3

ldw *a3++, b1 ; Load entry point

copy_section_top:

ldw *a3++, b0 ; byte count

ldw *a3++, a4 ; ram start address nop 3

[!b0] b copy_done ; have we copied all sections? nop 5

copy_loop:

ldb *a3++,b5

sub b0,1,b0 ; decrement counter

[ b0] b copy_loop ; setup branch if not done [!b0] b copy_section_top zero a1

[!b0] and 3,a3,a1 stb b5,*a4++

[!b0] and -4,a3,a5 ; round address up to next multiple of 4 [ a1] add 4,a5,a3 ; round address up to next multiple of 4

;****************************************************************************

;* Jump to entry point

;****************************************************************************

copy_done:

b .S2 b1 nop 5

四、C6455.cmd文件的编写

/*

============================================================================

* Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005 *

* Use of this software is controlled by the terms and conditions found in the * license agreement under which this software has been supplied.

*

============================================================================

*/ /*

============================================================================

* lnk.cmd v5.00 *

* Usage: lnk6x -o -m lnk.cmd * cl6x -z -o -m lnk.cmd

* * Description: This file is a sample linker command file that can be * used for linking programs built with the C compiler and * running the resulting .out file on a C620x/C670x * simulator. Use it as a guideline. You will want to * change the memory layout to match your specific C6xxx * target system. You may want to change the allocation * scheme according to the size of your program.

* * Notes: (1) You must specivy a directory in which rts6x00.lib is * located. either add a -i\ * file or use the system environment variable C_DIR to * specify a search path for the libraries.

* * (2) If the run-time library you are using is not named * rts6200[e].lib, rts6400[e].lib, or rts6700[e].lib, be

* sure to use the correct name here.

* *

============================================================================

*/ -c

-heap 0x1000 -stack 0x3000

/* Memory Map 1 - the default */ MEMORY {

L1D: o = 00f00000h l = 00008000h L1P: o = 00e00000h l = 00008000h

BOOT: o = 00800000h l = 00000400h //bootload程序地址 L2: o = 00800400h l = 00200000h //应用程序地址 }

SECTIONS {

.bootload > BOOT .text > L2 .stack > L2 .bss > L2 .cinit > L2 .cio > L2 .const > L2 .data > L2 .switch > L2 .sysmem > L2 .far > L2 .testMem > L2 } ??

五、将.out文件转化成.hex文件

利用CCS中hex6x.exe工具可以将out文件转化为hex文件 1、编写批处理文件makefile.cmd文件

flash.out /* input COFF file */ -a /* create ASCII image */

-image /* Create a memory image (no */ -boot -order L

-map memory.map /* create a hex map file */ -memwidth 32 /* Width of ROM/Flash memory -map appl2.map create a hex map file */ -bootorg 0xb0000400 /* address of the boot/copy-table */

-bootsection .bootload 0xb0000000 /* section containing our asm boot routine */

ROMS {

FLASH: org = 0xb0000000, len = 0x40000, romwidth = 32, files = {image.hex} }

2、将hex6x.exe工具、批处理文件、.out文件放在同一文件夹下或者指定文件夹下 在Windows命令cmd中到指定文件夹下输入hex6x.exe makefile.cmd

六、处理TI的文本hex文件,转化为可放在存储器中的C的数组

此处将Hex文件转化为TI_ARR.C文件

//×××××××处理程序××××××××××××// #include #include

char str1[128]; char str2[128]; char str3[128]; long Cnt = 0;

int getline(FILE * fp1, char * str1) { int i = 0; char chr1, chr2; while(1) { chr1 = getc(fp1); str1[i++] = chr1; if(chr1 == 0xa) /*回车换行*/ goto getlineend; if(chr1 == EOF) goto getlineend2; }

getlineend: str1[i] = 0; /*add '\\0' */ return 1;

getlineend2: return 0; }

void putConvline(FILE * fp2, char * str1) { /*convert .hex data to '0x........,' data */ int i,j; unsigned int strLength;

int num; char oriNum[12]; char rstNum[10]; strLength = strlen(str1); num = strLength / 12; /*00 08 00 00 --->12 char*/ rstNum[8] = ','; rstNum[9] = ' '; /*space*/ for(i=0; i

main() { FILE *fp1, *fp2; int flag; int length, i, j, k; int SrcIdx, DstIdx; int backChar; /*回退字符*/ int f_end; int lineCnt = 0;

char read_ch[7]; long n_modify_ptr = 0; if ((fp1=fopen(\ { /* 以只读方式打开文件1 */ printf(\ exit(0) ; } if ((fp2=fopen(\ { printf(\ exit(0) ; } flag = 0;

begin: f_end = getline(fp1, str1); if(f_end == 0) goto end; if((str1[0] >= '0') && (str1[0] <= '9') || (str1[0] >= 'A') && (str1[0] <= 'F')) { putConvline(fp2, str1); } lineCnt++; if((lineCnt % 100) == 0) printf(\ goto begin; end: fclose(fp1); fclose(fp2); }

七、建立burnflash的工程用于烧写flash 1、burnflash。C文件 /*

============================================================================

ATTENTION PLEASE:

1.PREDIV IN THE REGISTER WINDOW ALWAYS HAVE THE WRONG VALUVE! 2.this program is for initialization of the PLL1;

3.PLL1 should be initialized before anythings after POWER ON;

4.once you want to reconfigure the PLL1,you should power-off then on;

============================================================================ */

#define CHIP_6455 #include #include #include \

#include #include

#define FCnt 0x40000*4 //Byte #define FLASHADDRESS 0xb0000000; //TIME_TMR TMR_s_e1,TMR_e_e1; //TIME_TMR TMR_s_b1,TMR_e_b1; //TIME_TMR TMR_s_e2,TMR_e_e2; //TIME_TMR TMR_s_b2,TMR_e_b2;

void main ( void ) {

volatile unsigned int i,j;

volatile char * PData = (volatile char*)ProgData; unsigned char *pfadd; volatile char D=0; int Pll_Delay;

// initialize PLL1

for(Pll_Delay=0;Pll_Delay<=100000;Pll_Delay++);

InitPLL1(20); //50MHz*20 = 1GHz to CPU CORE InitPeriphral(); //enable all Periphrals InitPLL2(); //ddr2 250MHz EMIFA 125MHz

InitEMIFA();

TMR_InitDrv(1000); //1000MHz

//TEST FOR TIMER0 and TIMER1 LED1_flash(1000); //1000ms

//WRITE flash

printf(\

//TMR_GetTime(&TMR_s_e1); ChipEraseALL();

//TMR_Delta(&TMR_s_e1,&TMR_e_e1); LED1_flash(200); //1000ms

pfadd =(unsigned char *)FLASHADDRESS; //TMR_GetTime(&TMR_s_b1); for(i = 0;i

WriteFlashByte(pfadd++,PData[i+3]); WriteFlashByte(pfadd++,PData[i+2]); WriteFlashByte(pfadd++,PData[i+1]); WriteFlashByte(pfadd++,PData[i]); }

//TMR_Delta(&TMR_s_b1,&TMR_e_b1); printf(\ LED1_flash(10000); //1000ms while(1){}; }

所需的data.h文件

/********************************************************************* * (C) COPYRIGHT TEXAS INSTRUMENTS, INC. 2000-2002 *

* FlashBurn 64x Target Code header */

/* Change Log: */

#ifndef __datah__ #define __datah__

#pragma DATA_SECTION(ProgData, \static far unsigned int ProgData[0x40000]= {

#include \};

#endif

//××××××××××××××××××××××××××××××××××××

该工程的cmd文件即上文中的cmd文件去除boot部分。

Flashburn.zip

本文来源:https://www.bwwdw.com/article/2dmh.html

Top