02- VxWorks-BSP & Boot Sequcence

51
1 © M.S Ramaiah School of Advanced Studies - Bangalore PEMP ESD531 BSP & Booting Sequence Session Speaker B.N.Shobha Session 02

Transcript of 02- VxWorks-BSP & Boot Sequcence

Page 1: 02- VxWorks-BSP & Boot Sequcence

1© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

BSP & Booting Sequence

Session Speaker

B.N.Shobha

Session 02

Page 2: 02- VxWorks-BSP & Boot Sequcence

2© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Session Objectives

• To discuss general principles involved in booting a system and in VxWorks

• To motivate and clarify the transfer of control from hardware, to firmware, to software during system boot.

• To discuss Board Support Package concept in VxWorks

• To understand memory management and cross development in VxWorks

Page 3: 02- VxWorks-BSP & Boot Sequcence

3© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Session Topics

• General Boot Sequence

• Memory Layout in VxWorks

• Tornado directory Structure

• BSP organization

• VxWorks Images

• Booting process in VxWorks

• Cross-development

Page 4: 02- VxWorks-BSP & Boot Sequcence

4© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Boot Process• BIOS

– reads the boot sector of the boot disk (floppy, hard disk, …, according to the BIOS parameter setting)

• Floppy: the first sector• Hard disk: the first sector is the master boot record

(MBR) – stored the information about how a hard disk has been partitioned.

• boot sector ends with 0xAA55– Load the boot sector (512 bytes), which will contain

program code for loading the operating system kernel

JMP 0x03EDisk parametersProgram code loadingthe OS kernel0xAA55

0x0000x0030x03E

0x1FE

BootSector(Floppy)

Page 5: 02- VxWorks-BSP & Boot Sequcence

5© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

MBR• A small program that reads the partition table

– Checks which partition is active (i.e. bootable)– Reads the boot sector of active partition (boot sector-contains

another small program that reads the first part of the OS stored on that partition)

– jump into the boot sector at offset 0• The original partitioning scheme for PC hard disk allowed only

four primary partitions (too little in real-life) – only 4 partition entries. Each entry is 16 bytes

Code for loading the boot sector of the active partition

Partition 1Partition 2Partition 3Partition 40xAA55

0x000 0x1BE

0x1BE 0x0100x1CE 0x010

0x1DE 0x0100x1EE 0x0100x1FE 0x002

Page 6: 02- VxWorks-BSP & Boot Sequcence

6© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

MBR• Solution = Extended partition (EP) : allows partitioning a primary

partition into sub-partitions• Sub-partitions are logical partitions and behave like primary

partitions but are created differently• The first sector of extended partition is same as MBR• The first partition entry is for the first logical drive, yhe second

partition entry points to the next logical drive • The first sector of each PP or EP contains a boot sector

MBRBoot SectorData area of PP-1

Boot SectorData area of PP-3

EP

Boot SectorData area of PP-4

Unused Boot SectorData area of LP-1

Boot Sector

Unused Boot SectorData area of LP-2

Page 7: 02- VxWorks-BSP & Boot Sequcence

7© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Structure of a Partition Entry

• Booting is carried out from the active partition which is determined by the boot flag

Boot flag: 0=not active, 0x80 active

Begin: head number

Begin: sector and cylinder number of boot sector

System code: 0x83 Linux, 0x82: swap, 0x05: extend

Boot

HD

SEC CYL

SYS

HD

SEC CYL

low byte high byte

low byte high byte

1

2

1

1

2

1

4

4

End: head number

End: sector and cylinder number of boot sector

Relative sector number of start sectorNumber of sectors in the partition

Page 8: 02- VxWorks-BSP & Boot Sequcence

8© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

• Switch on. It will check disk drive (floppy or hard disk)• Boot sector contains an initial program (bootstrap program)

which is run to initialize all aspects of the system - CPU registers, device controllers, memory contents.

• The bootstrap program locates the OS kernel and loads it into memory.

• The OS then starts executing the first process and waits for some event to occur.

• The occurrence of an event is usually signaled by an interruptfrom either the hardware or the software.

• Hardware may trigger an interrupt by sending a signal to the CPU via the system bus.

• Software may trigger an interrupt by executing a special operation called a system call.

Booting a Computer

