C
Flashing instructions for Infineon boards
Note: Flash programming can be fully automated. For details, see OpenOCD based programming.
Introduction
There are multiple ways to program both the internal and external flash memories. The internal flash memory can be programmed over SWD or JTAG connection using any application that has implemented the required underlying protocol. Some of the Infineon TRAVEO T2G development boards contain an onboard KitProg programmer that is connected to the SWD pins of the MCU.
If a KitProg or a MiniProg solution is used, then the Infineon OpenOCD-based packages can be leveraged for programming. This includes both ModusToolbox Programming Tools and Auto Flash Utility. For other SWD or JTAG-based solutions, IDEs and debuggers from 3rd party vendors can be typically used as well.
Note: When selecting between SWD and JTAG, note that the maximum rated clock speeds differ between these two protocols. Also, the physical length of the traces and cables will affect the maximum clock speed. When working with the supported evaluation boards the typical clock speed for SWD is 10 MHz, and for JTAG it is 50 MHz.
Programming any external memory devices, such as Serial Memory Interface (SMIF) devices, is more complicated. A common approach is to load a supporting application on the device and program the external devices from the MCU itself (that is, only transport the data over the debug protocol). For many of the development boards in the TRAVEO T2G family series, this kind of functionality is provided by the programming tools out of the box.
OpenOCD-based programming
The Infineon-specific OpenOCD application is available, but not limited to, from the following software packages:
- ModusToolbox Programming Tools
- Infineon Auto Flash Utility
The OpenOCD application is at located in the corresponding software installation location under openocd/bin directory. The supporting scripts are available in the openocd/scripts directory. The openocd/scripts/interface directory contains scripts for the debug probe and the openocd/scripts/target contains the actual target scripts.
Note: The Infineon- customized OpenOCD may differ from the upstream OpenOCD distribution, and it may contain additional sources.
Note: If the OpenOCD binary directory is added to the system path, or the above software packages are installed in their corresponding default install locations, a suitable flashing target is added for all Qt Quick Ultralite targets, including the bootloader. For an example, flash_minimal for minimal. Using this target will invoke OpenOCD with the target binary.
Programming procedure
The flash programming procedure is as follows:
- Select a suitable script that interacts with the selected SWD or JTAG probe.
- Optionally, select a suitable utility application that handles external memory device programming.
- Select a suitable script that interacts with the target.
- Select the desired application (or bootloader) and issue a programming command for it.
When the same memory device, be it internal or external, is shared between multiple cores it is essential to remember that especially with flash-based storage any previously written data must be erased at first. The minimum sector or block size for erase operations is usually larger than the corresponding write block size. Hence, when programming applications (and bootloader) from multiple binary files, such as ELF, the erase blocks must not overlap with each other. The programming tools only erase and write data; they do not merge it.
Note: When using ELF as the binary container, any embedded debug sections are handled properly and are not written to the actual device. This simplifies the programming procedure, as debugging symbols can remain in place in the ELF files for the debugger.
In general, OpenOCD is driven using Tool Command Language (Tcl) programming language. The commands can be supplied either from the existing script files, the command-line, or from any combination of these.
Note: Pay attention to the OpenOCD command-line argument quoting. For paths, use forward slashes instead of backslashes. When invoking Tcl commands with parameters that are separated by whitespace, quote the entire command invocation. Thus, -c "program minimal.elf" and -c program minimal.elf are not the same. The latter would call program without any parameters, and minimal.elf would be evaluated not as a Tcl command but as an OpenOCD argument.
Scripts and programming commands
Interface script
The chosen interface script configures the desired debug probe.
| Programmer | Script |
|---|---|
| KitProg3 or MiniProg4 | interface/kitprog3.cfg |
| J-Link probe | interface/jlink.cfg |
Note: The interface scripts listed above are only examples. For details on the supported interfaces, see the interface directory or the OpenOCD documentation.
Device script
The chosen device script configures the desired target device properties such as flash addresses and register locations.
| Board | Script |
|---|---|
| TRAVEO T2G CYT3DL (4M and 4M LITE KIT) | target/traveo2_c2d_4m.cfg |
| TRAVEO T2G CYT4DL (6M [327-BGA-REF] and 6M LITE KIT) | target/traveo2_c2d_6m.cfg |
| TRAVEO T2G CYT4DL (6M [327-BGA-REV-B]) | target/traveo2_c2d_6m_b1.cfg |
| TRAVEO T2G CYT4EN (6M DDR) | target/traveo2_c2d_6m_ddr.cfg |
Programming commands
Programming commands are either individual functions that are embedded inside OpenOCD or vendor supplied Tcl scripts.
| Action | Command |
|---|---|
| Select SWD as transport. | transport select swd |
Program minimal.elf, verify that programming has succeeded and finally exit. | program minimal.elf verify exit |
Note: The program command does implicitly call both init and reset init. The details of the program script can be examined in the OpenOCD source package at src/flash/startup.tcl.
OpenOCD-based programming on external memory devices
In general, the external SMIF memory device programming requires using a special loader application. The loading application can be selected by defining SMIF0_LOADER and SMIF1_LOADER variables. The following list is not exhaustive. The supported SMIF loaders are typically listed in the selected device script, such as target/traveo_c2d_4m.cfg.
Note: In the previous device script versions the loader was selected using ENABLE_SEMPERFLASH_0, ENABLE_SEMPERFLASH_1, ENABLE_HYPERFLASH_0 or ENABLE_HYPERFLASH_1 variables. These are deprecated and should not be used anymore.
Note: When programming the external memory devices remember, that the MCU is initializing and enabling these. Whether the devices are deinitialized or powered down after programming is complete depends on the individual implementation details. Thus, it is important to verify that any subsequent reset signals are properly propagated to these external devices as well.
Otherwise the memory devices might be in a state that is either not supported or not handled due to program storage space concerns by the system initialization code, or otherwise in a state from which it is very difficult to programmatically recover. Various methods can be used to adjust the reset signal. For an example, OpenOCD variables ADAPTER_SRST_DELAY and ADAPTER_SRST_PULSE can be used.
SMIF loaders
| Board | Loader (SMIF channel) |
|---|---|
| TRAVEO T2G CYT3DL (4M and 4M LITE) |
|
| TRAVEO T2G CYT4DL (6M [327-BGA-REF]) |
|
| TRAVEO T2G CYT4DL (6M [327-BGA-REV-B]) |
|
| TRAVEO T2G CYT4EN (6M DDR) |
|
Further OpenOCD details
When using the OpenOCD, the users are advised to study the corresponding OpenOCD documentation and the supplied scripts. Among the most common settings, the protocol link speed can be changed by setting the ADAPTER_SPEED variable. The reset configuration can be changed using the reset_config command.
Note: Make sure you get the reset configuration right. On the TRAVEO T2G family, the devices have both external reset (typically named XRST) and JTAG test reset (typically named TRSTn) pins. These pins, however, are not equivalent. It is possible for the debugger to drive these pins separately: The MCU can be held in reset while JTAG-AP accessible debug registers are programmed, only after which the external reset is released. However, if these pins are tied together, as is the case for many TRAVEO T2G development boards, the debugging software may think it has programmed the debug registers, while in reality, the entire chip, including JTAG-AP, has been held in reset.
Using OpenOCD
While there are many options from which to choose, using the OpenOCD for typical applications is straightforward. In the examples below Traveo T2G 4M is used as the target.
Linux
openocd \
-f interface/kitprog3.cfg \
-c "set SMIF0_LOADER TV2_C2D_4M_SemperFlash_0.elf" \
-f target/traveo2_c2d_4m.cfg \
-c "program <PATH_TO_BINARY>/minimal.elf verify exit"Windows
openocd ^
-f interface/kitprog3.cfg ^
-c "set SMIF0_LOADER TV2_C2D_4M_SemperFlash_0.elf" ^
-f target/traveo2_c2d_4m.cfg ^
-c "program <PATH_TO_BINARY>/minimal.elf verify exit"Advanced usage
Instead of supplying multiple -c and -f arguments, it is also possible to create a Tcl script that performs the operations. The script below does exactly the same as the command above.
source [find interface/kitprog3.cfg] # Similar as `-f` argument. transport select swd set SMIF0_LOADER TV2_C2D_4M_SemperFlash_0.elf source [find traveo2_c2d_4m.cfg] program <PATH_TO_BINARY>/minimal.elf verify exit
You can refer to the OpenOCD documentation for details, but by default OpenOCD will look into several different directories when looking for a script file. Hence, it is possible to add scripts into these default search directories and supply just a name on the command-line. These directories include, but are not limited to, the following:
- The current directory,
- The home directory, and
%HOME%\.openocd%APPDATA%\OpenOCD(only on Windows)
- The
scriptsdirectory inside OpenOCD installation directory.
Note: On Windows the HOME environment variable may not exist by default. The OpenOCD does not construct it from USERPROFILE or HOMEDRIVE and HOMEPATH environment variables when compiling the default include path. However, the HOME environment variable can be manually added if it does not exist.
Available under certain Qt licenses.
Find out more.