Statistics
| Branch: | Revision:

root / latex / note_w02.tex @ 4f432e4a

History | View | Annotate | Download (9.29 KB)

1 d1ed66aa Quynh PX Nguyen
%!TEX root = note.tex
2
3
%%%%%%%%%%%%%%%%%%
4
% WEEK 2
5
%%%%%%%%%%%%%%%%%%
6
\section{Week 2}
7
    \subsection{Library \texttt{networkx}}
8
        \textbf{Graph object}
9
            \begin{lstlisting}
10
            {'A': {'B': {}, 'F': {}}, 'C': {'B': {}}, 'B': {'A': {}, 'C': {}, 'E': {}}, 'E': {'B': {}, 'D': {}, 'F': {}}, 'D': {'E': {}, 'G': {}}, 'G': {'D': {}}, 'F': {'A': {}, 'E': {}}}
11
            \end{lstlisting}
12
13
        \textbf{Function} \texttt{\_single\_source\_shortest\_path\_basic} (in betweenness.py)
14
15
            Variable meanings:
16
            \begin{itemize}
17
                \item sigma[v] is the number of shortest paths passing through vertice v
18
                \item D[v] is the distance from vertice s to vertice v
19
                \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.
20
            \end{itemize}
21
22
        \textbf{Function} \texttt{\_accumulate\_basic}
23
            S is an array
24
            S.pop() iteratively returns elements in array S, from the last to the top
25
26
    \subsection{Brandes 2001}
27
        I still do not understand Section 4, but I understand the pseudo-code. [21/09/2015]
28
29
    \subsection{OpenWRT}
30
31
        Download the SDK \footnote{http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk}
32
33
        README.SDK:
34
        \begin{lstlisting}
35
            This is the OpenWrt SDK. It contains a stripped-down version of
36
            the buildroot. You can use it to test/develop packages without
37
            having to compile your own toolchain or any of the libraries
38
            included with OpenWrt.
39
40
            To use it, just put your buildroot-compatible package directory
41
            in the subdir 'package/' and run 'make' from this directory.
42
        \end{lstlisting}
43
44
        \subsubsection{Definition}
45
            \textbf{SDK}
46
47
            \textbf{OpenWrt Build System} = build system for the OpenWrt Linux distribution
48
49
            \textbf{OpenWrt Linux distribution}
50
51
            \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.
52
53
            \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}
54
55
            \textbf{i386} = that chips win over ARM chips on the performance. It uses \texttt{Complex Instruction Set Computing - CISC}.
56
57
            \textbf{Debian on ARM}
58
59
60
        \subsubsection{Compile OpenWRT CC toolchain to get OpenWrt SDK}
61
            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}.
62
63
            \href{http://wiki.openwrt.org/doc/howto/build}{This tutorial} shows how to build \texttt{OpenWrt SDK from source}
64
65
            \begin{lstlisting}
66
# Clone OpenWRT, branch Chaos Clamer
67
git clone http://git.openwrt.org/15.05/openwrt.git
68
# Make OpenWrt build system check for missing packages on your build-system using one of the following commands
69
make defconfig
70
make prereq
71
# To set the target system (e.g. Broadcom BCM47xx)
72
# Select (by pressing Y) on item "[ ] Build the OpenWrt SDK"
73
make menuconfig
74
            \end{lstlisting}
75
76
            \begin{figure}[h]
77
                \label{fig:menuconfig}
78
                \caption{menuconfig}
79
                \includegraphics[scale=0.3]{make-menuconfig}
80
            \end{figure}
81
82
            \begin{lstlisting}
83
# It will take a while to finish
84
make
85
86
# 2nd run - ERROR
87
make[3] -C package/system/opkg host-compile
88
make -r world: build failed. Please re-run make with -j1 V=s to see what's going on
89
make: *** [world] Error 1
90
91
# 3rd run - NO ERROR
92
            \end{lstlisting}
93
94
            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}
95
96
    \subsubsection{Compile packages with OpenWrt SDK}
97
            Steps I performed
98
99
            \begin{itemize}
100
                \item Test building package with OpenWrt SDK BB on Linux Mint 17 (based on Ubuntu Trusty - 14)
101
                    \begin{lstlisting}
