Changeset 3161

Show
Ignore:
Timestamp:
07/06/07 21:40:00 (1 year ago)
Author:
n0-1
Message:

* /ignore for temporary files
* added kgdb documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/Docs/handbook/devel

    • Property svn:ignore set to
      splitup
      handbook-dev.log
      allinone
      handbook-dev.idx
      handbook-dev.toc
      handbook-dev.out
      handbook-dev.pdf
      cover.aux
      handbook-dev.aux
      handbook-dev.tex
  • trunk/freewrt/Docs/handbook/devel/handbook-dev.tex

    r2827 r3161  
    66\usepackage{amssymb} 
    77\usepackage{caption2} 
    8 \usepackage[canadian]{babel} 
     8\usepackage[english]{babel} 
    99\usepackage{varioref} 
    1010\usepackage{txfonts} 
     
    4343\usepackage{cancel} 
    4444%\usepackage[final, activate, verbose=true]{microtype} 
    45 \usepackage{ngerman} 
     45%\usepackage{ngerman} 
    4646%\usepackage{bookman} 
    4747%\usepackage[a4paper,twoside,rmargin=2cm,lmargin=2cm,tmargin=2.5cm]{geometry} 
     
    8888\newcommand{\entspr}{\stackrel{\wedge}{=}} 
    8989 
     90% Create some new commands for designing the text 
     91% applications 
     92\newcommand{\app}[1]{% 
     93        \textsf{\textit{#1}}} 
     94% terminology, vendor or product names 
     95\newcommand{\term}[1]{% 
     96        \textsc{#1}} 
     97% filenames and directories 
     98\newcommand{\file}[1]{% 
     99        \textsf{#1}} 
     100% user input 
     101\newcommand{\command}[1]{% 
     102        \texttt{\textbf{#1}}} 
     103% example code, output of applications 
     104\newcommand{\code}[1]{% 
     105        \texttt{#1}} 
     106% emphasized text (nicer than \emph{}) 
     107\newcommand{\strong}[1]{% 
     108        \textbf{#1}} 
     109 
    90110\chapter{Introduction} 
    91111 
     
    101121feedback and will try to update or correct the issues mentioned by you. 
    102122 
    103 The FreeWRT developer handbook is split into five distinct sections.  
     123The FreeWRT developer handbook is split into five distinct sections. 
    104124% ADK Overview 
    105125% SVN Grundlagen 
     
    137157 
    138158Examples starting with \$ indicate a command that should be invoked as a 
    139 unprivileged user.   
     159unprivileged user. 
    140160 
    141161\begin{Verbatim} 
     
    166186\item Debian GNU/Linux 
    167187\item Gentoo Linux 
    168 \item OpenSuSE  
     188\item OpenSuSE 
    169189\item Ubuntu GNU/Linux 
    170 \item Fedora Core  
     190\item Fedora Core 
    171191\item OpenBSD (partial support)\footnote{some addon packages does not compile} 
    172192\item MirOS BSD (partial support)\footnote{some addon packages does not compile} 
     
    261281\section{Getting the source} 
    262282 
    263 Go to a directory where you want to checkout the ADK.  
     283Go to a directory where you want to checkout the ADK. 
    264284To get the latest version of the FreeWRT ADK use one of these commands: 
    265285\begin{Verbatim} 
     
    290310% other projects (Gentoo, OpenWrt, OpenEmbedded, *BSD ports) 
    291311% Upstream Bugtracking and Mailinglist archives 
     312 
     313\section{Debugging Userspace} 
    292314 
    293315% gdbserver 
     
    330352(gdb) bt 
    331353#0  0x0044efa0 in op_yank (oap=0x7fff7d18, deleting=7, mess=1) at ops.c:2388 
    332 #1  0x004452bc in do_pending_operator (cap=0x7fff7c40, searchbuff=0x10006010 "",  
     354#1  0x004452bc in do_pending_operator (cap=0x7fff7c40, searchbuff=0x10006010 "", 
    333355    command_busy=0x7fff7c90, old_col=0, gui_yank=0, dont_adjust_op_end=646447176) 
    334356    at normal.c:1789 
     
    339361\end{verbatim} 
    340362 
     363\section{Debugging Kernelspace} 
     364 
     365To debug problems with kernel or modules, basically some debugger has to be 
     366enabled inside the kernel itself. There is more than only one implementation 
     367for doing the job, but FreeWRT sticks to the subsystem already being included 
     368into the vanilla kernel, namely \app{KGDB}. 
     369 
     370To be able to control the debugger on headless machines, some sort of 
     371client/server approach like with \app{gdbserver} has to be used. Luckily, our 
     372cross compiled \app{gdb} serves fine for this task. But unlike \app{gdbserver}, 
     373\app{KGDB} communicates via a serial port. As serial port access at the very 
     374early state \app{KGDB} starts using it (i.e. right after kernel execution 
     375starts) is very hardware--dependant, a few hardware--specific functions have to be 
     376provided for each supported device. At the time of this writing, only 
     377\code{rb-2.6} includes support for \app{KGDB}. 
     378 
     379First enable \code{FWRT\_DEBUG\_KGDB} in the ADK's config, then build the 
     380complete system. Besides enabling support for \app{KGDB} itself, this option 
     381causes the kernel and all modules to be built with debugging symbols included. 
     382 
     383\strong{BEWARE:} the generated kernel and modules are really huge in size, much 
     384too big to fit into any flash space (kernel around 20MB). So better build for 
     385use with nfsroot or compactflash disk. 
     386 
     387When booting the debug kernel, an attached serial terminal shows: 
     388\begin{Verbatim}[label=kernel with KGDB starting] 
     389GDB console initialized 
     390+ 
     391\end{Verbatim} 
     392first line is actually some hard--coded string inside debug console 
     393initialisation, so the only magic part is the \code{+} sign at the end. In 
     394\app{KGDB} protocol language this means "successful transfer", and is used here 
     395to start communication. 
     396 
     397Exit your terminal emulation and start the debugger: 
     398\begin{Verbatim}[label=gdb initialisation] 
     399$ cd build_mipsel/linux 
     400$ mipsel-linux-gdb vmlinux 
     401GNU gdb 6.3 
     402Copyright 2004 Free Software Foundation, Inc. 
     403GDB is free software, covered by the GNU General Public License, and you are 
     404welcome to change it and/or distribute copies of it under certain conditions. 
     405Type "show copying" to see the conditions. 
     406There is absolutely no warranty for GDB.  Type "show warranty" for details. 
     407This GDB was configured as "--host=i686-pc-linux-gnu 
     408--target=mipsel-linux-uclibc"... 
     409(gdb) set remotebaud 115200 
     410(gdb) target remote /dev/ttyUSB0 
     4110xffffffff8010dfcc in breakinst () at arch/mips/kernel/gdb-stub.c:1066 
     4121066            __asm__ __volatile__( 
     413warning: shared library handler failed to enable breakpoint 
     414(gdb) 
     415\end{Verbatim} 
     416Changing the directory into the kernel source's root is necessary as \app{gdb} 
     417automatically searches the current working directory for source files 
     418referenced by the debugging symbols inside the kernel. 
     419Alternatively/additionally you can specify search paths using the 
     420\code{directory} directive, e.g.: 
     421\begin{Verbatim}[label=specifying a search path in gdb] 
     422(gdb) directory ../../w-madwifi-0.9.3.1-4/madwifi-0.9.3.1/ 
     423Source directories searched: 
     424/var/tmp/portage/build_mipsel/linux-2.6-rb/linux-2.6.19.1/../../w-madwifi-0.9.3.1-4 
     425/madwifi-0.9.3.1:$cdir:$cwd 
     426(gdb) 
     427\end{Verbatim} 
     428 
     429Specifying the correct tty with \code{target remote} triggers the start of 
     430communication with \app{KGDB}. To make life happy, right after communication 
     431has started, the kernel triggers a break itself, so you have time to specify 
     432other options before continuing. 
     433 
     434Finally hit \code{c} for \code{continue} and watch the kernel booting. (The gdb 
     435console registered inside the kernel is being enabled for use as a regular 
     436output device, and kernel log messages output is being redirected via the 
     437\code{console=gdb} kernel parameter. 
     438 
     439To be able to debug kernel modules, you need to specify a path to the object 
     440files being debugged: 
     441\begin{Verbatim}[label=setting solib-search-path] 
     442(gdb) set solib-search-path /tmp/t/lib/modules/2.6.19.1/ 
     443(gdb) 
     444\end{Verbatim} 
     445\app{gdb} should recognise loading of a module on the test machine and load the 
     446corresponding object file itself. 
     447 
     448While \app{gdb} is running, the serial console is unusable for I/O. This means 
     449if kernel bugs somehow have to be triggered interactively, it is handy to have 
     450networking being configured so you can log in via \app{SSH} in parallel. Though 
     451after exiting from \app{gdb} (hit \code{ctrl-c} twice), you can reattach your 
     452terminal emulator to the serial port and continue using the serial console as 
     453usual. 
     454 
     455From now on, you can use \app{gdb} like when debugging any other application. 
     456 
    341457\chapter{Appliance Development Kit (ADK) Reference} 
    342458 
    343459\section{Filesystem structure} 
    344460 
    345 After a fresh checkout you get following file and directory structure in your  
     461After a fresh checkout you get following file and directory structure in your 
    346462working directory: 
    347463\begin{verbatim} 
     
    358474 
    359475You will see some more files there, containing license information, portability 
    360 code for different make implementations or some special files for automatic  
     476code for different make implementations or some special files for automatic 
    361477builds. We will concentrate on the above list for now. 
    362478 
    363479The docs/ directory contains a package template and the FreeWRT handbook's 
    364 as LaTeX source code.  
     480as LaTeX source code. 
    365481 
    366482\section{NFO system} 
     
    400516\section{Filesystems} 
    401517 
    402 % different kinds of possibilities  
     518% different kinds of possibilities 
    403519% squashfs, lzma, jffs2, yaffs2, ext2, nfs 
    404520