M68K BDM GDB Server Chris Johns 3 Nov 2007 The 'gdbserver' directory contains a GDB Remote protocol server which provides BDM support for GDB for a range of Coldfire and CPU32 processors. The server called 'm68k-bdm-gdbserver' will have been installed when you installed the M68K BDM package. Make sure the installed server executable's path is in your environment's path variable. The BDM GDB server support Linux and Windows using GDB's socket or pipe interfaces. The socket interface is the standard way GDB talks to a GDB remote server. The pipe mode is also supported. With the pipe mode GDB spawns the BDM GDB server and pipe the remote protocol to the new process. The BDM GDB Server support the BDM library's direct or remote protocol mode of operation. If you use the BDM library remote protocol the actual hardware will be 2 processes away from GDB. The GDB with the BDM GDB Server will break existing GDB scripts. All the features that the patched version had have been carried over to the BDM GDB Server with the added advantage of no patch to maintain plus a means to add support for new Coldfire processors simply with out the need to upgrade GDB. GDB Patched verses GDB Remote The old patched GDB and the newer GDB using the remote protocol will break existing BDM GDB scripts. All the features present in the patched GDB are present how-ever the commands to access the features have changed. There was no way to avoid this. The BDM GDB Server using a remote GDB has many advantages. The advantages are: - No need to patch GDB. - BDM fixes and updates with out the need to update GDB. - Simpler means of adding support for new Coldfire processors. The hardware break and watch points are supported. The registers shown by the standard 'info reg' command is now restricted to registers that are in normal use with-in a program. For example the 5235 processor shows: (gdb) info reg d0 0xcf206080 -819961728 d1 0x15001080 352325760 d2 0x19 25 d3 0x3f6afffc 1063976956 d4 0xffffedce -4658 d5 0xff77af57 -8933545 d6 0x5e0658c7 1577474247 d7 0xf9f3dcff -101458689 a0 0x0 0x0 a1 0xffe254d4 0xffe254d4 a2 0x79a7dae5 0x79a7dae5 a3 0xf75e4dbf 0xf75e4dbf a4 0x637a 0x637a a5 0xf3df7b7f 0xf3df7b7f fp 0x627a 0x627a sp 0x627a 0x627a ps 0x2704 9988 pc 0xffe254de 0xffe254de macsr 0x0 0 mask 0xffffff9b -101 acc0 0xef3b7df8 -281313800 acc1 0xe50bdd7a -452207238 acc2 0x3b7df47b 998110331 acc3 0xdbb7cff8 -608710664 accext01 0x3b7df87c 998111356 accext32 0xc1e2f47b -1042090885 The full list of available registers are: (gdb) info all-registers d0 0xcf206080 -819961728 d1 0x15001080 352325760 d2 0x19 25 d3 0x3f6afffc 1063976956 d4 0xffffedce -4658 d5 0xff77af57 -8933545 d6 0x5e0658c7 1577474247 d7 0xf9f3dcff -101458689 a0 0x0 0x0 a1 0xffe254d4 0xffe254d4 a2 0x79a7dae5 0x79a7dae5 a3 0xf75e4dbf 0xf75e4dbf a4 0x637a 0x637a a5 0xf3df7b7f 0xf3df7b7f fp 0x627a 0x627a sp 0x627a 0x627a ps 0x2704 9988 pc 0xffe254de 0xffe254de vbr 0x3f8 1016 cacr 0x0 0 acr0 0x16ed4064 384647268 acr1 0xf1bd2080 -239263616 rambar 0x20000020 536870944 othera7 0xedfafefb -302317829 csr 0x1000000 16777216 xcsr 0x8400000 138412032 aatr 0x5 5 tdr 0x40000000 1073741824 pbr 0x0 0 pbmr 0x0 0 abhr 0x0 0 ablr 0x0 0 dbr 0x0 0 dbmr 0x0 0 macsr 0x0 0 mask 0xffffff9b -101 acc0 0xef3b7df8 -281313800 acc1 0xe50bdd7a -452207238 acc2 0x3b7df47b 998110331 acc3 0xdbb7cff8 -608710664 accext01 0x3b7df87c 998111356 accext32 0xc1e2f47b -1042090885 The special BDM command are available. These are accessed using the GDB 'monitor' command. To get a list of available commands connect to the target then issue 'monitor bdm-help'. Note: At this point in time some commands are missing. They will be added. Building GDB The BDM GDB Server requires GDB 6.7 or later built for a m68k-elf or similar target. The standard FSF sources are the only sources the BDM GDB Server is tested with. You do not need to patch GDB but you will need to insure the 'expat' XML library is installed and GDB's configure script detecteds it correctly. Build and install GDB the normal way. For example: $ tar jxf gdb-6.7.1.tar.bz2 $ mkdir localhost $ cd localhost $ ../gdb-6.7.1/configure $ make all install Connecting with GDB Connect your pod to the PC and to your target hardware then power on the hardware. This example session is with the Axman 5235 board and using the remote target's pipe interface. Test you BDM hardware and software configuration by running one of the test programs in the M68K BDM package. Start GDB and obtain the standard GDB prompt. $ m68k-elf-gdb GNU gdb 6.7 Copyright (C) 2007 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=m68k-elf". (gdb) Connect to the target: (gdb) target remote | m68k-bdm-gdbserver pipe /dev/bdmcf0 Remote debugging using | m68k-bdm-gdbserver pipe /dev/bdmcf0 trying kernel driver: /dev/bdmcf0 trying bdm server: localhost:/dev/bdmcf0 m68k-bdm: detected MCF5235 m68k-bdm: architecture CF5235 connected to /dev/bdmcf0 m68k-bdm: Coldfire debug module version is 0 (5206(e)/5235/5272/5282) Process /dev/bdmcf0 created; pid = 0 Remote debugging using pipe 0xffe254e2 in ?? () (gdb) The 'target remote |' command tells GDB to use the remote protocol via the pipe interface. GDB will then use the remainder of the command line to invoke the BDM GDB Server. The command line used is the simplest one that can be used. It is: m68k-bdm-gdbserver pipe /dev/bdmcf0 The 'm68k-bdm-gdbserver' is required to be in your environment's path. You can also use a full path. The first parameter is the type of communications the GDB server is to use. In this case if the 'pipe' interface. It could be a socket and we will cover this later. The BDM GDB Server can accept other command line options. They are: m68k-bdm-gdbserver -vVhDd -t