102
svn export svn://svn.openwrt.org/openwrt/packages/utils/sed package/sed
103
grep DEPENDS package/sed/Makefile
104
make package/sed/compile # GOT ERROR HERE
105
106
configure: error: in `/home/quynh/Thesis/openwrt-bb/build_dir/target-mipsel_mips32_uClibc-0.9.33.2/sed-4.2.1':
107
configure: error: C compiler cannot create executables
108
See `config.log' for more details.
109
make[2]: *** [/home/quynh/Thesis/openwrt-bb/build_dir/target-mipsel_mips32_uClibc-0.9.33.2/sed-4.2.1/.configured_] Error 77
110
make[2]: Leaving directory `/home/quynh/Thesis/openwrt-bb/package/sed'
111
make[1]: *** [package/sed/compile] Error 2
112
make[1]: Leaving directory `/home/quynh/Thesis/openwrt-bb'
113
make: *** [package/sed/compile] Error 2
114
115
# SOLUTION
116
sudo apt-get install ccache
117
                    \end{lstlisting}
118
119
                \item Test building package with Ubuntu 14 in VMWare. I got the same error as when running with Linux Mint 17
120
121
                \item Install the library \texttt{ccache} manually would solve the problem
122
123
                \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.
124
            \end{itemize}
125
126
        \subsubsection{Install QEMU}
127
            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.
128
129
            After installation, I have a bunch of binary file \texttt{quem-*} in \texttt{/usr/local/bin}
130
131
        \subsubsection{Generate OpenWrt Image with QEMU}
132
            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.
133
134
            This \href{http://wiki.openwrt.org/doc/howto/obtain.firmware.generate}{Image Generator tutorial} has instruction on how to generate Image Builder firmware.
135
136
            Since when compiling OpenWrt toolchain, I didn't modify anything in \texttt{menuconfig}, so the target system of the SDK are bcm53xx.
137
138
            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}
139
140
            \begin{lstlisting}
141
cd openwrt
142
wget https://downloads.openwrt.org/chaos_calmer/15.05/bcm53xx/generic/OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64.tar.bz2
143
tar -xvjf OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64.tar
144
cd OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64
145
mv OpenWrt-ImageBuilder-15.05-bcm53xx.Linux-x86_64 ImageBuilder-15.05-bcm53xx.Linux-x86_64
146
147
# If you want to modify 'profiles', then:
148
vim ./ImageBuilder-15.05-bcm53xx.Linux-x86_64/target/linux/bcm53xx/profiles/100-Generic.mk
149
make image PROFILE=Generic
150
151
# The image is in ./bin directory
152
# ERROR: Can't find any *.bin file
153
            \end{lstlisting}
154
155
            I then tried to generate OpenWrt Firmware Image for \texttt{ar71xx} just like the original tutorial. This time I got all the *.bin file.
156
157
        \subsubsection{Run OpenWrt Firmware Image with QEMU}
158
            \begin{lstlisting}
159
qemu-system-x86_64 -kernel openwrt-15.05-ar71xx-generic-vmlinux.elf
160
            \end{lstlisting}
161
162
    \subsection{Questions}
163
        What is \emph{buildroot-compatible package directory}?
164
165
        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.
166
167
    \subsection{Technical Problems}
168
        \subsubsection{'build' folder for all output file from LaTeX with \emph{LaTeXTools}}
169
            So far I couldn't do it. I tried:
170
            \begin{itemize}
171
                \item Edit directly the simpleBuilder.py script, adding the option \texttt{"-output\_directory=./build"}. It shows error that *.log file cannot be written
172
                \item Change the \texttt{builder\_settings} \emph{Preferences -> Package Settings -> LaTeXTools -> Settings - User}
173
            \end{itemize}
174
175
            The solution now is to add extra line in \texttt{.gitignore} to not including the generated \emph{pdf} for each \emph{TeX} file.
176
177
        \subsubsection{Cannot compile package \texttt{sed}}
178
            Some line of errors from config.log
179
            \begin{lstlisting}
180
/home/quynh/Thesis/openwrt-bb/staging_dir/host/bin/
181
ccache_cc: 2: exec: ccache: not found
182
            \end{lstlisting}
183
184
            But I found the file ccache\_cc in that folder as shown below:
185
            \begin{lstlisting}
186
quynh in ~/Thesis/openwrt-bb/staging_dir/host/bin
187
$ ls | grep ccache
188
ccache_cc
189
ccache_cxx
190
            \end{lstlisting}
191
192
            Solution: sudo apt-get install ccache
193
194
195
    \subsection{Misc}
196
        [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.