1.2.10. Embedded runtime

In general the whole runtime is very scalable. By disabling features, you can scale it down to very small systems running on drives, mobile machine controllers, etc. So generally spoken, there is no difference between an “embedded” or “full” runtime. But as the requirements for those small systems are a bit different, there are a few components that have an alternative implementation, which fits better for embedded systems.

Those components usually have the Postfix “Embedded”. The following table describes the most central and most important special components and their specialties.

Standard Component

Embedded alternative

Description

CmpApp

CmpAppEmbedded

Supports only one application, but therefore has an option to run from flash optionally. Note, that the download format is different.

CmpAppBP

CmpAppBPEmbedded

Supports only basic breakpoints and some rudimentary conditional breakpoints. Execution Points, Flow Control and complex conditional breakpoints are not supported.

CmpEventMgr

CmpEventMgrEmbedded

Supports no IEC interface and has a datamanagement, that is optimized for memory consumption. The handling is optimal if there are only a small number of listeners.

CmpChannelMgr

CmpChannelMgrEmbedded

Those two components have to be selected in combination always. They support only one channel and are occupying less space in RAM and FLASH.

CmpChannelServer

CmpChannelServerEmbedded

CmpSettings

CmpSettingsEmbedded

Supports no settings file (ini file format), but therefore a static list of settings in memory. Those settings can be written and read and if the OEM customer likes to store them on a persistent media, this is possible.

CmpRouter

CmpRouterEmbedded

Supports only one main-net (= one block driver) and no routing between networks.

CmpSchedule

CmpScheduleEmbedded

Executes all IEC tasks in one super loop in the background. No preemption is supported.

CmpSchedule

CmpScheduleTimer

Similar to CmpScheduleEmbedded, but executes cyclic IEC tasks in the context of system timers. Those system timers may be based on hardware timers directly (beware of interrupt locks!) or on an embedded operating system.

CmpIoMgr

CmpIoMgrEmbedded

Supports the same main features as the IoMgr, but is optimized to run on systems w/o tasks and w/o semaphores.

SysFile

SysFileFlash

A very simple file implementation which works on memory mapped files in flash. It uses SysFlash to write data to flash, but the flash has to be memory mapped.

1.2.10.1. Compact download format

If an embedded runtime is using CmpAppEmbedded, instead of CmpApp, it also uses a different download format implicitly. This format is called “compact download”.

The following settings in device description shall be used: compact_download, constants-in-own-segment, code-segment-header-size.

Instead of using a flexible but complex tagged format, the compact download consists of one binary file, which can be directly downloaded to flash, and even be executed from there. The binary file starts with a header, which contains the most important information directly and points to more advanced sections within the binary.

Segment

Description

CodeHeader:

RTS_UI32 ulHeaderTag;

RTS_UI32 ulHeaderVersion;

RTS_UI32 ulHeaderSize;

RTS_UI32 ulTotalSize;

RTS_UI32 ulDeviceType;

RTS_UI32 ulDeviceId;

RTS_UI32 ulDeviceVersion;

RTS_UI32 ulFlags;

RTS_UI32 ulCompilerVersion;

RTS_UI32 ulCodeAreaSize;

RTS_UI16 usCodeAreaIndex;

RTS_UI16 usCodeAreaFlags;

RTS_UI32 ulOffsetCode;

RTS_UI32 ulSizeCode;

RTS_UI32 ulOffsetApplicationInfo

RTS_UI32 ulSizeApplicationInfo;

RTS_UI32 ulOffsetAreaTable

RTS_UI32 ulSizeAreaTable;

RTS_UI32 ulOffsetFunctionTable;

RTS_UI32 ulSizeFunctionTable;

RTS_UI32 ulOffsetExternalFunctionTable;

RTS_UI32 ulSizeExternalFunctionTable;

RTS_UI32 lOffsetRegisterIecFunctionTable;

RTS_UI32 ulSizeRegisterIecFunctionTable;

RTS_UI32 ulOffsetSourceCode;

RTS_UI32 ulSizeSourceCode;

RTS_UI32 ulCrc;

Header of the stream:

HeaderTag=0x1234ABCD

HeaderVersion=0x00000001

HeaderSize=104

Total size of header including all segments

Device type of the selected device

DeviceID of the selected device

Device version of the selected device

Download Flags

Compiler version of used CODESYS version

Code area size

Code area index

Code area flags

Offset in bytes, where the code segment begins

Size in bytes of the code segment

Offset in bytes, where the application info segment begins

Size in bytes of the application info segment

Offset in bytes, where the area table segment begins

Size in bytes of the area table segment

Offset in bytes, where the function table segment begins, Here the link function are specified:
- CodeInit
- GlobalInit
- GlobalExit
- Reloc
- DownloadCode
- TargetInfo

Size in bytes of the function table segment

Offset in bytes, where the external function table segment begins to link c functions against iec code

Size in bytes of the external function table segment

Offset in bytes, where the iec function table segment begins to link iec functions against the runtime system

Size in bytes of the external function table segment

Offset in bytes, where the optional sourcecode segment begins

Size in bytes of the optional sourcecode segment

RC32 of the complete download stream including the header with ulCRC written to 0!

Code segment

Code POUs

ApplicationInfo segment:

All names are transmitted 4 byte aligned:

Project name (ASCII string)
Author (ASCII string)
Version (ASCII string)
Description (ASCII string)
Profile (ASCII string)
Date of last change (DATE_AND_TIME)

Application info

Area segment:

List of AREA_INFO

Table of all used areas

Function table:

  1. pfCodeInit

  2. pfGlobalInit

  3. pfGlobalExit

  4. pfReloc

  5. pfDownloadCode

  6. pfTargetInfo

Function table to link to runtime

External Function table:

List of EXT_REF_INFO (4 Byte aligned for the next entry!)

Table of external references

IEC Function table:

List of FUNCTION_INFO with following name of the IEC function at the end (4 Byte aligned for the next entry!)

Table of IEC functions that can be called from C

Source code segment:

Actually not used

Optional source code segment for the source code of the used project

CRC

CRC over the complete download stream