Page 9: 02- VxWorks-BSP & Boot Sequcence

9© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Board Support Package (BSP)

• VxWorks is a modular design which isolates all hardware-specific functionality into a set of libraries called the Board Support Package(BSP). BSP for short, it is a software-only layer (hardware dependent)

• These libraries provide an identical software interface to the hardware of all boards.

• A Board + its BSP = “standard” platform for an O/S (hardware independent)

• They include facilities for hardware initialization, interrupt handling, hardware clock and timer control, mapping of local andbus memory, memory sizing.

Page 10: 02- VxWorks-BSP & Boot Sequcence

10© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Device 1 Device n...Quiet mode

Initialize driver

Register with O/S

Start device

CPU Self initialization

Addressing Control

Random Access Memory

Power On Reset

“C” code setup

Initialize Interrupt System

initialize and start Kernel

Remaining O/S initializations Start Application

BSP Device Initialization Frame Work

Page 11: 02- VxWorks-BSP & Boot Sequcence

11© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

BSP – Relationship to O/S

• BSP - Equivalent of a “lower” O/S layer.• It provides a “standard” set of capabilities for the main “higher”

O/S to run on• eg. memory, communications, and other device interfaces

• It provides a controlled startup sequence from power-on / reset (the “bootstrapping” process)

• includes the pre-kernel initialization and starting up the kernel itself

• Provides a set of switches to turn on/off different capabilities of and to the O/S.

• All the switches together represent the “standard” platform and its allowed variants

• The “ON” switches represent capabilities on the board and O/S

Page 12: 02- VxWorks-BSP & Boot Sequcence

12© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

BSP – Relationship to Device Drivers

• It provides a controlled startup sequence from power-on / reset for the devices to be initialized, and started up as usable devices to the O/S and application

• It provides a framework for each of the devices driver code to be included

• It uses the corresponding device driver’s code for this process• The controlled start-up sequence ensures a “sane” environment

which is progressively built up to full capability of the board

Page 13: 02- VxWorks-BSP & Boot Sequcence

13© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Tornado Directory Tree

/usr/wind

host

share

target

Tornado host-resident Tools

Shared XDR code

VxWorks OS.Board Support Package

Page 14: 02- VxWorks-BSP & Boot Sequcence

14© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Host Directory Tree

host

include

resourcetcl

Header files for Tornado Tools.

GUI, Tcl and Help supports filesStandard Tcl distribution

host-os Host-specific tools.binlibman

Tornado and GNU host executables.Tornado Tool librariesGNU man pages

man

srcUNIX man pages on Tornado toolsSource for VxColor demo.

Page 15: 02- VxWorks-BSP & Boot Sequcence

15© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Target Directory Tree

target

config

libman

Files to configure and build VxWorks

Libraries provided by VxWorksUNIX man pages

allbsp-name

Generic configuration files.Board Support Package (BSP)

h

unsupported

VxWorks header files

Tools, driverssrc Partial VxWorks source code.

Page 16: 02- VxWorks-BSP & Boot Sequcence

16© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Libraries

•Each library has corresponding include file(s).•VxWorks routines are grouped into libraries.

•Examples:Library Routine Include file(s)---------- ----------- ------------------taskLib taskSpawn taskLib.hmemPartLib malloc stdLib.hsemLib semTake semLib.h

sockLib send types.h, socket.hsockLib.h

lstLib lstGet lstLib.h

Page 17: 02- VxWorks-BSP & Boot Sequcence

17© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

VxWorks System Components

Page 18: 02- VxWorks-BSP & Boot Sequcence

18© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

• We are porting VxWorks to a new target board– VxWorks and the Tornado debugger are already available for

the target processor / architecture– Tornado and VxWorks development capability is already

available for the host• Reference BSP on same processor / architecture• Device driver code for devices on board• BSP template for processor architecture

What is BSP Build/Create Means?

Page 19: 02- VxWorks-BSP & Boot Sequcence

19© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

BSP primary files

• Primary BSP files:- Source files.- Include files.- Make files.

• Source files:- Generic code is written in C. Architecture specific and- performance optimized code is assembly.

• Include files:- All includes and definitions specific to a CPU board are localized in two files.

• Make file:- Controls building of all images

Page 20: 02- VxWorks-BSP & Boot Sequcence

20© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531BSP Source and Include files

• target/config/all/configAll.h specifies default, or base specifies default, or base configuration which applies to all boards. Modifying this configuration which applies to all boards. Modifying this file is discouraged.file is discouraged.

• target/config/bsp/config.h extends or overrides the extends or overrides the defaults specified in defaults specified in configAll.hconfigAll.h for the particular board for the particular board BSP. Modify this file to change the VxWorks image for BSP. Modify this file to change the VxWorks image for this board.this board.

• target/config/bsp/<bspname>.h is a BSP specific header is a BSP specific header of static constructsof static constructs

Page 21: 02- VxWorks-BSP & Boot Sequcence

21© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Booting• Hardware must first be configured:

• VxWorks Boot ROMs replace board manufacturer’s ROMs.

• Jumpers (etc.) set as described in target\config\bsp\target.txt.

• VxWorks Boot ROMs enable:• Setting boot parameters via a serial connection.• Downloading & executing VxWorks image.

• Booting scenarios:• ethernet• serial • BOOTP / TFTP • shared memory network• local disk

Page 22: 02- VxWorks-BSP & Boot Sequcence

22© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

VxWorks Image flow

romInit.sAll RAM ImagessysALib.s

bootInit.c

CPU Self initialization

Addressing Control

Random Access Memory

Power On Reset

“C” code setup

Initialize Interrupt System

All ROM Images

usrConfig.c

Calls for rest of the sequence

bootConfig.c(only for

bootROM)

romInit

sysInit

romStart

usrInit

ApplicationsysLib.c

Page 23: 02- VxWorks-BSP & Boot Sequcence

23© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Boot Sequence in VxWorks

romInit(): File -> romInit.sa. disable interrupts b. save boot type (cold/warm)c. enable DRAM and DRAM refreshd. Initialize stack pointere. branch to C Entry point -romStart()

2. romStart(): File -> bootInit.ca. copy text and data segment from ROM to RAMb. clear memoryc. decompress imaged. if (i960) invoke sysInitAlt() else usrInit()

Page 24: 02- VxWorks-BSP & Boot Sequcence

24© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Boot Sequence in VxWorks ( Cont)

3. usrInit(): File -> usrConfig.ca.a. if (SPARC) initialize register window managementif (SPARC) initialize register window managementb.b. if (MIPS) if (MIPS) sysGpInitsysGpInit() to initialize global pointer: File () to initialize global pointer: File --> > bootInit.cbootInit.cc.c. zero zero bssbss ((uninitializeduninitialized data) data) File File --> > usrConfig.cusrConfig.cd.d. save save bootTypebootType in in sysStartTypesysStartTypee.e. intVecBaseSetintVecBaseSet() to set vector base table:() to set vector base table:f.f. excVecInitexcVecInit() to initialize all system and default interrupt vectors() to initialize all system and default interrupt vectorsg.g. excShowInitexcShowInit() to initialize exception show utility() to initialize exception show utilityh.h. sysHwInitsysHwInit() to initialize board dependent hardware: File () to initialize board dependent hardware: File --> > sysLib.csysLib.cI.I. usrKernelInitusrKernelInit() to initialize the wind kernel: File () to initialize the wind kernel: File --> >

target/target/src/config/usrKernel.csrc/config/usrKernel.cj.j. Enable instruction/data cache if applicableEnable instruction/data cache if applicablek.k. kernelInitkernelInit()()

Page 25: 02- VxWorks-BSP & Boot Sequcence

25© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Boot Sequence in VxWorks ( Cont..)

