1The following section gives some tips and tricks on how to use efficiently 2OpenWrt on a regular basis and for daily work. 3 4\subsection{Compiling/recompiling components} 5 6The buildroot allows you to recompile the full environment or only parts of it 7like the toolchain, the kernel modules, the kernel or some packages. 8 9For instance if you want to recompile the toolchain after you made any change to it 10issue the following command: 11 12\begin{Verbatim} 13make toolchain/{clean,compile,install} 14\end{Verbatim} 15 16Which will clean, compile and install the toolchain. The command actually expands to the 17following: 18 19\begin{Verbatim} 20make[1] toolchain/clean 21make[2] -C toolchain/kernel-headers clean 22make[2] -C toolchain/binutils clean 23make[2] -C toolchain/gcc clean 24make[2] -C toolchain/uClibc clean (glibc or eglibc when chosen) 25\end{Verbatim} 26 27Of course, you could only choose to recompile one or several of the toolchain components 28(binutils, kernel-headers gcc, C library) individually. 29 30The exact same idea works for packages: 31 32\begin{Verbatim} 33make package/busybox/{clean,compile,install} 34\end{Verbatim} 35 36will clean, compile and install busybox (if selected to be installed on the final rootfs). 37 38Supposing that you made changes to the Linux kernel, but do not want to recompile everything, 39you can recompile only the kernel modules by issuing: 40 41\begin{Verbatim} 42make target/linux/compile 43\end{Verbatim} 44 45To recompile the static part of the kernel use the following command: 46 47\begin{Verbatim} 48make target/linux/install 49\end{Verbatim} 50 51\subsection{Using quilt inside OpenWrt} 52 53OpenWrt integrates quilt in order to ease the package, kernel and toolchain 54patches maintenance when migrating over new versions of the software. 55 56Quilt intends to replace an old workflow, where you would download the new 57source file, create an original copy of it, an a working copy, then try to 58apply by hand old patches and resolve conflicts manually. Additionally, using 59quilt allows you to update and fold patches into other patches easily. 60 61Quilt is used by default to apply Linux kernel patches, but not for the other 62components (toolchain and packages). 63 64\subsubsection{Using quilt with kernel patches} 65 66Assuming that you have everything setup for your new kernel version: 67\begin{itemize} 68\item \texttt{LINUX\_VERSION} set in the target Makefile 69\item config-2.6.x.y existing 70\item patches-2.6.x.y containing the previous patches 71\end{itemize} 72 73Some patches are likely to fail since the vanilla kernel we are patching 74received modifications so some hunks of the patches are no longer applying. 75We will use quilt to get them applying cleanly again. Follow this procedure 76whenever you want to upgrade the kernel using previous patches: 77 78\begin{enumerate} 79\item make target/linux/clean (removes the old version) 80\item make target/linux/compile (uncompress the kernel and try to apply patches) 81\item if patches failed to apply: 82\item cd build\_dir/linux-target/linux-2.6.x.y 83\item quilt push -a (to apply patches where quilt stopped) 84\item quilt push -f (to force applying patches) 85\item edit .rej files, apply the necessary changes to the files 86\item remove .rej files 87\item quilt refresh 88\item repeat operation 3 and following until all patches have been applied 89\item when all patches did apply cleanly: make target/linux/refresh 90\end{enumerate} 91 92Note that generic (target/linux/generic-2.6/linux-2.6.x/) patches can be found in 93\texttt{build\_dir/linux-target/linux-2.6.x.y/patches/generic} and platform specific 94patches in \texttt{build\_dir/linux-target/linux-2.6.x.y/patches/platform}. 95 96\subsubsection{Using quilt with packages} 97 98As we mentioned earlier, quilt is enabled by default for kernel patches, but not for 99packages. If you want to use quilt in the same way, you should set the QUILT environment 100variable to 1, e.g: 101 102\begin{Verbatim} 103make package/busybox/{clean,compile} QUILT=1 104\end{Verbatim} 105 106Will generate the patch series file and allow you to update patches just like we described 107before in the kernel case. Note that once all patches apply cleanly you should refresh them 108as well using the following command: 109 110\begin{Verbatim} 111make package/busybox/refresh QUILT=1 112\end{Verbatim} 113