C2 Prog
C2 Prog
5 - Manual
Table of Contents
1 - Overview...............................................................................................................................................1
2 - Quick Start............................................................................................................................................2
3 - Detailed Description.............................................................................................................................6
4 - Multi-core Devices..............................................................................................................................16
5 - Appendix.............................................................................................................................................18
1 Overview
C2Prog is a flash programming tool for TI C2000™ and MSP430™ MCUs. Rather than relying exclusively
on JTAG as the communication interface between the programming tool and the MCU, C2Prog also
supports reflashing over RS-232, RS-485, TCP/IP, USB and Controller Area Network (CAN). The
programmer is, therefore, well suited for deployment in the field where the JTAG port is typically not
accessible.
Some salient features of the programmer are:
• Support for multiple communication interfaces and protocols
• Smart detection of which flash sectors must be erased (or manual section selection if desired)
• Automatic 32-bit CRC (Cyclic Redundancy Check) generation and programming (allowing the
firmware to verify the flash integrity at MCU bootup)
• Compatible with standard Intel Hex file allowing for other data (such as FPGA code) to be
programmed into MCU flash
• “Extended Hex Files” that can be encrypted and contain all the settings for programming,
including the secondary bootloader
• “Remote Link Files” for programming extended hex files stored on a server
• Command-line interface for generating “extended hex” and “remote link” files
• Fast serial communication protocol that works reliably with USB-to-RS232 converters
• Support for point-to-point as well as multidrop networks
• DTR/RTS control for resetting MCU in bootload mode
• Support for Texas Instruments ultra-low-cost XDS100 JTAG emulator
• DLL interface for batch programming and integration of C2Prog functionality into other
applications (requires “professional” or “integration” license for C2Prog – see our Code-Shop)
If the “Automatically check for updates” option is enabled, the programmer will periodically query the
update-server to check if a newer version of the application is available.
c2000-tools:
hex2000 -romwidth 16 -memwidth 16 -i -o .\Debug\test.hex .\Debug\test.out
470-tools:
hex470 -romwidth 8 -memwidth 8 -i -o .\Debug\test.hex .\Debug\test.out
msp430-tools:
hex430 -order MS -romwidth 16 -i -o .\Debug\test.hex .\Debug\test.out
An Intel Hex file only contains raw flash data. It does not define any target specific information such as
the type of MCU to be programmed, its oscillator frequency, the communication protocol to be used,
etc. This information must be configured in the “Programming Configuration” panel.
Important: Do not interrupt the programming as this can cause the MCU to be permanently locked.
Also, do not power-cycle or reset the target during programming.
JTAG:
CAN:
USB:
Valid entries for the serial port are “COM1”, “COM2”, etc.
1 All CAN drivers are made available as open source under the GNU Lesser General Public License (LGPL). See
http://www.codeskin.com/opensource for more information.
It is recommended that this command be configured as a final build step, in combination with the hex-
file generation. Shown below is a sample batch file named genehx.bat, stored in the root of a C28 CCS
project, that can be called as a final build step as follows:
Sample genehx.batfile:
• file:///c:/file.ehx
• http://hostname/directory/file.ehx
• http://username:password@hostname/directory/file.ehx
• ftp://username:password@hostname/directory/file.ehx
The following command creates an extended hex file with password protection and license agreement.
All keys to unlock the flash are specified as 0x1234 and the sectors selected to be erased are A,B,C and D
(hex 0xF = binary 1111).
C2ProgShell.exe -target="2811_30MHz" -hex=test.hex\
-keys=1234,1234,1234,1234,1234,1234,1234,1234 \
-sectors=F -crc -ehx=test.ehx -pass="very secret" \
–license=license.txt
The following command programs the flash using a password protected Extended Hex file:
C2ProgShell.exe -shell -hex=test.ehx -pass="very secret" -port=COM1
2 The “-port” option is only available with the professional license of C2Prog
3 The DLL interface is only available with the professional license of C2Prog
c2pProgram can be called as “blocking” or “non-blocking”. In blocking mode, the function will not
return until the programming has completed (successfully, or with an error). In the non-blocking mode,
the function returns immediately, and the progress of the programming (and its success) must be polled
by means of the c2pGetProgressInfo call. This allows the application, which uses the C2Prog-DLL, to
display progress information while the programming takes place.
It is important to understand that once a flash programming session has been initiated, it must be
allowed to complete. Aborting the session in midstream may permanently damage the MCU.
0x3F7FFF
CSM
(and entry
0xFFFF point)
0x3F7F80
0x0000
0xFFFF
32-bit CRC
0x0000
32-bit CRC
0x0044
Code
CSM
0x0040
If the “Append CRC” box is checked, or “-crc” command line option is used, C2Prog will first parse the
hex-file and determine the lowest and highest address to be programmed. For a 240x MCU, this includes
the CSM zone (4 keys), for a 28xx MCU, the CSM zone is ignored (including keys, reserved words, and
program entry points). Next, the 32-bit CRC is calculated and appended at the top of the memory, i.e. at
the two addresses above the highest address of the hex-file determined before. In addition, a CRC
delimiter, one zero word (0x0000), is added on top of the two CRC words.
The 32-bit CRC algorithm used has the following parameters:
• Polynomial: 0x04c11db7
• Endianess: big-endian
• Initial value: 0xFFFFFFFF
• Reflected: false
• XOR out with: 0x00000000
• Test stream: 0x0123, 0x4567, 0x89AB, 0xCDEF results in CRC = 0x612793C3
Please refer to the Appendix of this manual for an CRC32 implementation example.
In contrast to a typical data-stream with the CRC transmitted at the end, the C2Prog CRC must be verified
by processing the flash data starting with the CRC, i.e. one memory address below the CRC delimiter
(0x0000). A successful data-verify results in a CRC register value of zero (0x00000000).
A typical flash verification algorithm running at DSP powerup appears as follows:
1. Set a memory pointer to the highest possible program address.
2. Decrement the pointer until it points to the CRC delimiter (0x0000), skipping all 0xFFFF values.
3. Decrement the counter by one more address (at which time it points to the first CRC word).
FlashPtr = FLASH_TOP;
// search for CRC delimiter
while((*FlashPtr != 0x0000) && (FlashPtr > FLASH_BOT)){
FlashPtr--;
}
// process stream, CRC first
CRCRegister = 0xFFFFFFFFL;
while(FlashPtr > FLASH_BOT){
FlashPtr--;
// each CRC32Step() shifts one byte into the CRC register
CRCRegister = CRC32Step4(((*FlashPtr >> 8) & 0xFF), CRCRegister);
CRCRegister = CRC32Step(((*FlashPtr >> 0) & 0xFF), CRCRegister);
}
// at this point CRCRegister should be reading zero
0 1 0
• SW1.3 = OFF
Note that the F28M35 UART bootloader is communicating via pins UART0_RX PA0_GPIO0 and
UART0_TX PA1_GPIO1. Unfortunately, these pins are not connected to an RS-232 transceiver on the
Concerto controlCARD or Experimenter Kit. Therefore, users of the Concerto controlCARD will have to
provide an additional tranceiver in order to utilize the UART bootmode.
• F28M35X-M3-256K: For programming M3 cores with 256K of Flash (H20B1, H20C1, H22B1,
H22C1, H32B1)
• F28M35X-C28-256K: For programming C28 cores with 256K of Flash (H20B1, H20C1, H22B1,
H22C1, H32C1)
• F28M35X-C28-512K: For programming C28 cores with 512K of Flash (H32B1, H50B1, H50C1,
H52B1, H52C1)
With these configurations, it is possible to program cores individually. When choosing a Concerto target,
it is important that the correct external clock frequency be selected. Currently, only 20 MHz
configurations are provided.
Both cores of the Concerto can be programmed without the need for resetting the device after the first
core has been reflashed. This is achieved by first programming the C28 core, and subsequently selecting
the “after-C28” option for the M3 target. This process can be automated by using the C2Prog DLL or
command-line interface.
Sample batch file for programming both cores in one session:
SET C28_EHX_FILE="blinky_dc_c28.ehx"
SET M3_EHX_FILE="blinky_dc_m3.ehx"
Note how the “after-C28” option is used for the M3 ehx file.
// first nibble
nibble = (byteIn >> 4) & 0x0F;
crc = CRC32StepNibble(nibble, crc);
// second nibble
nibble = (byteIn) & 0x0F;
crc = CRC32StepNibble(nibble, crc);
return(crc);
}
c2pStatus c2pInitializeLibrary()
Initializes the programming environment. Has to be called by the application before any other API
functions are used.
Returns:
zero (0), if call successful
error code, otherwise – use c2pGetErrorDescription for description of error
c2pStatus c2pProgram
(char* fileName, char* password, char* protocol, char* port, short wait)
Initiates flash programming. Note that only one flash programming session can be active at any time.
Parameters:
fileName: Full path and name of ehx file
password: Password to decrypt ehx file. If no password is used, provide empty string (“”)
protocol: Reserved for future use. It is recommend that the string “default” be used
port: Name of communication port
wait: If set to 0, the function launches the programming session and returns immediately.
Otherwise, the call blocks until the programming session terminates
Returns:
zero (0), if call successful
error code, otherwise – use c2pGetErrorDescription for description of error
Example:
c2pProgram("D:\\data\\Firmware.ehx", "", "default", "XDS100v2", 1);
Obtains status information while programming session is active. This function is typically used after a non-
blocking call to c2pProgram to display progress, status and error information. If a fault occurred during
programming, the function returns an error code and the value of state indicates in which state the
error occurred.
Parameters:
state:
0: Idle / Done
1: Establishing communication with PBL
2: Downloading SBL
3: Establishing communication with SBL
4: Erasing flash
5: Programming flash
c2pStatus c2pExtract
(char* ehxFileName, char* password, char* hexFileName)
Extracts firmware image from ehx file and saves it as raw Intel hex.
Parameters:
ehxFileName: Full path and name of ehx file
password: Password to decrypt ehx file. If no password is used, provide empty string (“”)
hexFileName: Full path and name of hex file (note: existing file will be overwritten)
Returns:
zero (0), if call successful
error code, otherwise
Converts the contents of a hex file into a payload image, and creates a new hex file which combines the
contents of a carrier hex file with the payload image. For dual processors, this function can be used to
stage a program image for core B into the flash memory of core A, that c ore A can transfer into core B.
More details about the image format can be found after this description of the API calls.
Parameters:
carrierHexFileName: Full path and name of hex file containing program data to which the
image data will be added (note: this file is not modified by the function)
carrierDataWidth: Data width (in bits) of carrier hex file
payloadHexFileName: Full path and name of hex file that will be converted in to an image
(note: this file is not modified by the function)
payloadDataWidth: Data width (in bits) of payload hex file
imageAddress: Address in carrier space at which image will be located
outHexFileName: Full path and name of hex file to be generated, containing both the carrier
and image data (note: existing file will be overwritten)
Returns:
zero (0), if call successful
error code, otherwise
c2pStatus c2pGetErrorDescription
(c2pStatus error, char* errorDescription, int errorStringMaxLen)
Firmware Image
Data Record #0 Data Record #1 Data Record #2 ... Data Record #N-1 Termination Record
Data Record
The CRC is a 16-bit value calculated over entire Data Packet (k+2 bytes) (CCITT polynomial:
x^16+x^12+x^5+1, initial value = 0xFFFF). All values are stored in Big Endian notation, starting with the
most significant byte (MSB).
The Record Data contains image data as well as the address to which the data needs to be copied when
the image is deployed (target address).
Record Data
Termination Record
0x0000 0x1D0F