####################################################### # # README.txt # # how to build an i386-linux to ppc-linux Cross Debugger # with the new gdb target mpcbdm # # Version: 1.2.3 # Date: 2002/04/05 # Firstdate: 1999/09/03 # Author: FP, mailto: Frank.Przybylskivas-gmbh.de # Copyright:(c) 1999,2000,2001,2002 VAS GmbH # ####################################################### Contact and Help: Please mailto:bdm4gdb-users@lists.sourceforge.net if you have any questions, problems, new ideas! This list is search able via http://www.geocrawler.com/redir-sf.php3?list=bdm4gdb-users. Here's a for non-commercial usage free blueprint for a BDM interface for the MPC860. Included in the archive is the source code for a new gdb target mpcbdm. This target communicates over a standard printer port with the BDM-Port of the MPC8xx processor family. The adapter uses only two 74HC14 (six inverting Schmitt-Triggers) and a couple of discrete elements. Features: access to MPC860 registers, special purpose registers (with names of bit fields), memory, download code ( about 114kbit/s, kernel takes about 20s), disassemble and debug code in MPC860 system, starting, stopping, software breakpoints, single stepping (both assembler instructions and source code), FLASH support (right now only for AMD 29LV160), booting the MPC without any PROM, starting linux kernel from target's RAM without any firmware or boot ROM. Acknowledgments: Based on Sergey Drazhnikov work, thanks Sergey! Tested with a MPC860SR 50MHz on a TQ-Components TQM860-Board. Thanks goes also to Wolfgang Denk, www.denx.de, for lots of ideas and hints and aid to get the board running linux. Thanks to Raphael Bossek for the sourceforge project site! http://bdm4gdb.sourceforge.net/ and http://sourceforge.net/projects/bdm4gdb/ Thanks to Erwin Rol for his VFLS solution for the first adapter version. Thanks to Jean-Paul Iribarren for bug fixes and his Cygwin / Insight version of the mpcbdm target. Thanks to anybody else who have taken part in developing this project and I forgot to mention here explicitly. Thanks to No Warranty! Use at own risk! Watch out especially for the voltages allowed on the BDM port input pins of your target processor! Requires a host running linux, tons of installed software... Have fun! Copyright (c) 1999, 2000, 2001, 2002 VAS GmbH, Hamburg , Germany. Visit our home page at www.vas-gmbh.de. Contact me via mailto:Frank.Przybylski@vas-gmbh.de ------------------------------------------------------------- List of files in mpcbdm.tar.gz: MPCBDM/README.txt # you're just reading me MPCBDM/index.html # the mpcbdm html project description MPCBDM/VDB2.gif # schematic of adapter version 2 MPCBDM/mpcbdm.c # the target source code files MPCBDM/mpcbdm.h MPCBDM/Makefile.in # the adapted makefile MPCBDM/linux.mt # tell gdb which target can use mpcbdm MPCBDM/mpc.init # gdb script file for TQM boards BuildGDB # shell script to build the cross gdb BuildLinux # shell script to fix image and initrd sections for download ------------------------------------------------------------- Because 'mpcbdm' is no official target for the gdb (not yet?), you need to build your own gdb with 'mpcbdm' support. Therefore gdb needs to know about the new target (linux.mt), how to make it (Makefile.in) and the source files mpcbdm.[ch]. For those who are not familiar with compiling gdb, I have included a simple shell script 'BuildGDB' which automates the building steps. See below, how to invoke 'BuildGDB'. If you know what you do, just copy the two source files and the Makefile.in into the $GDB/gdb dir and the target definitions into $GDB/gdb/config/powerpc/, configure for target=powerpc-linux and build gdb. ------------------------------------------------------------- Invoking 'BuildGDB': All 'BuildGDB' needs is the source archive gdb-5.0.tar.gz and the extracted mpcbdm archive in the same directory. 1. make directory (place holder $DirGDB) where to build (and install) the cross debugger: > mkdir $DirGDB > cd $DirGDB 2. copy mpcbdm and gdb source archives to $DirGDB: > cp gdb-5.0.tar.gz $DirGDB > cp mpcbdm.tar.gz $DirGDB 3. extract mpcbdm.tar.gz archive: > tar -xzvf mpcbdm.tar.gz this should produce the directory 'MPCBDM/' and one script 'BuildGDB'. If you want to use the script to build also a linux kernel to use with gdb download procedures, you have to adapt the script to your directory structure. Building just gdb should be possible without any modifications. 4. run the 'BuildGDB' script: > ./BuildGdb gdb this should produce tons of output. All this output is logged to 'build-gdb'. If everything works fine there should be two new directories: gdb-5.0 (the gdb source tree) and build-gdb (the VPATH) and the cross debugger: powerpc-linux-gdb. If you want to debug the debugger replace '-O2' with '-g' in SET_CFLAGS=CFLAGS=-O2 in 'BuildGDB'. ---------------------------------------------------------------- Running the cross debugger: Here's a quick tour of how to run the gdb with mpcbdm target. The mpcbdm target needs access to the ioport address space. The obvious way to get these access rights is to run powerpc-linux-gdb as root (e.g. via sudo). Another way is now to SUID root on powerpc-linux-gdb: >chmod a+s powerpc-linux-gdb >chown root powerpc-linux-gdb # you need root rights for this step Depending on your Linux distribution, SUID might only function in special directories, e.g. /usr/bin. Start the debugger with executing a gdb script to disable MPC internal watchdog (default is about 2.5s) (use 'gdb's 'source' command to run script files inside') >powerpc-linux.gdb -x MPCBDM/mpc.init See gdb script mpc.init for details (especially the MPC's internal watchdog took me some time) help target # show available targets h mp # help mpcbdm:list target mpcbdm obscure commands info target # show actual target target mpcbdm 0 # start debugging over BDM, resets processor show target # show active targets parameter show mpcbdm_delay # show delay value for BDM signals set mpcbdm_delay 10 # set delay value to 10 (default 0) mp spr # show list of gdb supported special purpose registers mp sprs # list important special purpose registers mp spr der = 0x7002400f # set Debug Enable Register to a reasonable value mp upms # show contents of UPM A and memory mapping help mp flash # show help for FLASH support normal gdb functionality: x/20i 0x100 # disassemble the first 20 instructions from monitor program j *0x100 # with TQM860 Board: jump to start monitor after reseting # to have all processor settings correct (UPMs etc) c # continue will do also start up the monitor on TQM # break with -c if there is an auto application # with TQM it's also possible to use the 'init' macro # for reset and 'tqmmem' for a simple memory setup set {int} 0x500000 = 2880293630 # check, if you can write into RAM x/1xw 0x500000 # and if memory holds that information lo jen 0x30000 # load object file with offset 0x30000 (assume jen begins at 0x0) sym jen # load also debugging informations (gcc -g option) b *0x30060 # set break point at address 0x30000 i b # info about breakpoints j *0x30000 # start program at 0x30000 i r # info about registers, see 'rd' macro set $r12 = 0x1234 # set gpr 12 to 0x1234 c # continue after hitting breakpoint si # step one processor instruction d 1 # delete breakpoint number 1 dis 1 # disable breakpoint 1 en 1 # enable breakpoint 1 disp /i $pc # after stopping display next instruction p/x $r9 # print gpr9 in hex l main # list function Try 'help' inside the gdb for lot's of information. Try 'show mpcbdm[TAB][TAB]' to get a list of mpcbdm specific variables. ---------------------------------------------------------------- Included in 'BuildGDB' is a part of how to build a cross kernel and make gdb uploading this kernel into the MPC860 system via BDM. To use the FLASH routines your target has to be configured (GPCM, using the fast flash routines also the UPM). See 'Init' and 'TQMMem' macros in mpc.init for memory setup. I use 'Init' and 'DoInit' to upload my kernel into the target, setting up a kernel command line, then 'c' for continue to start the kernel. ---------------------------------------------------------------- New features in version 1.2.3: hopefully flexible flash routines using a text configuration file, fixed MSR/SRR1 bug (machine state got corrupted, disturbing especially early kernel debugging) ---------------------------------------------------------------- New features in version 1.2.2-pre: adapted tablewalk to linux-2.4, fixed several bugs in the BDM protocol, mem upload/download, mmu and cache debugging and dcache flushing debugging of specific layer routines via 'set mpcbdm_verbose 0xXX' (see mpcbdm.h for VERBOSE_XXX, nice is 0x8 for MMU debugging) ---------------------------------------------------------------- New features in version 1.2: supporting 8,16 and 32 bit wide FLASH over layered routines new layered PORT routines (try 'mp port') better reattach strategy ---------------------------------------------------------------- Bugs: segmentation faults on running object files without main() no user guide yet ;-) ---------------------------------------------------------------- Have fun! Frank