Statistics
| Branch: | Revision:

root / latex / note_w04.tex @ d1ed66aa

History | View | Annotate | Download (8.03 KB)

1 d1ed66aa Quynh PX Nguyen
%!TEX root = note.tex
2
3
%%%%%%%%%%%%%%%%%%
4
% WEEK 4
5
%%%%%%%%%%%%%%%%%%
6
\section{Week 4}
7
    \subsection{Install package - nano - with dependency into OpenWrt Image}
8
        \href{http://wiki.openwrt.org/doc/devel/feeds}{Feeds}
9
10
        If we use \texttt{./scripts/feeds install -a -p packages}, then when issuing \texttt{make}, all the libraries, packages in the feed \texttt{packages} will be compiled. Don't use \texttt{-a}, since it might lead to error during \texttt{make}, and you do not need all those packages.
11
12
        \begin{lstlisting}
13
$ ./scripts/feeds install -p packages nano
14
Installing package 'nano'
15
16
# Press 'Y' to select to install package "nano" in make menuconfig: Utilities -> Editor
17
18
# Create config.diff so that we can create an image later with the exact same configuration
19
$ ./scripts/diffconfig.sh > config_10:47.diff
20
21
# Compile the toolchain to get SDK, ImageBuilder, and firmware image
22
$ make
23
24
# Running the image with QEMU
25
cd ./bin/realview
26
qemu-system-arm -M realview-eb-mpcore -kernel openwrt-realview-vmlinux-initramfs.elf -net nic -net user -nographic
27
28
# Show all the installed packages with this image
29
root@OpenWrt:/# opkg list-installed
30
31
        \end{lstlisting}
32
33
        This is the original installed packages
34
35
        \begin{lstlisting}
36
root@OpenWrt:/# opkg list-installed
37
base-files - 157-r47101
38
busybox - 1.23.2-1
39
dropbear - 2015.67-1
40
fstools - 2015-09-15-cc63723d886fde2cd364a545b7cb05b70721b83f
41
jshn - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
42
jsonfilter - 2014-06-19-cdc760c58077f44fc40adbbe41e1556a67c1b9a9
43
libblobmsg-json - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
44
libc - 0.9.33.2-1
45
libgcc - 4.8-linaro-1
46
libjson-c - 0.12-1
47
libjson-script - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
48
libnl-tiny - 0.1-4
49
libubox - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
50
libubus - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e
51
libuci - 2015-08-27.1-1
52
mtd - 21
53
netifd - 2015-09-27-509ffb22475ebdd5291d510a098f996473951344
54
opkg - 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-8
55
procd - 2015-09-16-b6618ffab8ed4981c57f53929276559698541462
56
terminfo - 5.9-2
57
ubox - 2015-07-14-907d046c8929fb74e5a3502a9498198695e62ad8
58
ubus - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e
59
ubusd - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e
60
uci - 2015-08-27.1-1
61
usign - 2015-05-08-cf8dcdb8a4e874c77f3e9a8e9b643e8c17b19131
62
        \end{lstlisting}
63
64
        This is all the packages we get when selecting nano
65
66
        \begin{lstlisting}
67
root@OpenWrt:/# opkg list-installed
68
base-files - 157-r47101
69
busybox - 1.23.2-1
70
dropbear - 2015.67-1
71
fstools - 2015-09-15-cc63723d886fde2cd364a545b7cb05b70721b83f
72
jshn - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
73
jsonfilter - 2014-06-19-cdc760c58077f44fc40adbbe41e1556a67c1b9a9
74
libblobmsg-json - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
75
libc - 0.9.33.2-1
76
libgcc - 4.8-linaro-1
77
libjson-c - 0.12-1
78
libjson-script - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
79
libncurses - 5.9-2 # This one is new
80
libnl-tiny - 0.1-4
81
libubox - 2015-06-14-d1c66ef1131d14f0ed197b368d03f71b964e45f8
82
libubus - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e
83
libuci - 2015-08-27.1-1
84
mtd - 21
85
nano - 2.4.1-1 # This one is new
86
netifd - 2015-09-27-509ffb22475ebdd5291d510a098f996473951344
87
opkg - 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-8
88
procd - 2015-09-16-b6618ffab8ed4981c57f53929276559698541462
89
terminfo - 5.9-2
90
ubox - 2015-07-14-907d046c8929fb74e5a3502a9498198695e62ad8
91
ubus - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e
92
ubusd - 2015-05-25-f361bfa5fcb2daadf3b160583ce665024f8d108e
93
uci - 2015-08-27.1-1
94
usign - 2015-05-08-cf8dcdb8a4e874c77f3e9a8e9b643e8c17b19131
95
        \end{lstlisting}
96
97
    \subsection{Boost library}
98
99
        Download \textbf{boost} library: \href{http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download}{here}
100
101
        \begin{lstlisting}
102
$ wget http://netix.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
103
$ tar -xf boost_1_59_0.tar.gz
104
$ rm tar -xf boost_1_59_0.tar.gz
105
$ cd boost_1_59_0/
106
        \end{lstlisting}
107
108
        Read \href{http://www.boost.org/doc/libs/1_59_0/more/getting_started/unix-variants.html}{Getting Started with Boost}
109
110
        The Boost Graph Library is a header-only library and does not need to be built to be used. The only exceptions are the GraphViz input parser and the GraphML parser. ==> Since I don't think OpenWrt will parse anyfile for GraphViz, so probably we do not need to build anything?!
111
112
113
    \subsection{Creating package from C++ code \& Installing it}
114
        \href{https://manoftoday.wordpress.com/2007/10/11/writing-and-compiling-a-simple-program-for-openwrt/}{Writing and Compiling A Simple Program For OpenWrt}
115
116
        \textbf{Package libboost is missing dependencies for the following libraries:libstdc++.so.6}
117
118
        https://forum.openwrt.org/viewtopic.php?id=5446
119
120
            You should link your executable against uclibc++
121
122
            Also remember to install the package: libstdcpp.
123
124
        \textbf{After having libboost.ipk, how to add to OpenWrt image with make menuconfig}
125
            \begin{lstlisting}
126
quynh in ~/Thesis/quynhnguyen-ms
127
$ TOOLCHAIN_DIR="/home/quynh/Thesis/cc-openwrt"
128
$ cp -r libboost $TOOLCHAIN_DIR/package/custom
129
130
quynh in ~/Thesis/cc-openwrt
131
$ make package/custom/libboost/compile
132
133
$ make menuconfig
134
135
# Then select the package libboost in Utilities
136
137
# Then, build a new image.
138
$ make
139
            \end{lstlisting}
140
141
        \textbf{Script to run after make menuconfig}
142
143
            This script will compile the OpenWrt toolchain, create SDK, and OpenWrt image with the necessary packages.
144
145
            \begin{lstlisting}
146
_description=$1
147
_separator="_"
148
_now="$(date +'%Y_%m_%d_%H_%M')"
149
_filename="$_now$_separator$_description"
150
./scripts/diffconfig.sh > config.diff
151
make
152
cd ./bin/realview
153
mkdir $_now
154
mv ../../config.diff ./
155
find . -maxdepth 1 -type f -name '*' -exec mv -n {} ./$_now \;
156
echo "All binary files are in ./bin/realview/$_now"
157
cd $_now
158
ELFFILE="openwrt-realview-vmlinux-initramfs.elf"
159
qemu-system-arm -M realview-eb-mpcore -kernel $ELFFILE -net nic -net user -nographic
160
            \end{lstlisting}
161
162
163
    \subsection{Add python-light to openwrt}
164
        The Python package can be found \href{https://github.com/openwrt/packages/blob/master/lang/python/Makefile}{here in github}
165
166
167
        How to add Python package to OpenWrt image?
168
        \begin{lstlisting}
169
./scripts/feeds install -p package python
170
# Select 'python-light' in Languages
171
make menuconfig
172
173
# To see if introducing python-light package will produce any error in compiling the OpenWrt toolchain
174
make package/python/compile
175
176
        \end{lstlisting}
177
178
    \subsection{Add python library networkx to OpenWrt}
179
        Create a simple program. Follow the similar guideline for \href{https://manoftoday.wordpress.com/2007/10/11/writing-and-compiling-a-simple-program-for-openwrt/}{Writing and Compiling A Simple Program For OpenWrt (C++)}. This guide also works with python.
180
181
        Save the file as \texttt{libnetworkx/src/libnetworkx.py}. This program will print all the functions in the library networkx.
182
183
        \begin{lstlisting}
184
#! python
185
import networkx
186
187
if __name__ == '__main__':
188
    print "Success"
189
    print dir(networkx)
190
        \end{lstlisting}
191
192
        The \texttt{libnetworkx/src/Makefile}
193
194
        \begin{lstlisting}
195
libnetworkx: libnetworkx.py
196
    ln -s libnetworkx.py libnetworkx
197
    chmod +x libnetworkx
198
199
clean:
200
    rm libnetworkx
201
        \end{lstlisting}
202
203
        Create a Makefile for OpenWrt in \texttt{libnetworkx/Makefile}
204
205
        After having all the files in place, then move them to the OpenWrt Toolchain. Compile the package, and select to install the package in make menuconfig. Compile the toolchain. Run the image with QEMU. Run the binary file \texttt{libnetworkx} to see whether the print command works.
206
207
        \textbf{Error: No module named networkx}
208
209
            How can we copy the whole module networkx and put it with the source
210
            \begin{lstlisting}
211
root@OpenWrt:/# libnetworkx
212
Traceback (most recent call last):
213
  File "/bin/libnetworkx", line 2, in <module>
214
    import networkx
215
ImportError: No module named networkx
216
            \end{lstlisting}