CDE RTOS Hacking: Show it as an RTOS component

Technically, a normal user component can implement any RTOS. This is what I did with the Micrium MicroC/OS-II component. That way the component shows up in the ‘Embedded Components’ group. But how to make it showing up as RTOS component inside the ‘Operating System’ group as the FreeRTOS component? What I want is this: to show the RTOS component under the ‘Operating System’ group of my project:

FreeRTOS in the Operating System Group

FreeRTOS in the Operating System Group

First I was thinking this is accomplished with marking the component category as ‘Operating System’ in the Component Wizard:

Component Category

Component Category

But: this has not the desired effect. All what this does is to list the component under the ‘Operating Systems’ group in the Components Library View:

Components Library with Operating Systems

Components Library with Operating Systems

I have found two ways to show the component under the ‘Operating Systems’ group:

1. CDE Component Wizard (Eclipse based)

With MCU10.2, there is a CDE (Component Development Environment) Component Wizard. Here you can create a new component using the menu File > New > Other. This gives the following dialog:

New Component with Wizard

New Component with Wizard

Pressing Next, and I can select to create an RTOS:

New RTOS Component

New RTOS Component

This will then everything set up in order to show the component in the ‘Operating Systems’ group.

This approach has two disadvantages:

  1. You need a special professional license from Freescale to create such an RTOS component. Otherwise the option as shown in the above dialog is disabled.
  2. This approach only works for new components. So as for myself who already had created a component and want to move it to a ‘real’ RTOS component, this approach will not work.

2. Hacking the Bean File

The approach I used was to hack the *.bean file of the component (see this post about all the different files of a component). All what I have to do is to add

<OperatingSystemId>NameOrIDofMyRTOS

to the <Options> XML element. Of course replace NameOrIDofMyRTOS with your own ID. I’m using ‘FreeRTOS’ for my FreeRTOS component.

Below is the beginning of my FreeRTOS.bean file which has the <OperatingSystemId> on line 14:

<?xml version="1.0" encoding="UTF-8"?>
<Bean>
<Header>
<Name>FreeRTOS</Name>
<Description>FreeRTOS</Description>
<Author>Erich Styger</Author>
<Version>01.194</Version>
<Icon>FreeRTOS</Icon>
<TypesFiles>PE,FreeRTOS\FreeRTOS</TypesFiles>
<FileVersion>6</FileVersion>
</Header>
<Options>
<Category>Operating Systems</Category>
<OperatingSystemId>FreeRTOS
<BW_HelpType>BasicPlusUsageAppNote</BW_HelpType>
<BW_HelpFiles>,Properties,Methods,Events,"Typical Usage","Application Notes"</BW_HelpFiles>
<BW_AutoSaveHelp>yes</BW_AutoSaveHelp>
<BW_AutoSaveDriver>yes</BW_AutoSaveDriver>
<BW_DetailedHelp>yes</BW_DetailedHelp>
<BW_NeedTps>yes</BW_NeedTps>
<BW_NeedUst>9</BW_NeedUst>
<BW_NeedCns>0</BW_NeedCns>
<BeanStatus>PROPOSAL</BeanStatus>
...

As a side note: on line 13 () is what I have set as Component Category in the Component Wizard.

Usage of OperatingSystemId

With having the <OperatingSystemId> defined, I can use it in my components. For example if I want to do different things depending on the RTOS I’m using, I can write:

%if defined(OperatingSystemId) & OperatingSystemId = 'FreeRTOS'
/* include RTOS header files */
#include "FreeRTOS.h" /* for vTaskDelay() */
#include "task.h"
%endif
...
%-BW_METHOD_BEGIN WaitOSms
%ifdef WaitOSms
%if defined(RTOS) %-RTOS defined in properties, e.g. uCOS-II
#define %'ModuleName'%.%WaitOSms(ms) \
(void)%@RTOS@'ModuleName'%.OSTimeDlyHMSM(0,0,(ms)/1000,(ms)%%1000)
%else
#define %'ModuleName'%.%WaitOSms(ms) \
%if defined(OperatingSystemId) & OperatingSystemId = 'FreeRTOS'
vTaskDelay(ms/portTICK_RATE_MS)
%else
%'ModuleName'%.%Waitms(ms) /* no RTOS used, so use normal wait */
%endif
%endif

I used the above code in my Wait component.

Note: Checking for the <OperatingSystemId> has one disadvantage: I need to know all the different IDs. How to deal with ‘unknown’ operating systems? There is a solution for this with the ‘RTOS Adapter’ concept of Processor Expert which is not covered in this post.

One Instance Only, please!

The other thing to set for an RTOS component: that there can be only one instance of it:

One Instance of component

One Instance of component

That way there can be only one RTOS component in the project.

Note: Only having one RTOS usually makes sense, and this is what I have right now anyway. But I’m thinking about special applications where I might want to have multiple operating systems, say a real time one and a non-realtime one. Not sure how Processor Expert will support this, but I guess I’ll have to find it out :-).

Summary

In order to show a component in the RTOS Processor Expert project group, I need to set the <OperatingSystemId> in the component .bean file. I can use that ID to perform custom things in my other components depending on which RTOS is used (if I know their ID). Additionally I should set the ‘one instance only’ flag for the component.

Happy RTOS Hacking 🙂

Advertisements

One thought on “CDE RTOS Hacking: Show it as an RTOS component

  1. Pingback: CDE Hacking: Where is my stuff? A dissection… | MCU on Eclipse

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s