Statistics
| Branch: | Revision:

## root / latex / note_w02.tex @ d1ed66aa

 1 %!TEX root = note.tex  %%%%%%%%%%%%%%%%%%  % WEEK 2  %%%%%%%%%%%%%%%%%%  \section{Week 2}   \subsection{Library \texttt{networkx}}   \textbf{Graph object}   \begin{lstlisting}   {'A': {'B': {}, 'F': {}}, 'C': {'B': {}}, 'B': {'A': {}, 'C': {}, 'E': {}}, 'E': {'B': {}, 'D': {}, 'F': {}}, 'D': {'E': {}, 'G': {}}, 'G': {'D': {}}, 'F': {'A': {}, 'E': {}}}   \end{lstlisting}   \textbf{Function} \texttt{\_single\_source\_shortest\_path\_basic} (in betweenness.py)   Variable meanings:   \begin{itemize}   \item sigma[v] is the number of shortest paths passing through vertice v   \item D[v] is the distance from vertice s to vertice v   \item P[v] contains predecessors for node v. The predecessors satisfies the condition that if we traverse through it, the path is the shortest one.   \end{itemize}   \textbf{Function} \texttt{\_accumulate\_basic}   S is an array   S.pop() iteratively returns elements in array S, from the last to the top   \subsection{Brandes 2001}   I still do not understand Section 4, but I understand the pseudo-code. [21/09/2015]   \subsection{OpenWRT}   Download the SDK \footnote{http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk}   README.SDK:   \begin{lstlisting}   This is the OpenWrt SDK. It contains a stripped-down version of   the buildroot. You can use it to test/develop packages without   having to compile your own toolchain or any of the libraries   included with OpenWrt.   To use it, just put your buildroot-compatible package directory   in the subdir 'package/' and run 'make' from this directory.   \end{lstlisting}   \subsubsection{Definition}   \textbf{SDK}   \textbf{OpenWrt Build System} = build system for the OpenWrt Linux distribution   \textbf{OpenWrt Linux distribution}   \textbf{Instruction set architecture} = the translator that turns the code a machine is running into instructions a processor can understand and execute. It's an important part of a processor.   \textbf{ARM} = a simpler instruction set architecture comparing to the \texttt{x86}. It has the power efficiency. It uses \texttt{Reduced Instruction Set Computing - RISC}   \textbf{i386} = that chips win over ARM chips on the performance. It uses \texttt{Complex Instruction Set Computing - CISC}.   \textbf{Debian on ARM}   \subsubsection{Compile OpenWRT CC toolchain to get OpenWrt SDK}   Compile the \texttt{OpenWrt Chaos Calmer}. More information can be found in \href{http://wiki.openwrt.org/doc/howto/buildroot.exigence}{OpenWrt build system - Installation}.   \href{http://wiki.openwrt.org/doc/howto/build}{This tutorial} shows how to build \texttt{OpenWrt SDK from source}   \begin{lstlisting}  # Clone OpenWRT, branch Chaos Clamer  git clone http://git.openwrt.org/15.05/openwrt.git  # Make OpenWrt build system check for missing packages on your build-system using one of the following commands  make defconfig  make prereq  # To set the target system (e.g. Broadcom BCM47xx)  # Select (by pressing Y) on item "[ ] Build the OpenWrt SDK"  make menuconfig   \end{lstlisting}   \begin{figure}[h]   \label{fig:menuconfig}   \caption{menuconfig}   \includegraphics[scale=0.3]{make-menuconfig}   \end{figure}   \begin{lstlisting}  # It will take a while to finish  make  # 2nd run - ERROR  make[3] -C package/system/opkg host-compile  make -r world: build failed. Please re-run make with -j1 V=s to see what's going on  make: *** [world] Error 1  # 3rd run - NO ERROR   \end{lstlisting}   Inside the directory \textbf{target-arm\_cortex-a9\_uClibc-0.9.33.2\_eabi} in \texttt{build\_dir}, we have \texttt{OpenWrt-SDK-bcm53xx\_gcc-4.8-linaro\_uClibc-0.9.33.2\_eabi.Linux-x86\_64}. This one is the \texttt{compiled toolchain}, or the \texttt{OpenWrt SDK, version Chaos Calmer}   \subsubsection{Compile packages with OpenWrt SDK}   Steps I performed   \begin{itemize}   \item Test building package with OpenWrt SDK BB on Linux Mint 17 (based on Ubuntu Trusty - 14)   \begin{lstlisting}  svn export svn://svn.openwrt.org/openwrt/packages/utils/sed package/sed  grep DEPENDS package/sed/Makefile  make package/sed/compile # GOT ERROR HERE  configure: error: in /home/quynh/Thesis/openwrt-bb/build_dir/target-mipsel_mips32_uClibc-0.9.33.2/sed-4.2.1':  configure: error: C compiler cannot create executables  See config.log' for more details.  make[2]: *** [/home/quynh/Thesis/openwrt-bb/build_dir/target-mipsel_mips32_uClibc-0.9.33.2/sed-4.2.1/.configured_] Error 77  make[2]: Leaving directory /home/quynh/Thesis/openwrt-bb/package/sed'  make[1]: *** [package/sed/compile] Error 2  make[1]: Leaving directory /home/quynh/Thesis/openwrt-bb'  make: *** [package/sed/compile] Error 2  # SOLUTION  sudo apt-get install ccache   \end{lstlisting}   \item Test building package with Ubuntu 14 in VMWare. I got the same error as when running with Linux Mint 17   \item Install the library \texttt{ccache} manually would solve the problem   \item After successfully compile the package, you will find *.ipk in the folder [./bin/bcm53xx/packages/base/]. Where \texttt{bcm53xx} is the code of the target device. It can also be \texttt{ar71xx} or something else.   \end{itemize}   \subsubsection{Install QEMU}   Check out \href{http://wiki.qemu.rg/Download}{Wiki} for instruction. It will took a while to install, since QEMU required several packages that are not present on my system.   After installation, I have a bunch of binary file \texttt{quem-*} in \texttt{/usr/local/bin}   \subsubsection{Generate OpenWrt Image with QEMU}   This \href{http://wiki.openwrt.org/doc/howto/obtain.firmware}{Obtaining Firmware} page summarizes different ways to obtain \texttt{OpenWrt Firmware Image (OFI)} file. After having the OFI, then we can feed it into QEMU.   This \href{http://wiki.openwrt.org/doc/howto/obtain.firmware.generate}{Image Generator tutorial} has instruction on how to generate Image Builder firmware.   Since when compiling OpenWrt toolchain, I didn't modify anything in \texttt{menuconfig}, so the target system of the SDK are bcm53xx.   The profile for bcm53xx can be found \href{https://dev.openwrt.org/browser/trunk/target/linux/bcm53xx/profiles/100-Generic.mk?rev=42143}{here}. I (randomly) pick \texttt{BCM53010}   \begin{lstlisting}  cd openwrt  wget https://downloads.openwrt.org/chaos_calmer/15.05/bcm53xx/generic/OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64.tar.bz2  tar -xvjf OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64.tar  cd OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64  mv OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64 ImageBuilder-15.05-bcm53xx.Linux-x86_64  # If you want to modify 'profiles', then:  vim ./ImageBuilder-15.05-bcm53xx.Linux-x86_64/target/linux/bcm53xx/profiles/100-Generic.mk  make image PROFILE=Generic  # The image is in ./bin directory  # ERROR: Can't find any *.bin file   \end{lstlisting}   I then tried to generate OpenWrt Firmware Image for \texttt{ar71xx} just like the original tutorial. This time I got all the *.bin file.   \subsubsection{Run OpenWrt Firmware Image with QEMU}   \begin{lstlisting}  qemu-system-x86_64 -kernel openwrt-15.05-ar71xx-generic-vmlinux.elf   \end{lstlisting}   \subsection{Questions}   What is \emph{buildroot-compatible package directory}?   How big should I set for the size of the QEMU image? In \href{http://www.aurel32.net/info/debian_arm_qemu.php}{here} they set aside 10G for creating the image.   \subsection{Technical Problems}   \subsubsection{'build' folder for all output file from LaTeX with \emph{LaTeXTools}}   So far I couldn't do it. I tried:   \begin{itemize}   \item Edit directly the simpleBuilder.py script, adding the option \texttt{"-output\_directory=./build"}. It shows error that *.log file cannot be written   \item Change the \texttt{builder\_settings} \emph{Preferences -> Package Settings -> LaTeXTools -> Settings - User}   \end{itemize}   The solution now is to add extra line in \texttt{.gitignore} to not including the generated \emph{pdf} for each \emph{TeX} file.   \subsubsection{Cannot compile package \texttt{sed}}   Some line of errors from config.log   \begin{lstlisting}  /home/quynh/Thesis/openwrt-bb/staging_dir/host/bin/  ccache_cc: 2: exec: ccache: not found   \end{lstlisting}   But I found the file ccache\_cc in that folder as shown below:   \begin{lstlisting}  quynh in ~/Thesis/openwrt-bb/staging_dir/host/bin  \$ ls | grep ccache  ccache_cc  ccache_cxx   \end{lstlisting}   Solution: sudo apt-get install ccache   \subsection{Misc}   [11:10 - 11:30] I'm doing shitty things now. Removing gcc-base, and as a result most packages are being removed: chrome, mozilla, gedit, tortoise, skype, python, libqt4, networkmanager. Now I don't have the internet connection anymore.