Compiling Embedded C Code : Compiling Generated Code : Downloading and Execution

Downloading and Execution

After the target is booted and the generated code is compiled, you can run the executable. If you intend to run the model directly on the embedded prototyping system target, you should start the target server on the host machine, load the executable, and start it on the target.

The target server can be started from the command line using the following command:

tgtsvr -V <target name>

Load the executable using the following command:

ld 1, 0, “<executable name>”

Run the executable using the following command:

vxmain

If you intend to run the model using the WindSh remote shell, you must complete the following:

1.
2.
Run WindSh.
3.
4.

These actions can be done using the run_windsh batch file, whose full name (including path) should be printed into the #Run script name paragraph of the <target>.rtrg file. It looks something like the following:

#Run script name:”%STM_ROOT%\bin\run_windsh <target name>”,

In the command, <target name> is the name or TCP/IP address of the target machine.

Note: The files run_windsh.bat and run_windsh.csh are located in the encrypted VxWorks distribution file.

The run_windsh batch file has two input parameters (target name and executable name) and looks like the following:

For Windows host platforms:

#Creating of the file for model executable download and execution
echo ioGlobalStdSet(0,vf0) >> run_model.bat - reopening of the virtual I/O channel 0
echo ioGlobalStdSet(1,vf0) >> run_model.bat - designation of standard input file
echo ioGlobalStdSet(2,vf0) >> run_model.bat - designation of standard error file
echo logFdAdd(vf0)" >> run_model.bat - sending logging output to the virtual channel 0
echo ld 1,0, "%2" >> run_model.bat - download of the executable
echo vxmain >> run_model.bat - model execution starting
start tgtsvr %1 –C –c%WIND_BASE%/target/config/pc486/vxworks - target server starting
#WindSh running
windsh -n -s run_model.bat %1 > null
 

For UNIX platforms (Solaris):

#Creating of the file for model executable download and execution
#! /bin/csh -f
echo 'vf0=open("/vio/0",2,0)' > run_model.csh
echo "ioGlobalStdSet(0,vf0)" >> run_model.csh
echo "ioGlobalStdSet(1,vf0)" >> run_model.csh
echo "ioGlobalStdSet(2,vf0)" >> run_model.csh
echo "logFdAdd(vf0)" >> run_model.csh
echo 'ld 1,0, "'$2'"' >> run_model.csh
echo "vxmain" >> run_model.csh
windsh -n -s run_model.csh $1
 
 

Now the model system is ready for debugging.