
VxWorks
BSP Developer’s Guide, 6.0
122
one LED available on your target hardware or a port pin that can be connected to
a logic analyzer.
One useful bit of code that you can add to the bootConfig.c file or the bootInit.c
file are LED routines such as those presented in 3.2.3 Using Debug Routines in the
Initialization Code, p.57. If you followed the advice in that section, which is
recommended as the first step in creating a new BSP, the code verifies that the tools
are working, as well as provides a debugging tool.
If the system does not have an LED available, an alternative is to set up the routines
discussed in this section so that they change the status of a port pin that you can
then read with a logic analyzer.
This type of debugging can be extremely difficult, and it is strongly encouraged
that you have better tools, such as an OCD device. If you do use LEDs for
debugging, you must be very creative to see what is happening in the system.
One routine missing from the LED library described earlier is a routine to blink the
LED on and off. A sample routine is as follows:
void ledBlink(int n)
{
int i,j;
/*
* The 200000 value is picked to be around 1 second of delay. Adjust as
* needed.
*/
sysLedInit();
for(j=0; j < n; j++)
{
for(i=0; i < 200000; i++) sysLedOn();
for(i=0; i < 200000; i++) sysLedOff();
}
/* just to create a pause between blinks */
for(i=0; i < 200000; i++) sysLedOff();
}
The call to make is the ledBlink( ) call. A useful approach is to start off with
ledBlink(1) and then use ledBlink(2) and so forth. This is an easy way to tell where
the system is within the code as it is executing. This is also a powerful runtime tool
that can get you to the point at which you see the VxWorks boot banner and menu
system on the serial output device.
Once the VxWorks boot banner successfully appears, you should be able to use
printf( ) routines or some of the debugging facilities already built into the boot
menu to help debug. Even before printf( ) routines are available, some debugging
information can be output on the serial device after sysHwInit( ) is called. Add the
following code to the BSP sysLib.c file. This code should work with any BSP that
includes a serial driver that can be operated with polled mode output.
Comentários a estes Manuais