infineon Aurix TC23x
Porting Paulus on infineon Aurix TC23x
File structure
After installation of Paulus the source code is stored in the file structure shown in Table 1 describes the contents.
directory | description |
/paulus_aurix_tc23xx | project folder with all necessary HighTec IDE project files |
/bootloader | target independent CANopen sources for Paulus |
/eds | Design Tool project of Paulus with all generated files, e.g. the EDS file and documentation files |
/aurix_tc23xx/ | Target-specific sources of Paulus, e.g. CAN-driver, low-level drivers and supporting services from infineon Corporation e.g flash-service. |
/aurix_tc23xx/aurix_flash.[ch] | target-specific flash routines |
/aurix_tc23xx/aurix_can.[ch] | CAN routines |
/aurix_tc23xx/aurix _init.c | CPU initialization |
/aurix_tc23xx /environ.h | header file for the environment definition |
/aurix_tc23xx /bl_config.h | Paulus configuration file |
/aurix_tc23xx /Config | Configurations infineon iLLD driver package for Aurix devices |
/aurix_tc23xx / HighTec_BSP | HighTec created BSP sources, supporting for e.g. startup, clock settings, interrupt table |
/example | example application with a CANopen slave project (s1) |
/tools | checksum generator tool for Paulus |
main.c | main loop of Paulus |
Table 1: File structure
The initialization of the CAN controller is done in module aurix_tc23xx / can.c.
In module aurix_tc23xx / init.c the I/O pins for the CAN interface have to be initialized.
In module aurix_tc23xx / init.c there must be the functions getBitRate() and getNodeId() available. Usually the CANopen network parameters are provided by reading jumpers or by loading from flash memory.
Development environment
Paulus on the platform of Infineon Aurix was developed with the HighTec Development Platform v1.6 with compiler tricore gcc v4.9.3. The Hardware environment is the infineon Application Kit TC234 v1.0.
Paulus configuration
In general the initialization function initializes only the absolutely necessary peripherals like clock system, CAN controller, memory management as needed by Paulus and a timer for Heartbeat or LSS. Nevertheless, there might be situations where it makes sense that Paulus initializes other functionalities which are later used by the application as well. As an example consider the serial interface for debug messages.
CAN bit rate
The CAN bit rate is coded by the index of the CAN bit timing table according to /CiA-305/. The index of the default CAN bit rate is specified about the compiler-define BITRATE_INDEX_<bit_rate> in /aurix_tc23xx /bl_config.h:
#define BL_USED_BITRATE_INDEX BITRATE_INDEX_125K
The default CAN bit rate is 125 kbit/s and can be changed by LSS services. The LSS services are described in /Paulus_man/ and base on /CiA-305/. The supported CAN bit rates are depending on the clock of the CAN controller and are listed in /aurix_tc23xx /aurix_can_can.c. The value FFh for segment3 marks unsupported CAN bit rates. The clock for the activation of the CAN bit rate is generated by timer STM0 system timer with a period of 1 ms.
Heartbeat producer
Timer STM0 is also used for the generation of Heartbeat producer messages.
Debug output
By the compiler-define DEBUG some debug output can be activated. But the Debug output via printf is not implemented yet. No HW interface is easily available on eval-board. The compiler-define is set in file /aurix_tc23xx/bl_config.h:
#define DEBUG 1
In general the initialization function will initialize only the absolutely necessary peripherals like clock system, CAN controller, memory management as needed by Paulus. Nevertheless, there might be situations where it makes sense that Paulus initializes other functionalities which are later used by the application as well. As an example consider the serial interface for debug messages.
Generating application software
The application software consists of an application header and an application program.
Figure 1: structure of application software
The application program has to be prepared for download by the following steps:
build the application program in binary format
calculate the CRC of the application program, build the application header and generate the application software to download
configure the start address of the application software in Paulus
Paulus checksum
The program paulus_cksum calculates the CRC checksum of the binary application program generates the application header and stores the application header and the application program in a new file. This file can be loaded in the device by Paulus.
Unused bytes in the application header are set to 0x00 with the Aurix. The length of the application header is 256 bytes.
Example: The download file for the binary application program s1_aurix_tc23xx.download is generated about Windows console:
C:\jsc\Paulus_Aurix_TC23x_v4.9.3\software\tools>paulus_cksum -v -C -l 256
-x 0x8000C100 s1_aurix_tc23xx.bin -O s1_aurix_tc23xx.download
reduce Flash end to file end: 0x00011024
reduce EndAddr to the Flash end 0x00011023
address - crc: 0x00000000, start: 0x00000000, end: 0x00011023, exec 0x8000c100
Flash end: 0x00011024
out: >s1_aurix_tc23xx.download<
input: >s1_aurix_tc23xx.bin<
calc CRC from 0x00000000 to 0x00011023
size: 0x00011024, crc: 0x0dab
Writing Appl. to >s1_aurix_tc23xx.download<:
length: 69668/0x11024, crc: 0x0dab, execadr: 0x8000c100
Besides checking the CRC Paulus checks also the size of the application header. A size of 0 is invalid. An application may destroy the ’valid’ information by overwriting the size with 0. That is always possible on the Infineon Aurix FLASH, because the byte content is 0x00 after erasing.
More detailed information from this tool can find in /Paulus_CRC/.
To prepare: In order to produce a usable binary file from the Intel hex file output of HighTec IDE you can use the free software tool HEX2BIN. The hex file was generated via HighTec IDE postbuild step (tricore-objcopy -O ihex s1_aurix_tc23xx.elf s1_aurix_tc23xx.hex).
See example in Windows console (hex2bin tool):
C:\jsc\Paulus_Aurix_TC23x_v4.9.3\software\tools>hex2bin.exe -s 0x80000C100 s1_aurix_tc23xx.hex
hex2bin v1.0.1, Copyright (C) 1999 Jacques Pelletier
Lowest address = 00000000
Highest address = 0001D123
Start address
It is important that the start address of the application software in the flash memory and the information in the Paulus configuration in aurix_tc23xx /aurix_tc23_flash.h are identical. The application software is stored as a separate program in the flash memory additionally to the bootloader program. Therefore the application software is flashed to:
#define FLASH_PROGRAM_START_ADR 0x80000C000
The length of the application header is 256 byte. The program start of the application is at address (FLASH_PROGRAM_START_ADR + 256 bytes).
Memory
Shared RAM
The shared RAM for data exchange between bootloader and application starts at address 0xC0000000 from Scratch-Pad RAM (PSPR). The size of the shared RAM is specified in <target>/bl_interface.h by the compiler-define BL_JUMPCODE_SIZE. The shared memory is installed in <target>/bl_interface.h as follow:
UNSIGNED8 jumpcode[BL_JUMPCODE_SIZE] __attribute__ ((section (".noinit")));
The keyword for the re-start of the application program is set in byte 0-3 of jumpcode. Paulus uses the keyword “APPL” or “BOOT” to start the application program, see /Paulus_man/.
Flash
The total size of the Aurix TC23x flash (PFLASH0) is 2Mb. The current implementation of Paulus occupies a memory area of 48Kb from this. Therefore 2000Kb (less 0x100 byte crc header) flash memory area available for the application software.
Figure 2: Flash memory mapping
The flash area for configuration data of Paulus is located at the DFlash address 0xAF000000 and following. On this address and the following Paulus stores the node-ID and the CAN bit rate index during the execution of the LSS service “LSS store configuration“. The addresses are configurable in aurix_tc23xx /bl_interface.h:
#define FLASH_ADDRESS_NODEID 0xAF000000
#define FLASH_ADDRESS_BITRATE_INDEX 0xAF000001
After the next re-start Paulus read this flash addresses, saved the values in an own RAM variables and uses this node-ID and this CAN bit rate index for communication. The new CAN bit rate cannot be activated by NMT-Command Reset Application. If the LSS services are not used, Paulus uses the node-ID and CAN bit rate index configured in aurix_tc23xx / bl_config.h.
Example application
CANopenSlave1 is an example for an application program. The directory example/ CANopenSlave1_aurix_tc23x contain the compiler project and the application-specific functions. For compilation the CANopen Library and the suitable driver package is necessary. The CANopen Library and the driver package belong not to the delivery scope of Paulus. The binary application software in example/ CANopenSlave1_aurix_tc23x/bin/s1_aurix_tc23xx.download can be used for a quick start.
The linker file of this example project is adapted on these memory requirements (flash addresses and shared RAM section).
See settings in linker file from example (iROM.ld):
/*
* Global
*/
/*Program Flash Memory (PFLASH0)*/
__PMU_PFLASH0_BEGIN = 0x8000C100;
__PMU_PFLASH0_SIZE = (2M - 48K); /* 48K for Paulus Bootloader */
…
/*
* Internal flash configuration
*/
MEMORY
{
PMU_PFLASH0 (rx!p) :org = 0x8000C100, len = (2M - 48K) /*Program Flash Memory (PFLASH0)*/
PMU_DFLASH0 (r!xp): org = 0xAF000000, len = 128K /*Data Flash Memory(DFLASH0)*/
BROM (rx!p): org = 0x8FFF8000, len = 32K /*Boot ROM (BROM)*/
PMI_PSPR (wx!p): org = 0xC0000000, len = 8K /*Scratch-Pad RAM (PSPR)*/
…
}
This example has included source files bl_interface.c, bl_interface.h from bootloader. The application program can request an update by jumping back into Paulus by writing of the program control command start application program (value 1) on object 1F51h/1. The application program calls the macro BOOTLOADER_JUMP(APPL). This call is implemented in usr_301.c /sdoWrInd(). The application program stores the keyword “APPL” in the shared RAM and jumps into Paulus. Paulus is re-started and stays running until the application program is started by command.
References
/CiA-305/ | CANopen Layer Setting Services and Protocols, CiA |
/Paulus_CRC/ | manual “Paulus Checksum Tool”, see file tools/manual_cksum.pdf |
/Paulus_man/ | manual “Paulus User Manual”, see file UserMan_Paulus_Bootloader_e.pdf |
Table 2: References