Upload
ralf-fitzgerald
View
216
Download
2
Embed Size (px)
Citation preview
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 1
Specialist Rhapsody
Getting Rhapsody In C generated code to run
on your target
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 2
The Three Steps To Success Step 1:
The simplest way to get Rhapsody in C generated code to run on your target is to run it without using an Operating System or without using the Rhapsody OXF Framework. Since there’s no framework or operating system, we won’t be able to use asynchronous events or timeouts and we won’t of course be able to create threads, mutexes, … All that is needed is just informing Rhapsody how to create a make file and how to compile, link and perhaps even connect to the target and download the executable and run it.
Step 2: Once the first step has been accomplished, we can then get the Interrupt
Driven Framework to run on the target. This will allow asynchronous events and timeouts to be used.
Step 3: The final step if necessary is to port the Operating System so that we can
create threads, mutexes, … and thus use Rhapsody without any limitations.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 3
Step 1: Getting code to run
First of all we need to add a new environment to Rhapsody specific to your target.
In the Rhapsody\Share\Properties directory, either create a new siteC.prp file or edit an existing one to add a new environment
Name the new environment in the format “framework”_”compiler”_”cpu”
For this example we will use an environment using the GreenHills compiler for a PowerPC. The environment will thus be called NOF_GreenHills_PPC where NOF implies No Framework, GreenHills is the compiler and PPC the cpu
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 4
SiteC.prp
Soon we will create a file containing properties specific to the new environment called siteC_“framework”_”compiler”_”cpu”.prp
Add an Include statement to include this file ex:
Default environment
Include statement
New environment
This example shows just two environments, you can of course, specify as many as you need.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 5
SiteC_NOF_GreenHills_PPC.prp
In order to create the included properties file; we can either copy an existing file (recommended approach) or create a new one and cut and paste the appropriate properties from a suitable environment in the factoryC.prp file
Creating a separate properties file specific for each new environment makes it easier to manage multiple environments. Alternatively instead of creating a separate file and using an Include statement, we could have put all the properties in the SiteC.prp
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 6
Properties
The file should contain the following properties:
All we need to do now is give them appropriate values
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 7
Before we start
When setting the properties, if we need to add characters “ or \ to a property of type String, then we must precede the character by \ ex: \” or \\
If any paths have spaces in them, then the paths must be enclosed in “”
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 8
Property : InvokeExecutable
This property is used to inform Rhapsody how to execute the generated executable.
For example the following calls a batch file called greenhills_ppc_run.bat passing the name of the executable
$OMROOT is an environment variable that will be set by Rhapsody to point to the Rhapsody\share directory.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 9
Property : Invoke Make
This property is used to inform Rhapsody how to invoke the make
For example the following calls a batch file called greenhills_ppc_make.bat passing the name of the make file and make target
$OMROOT is an environment variable that will be set by Rhapsody to point to the Rhapsody\share directory.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 10
Property : ParseErrorMessage
This property is used to inform Rhapsody how to interpret an error in order to find where the error occurred, so that double-clicking on the error in the output window automatically opens the appropriate diagram or positions the browser to where the error is located.
It is used in combination with the property ErrorMessageTokensFormat
Rhapsody interprets just a single line in order to determine the file name and line number. If however the error message is split onto several lines (such as with the Tasking compiler), then double-clicking the error will not work.See annex for examples.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 11
Property : Include
This property is used by the makefile to specify the environment-specific command that is generated in the makefile to include other makefiles
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 12
Properties : Exe/Obj/Lib Extension
These properties inform the make file of the extensions for executable files, object files and library files.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 13
Property : EntryPoint
This property is generally set to “main” as this is the usual entry point. However sometimes some operating systems use main themselves. In these cases, the Rhapsody entry point can be renamed to something else, ex: with the operating system ThreadX, it is renamed to txmain
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 14
Property : UseRemoteHost
Generally this property will be set to “False” and the corresponding property RemoteHost will be left blank. It is only really used when a DLL is present to allow remote connections to IDE’s such as Tornado.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 15
Property : ReactiveVtblKind
When generating code for a reactive object, Rhapsody creates a virtual table so that the reactive object knows how to invoke operations on its owner. With no framework or with the Interrupt Driven Framework, a reduced virtual table can be used saving valuable RAM.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 16
Property : OSFileSystemCaseSensitive
Some operating systems such as Solaris, are case sensitive, if this is the case then set this property to “True” otherwise leave it as “False”
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 17
Property : ObjectDirectory
This property can be used if you want the generated objects to be located in a particular sub directory. Leaving it blank means that when compiling all objects will be located in the same directory as the source files.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 18
Property : BuildSet
Generally this property is used to define just two build sets “Debug” and “Release”. However if more build sets are needed, then they can be defined and the make file can make use of them.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 19
Property : Imp/Spec extension
This property sets up the extensions for the generated source and header files.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 20
Property : AdditionalReservedWords
This property allows a list of additional reserved words to be defined that Rhapsody will not allow you to use.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 21
Property : IsFileNameShort
On some older compilers, sometimes the number of characters for filenames must be limited to 8 characters. If this is the case then setting this property to “True” will ensure that all filenames are truncated to the first 8 characters. In most cases this property will be left at “False”
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 22
Property : QuoteOMROOT
This property specifies whether to enclose the value of the OMROOT path variable in double quotes in the generated makefile. Most of the time this property will be set to “True”
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 23
Property : ObjectName
This property specifies an alternative name for the compiled object file in the generated makefile. Most of the time, it will be left blank.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 24
Property : CPPCompileCommand
This property specifies how to compile a source file. Often it is implemented as two lines: an echo statement indicating that it is compiling a specific file followed by the syntax for compiling. The $(CPP) macro is generally defined in the makefile, the $OMFileCPPCompileSwitches are defined in the property CPPCompileSwitches.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 25
Property : CPPCompileSwitches
This property is used to list all the necessary compilation switches, defines etc that are needed in order to compile a file.
ex:
Compiler specific options Additional define
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 26
Property : CppCompile(BuildSet)
This set of properties (one for each specific build set) is used to specify additional properties to the previously defined property CPPCompileSwitches.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 27
Property : LinkSwitches
This property is used to list all the necessary link switches that are needed in order to do a link.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 28
Property : Link(BuildSet)
This set of properties (one for each specific build set) is used to specify additional properties to the previously defined property LinkSwitches.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 29
Property : DependencyRule
This property specifies how dependencies are generated to the makefile.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 30
Property : ObjCleanCommand
This property specifies the environment-specific command used to clean the object files generated by a previous build.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 31
Property : MakeFileContent : start
This is the most complicated property since we need to specify a template make file
ex:
Opening quote
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 32
MakeFileContent : continued
With no Framework or the Interrupt Driven Framework, there is no animation or tracing available.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 33
MakeFileContent : End
Compiling the main
Creating anexecutable
Creating alibrary
Removinggenerated
filesEnd quote
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 34
Share\etc directory
The first two properties that we modified invoke a couple of batch files in order to execute the executable and also invoke a make.
These files need to be created. ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 35
RiC_SignalGenerator Model
The RiC_SignalGenerator Model does not use the Rhapsody framework and can be used to test out our new environment.
Open the model and select the SignalGenerator component Copy the microsoft_nt environment and rename to the name
of your new environment Select the new environment from the list If the new environment is missing, then you’ll need to check
that the properties are correct. Often a spelling mistake or a missing “ is the cause of the problem.
If you modify the siteC.prp or site.prp file, then you don’t need to exit Rhapsody, but you must close the model and then reopen it for Rhapsody to read the modified properties.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 36
Generate / Make
If the properties have been correctly configured, then it should be possible to generate and make ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 37
Run
If you have setup the batch file to correctly invoke the debugger and download the executable, then doing “run” should do exactly this.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 38
Step 2
Once the Signal Generator model runs satisfactorily, it should be pretty straightforward to get the Interrupt Driven Framework to work.
As before a new environment needs to be created ex: IDF_Greenhills_PPC as well as an extra properties file such as siteC_IDF_Greenhills_PPC.prp
Just a few modifications will be needed to convert the NOF_GreenHills_PPC.prp file into the IDF_GreenHills_PPC.prp file. These modifications will mainly be in the CppCompileSwitches and MakeFileContent property
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 39
Property : CPPCompileSwitches
The property CPPCompileSwitches will need some extra include directives so as to be able to locate the IDF header files
ex:
-I$(CIDF_ROOT)/greenhills_ppc
-I$(CIDF_ROOT)/greenhills_ppc/oxf
The environmental variable CIDF_ROOT will need to be configured to point to the location of the IDF ex:D:\Rhapsody42\Demos\CDemos\RiC_InterruptDrivenFramework\idf
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 40
Property : MakeFileContent changes
The property MakeFileContent will need to be modified so that when a link is done, it will include the appropriate idf library.
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 41
Additional Defines
If your target doesn’t support malloc/free or printf then you should add an extra couple of defines to the property CPPCompileSwitches
ex:
NO_MALLOC NO_PRINT
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 42
IDF
It should now be possible to open the RiC_InterruptDrivenFramework model and select the IDF component
Copy the microsoft_nt environment and rename to the name of your new environment
Select the new environment from the list If the new environment is missing, then you’ll need to check
that the properties are correct. As mentioned previously, often a spelling mistake or a missing “ is the cause of the problem.
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 43
Generate / Make
If the properties have been correctly configured, then it should be possible to generate and make the IDF library
ex:
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 44
PingPongTest
Once the idf library has been created, we can now select the PingPongTest (This test doesn’t use timeouts, which we haven’t implemented yet for our new environment)
Once more, copy the microsoft_nt environment and rename and select the new environment
We should now be able to generate / make / run If there are errors, then it is possible that the CIDF_ROOT is
not pointing to the correct location
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 45
Execution
The output should be:
Ping
Pong
Ping
Pong
Ping
Pong
…
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 46
Using the Timer
In order to use timeouts in statecharts, we must modify the global function RiCInitTimer() in the RiC_IdfP package to initialise a periodic interrupt to call the global interrupt RiCTick() every RIC_MS_PER_TICK
ex:
Proprietary and Confidential
www.ilogix.com
AnnexAnnex
Examples of settings for properties:
ParseErrorMessage and ErrorMessageTokensFormat
used for extracting
Line number and file name from errors
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 48
Annex I CAD-UL
Error: CC86-E-FATAL:D:\RhapsodyV301\Demos\CDemos\IDF\idf\cadul\oxf\MemAlloc.h: 20:
ParseErrorMessage : [^FATAL:] ([A-Za-z0-9_\]+[.][A-Za-z0-9]+) :([0-9]+)[:]
ErrorMessageTokensFormat: ToTalNumberOfTokens=2, FileTokenPosition=1, LineTokenPosition=2
ARM
Error: "MainTest.c", line 27: Warning: C2207W: inventing 'extern int RiCOXFInit();'
ParseErrorMessage: "^\"(.*)\".*line ([0-9]*): (.*)$"
ErrorMessageTokensFormat "ToTalNumberOfTokens=3, FileTokenPosition=1, LineTokenPosition=2"
Borland
Error: Error Toto.c 27: Undefined symbol 'i' in function Toto_Init
ParseErrorMessage : "(Error|Warning) ([A-Za-z0-9_]+[.][A-Za-z0-9]+) ([0-9]+)[:]"
ErrorMessageTokensFormat : "ToTalNumberOfTokens=3, FileTokenPosition=2, LineTokenPosition=3"
Keil
Error: "*** ERROR C67 IN LINE 27 OF TOTO.C: 'i': undefined identifier
ParseErrorMessage : "[^LINE]([0-9]*) OF ([A-Za-z0-9_]+[.][A-Za-z0-9]+)[:]"
ErrorMessageTokensFormat : ToTalNumberOfTokens=2, FileTokenPosition=2, LineTokenPosition=1
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 49
Annex II Microsoft
Error: Toto.c(27) : error C2065: 'i' : undeclared identifier
ParseErrorMessage: "([^(]+)[(]([0-9]+)[)] [:] (error|warning|fatal error)"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=3, FileTokenPosition=1, LineTokenPosition=2"
Gnu
Error: Toto.c:27: `i' undeclared (first use this function)
ParseErrorMessage: "([^:]+)[:]([0-9]+)[:]"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=2, FileTokenPosition=1, LineTokenPosition=2"
Texas Instruments
Error: "toto.c", line 27: [F108] 'i' undefined
ParseErrorMessage: "^\"(.*)\".*line ([0-9]*): (.*)$"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=3, FileTokenPosition=1, LineTokenPosition=2"
PanaX
Error: RiCIdfPkg.c:263:(E)8313 there is no #endif associated with #if/#ifdef/#ifndef.
ParseErrorMessage : "([^:]+)[:]([0-9]+)[:]"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=2, FileTokenPosition=1, LineTokenPosition=2"
www.ilogix.comRhapsody V4.2 "Specialist" Tool Training © I-Logix 1999-2003 08/08/2003 50
Annex III Hitachi
Error: SignalGeneratorPkg.h(32) : C2105 (E) Incomplete tag used in declaration
ParseErrorMessage: "([^(]+)[(]([0-9]+)[)[:]"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=2,FileTokenPosition=1,LineTokenPosition=2"
Metaware ARC
Error: w "ReactiveClass.c",L23/C13(#290): rootState_entDef: Static function is not referenced.
ParseErrorMessage: "\"([^\"]+)\",L([0-9]+)/"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=2,FileTokenPosition=1,LineTokenPosition=2"
IAR
Error: "idf.h",25 Error[2]: Failed to open #include file 'stdio.h'
ParseErrorMessage : "^\"(.*)\", ([0-9]*): (.*)$"
ErrorMessageTokensFormat: "ToTalNumberOfTokens=3, FileTokenPosition=1, LineTokenPosition=2"