VxWorks Simulator "Hello World" tutorial
Setup the project:
- From the "Start" menu, "All Programs">"Tornado 2.2">"Tornado"
- If the "Create Project in New/Existing Workspace" dialog is up, click on "New". If not, from the "File" menu select "New Project..."
- Click "Create downloadable application modules for VxWorks", click "OK"
- Enter the following parameters:
- "Name:", "helloworld"
- "Location:", "C:\Tornado2.2\target\proj\helloworld"
- "Add to a New or Existing Workspace", "C:\Tornado2.2\target\proj\Workspace0.wsp"
- Click "Next"
- Select the "A toolchain" option. Select "SIMNTgnu" to use the simulator. Otherwise, select the appropriate toolchain. Click "Next"
- Click "Finish"
Add a file and enter the program:
- From the "File" menu, select "New..."
- Select the following parameters:
- From the left box, "C/C++ Source File"
- "Add to project:", "helloworld.wpj"
- "File name:", "helloworld.c"
- "Location:", "C:\Tornado2.2\target\proj\helloworld"
- Click "OK"
- Enter the following into helloworld.c:
#include <vxworks.h> void helloworld() { printf("hello world\n"); }
- Press CTRL+S to save
Build the project:
- From the "Build" menu, select "Build"
- Click "OK" to generate dependencies (i.e. include files).
- You should get the following output in the "Build Ouput" window:
ccsimpc -g -mpentium -ansi -fno-builtin -fno-defer-pop -I. -IC:\Tornado2.2\target\h\ -DCPU =SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu -c ..\helloworld.c vxrm ..\prjObjs.lst Generating ..\prjObjs.lst... ccsimpc -r -nostdlib -Wl,@..\prjObjs.lst -o partialImage.o nmsimpc -g partialImage.o @..\prjObjs.lst | wtxtcl C:\Tornado2.2\host\src\hutils\munch.tcl -c simpc > ctdt.c ccsimpc -c -fdollars-in-identifiers -g -mpentium -fno-builtin -fno-defer-pop -I. -IC:\Torn ado2.2\target\h\ -DCPU=SIMNT -DTOOL_FAMILY=gnu -DTOOL=gnu ctdt.c -o ctdt.o ccsimpc -r -nostdlib -Wl,--force-stabs-reloc partialImage.o ctdt.o -o helloworld.out Done.
Start the simulator, download and run your program
- From the "Tools" menu, select "Simulator..." (Or click the "Launch Simulator" button)
- Click "OK" to run the standard simulator
- If you get a 'A Target Server named "vxsim@XXXXXXX" is required and will be started.' dialog, click "OK". (Note: If you've been messing around with the full simulator, click "Details >>" and ensure the "Integrated simulator" option is selected.)
- A "VxSim0" window should appear and the red target server icon should appear in your system tray.
- Right-click on "hellowworld Files" and select "Download helloworld.out".
- From the "Tools" menu, select "Shell..."; click "OK". (Or click the "Launch Shell" button).
- In the shell window, type "i" and hit ENTER to see the list of running tasks. You should get something like:
-> i NAME ENTRY TID PRI STATUS PC SP ERRNO DELAY ---------- ------------ -------- --- ---------- -------- -------- ------- ----- tExcTask _excTask dd8de0 0 PEND 40984c dd8ce4 0 0 tLogTask _logTask dd32b0 0 PEND 40984c dd31b4 0 0 tWdbTask _wdbTask dce668 3 READY 40984c dce51c 0 0 value = 0 = 0x0 ->
- Type "helloworld" and hit ENTER. You should get the following output:
-> helloworld hello world value = 12 = 0xc = __major_os_version__ + 0x8 ->
- You're finished.
See also my bootable project tutorial
Technorati tags: vxworks