5 usrRoot(): File -> bootConfig.c {initialize I/O sub-system; install drivers; create devices; setup network as necessary for the particular configuration; may also create the system symbol table if one is to be included; Spawn the boot command loop task

a.memInit(): initialize memory poolb.sysClkConnect(): set up system timer :File -> sysLib.cc.sysClkRateSet()d.sysClkEnable()e.sysProcNumSet(): set unique processor number for the

boardf. iosInit(): Initialize I/O system.

Page 26: 02- VxWorks-BSP & Boot Sequcence

26© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Vx-Works Image ROM & RAM Memory Layout

USER_RESERVED_MEM

ROM IMAGE

STACK SAVE

RESERVED

Exc Vectors,exc msg,bootline

0

0

Unused ROM

Compressed Boot Program

Bootstrap data

Bootstrap text

0x0000 0000 = LOCAL_MEM_LOCAL_ADRS

0x0010 0000 = LOCAL_MEM_LOCAL_ADRS + LOCAL_MEM_SIZE

= sysPhysMemTop()

0x0000 1000 = RAM_LOW_ADRS & RAM_ADRS

0x0009 0000 = RAM_HIGH_ADRS

= FREE_RAM_ADRS

ROM

RAM

0xFF80 0000 = ROM_BASE_ADDRS

(romInit+ROM_COPY_SIZE) or binArrayStart

0xFF8x xxxx = binArrayStart

0xFF80 0008 = ROM_TEXT_ADDRS

1 MB BoardsysMemTop()

Page 27: 02- VxWorks-BSP & Boot Sequcence

27© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Memory Layout• The data segment of a ROM-resident standalone VxWorks

system is loaded at low address to minimize fragmentation.• The data segment of the ROM-resident boot ROMs is loaded at

high address so that loading VxWorks does not overwrite the resident boot ROMs.

Types ofImages

VxWorksTornado

VxWorksStandalone

Boot Program

ROMablecompressed

_ vxWorks.st_rom bootrom

ROMableuncompressed

vxWorks_rom _ bootrom_uncmp

ROMresident

vxWorks.res_rom_nosym vxWorks.res_rom bootrom_res

Downloadableuncompressed

vxWorks vxWorks.st _

Page 28: 02- VxWorks-BSP & Boot Sequcence

28© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Memory Layout

LOCAL_MEM_LOCAL_ADRSRAM_LOW-ADRS

FREE_RAM_ADRS

VxWorks

SYSTEM

MEMORY

POOLsysMemTop( )

WDB_POOL_SIZE

USER_RESERVED_MEMsysPhysMemTop( )

Page 29: 02- VxWorks-BSP & Boot Sequcence

29© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Target Server Memory Pool

• A pool of memory on the target reserved for use by the Tornado tools :

• Dynamic loading of object modules.• Spawning task from WindSh or CrossWind.• Creation of variables from WindSh.• The initial size of the target server memory pool is configured by

WDB_POOL_SIZE. • The default is 1 / 16 of sysMemTop( ) - FREE_RAM_ADRS.• Additional memory is silently allocated from the system memory

pool, if needed.

Page 30: 02- VxWorks-BSP & Boot Sequcence

30© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531System Memory Pool

• Initialized at system startup.

• Used for dynamic memory allocation in programs :• malloc( ).• Creating tasks (stack and TCB).

• Can modify USER_RESERVED_MEM to reserve memory for application-specific use.

• May need to modify sysPhysMemTop( ) (or just LOCAL_MEM_SIZE) when adding memory to your board.

• To add off board memory :void memAddToPool (pPool, poolSize)

pPool must be the local address of the memory.

• VxWorks memory requests.

Page 31: 02- VxWorks-BSP & Boot Sequcence

31© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Allocating / Releasing Memory

• Uses first-fit algorithm.

• To dynamically allocate memory :void *malloc (nBytes)

Returns a pointer to the newly allocated memory or NULLon error.

• Free memory is stored in a linked list.• Some (small) overhead for each malloc( ).

• To release allocated memory :void free (ptr)

Adjacent blocks are coalesced.

Page 32: 02- VxWorks-BSP & Boot Sequcence

32© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Debugging Options• Default malloc( ) debugging : If request too large, log an

error message.• Default free( ) debugging :

•Check block for consistency• If corrupted: suspend task, log error message.

• Can change default debugging options with :void memOptionsSet (options)

Options can be :+ MEM_ALLOC_ERROR_LOG_FLAG- MEM_ALLOC_ERROR_SUSPEND_FLAG+ MEM_BLOCK_CHECK+ MEM_BLOCK_ERROR_LOG_FLAG+ MEM_BLOCK_ERROR_SUSPEND_FLAG

Page 33: 02- VxWorks-BSP & Boot Sequcence

33© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Examining Memory

• Enter the memory partition ID in the Show box.• Use the browser.

Free List

mv152-external@mekong: Mempart Ox

Totalbytes = 3870840

Allocatedblocks = 86bytes = 467224

Freeblocks = 7bytes = 3403584

Cummulativeblocks = 88bytes = 467832

Free List0

addr = 0x3fd8f8size = 9604

1addr = 0x4ef90size = 3355432

Page 34: 02- VxWorks-BSP & Boot Sequcence

34© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Additional System Memory Management Routines

void *calloc(nElems, size ) Allocate zeroed memory for an array.

void *realloc(ptr,newSize) Resize an allocated block. The block may be moved.

int memFindMax( ) Returns the size of the largest free blockin system memory.

• High level routines like malloc( ) and free( ) calllower level routines, specifying the system memory pool.

Page 35: 02- VxWorks-BSP & Boot Sequcence

35© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Creating a memory Partition

• Returns a partition id (PART_ID) or NULL or error.

• The memory for this partition (pPool) may be taken from :

PART_ID memPartCreate (pPool, size)

pPool Pointer to memory for this partition

size Size of memory partition in bytes.

• A separate memory board.• A block allocated from the system memory partition.• The top of the CPU board’s RAM.

Page 36: 02- VxWorks-BSP & Boot Sequcence

36© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Managing Memory Partitions

• System partition management routines call routines listed below, specifying the PART_ID as memSysPartId.

Generic System Memory Pool

memPartAlloc( ) malloc( )memPartFree( ) free( )

memPartShow( ) memShow( )

memPartAddToPool( ) memAddToPool( )

memPartOptionsSet( ) memOptionsSet( )

memPartRealloc( ) realloc( )

memPartFindMax( ) memFindMax( )

Page 37: 02- VxWorks-BSP & Boot Sequcence

37© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Example Creating a Memory Partition

-->partId=memPartCreate(pMemory, 100000)new symbol “partId” added to symbl table.partId = 0x23ff318 : value = 37745448 = 0x23ff328 = partId + 0x10

-->ptr=memPartAlloc(partId, 200)new symbol “ptr” added to symbl table.ptr = 0x23ff2ec : value = 37652632 = 0x23e8898

-->show partIdstatus bytes blocks ave block max blockcurrentfree 99776 1 99776 99776alloc 208 1 208 -

cumulativealloc 208 1 208 -

Page 38: 02- VxWorks-BSP & Boot Sequcence

38© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Vx-Works Standard Images

• Not all BSPs will support all of these images. Some BSPssupport additional images.

• Standalone VxWorks has a target shell and built-in symbol table.Network support is included but not initialized.

• The file target\h\make\rules. BSP has the make rules for building these images.

Page 39: 02- VxWorks-BSP & Boot Sequcence

39© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Vx-Works Standard Images (contd..)

The project facility can build the following VxWorks image in a bootable project:

Downloadable image:vxWorks: does not contain within it the bootstrap code to copy

itself out of ROM into RAM.ROMable image:

vxWorks_rom : uncompressed copies VxWorks, from ROM to RAM

vxWorks.st_rom:(Compress): ROM is lessvxWorks.res_rom:(Resident): When RAM less - text in ROM

rest in RAMBoot ROM image: executes in ROM

Page 40: 02- VxWorks-BSP & Boot Sequcence

40© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Vx-Works Scaling and Configuration

• Configuring VxWorks involves:– Specifying which VxWorks facilities will be included

(scaling VxWorks).• May be done with Project tool, or by editing files.

– Constants for some modules may require editing files.

• The configuration of the VxWorks images you build is governed by information from three sources:– target\config\all\configAll.h default base configuration– target\config\bsp\config.h board specific

configuration– The Project tool, if used.

Page 41: 02- VxWorks-BSP & Boot Sequcence

41

PEMP ESD531

Cross-Development

Page 42: 02- VxWorks-BSP & Boot Sequcence

42© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531WindSh

Interactive C-expression interpreter allows :• Accessing all VxWorks facilities. • Invoking any subroutine in memory. • Creating and examining variables.• Automating interactions with target.• Defining user commands

Interactive Tcl interpreter allows :• For UNIX hosts, invoke from the

Launcher.(UNIX Hosts)• For PC host, invoke from the Tornado

developmentenvironment Tools menu or the launch toolbar.(PC

Host)

Page 43: 02- VxWorks-BSP & Boot Sequcence

43© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531How the Shell interprets Commands

WindSh uses the target server’s system symbol table andthe following rules to interpret an expression :

retVal = printf (“Foo is %d\n”, foo)i (tWdbTask)

1. Look for symbol in the symbol table.2. Look for _symbol in the symbol table.3. Create symbol if it is to the left of a ‘=‘ and does not exist

in the symbol table.4. Convert a task name to a task ID.5. If you do not specify one of the arguments to a function,

the Shell will pass a zero. Some common commands are WindSh built-ins and not functions.

Page 44: 02- VxWorks-BSP & Boot Sequcence

44© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531WindSh as a C Interpreter

• Shell command syntax is generally the same as the C programming language.

-> x = (8 * 6) / 4x=0x20ff378: value = 12 = 0xc

-> name = “Nelson”new symbol “name” added to symbol table.name = 0x23fe798: value = 37742504 = 0x23fe7a8 = name + 0x10

-> printf (“Hello %s, number is %d.\n”, name, 0x20)value = 29 = 0x1d -> xx = 0x20ff378: value = 12 = 0xc

Page 45: 02- VxWorks-BSP & Boot Sequcence

45© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Shell Line Editing

• History mechanism like UNIX Korn Shell.• Type h to see previous commands.• Press esc to toggle from input to edit mode.• Leave edit mode by pressing esc or return.• Editing mode uses vi - like commands , including :

h j k l

Page 46: 02- VxWorks-BSP & Boot Sequcence

46© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Shell Special Characters

Character Description

^H Delete a character (backspace).

^U Delete an entire line.

^C (UNIX) Terminate a function call and return to^-Break (PC) shell prompt.

^X (UNIX) Reboot VxWorks (trap to the boot ROM’s).

^S Temporarily suspend terminal output.

^Q Resume terminal output.

Esc Toggle between regular input mode and K-shell edit mode.

Page 47: 02- VxWorks-BSP & Boot Sequcence

47© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Shell Built-in Commands

WindSh provides common commands needed for development:• sp Create a task with default options.• td Delete a task.• ts / tr Suspend / resume a task.• b Set or display break point.• s Step a task.• c Continue a task.• tt Trace a task’s stack.• i / ti Give (detailed) task information.• ld/unld Load / unload a module.• browse Display object information in Browser.• show Display object information in WindSh.

Page 48: 02- VxWorks-BSP & Boot Sequcence

48© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

Shell Redirection

• Shell input can be redirected to come from a file.-> < script

• Shell output can be redirected to a file.-> h( ) > hFile

• Caveat: I/O can only be redirected to devices accessible to the WindSh process running on the developmenthost, not local devices on the target !

Page 49: 02- VxWorks-BSP & Boot Sequcence

49© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531WindSh Debugging

•Can debug target resident tasks from WindSh:

•See the windsh appendix to the Tornado User’s Guidefor information on these (and other) windsh primitives.

•Set and remove breakpoints b, bd, bdall•Single step s, so•Disassemble code l•Trace a task’s stack tt•Resume execution c

•Debugging is done at the assembly code level.Use remote debugger for source-level debugging.

Page 50: 02- VxWorks-BSP & Boot Sequcence

50© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531

• Example:-> b (printf)-> sp (stuff)task spawned: id = 0x23e0a3c, name = t3value = 37620284 = 0x23e0a3cBreak at 0x2005f78: _printf Task: 0x23e0a3c (t3)

-> tt( )20461b8 _vxTaskEntry+10: _stuff (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)23feb4a _stuff +12: func1 (1)23febf2 _func1 +18: _printf (23fec39, 23fec2e)value = 0 = 0x0

• If a task halts unexpectedly, tt( ) can be used to find out what routine failed.

Debugging Example

Page 51: 02- VxWorks-BSP & Boot Sequcence

51© M.S Ramaiah School of Advanced Studies - Bangalore

PEMP ESD531Summary

• Boot sector of bootable device will load the kernel image in themain memory

• VxWorks is a modular design which isolates all hardware-specific functionality into a set of libraries called the Board Support Package(BSP).

• The data segment of a ROM-resident standalone VxWorks system is loaded at low address to minimize fragmentation

• WindSh provides common commands needed for development• Shell command syntax is generally the same as the C

programming language• A pool of memory on the target reserved for use by the Tornado

tools