02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

VxWorks 5.5<br />

<strong>BSP</strong> Developer’s <strong>Guide</strong><br />

Caveats<br />

Because the virtual I/O driver requires the kernel, add the following line to<br />

config.h:<br />

#undef INCLUDE_WDB_VIO<br />

There is an important caveat if you are planning to use the target agent’s serial-line<br />

communication path. When the kernel is first started, interrupts are enabled in the<br />

processor, but driver interrupt handlers are not yet connected. You must take care<br />

to ensure that the serial device you use for agent communication does not generate<br />

an interrupt. If your board has an interrupt controller, use it to mask serial<br />

interrupts in sysHwInit( ). Beware that the target agent tries to use all drivers in an<br />

“interrupt on first packet” mode. As a result, you should modify the serial driver<br />

to refuse to go into interrupt mode, even if the agent requests it.<br />

System-Mode Debugging Techniques<br />

After you have the agent working, you will want to use it to debug the VxWorks<br />

image to which it is linked. To save download time, you should link the VxWorks<br />

code you want to test into the ROM image. In particular, you should glance at<br />

section 3.4 Using a Minimal Kernel, p.55 to see what driver code to link with<br />

VxWorks. To avoid remaking ROMs, consider adding hooks to your <strong>BSP</strong> and<br />

driver routines as follows:<br />

void (*myHwInit2Hook)(void); /* declare a hook routine */<br />

...<br />

void sysHwInit2 (void)<br />

{<br />

if (myHwInit2Hook != NULL) /* and conditionally call it */<br />

{<br />

myHwInit2Hook();<br />

return;<br />

}<br />

... /* default code */<br />

}<br />

This allows you to replace the routine from the debugger dynamically. For<br />

example, to override the behavior of sysHwInit2( ) above, just create a new<br />

version of it called myHwInit2( ) in a module called myLib.o, and then type:<br />

(gdb) load myLib.o<br />

(gdb) set myHwInit2Hook = myHwInit2<br />

(gdb) break myHwInit2<br />

(gdb) continue<br />

However, if you start the agent before the kernel, you must start it after the call to<br />

sysHwInit( ). Thus, you cannot override sysHwInit( ). On the other hand, you<br />

54

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!