Skip to main content

Kernel Shell Usage in VxWorks

·521 words·3 mins
VxWorks Shell Kernel Shell C Interpreter Command Interpreter
Table of Contents
Free Training - This article is part of a series.
Part 17: This Article

Learning Objectives
#

After completing this section, you will be able to:

  • Understand the C interpreter
  • Understand the command interpreter
  • Use common and useful kernel shell functions

The VxWorks kernel shell supports two modes: the C interpreter and the command interpreter, each designed for specific tasks in development, debugging, and system management.


Switching Between Shell Modes
#

To switch between modes, type the interpreter name into the shell:

-> cmd
[vxWorks *]# C
->

You can also prefix a single command with an interpreter to execute it immediately:

-> cmd
[vxWorks *]# C x=42
New Symbol “x” added to kernel symbol table.
value = 42 = 0x2a = '*'
[vxWorks *]# C
->

The C Interpreter in VxWorks
#

Features of the C Interpreter
#

  1. Ideal for prototyping and debugging in kernel space

  2. Allows manipulation of global variables:

    • Examine values
    • Change values
    • Create new variables
  3. Invokes almost any function in memory:

    • Passes up to 10 arguments to functions, padding with zeros if needed
    • Prints function call results and other evaluated expressions

Using the C Interpreter
#

Type C (uppercase) to start the interpreter. Its syntax closely resembles standard C:

C Interpreterer

Working with Variables
#

  1. Assigning a value to an undefined symbol creates a new variable
  2. Interpreter searches for symbols in the symbol table
  3. 32-bit vs 64-bit interpreters interpret integer sizes differently
  4. Use casts to interpret non-integer types (temporary per access)
  5. Supported types include: long long, unsigned types, scientific notation

C Variable

C Interpreter Notes
#

  • Parentheses in function calls can sometimes be omitted:
-> func &mac, 27
  • Symbolic macros are not supported:
-> sem1 = semMCreate(SEM_Q_PRIORITY)   # ❌
-> sem1 = semMCreate(0x1)             # ✅
C control structures (for, while, if) and data structures are not supported in the shell.

The Command Interpreter in VxWorks
#

Features of the Command Interpreter
#

Switch to the command interpreter using:

-> cmd
  1. Monitor and debug RTPs

  2. UNIX-style commands:

    • File: pwd, cat, cd
    • Task: task spawn, task info, task delete
  3. Supports command aliasing:

[vxWorks *]# alias foo "task info"
  1. Symbol evaluation:
[vxWorks *]# echo Address = &test Value = $test

RTP Commands in Command Interpreter
#

  • Launch help: -> help rtp
  • Launch an RTP: -> rtp exec fn
  • Show all RTPs: -> rtp
  • Attach to one RTP: -> rtp attach 0xN
  • Show tasks in attached RTP: -> rtp task

Command Interpreter Features
#

Supports shell control characters:

  • Pipe:
[vxWorks *]# cat file.txt | more
  • Backquote evaluation:
[vxWorks *]# bp 'expr &printf + 0x4'
  • Input/output redirection:
[vxWorks *]# cat file > file2
[vxWorks *]# /foo/bar/rtp.vxe < file2 >> file2

Useful Shell Functions
#

Debugging Commands
#

Dynamic printf commands (dprintf) help locate race conditions and debug without recompiling:

  1. Enable INCLUDE_DEBUG for dprintf() and hdprintf() in C interpreter
  2. Enable INCLUDE_DEBUG_SHELL_CMD for command interpreter dprintf
  3. Allows runtime printf insertion in kernel modules or RTPs

System Information Commands
#

Function Description
devs() Lists all devices on the target system
lkup() Searches symbol tables with regex
lkAddr() Finds symbols near a specific address
printErrno() Displays the most recent error status

Show Functions
#

Provide detailed target system info (C interpreter only, requires associated VIP component):

  • taskShow() – Configure INCLUDE_TASK_SHOW
  • memShow() – Configure INCLUDE_MEM_SHOW

Show Commands

Free Training - This article is part of a series.
Part 17: This Article

Related

Kernel Shell Configuration and Commands in VxWorks
·336 words·2 mins
VxWorks Shell Kernel Shell Configuration
Command Line Editing and Object-Module Loader in VxWorks
·399 words·2 mins
VxWorks Shell Object-Module Loader VI Emacs
Introduction to the VxWorks Kernel Shell
·320 words·2 mins
VxWorks Shell Kernel Development Debugging