wiki:TBR/Review/Debugging/Start

Debugging

WARNING THE CONTENT MAY BE OUT OF DATE

Hardware Assisted Debugging

Embedded processors these days provide hardware assisted debugging. Typically the processor provides an interface which allows an external device the ability to take control of the processor. In the past hardware assisted debugging required an emulator. These were expensive, often difficult and fragile to connect to the target hardware and often limited in numbers in a project making debugging a time share operation. Any newer or faster processor usually required a new emulator. Todays microprocessors implement a range of functions found in emulators in the processor allowing every target the ability to be used for hardware assisted debugging.

Different microprocessors have different ways of the implementing hardware assisted debugging.

  • Freescale Coldfire and M683xx processors use Background Debug Mode (BDM).
  • ARM uses JTAG.
  • PowerPC MPC5xx and MPC8xx use BDM, while the rest of the PowerPC family uses various kinds of JTAG interfaces.

Coldfire and M683xx BDM

The BDM interface is a synchronous serial bus interface. The physical interface (connector) varies between the M683xx and Coldfire processor yet the way BDM works is similar. BDM is support by an Open Source Project which you can find here http://bdm.sourceforge.net/. The BDM project's software uses a low cost pod that connects between your target hardware. You can use the older parallel port pods that connect to your PC's parallel port or you can use the newer USB pods.

The USB pod is an open source design called the Turbo BDM Light Coldfire (TBLCF) created by Daniel Malik. You can download the design and build yourself http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&thread.id=624 or you can obtain a manufactured pod from Axiom Manufacturing http://www.axman.com/?q=node/303.

If using a parallel port pod watch you get the correct pod. Different procesor speeds and core voltages require different pods. Newer pods should be able to handle the faster processors and different core voltages.

The latest version of the BDM software use a GDB server program and allows the use of the standard M68K GDB tool provided in the RTEMS binary tools packages.

Starting With Hello World

Congratulations! You are a new RTEMS user and you just got the hello world example to run on either a simulator or target hardware. You are on top of the world. So you modify hello world -- wouldn't it be cool to put a sleep between some prints like this:

printf( "Hello world -- line 1\n");
sleep(1);
printf( "Hello world -- line 2\n");

That sleep() could be any other call which blocks the caller while time passes. But when you run this program, it only prints "Hello world -- line 1" and appears to lock up. What is happening?

The answer is simpler than you think. RTEMS is always custom configured to meet the requirements of an application. This means that the number and types of objects and device drivers available are tailored. The hello world application does not require a clock device driver and thus it is not configured. When you added the sleep(), you added a call which needs the clock device driver configured in order to work. All you have to do is added this line to the configure section of the application BEFORE including confdefs.h.

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

As you add to your program, you may have to increase the number of objects configured as well.

Standard IO and File Issues

Newlib's Stdio Functions return -1/EOF

The stdio functions in newlib depend on both initialised and uninitialised data. If you find they are returning -1, ensure your .bss and .data sections are correctly setup. Check your linkcmds file is creating the correct memory map and that your bsp boot process is copying/zeroing all appropriate sections in ram. It's also worth double checking that your ram and other hardware is working correctly!

open, fopen, and socket creation fail

RTEMS has very tight default configuration limits. Not being able to open a file or create a socket is a common error which indicates that you need to configure enough open file descriptors. By default, the constant CONFIGURE_LIBIO_MAXIMUM_DESCRIPTORS is set to 3 for stdin, stdout, and stderr. You will need to set it to the appropriate value for your application.

Last modified on Nov 20, 2018 at 12:01:26 AM Last modified on Nov 20, 2018, 12:01:26 AM