Reprint content, source address http://www.qiytech.com/jiejuefangan/gongyekz/922.html
Abstract: in order to solve the problem of upgrading the DSP program in special occasions, taking tms320f28035 as an example, this paper introduces an online upgrade method which is suitable for tms320c2000 series DSP to realize program updating based on serial communication. This paper describes the basic idea and implementation steps of the online upgrade method, and gives the program code of the key part. The experiment proves that this method is simple and reliable and can be used in the upgrade and update of the embedded device software program.
keywords: online upgrade; DSP; serial communication; Flash
TMS320C2000 Series DSP is the Texas Instruments Company (TI) introduced a set of microcontrollers and high-performance DSP features in one of the DSP series. This series of DSP has the powerful control signal processing ability [1], can realize the complex control algorithm. With the development of electronic technology and the continuous improvement of users ' requirements, it may be necessary to update the embedded device program which has already been put into use, while the general program upgrade method is to remove the device in the field and update the program through the emulator after exposing the JTAG port [2-4]. This method is simple and effective, but for some special occasions, it will bring great inconvenience to the program upgrade [2]. Taking tms320f28035 as an example, this paper describes a method for online updating of tms320c2000 series DSP applications, which can be separated from the JTAG emulator without changing the power-up mode of DSP.
1 basic idea of online upgrade
The general DSP-based software program update is implemented by the JTAG interface operation in the CCS environment. The JTAG-based approach is easy to operate and easy to debug, but is often limited by space and transmission distances. For example, a DSP system installed in a complex, closed environment, when the program needs to update or upgrade, using the Jtag interface is difficult to achieve online upgrade program [3]. The online upgrade technology based on serial communication is to achieve the purpose of program upgrading by burning the application with the bottom program, which is not limited by complex system and complex environment. In addition, the online upgrade method does not need to change the DSP startup mode, directly using the DSP default internal flash mode to start [5], eliminating the need for some of the DSP PIN hardware setup trouble. The underlying program refers to the program that has been cured in the DSP designated Flash space, does not allow the user to modify and erase, is mainly used to achieve online upgrade timing, data reception and code burning functions, the program uses the FLASH2803X_API inventory function (see section 2.2) The application is the user's upgrade program [3].
F28035 DSP each power-on reset, first run the underlying program, connect with the PC, and then according to the instructions of the PC to determine whether you need to upgrade the application. If required, the application code sent via the serial port will be burned to the F28035 on-chip flash specified sector, otherwise the original application will continue to execute. When the application is large or the size of the DSP's RAM is small, the application code can be sent to DSP,DSP to receive and burn a batch of code, and then the next batch of code to receive and write work, until all the application code is burned and finished.
2 specific implementations of online upgrades
2.1 Applications
The user's application is generated by a CCS-compiled connection to a target file (. Out) in a modular format, where the code and data are stored in separate segments, and therefore cannot be used directly to burn flash, which needs to be converted to a data format that flash can recognize-binary (. bin). This article uses Hex2000.exe and FileOshell.exe tools to implement file conversions. First, the application builds the. out file by compiling the connection, and then converts the. out file to a. hex file by Hex2000.exe, and then converts the file to a. bin file by using FileOshell.exe. First, make a batch file with the following content:
Example_2803xadcsoc.out
-map Example_2803xadcsoc.map
-O Example_2803xadcsoc.hex
-M
-memwidth 16
-image
ROMS
{
Flash28035:origin = 0x3e8000, len= 0x1000, romwidth=
FILL=0XFFFF,
}
Where Example_2803xadcsoc.out is the file generated by the CCS application,-map is the generation of the map file;-O is the hex file;-M is the motorola-s format;-memwidth 16 means memory bit is -image refers to the selection of image files; ROMS is the starting address, length, number of digits, and padding for the desired conversion. This article chooses to start from 0x3e8000, the length is 4 KB, namely FLASHH,FLASHH the unused part uses 0xFFFF fills, this article named this batch file: Example_2803xadcsoc.cmd. Next, to build the. bin file, first do an MS-DOS batch file with the following contents: Ifileioshell.exe-i example_2803xadcsoc.hex-o Example_2803xadcsoc.bin
Pay attention to the Example_2803xadcsoc.out, Hex2000.exe, FileIO
Shell.exe, Example_2803xadcsoc.cmd, and MS-DOS batch files are placed in the same directory, and then double-click the MS-DOS batch file to generate the required example_2803xadcsoc.bin files.
2.2 Bottom -level programs
The underlying program is used to implement the data sent by the serial port burning to the specified part of Flash, involving the correct positioning of the application and reset after the start-up process, is to achieve the entire online upgrade focus. The underlying program is shown in Flowchart 1. The underlying program mainly implements the following functions [3]:
(1) power-on Reset query function. After power-on reset, receive the command sent by the host computer to determine whether to upgrade. If the host computer is sending an upgrade command, jump to the bottom of the program to upgrade the partial execution; otherwise, jump to the original application to execute.
(2) The function of removing the burning and writing program. Since F28035 on-chip flash does not support running programs in one of the sectors to erase or burn other sectors, this part of the program that receives data and writes Flash work (that is, the upgrade part of the underlying program) needs to be moved to on-chip ram or off-chip ram. The functions that implement the program removal are:
void MemCopy (Uint16 *sourceaddr, Uint16 *source End
ADDR, Uint16 *destaddr)
{
while (Sourceaddr < SOURCEENDADDR)
{
*destaddr++ = *sourceaddr++;
}
return;
}
Where sourceaddr is the starting address for the upgrade program in Flash, SOURCEENDADDR is the end address of the upgrade program in Flash, and DESTADDR is the first address to move to memory.
(3) Receive the application code sent by the host computer and save to the DSP
The specified in-memory (typically the Ram area). This is achieved through the serial port RS232. and determines that the portion of memory used for data preservation is not occupied. For example, if you need to stage your application code into the L0 saram area of F28035 (address space 0x3f8000-0x3f8800). The definition array Uint16 blockbuffer[2048] is used to store the application code, using the memory location statement in the underlying program, and positioning the buffer array above to the appropriate storage space:
#pragma data_section (Blockbuffer, "Blocktransferbuffer");
In the bottom-level program cmd file, the positioning statement is used to locate the Blocktransferbuffer to the L0 SRAM space of the DSP:
blocktransferbuffer:> L0 SARAM page=2
Address space: 0x3f8000~0x3f8800
By setting the underlying program above, the application can be cached to the specified RAM area.
(4) After the code is received, the code in memory is burned to the specified flash sector, which is done by calling the Flash2803x_api library function. The FLASH2803X_API library functions used in the underlying program are as follows [6]:
The function of ① erase sector is Uint16 flash28035_erase (Uint16 sectormask,&fstatus), where Sectormask is the sector that will be erased;& Fstatus The status value returned after the erase operation to determine if the erase operation was successful. ② writes the program to the flash sector as a function of Uintl6 Flash28035_program (&FLASHADDR, &buffaddr,length,&fstatus), where,& FLASHADDR is the start address of the flash sector that is about to be burned, &buffaddr is the first address of the memory space for the program that is about to be prepared for burning, and the length of the program, &fstatus is the state value returned after the burn-write operation. Used to determine if the burn-write operation was successful. ③ Checksum write to Flash program is Uint16 flash28035_verify (&flashaddr,&buffaddr,length,&fstatus), where,& FLASHADDR Specifies the first address to be compared from within the Flash, the &BUFFADDR is the first address of the file to be compared, and the length is the number of the bit words that need to be compared, and the &fstatus is the state value returned after the checksum is performed. Used to determine if the checksum operation was successful.
2.3 Positioning of the underlying programs and applications
After the DSP F28035 power-on reset, the CPU obtains the reset vector from the internal boot ROM. The reset vector points to the boot ROM and executes its internal bootloader program, which is determined to boot from the internal flash after execution is complete. The program pointer jumps to the 0X3F7FF6 of the Flash. Since this address is fixed, the underlying program must be written in a space with this address as the starting address. DSP into the low-level software program to run, first by receiving the host computer command to determine whether to upgrade online, if the online upgrade, then jump to the corresponding upgrade program execution; otherwise, jump to the original application to execute. An absolute address jump is used when the underlying program jumps to the original application where it is executed. Some of the programs are as follows:
#define JUMPGXCX (void (*) (void)) 0x3e8ffe
Define the application's jump address
Sci_sendstatus ("upgrade program?") (y/n): ")
The up-level machine asks if the upgrade
temp = Scia_getbytedata_app ();
Receives the upgrade command sent by the host computer
if (temp== ' y ')
{
Main2 (); If you upgrade, jump to the upgrade program to execute
}
Else
{
(*JUMPGXCX) ();
If you do not upgrade, use an absolute address to jump to the application execution
}
}
The cmd configuration of the underlying program is consistent with the application's CMD configuration and cannot generate address conflicts. Also, be aware of the underlying program and application's jump address configuration.
Some of the underlying program CMD files are configured as follows:
Begin:origin = 0x3f7ff6, length = 0x000002
Reset:origin = 0x3fffc0, length = 0x000002/*
Codestart: > BEGIN PAGE = 0
Some of the application CMD files are configured as follows:
Begin:origin = 0x3e8ffe, length = 0x000002
Codestart: > BEGIN PAGE = 0
3 Burn-Write steps
First, the underlying program is burned to the F28035 via the Jtag interface, and then the application is burned to write. The process of burning the application is: first, the parameters of the serial debugging tool are configured as baud rate 9 bit/s, 8 bit data bit, 1 bit stop bit, no parity bit; Select Send text file, send the application's. bin file to the DSP. Because the Ram area of the F28035 is relatively small, you can take the method of dividing the application code into multiple sends. The burn-write procedure is shown in 2.
This paper introduces an on-line upgrade technology of DSP application based on serial communication, which can realize the update and upgrade of the module software without opening the chassis. It has been found that it takes longer to update the program using the online upgrade technology than the JTAG-burning program, but it solves the problem of difficult program upgrading in complicated situations. In short, this method is simple and reliable, it can be applied to the software program update and upgrade of embedded device.
On-line upgrade method of DSP application based on serial communication