The following BDM devices are supported: PD BDM and ICD BDM. A good description can be found in Motorola Apnote AN1230 on how to build your own BDM. Another excellent reference can be found at Pavel Pisa's pages here. I built my own BDM PD using the Motorola example. A good online gdb manual can be found here: http://sources.redhat.com/gdb/onlinedocs/gdb_toc.html
It is very recommended to spend some time (1-2 hours) going through the online manual or a printout to get an idea what GDB can do. It will save you hours if not weeks of debugging. Learn to understand conditional breakpoints or how to use watchpoints.
The port setting must be one of the standard address ranges for parallel ports. The setting must be a bidirectional mode like ECP or EPP. (add more info later...)
One of the following devices names should be used for the BDM interface:
| BDM type | Device name LPT1 | Device name LPT2 |
| PD | /dev/bdmcpu320 | /dev/bdmcpu321 |
| ICD | /dev/bdmcpu328 | /dev/bdmcpu329 |
The following is the output one should expect when running m68-bdm-elf-gdb without any parameters and without any .gdbinit script which we discuss below. Since I have a PD BDM at LPT1 I use /dev/bdmcpu320
The BDM interface will reset the MC68332 when using the target command. Since the BDM is enabled during the reset the MC68332 will read at location $0 for the initial stack (sp) and $4 for the initial program counter (pc). See the gdb transcript below. Syntax of print or p and for x the online help.
$ m68k-bdm-elf-gdb GNU gdb 5.3 Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i686-pc-cygwin --target=m68k-bdm-elf". (gdb) target bdm /dev/bdmcpu320 Remote bdm connected to /dev/bdmcpu320 (gdb) print $pc $1 = (void *) 0xe1e0 (gdb) print $vbr $2 = (void *) 0x0 (gdb) print $sp $3 = (void *) 0x2ffc (gdb) x /x 0x0 0x0: 0x00002ffc <<<< Initial stack location (gdb) 0x4: 0x0000e1e0 <<<< Initial PC (gdb)
(In case of errors: look here)
The .gdbinit script is a good way to have some of the sane defaults and not be typing an RSI for some silly defaults.
set history save #enable gdb history target bdm /dev/bdmcpu320 #select bdm target device bdm-select-cpu32 #use only cpu32 subset bdm_setdriverdebug 0 #no driver debug (default 0) bdm_setdebug 0 #no libBDM.a debug info set remotecache off #remote cache off bdm_setdelay 30 #INCREASE IN CASE OF PROBLEMS bdm_reset #reset chip and keep in reset set $sfc=5 set $dfc=5
set history save target bdm /dev/bdmcpu320 bdm-select-cpu32 bdm_setdriverdebug 0 bdm_setdebug 0 set remotecache off bdm_setdelay 10 bdm_reset set $sfc=5 set $dfc=5 # Display an exception stack # define displayExceptionStack set $frsr = *(unsigned short *)$sp set $frpc = *(unsigned long *)((unsigned long)$sp + 2) set $frfvo = *(unsigned short *)((unsigned long)$sp + 6) set $frcode = $frfvo >> 12 set $frvect = ($frfvo & 0xFFF) >> 2 printf "EXCEPTION -- SR:0x%X PC:0x%X FRAME:0x%x VECTOR:%d\n", $frsr, $frpc, $frcode, $frvect if $frcode==0x2 set $fripc = *(unsigned long *)((unsigned long)$sp + 0x8) set $frssw = *(unsigned short *)((unsigned long)$sp + 0x16) printf " INSTRUCTION PC:0x%X\n", $fripc, end if $frcode==0xC set $frfault = *(unsigned long *)((unsigned long)$sp + 0x8) set $fripc = *(unsigned long *)((unsigned long)$sp + 0x10) set $frssw = *(unsigned short *)((unsigned long)$sp + 0x16) printf " ADDRESS:0x%X INSTRUCTION PC:0x%X SSW:0x%X\n", $frfault, $fripc, $frssw end end source run332.gdb
The .gdbinit has an example of how to define a command. The command displayExceptionStack display an exception stack. This can come in handy in case the 68332 traps into an exception. The stack layout is different than gdb expects.
The last line in the .gdbinit has a source command that loads run332.gdb
The run332.gdb script is a gdb script that contains the basic initialization code to set up the MRM from GDB. It defines a command named bdm_hw_init that initializes the 68332 registers, sets the cpu to 25 MHz., disables the HW Watchdog, so that the RAM starts at 0x0, the EEPROM is placed at 0x080000, and some other things as well. The script has enough comments to understand what is going on.