diff options
author | Minijackson <minijackson@riseup.net> | 2020-10-13 14:46:56 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2020-10-13 14:46:56 +0200 |
commit | 65149417e1deb23f83726edfd41f3215ae0591e0 (patch) | |
tree | 90c6bcb4ad6dd9c597d04b51845e02d63c450237 | |
parent | c9e775a44cb316d578827f333531f5101aa29658 (diff) | |
download | wtf-is-linux-slides-master.tar.gz wtf-is-linux-slides-master.zip |
-rw-r--r-- | 2020-09-29.md | 387 | ||||
-rw-r--r-- | 2020-10-06.md | 119 | ||||
-rw-r--r-- | 2020-10-13.md | 432 | ||||
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | bibliography.bib | 21 | ||||
-rw-r--r-- | res/DHCP_session.png | bin | 0 -> 61621 bytes | |||
-rw-r--r-- | res/home-network.jpg | bin | 0 -> 75431 bytes | |||
-rw-r--r-- | res/plantuml/buildroot-overview.plantuml | 34 | ||||
-rw-r--r-- | res/plantuml/buildroot-process.plantuml | 41 | ||||
-rw-r--r-- | res/plantuml/buildroot-project.plantuml | 41 | ||||
-rw-r--r-- | res/rfc791.pdf | bin | 0 -> 52132 bytes | |||
-rw-r--r-- | res/rfc791.png | bin | 0 -> 314322 bytes |
12 files changed, 1086 insertions, 2 deletions
diff --git a/2020-09-29.md b/2020-09-29.md new file mode 100644 index 0000000..8aa0608 --- /dev/null +++ b/2020-09-29.md | |||
@@ -0,0 +1,387 @@ | |||
1 | --- | ||
2 | title: WTF is Linux | ||
3 | author: Rémi Nicole <remi.nicole@smile.fr> | ||
4 | date: 2020-09-29 | ||
5 | slide-level: 2 | ||
6 | aspectratio: 169 | ||
7 | |||
8 | theme: metropolis | ||
9 | colortheme: owl | ||
10 | beameroption: "show notes on second screen=right" | ||
11 | |||
12 | toc: true | ||
13 | highlightstyle: breezedark | ||
14 | lang: en-US | ||
15 | |||
16 | bibliography: ../bibliography.bib | ||
17 | --- | ||
18 | |||
19 | # Before we get started | ||
20 | |||
21 | ## Reminder | ||
22 | |||
23 | - Please fill the [form](https://mensuel.framapad.org/p/zufgimy2yy-9j3n) | ||
24 | - Please have a GNU/Linux system with an SD card reader | ||
25 | |||
26 | |||
27 | ## Where were we | ||
28 | |||
29 | ::: notes | ||
30 | |||
31 | - We managed to boot the system! | ||
32 | - What we needed was: | ||
33 | - A file system to store files, and to be used as the root directory | ||
34 | - An init program in this file system, and started by the kernel | ||
35 | |||
36 | ::: | ||
37 | |||
38 | |||
39 | # It works but... | ||
40 | |||
41 | |||
42 | ## The init problem | ||
43 | |||
44 | - init is a shell | ||
45 | - we want to automate some tasks: | ||
46 | - re-mounting the `/` directory in read-write mode | ||
47 | - networking? | ||
48 | - anything our system should do | ||
49 | |||
50 | |||
51 | ## The networking problem | ||
52 | |||
53 | - We want to access the network: | ||
54 | - get updates | ||
55 | - execute our primary function | ||
56 | |||
57 | |||
58 | ## The user problem | ||
59 | |||
60 | users, anyone? | ||
61 | |||
62 | ::: notes | ||
63 | |||
64 | - At no point in our creation of a system we had to create a user, or add | ||
65 | a password | ||
66 | |||
67 | ::: | ||
68 | |||
69 | |||
70 | # Automating tasks | ||
71 | |||
72 | ## Goal | ||
73 | |||
74 | We want to execute programs or code when the system is starting | ||
75 | |||
76 | |||
77 | ## Attempt number 1 | ||
78 | |||
79 | Let's make a shell script | ||
80 | |||
81 | ::: notes | ||
82 | |||
83 | - Instead of just launching a command-line as first program, let's execute some | ||
84 | commands automatically before, and *then* launch the command-line | ||
85 | |||
86 | ::: | ||
87 | |||
88 | |||
89 | ## Attempt number 2 | ||
90 | |||
91 | Let's use SysV-style init | ||
92 | |||
93 | |||
94 | ## SysV-style init | ||
95 | |||
96 | - The init process reads `/etc/inittab` | ||
97 | - Starts processes as specified by this configuration | ||
98 | |||
99 | |||
100 | ## inittab | ||
101 | |||
102 | This file is a series of files in this format: | ||
103 | |||
104 | ```ini | ||
105 | <id>:<runlevels>:<action>:<process> | ||
106 | ``` | ||
107 | |||
108 | ::: notes | ||
109 | |||
110 | Busybox does not support each of these features | ||
111 | |||
112 | ::: | ||
113 | |||
114 | ## inittab (Busybox version) | ||
115 | |||
116 | ```ini | ||
117 | # ,-- out of scope | ||
118 | # | | ||
119 | # vvv | ||
120 | <tty>::<action>:<process> | ||
121 | ``` | ||
122 | |||
123 | `action` can be one of: | ||
124 | |||
125 | - sysinit | ||
126 | : normal process started at boot | ||
127 | - shutdown | ||
128 | : process started before shutting down | ||
129 | - reboot | ||
130 | : process started before rebooting | ||
131 | - ... | ||
132 | |||
133 | ## inittab example | ||
134 | |||
135 | ```ini | ||
136 | # Mount /proc and /sys, and remount / in read-write mode | ||
137 | ::sysinit:/etc/init.d/mount-special-filesystems | ||
138 | |||
139 | # Setup the network | ||
140 | ::sysinit:/etc/init.d/setup-network start | ||
141 | |||
142 | # Start additional services | ||
143 | ::sysinit:/etc/init.d/miniserve start | ||
144 | |||
145 | # ... | ||
146 | ``` | ||
147 | |||
148 | ::: notes | ||
149 | |||
150 | - Note the start argument in the two last services | ||
151 | |||
152 | ::: | ||
153 | |||
154 | ## Changing to SysV-style init | ||
155 | |||
156 | We just have to change the `init=` kernel parameter to Busybox's `init`. | ||
157 | |||
158 | ## The long-running processes problem | ||
159 | |||
160 | - We need to launch long-running processes in the background | ||
161 | - We also need a way to stop them | ||
162 | |||
163 | ::: notes | ||
164 | |||
165 | - We might want to stop a process if something goes wrong, if we want to modify | ||
166 | the configuration, etc. | ||
167 | |||
168 | ::: | ||
169 | |||
170 | |||
171 | ## The `start-stop-daemon` command | ||
172 | |||
173 | Can do multiple things: | ||
174 | |||
175 | - Start a process in a background | ||
176 | - Start a process as a different user | ||
177 | - Write the PID of the launched process into a file (called a "PID file") | ||
178 | - Kill a process with a PID file | ||
179 | |||
180 | :::notes | ||
181 | |||
182 | - We don't have our users figured out yet | ||
183 | - Reminder, this is still the old/light way of doing things, so you might not | ||
184 | have this command on your Linux | ||
185 | |||
186 | ::: | ||
187 | |||
188 | |||
189 | ## Example service script | ||
190 | |||
191 | ```sh | ||
192 | #!/bin/sh | ||
193 | |||
194 | PIDFILE="/var/run/myprogram.pid" | ||
195 | |||
196 | case "$1" in | ||
197 | start) | ||
198 | start-stop-daemon -S -p "$PIDFILE" -m -b \ | ||
199 | -x myprogram -- args... | ||
200 | ;; | ||
201 | stop) | ||
202 | start-stop-daemon -K -p "$PIDFILE" | ||
203 | ;; | ||
204 | esac | ||
205 | ``` | ||
206 | |||
207 | # Networking | ||
208 | |||
209 | ## What's in an IP packet | ||
210 | |||
211 | ![Anatomy of an IP packet[@corkami:rfc791]](../res/rfc791.png){ height=80% } | ||
212 | |||
213 | ::: notes | ||
214 | |||
215 | - From this, we can conclude that we need an IP address for every packet sent | ||
216 | over IP | ||
217 | |||
218 | - Also, we see that we cannot contact a server through it's domain name (like | ||
219 | google.com), we have to use IP addresses | ||
220 | |||
221 | ::: | ||
222 | |||
223 | ## A home network | ||
224 | |||
225 | ![Home network example[@wikimedia:network1]](../res/home-network.jpg){ height=80% } | ||
226 | |||
227 | ## Some definitions | ||
228 | |||
229 | - IP address | ||
230 | : Identifier that allows you to get messages/packets | ||
231 | - Subnet | ||
232 | : A defined subset of all IP addresses. For example 192.168.1.0/24 means all IP | ||
233 | addresses from 192.168.1.0 to 192.168.1.255 | ||
234 | - Router | ||
235 | : Machine that connects one subnet to another. Usually, it is the subnet of | ||
236 | your home, to the global internet | ||
237 | - Gateway | ||
238 | : A machine where you send your internet packets, so that they are transferred | ||
239 | to the "real" recipient. It is usually your router. | ||
240 | |||
241 | ::: notes | ||
242 | |||
243 | - The `/24` in the example subnet is what we call a "mask" | ||
244 | |||
245 | It is nice to have a postal mail analogy. In this case: | ||
246 | |||
247 | - IP address is your home address | ||
248 | - Subnet is your town name, street name | ||
249 | - Router and gateway would be your postman company (La Poste, UPS, Fedex, or | ||
250 | whatever) | ||
251 | |||
252 | ::: | ||
253 | |||
254 | ## Network interfaces | ||
255 | |||
256 | - Represent a way to connect to a network | ||
257 | - Stores each: | ||
258 | - One or more IP address | ||
259 | - A subnet | ||
260 | |||
261 | ::: notes | ||
262 | |||
263 | - If you have two Ethernet ports, you could connect to two different networks | ||
264 | - In this example you would have one interface for each of your Ethernet port | ||
265 | - And maybe one more interface for your WiFi connection, if you have the | ||
266 | hardware for it | ||
267 | |||
268 | ::: | ||
269 | |||
270 | ## What you need to connect to a network | ||
271 | |||
272 | - An IP address | ||
273 | - The subnet of your network | ||
274 | - A gateway, if you want to connect your network to other networks, like the | ||
275 | world wide web | ||
276 | - A DNS server's IP address, if you want to resolve host names, like | ||
277 | <http://example.com> | ||
278 | |||
279 | ## Configuring a network interface | ||
280 | |||
281 | - The static way | ||
282 | - The dynamic way | ||
283 | |||
284 | ::: notes | ||
285 | |||
286 | - The static way is simpler to configure, but you have to know in advance the | ||
287 | device that are going to connect to your network, and have a static IP | ||
288 | address for all of them | ||
289 | - You also have to know in advance the subnet and IP address of your router | ||
290 | |||
291 | - The dynamic way is the one that you use on your personal computers | ||
292 | - This is the mode were you try to ask for all these parameters | ||
293 | |||
294 | ::: | ||
295 | |||
296 | ## The static way | ||
297 | |||
298 | ```sh | ||
299 | # Set the IP address and subnet | ||
300 | ip addr add $ip/$mask dev $interface | ||
301 | # Activate this interface | ||
302 | ip link set $interface up | ||
303 | # Set the default gateway | ||
304 | ip route add default via $gateway dev $interface | ||
305 | # Add the default DNS server | ||
306 | echo "nameserver $nameserver_ip" >> /etc/resolv.conf | ||
307 | ``` | ||
308 | |||
309 | ::: notes | ||
310 | |||
311 | For QEMU's defaults: | ||
312 | |||
313 | - `busybox ip addr add 10.0.2.42/24 dev eth0` | ||
314 | - `busybox ip link set eth0 up` | ||
315 | - `busybox ip route add default via 10.0.2.2 dev eth0` | ||
316 | - `echo "nameserver 10.0.2.3" >> /etc/resolv.conf` | ||
317 | |||
318 | ::: | ||
319 | |||
320 | ## The dynamic way | ||
321 | |||
322 | - DHCP for the win! | ||
323 | - meaning Dynamic Host Configuration Protocol | ||
324 | |||
325 | . . . | ||
326 | |||
327 | - we need a DHCP client on our machine and a DHCP server on the network | ||
328 | |||
329 | ::: notes | ||
330 | |||
331 | DHCP is a protocol that allows us to get all of this information: | ||
332 | |||
333 | - A new, unused IP address | ||
334 | - The subnet of the network | ||
335 | - The address of the gateway | ||
336 | - The address of the DNS server | ||
337 | |||
338 | ::: | ||
339 | |||
340 | ## DHCP overview | ||
341 | |||
342 | ![DHCP overview[@wikimedia:dhcp]](../res/DHCP_session.png){ height=80% } | ||
343 | |||
344 | ## Implementation | ||
345 | |||
346 | - Here we can use the `udhcpc` command of Busybox | ||
347 | |||
348 | # Users | ||
349 | |||
350 | ## Current status | ||
351 | |||
352 | Right now we have none | ||
353 | |||
354 | ::: notes | ||
355 | |||
356 | Do a `ls -l` on the machine | ||
357 | |||
358 | ::: | ||
359 | |||
360 | |||
361 | ## The passwd file | ||
362 | |||
363 | Each line of `/etc/passwd` contains: | ||
364 | |||
365 | - Login name (what we were missing) | ||
366 | - Field unused today (was the password, but it got moved to another file) | ||
367 | - Numerical ID of the user | ||
368 | - Numerical ID of the main group for user | ||
369 | - User name or comment | ||
370 | - Home directory | ||
371 | - Optional default shell | ||
372 | |||
373 | ## Example | ||
374 | |||
375 | ```ini | ||
376 | # ,--- tells that the password is in another file | ||
377 | # | | ||
378 | # v | ||
379 | root:x:0:0:System administrator:/root:/bin/sh | ||
380 | ``` | ||
381 | |||
382 | ## Login "screen" | ||
383 | |||
384 | - Now we can add one to the `inittab` | ||
385 | - This is the `getty` command of `busybox` | ||
386 | |||
387 | # References | ||
diff --git a/2020-10-06.md b/2020-10-06.md new file mode 100644 index 0000000..31133e4 --- /dev/null +++ b/2020-10-06.md | |||
@@ -0,0 +1,119 @@ | |||
1 | --- | ||
2 | title: WTF is Linux | ||
3 | author: Rémi Nicole <remi.nicole@smile.fr> | ||
4 | date: 2020-10-06 | ||
5 | slide-level: 2 | ||
6 | aspectratio: 169 | ||
7 | |||
8 | theme: metropolis | ||
9 | colortheme: owl | ||
10 | beameroption: "show notes on second screen=right" | ||
11 | |||
12 | toc: true | ||
13 | highlightstyle: breezedark | ||
14 | lang: en-US | ||
15 | |||
16 | bibliography: ../bibliography.bib | ||
17 | --- | ||
18 | |||
19 | # Before we get started | ||
20 | |||
21 | ## Practical work practicalities | ||
22 | |||
23 | - One or two group is going to have only 1 Raspberry | ||
24 | - SD card readers are provided | ||
25 | |||
26 | # Buildroot | ||
27 | |||
28 | ## Overview | ||
29 | |||
30 | { height=80% } | ||
31 | |||
32 | ## Single-project process | ||
33 | |||
34 | { height=80% } | ||
35 | |||
36 | ## Overall process | ||
37 | |||
38 | { height=80% } | ||
39 | |||
40 | ## Configuring Buildroot | ||
41 | |||
42 | - Same as the Linux kernel | ||
43 | - Allows you to set: | ||
44 | - Target architecture | ||
45 | - Target packages | ||
46 | - Build options | ||
47 | - ... | ||
48 | |||
49 | ## Default configuration | ||
50 | |||
51 | - To list available default configurations: | ||
52 | - `make list-defconfigs` | ||
53 | - To set the configurations as one of the default: | ||
54 | - `make <configuration>_defconfig` | ||
55 | |||
56 | ::: notes | ||
57 | |||
58 | We're going to use `raspberrypi2_defconfig` | ||
59 | |||
60 | ::: | ||
61 | |||
62 | |||
63 | ## Hierarchy of a Buildroot project | ||
64 | |||
65 | - package/ | ||
66 | : All the available packages | ||
67 | - toolchain/ | ||
68 | : Packages for building stuff | ||
69 | - linux/ | ||
70 | : The Linux kernel package | ||
71 | - system/skeleton/ | ||
72 | : The skeleton of the target Linux system | ||
73 | - board/ | ||
74 | : All the board-specific files | ||
75 | - docs/ | ||
76 | : The documentation of Buildroot | ||
77 | - And other things | ||
78 | |||
79 | ::: notes | ||
80 | |||
81 | By board-specific files, we can mean: kernel config & patches, scripts, etc. | ||
82 | |||
83 | ::: | ||
84 | |||
85 | ## Hierarchy of a Buildroot output | ||
86 | |||
87 | Everything into `output/` | ||
88 | |||
89 | - images/ | ||
90 | : The images to flash | ||
91 | - target/ | ||
92 | : The target root filesystem | ||
93 | - And other things | ||
94 | |||
95 | ## Demo time | ||
96 | |||
97 | - _[Raspberry PI 2's pins](https://www.electronicwings.com/public/images/user_images/images/Raspberry%20Pi/RaspberryPi_UART/Raspberry%20pi%203%20UART%20pins.png)_ | ||
98 | - _[Serial cable's datasheet](https://docs.rs-online.com/12f1/0900766b811b9e83.pdf)_ page 7 | ||
99 | |||
100 | ::: notes | ||
101 | |||
102 | - Show Buildroot's download page | ||
103 | - Go to extracted Buildroot directory | ||
104 | - Show available defconfigs | ||
105 | - Use `raspberrypi2_defconfig` | ||
106 | - `make all` | ||
107 | - Show output directory | ||
108 | - Flash image on sdcard | ||
109 | - Put sdcard on raspberry pi | ||
110 | - Show | ||
111 | - Boot raspberry | ||
112 | |||
113 | ::: | ||
114 | |||
115 | # Installing GNU/Linux | ||
116 | |||
117 | |||
118 | |||
119 | # References | ||
diff --git a/2020-10-13.md b/2020-10-13.md new file mode 100644 index 0000000..f8a67f4 --- /dev/null +++ b/2020-10-13.md | |||
@@ -0,0 +1,432 @@ | |||
1 | --- | ||
2 | title: WTF is Linux | ||
3 | author: Rémi Nicole <remi.nicole@smile.fr> | ||
4 | date: 2020-10-13 | ||
5 | slide-level: 2 | ||
6 | aspectratio: 169 | ||
7 | |||
8 | theme: metropolis | ||
9 | colortheme: owl | ||
10 | beameroption: "show notes on second screen=right" | ||
11 | |||
12 | toc: true | ||
13 | highlightstyle: breezedark | ||
14 | lang: en-US | ||
15 | |||
16 | bibliography: ../bibliography.bib | ||
17 | --- | ||
18 | |||
19 | # Makefile primer | ||
20 | |||
21 | ## Goal | ||
22 | |||
23 | Make is a tool to create files | ||
24 | |||
25 | |||
26 | ::: notes | ||
27 | |||
28 | A Makefile is a file that will direct Make on how to create these files | ||
29 | |||
30 | ::: | ||
31 | |||
32 | ## Concepts---Rules[^rule-intro] | ||
33 | |||
34 | Target | ||
35 | : Usually the name of a file/directory that this rule creates | ||
36 | |||
37 | Prerequisites | ||
38 | : The files/directories that are needed to produce the target | ||
39 | |||
40 | Recipe | ||
41 | : The commands to execute in order to create the target | ||
42 | |||
43 | ```make | ||
44 | my_executable: source_1.c source_2.c | ||
45 | gcc source_1.c source_2.c -o my_executable | ||
46 | ``` | ||
47 | |||
48 | [^rule-intro]: <https://www.gnu.org/software/make/manual/make.html#Rules> | ||
49 | |||
50 | ::: notes | ||
51 | |||
52 | - The target can also be an action, but it is rarer | ||
53 | - If one of the prerequisite changes, Make figures out that the target needs to | ||
54 | be created again | ||
55 | |||
56 | ::: | ||
57 | |||
58 | ## Concepts---Variables[^variables] | ||
59 | |||
60 | Very similar to shell variables, but use `$(VAR)` to expand it. | ||
61 | |||
62 | ```make | ||
63 | MY_SOURCES = source_1.c source_2.c | ||
64 | |||
65 | my_executable: $(MY_SOURCES) | ||
66 | gcc $(MY_SOURCES) -o my_executable | ||
67 | ``` | ||
68 | |||
69 | [^variables]: <https://www.gnu.org/software/make/manual/make.html#Using-Variables> | ||
70 | |||
71 | ## Concepts---Implicit Variables[^implicit-variables] | ||
72 | |||
73 | Some variables are set implicitly by Make, for example: | ||
74 | |||
75 | `$(CC)`{.no_minted} | ||
76 | : The C compiler | ||
77 | |||
78 | `$(CXX)`{.no_minted} / `$(CPP)`{.no_minted} | ||
79 | : The C++ compiler | ||
80 | |||
81 | `$(RM)`{.no_minted} | ||
82 | : The `rm -f` command | ||
83 | |||
84 | `$(MAKE)`{.no_minted} | ||
85 | : The `make` command | ||
86 | |||
87 | [^implicit-variables]: <https://www.gnu.org/software/make/manual/make.html#Implicit-Variables> | ||
88 | |||
89 | ::: notes | ||
90 | |||
91 | Yes, you can call "make" inside of a Makefile | ||
92 | |||
93 | ::: | ||
94 | |||
95 | ## Concepts--Automatic Variables[^automatic-variables] | ||
96 | |||
97 | Some variables are set automatically per-rule, for example: | ||
98 | |||
99 | `$@`{.no_minted} | ||
100 | : The target of the current rule | ||
101 | |||
102 | `$<`{.no_minted} | ||
103 | : The first prerequisite of the current rule | ||
104 | |||
105 | `$^`{.no_minted} | ||
106 | : All prerequisites of the current rule | ||
107 | |||
108 | ... | ||
109 | |||
110 | [^automatic-variables]: <https://www.gnu.org/software/make/manual/make.html#Automatic-Variables> | ||
111 | |||
112 | ## Our example redone | ||
113 | |||
114 | ```make | ||
115 | MY_SOURCES = source_1.c source_2.c | ||
116 | |||
117 | my_executable: $(MY_SOURCES) | ||
118 | $(CC) $^ -o $@ | ||
119 | ``` | ||
120 | |||
121 | ## Relation with Buildroot | ||
122 | |||
123 | Buildroot uses Makefiles to: | ||
124 | |||
125 | - Figure out which packages to (re-)compile | ||
126 | - How to compile them | ||
127 | - Create the outputs (images, root filesystem, etc.) in general. | ||
128 | |||
129 | But it is heavily abstracted | ||
130 | |||
131 | # Setting up Buildroot for our modifications | ||
132 | |||
133 | ## For additional packages | ||
134 | |||
135 | - We create the directory `package/<company>` | ||
136 | - We put our additional packages in it | ||
137 | - We create the `my_company.mk` and `Config.in` files[^adding-project-specific-packages] | ||
138 | - And include the new `Config.in` in `package/Config.in` | ||
139 | |||
140 | [^adding-project-specific-packages]: | ||
141 | <https://buildroot.org/downloads/manual/manual.html#customize-packages> | ||
142 | |||
143 | ## Packages Makefile | ||
144 | |||
145 | ```makefile | ||
146 | include $(sort $(wildcard package/my_company/*/*.mk)) | ||
147 | ``` | ||
148 | |||
149 | ## Packages configuration file | ||
150 | |||
151 | In `package/my_company/Config.in`: | ||
152 | |||
153 | ```kconfig | ||
154 | source "package/my_company/my_package1/Config.in" | ||
155 | source "package/my_company/my_package2/Config.in" | ||
156 | source "package/my_company/.../Config.in" | ||
157 | # ... | ||
158 | ``` | ||
159 | |||
160 | ## Packages configuration file inclusion | ||
161 | |||
162 | In `package/Config.in`: | ||
163 | |||
164 | ```kconfig | ||
165 | # ---8<--- Rest of the configuration | ||
166 | |||
167 | # We add our own packages in our own submenu | ||
168 | menu "My Company packages" | ||
169 | # We just created this file | ||
170 | source "package/my_company/Config.in" | ||
171 | endmenu | ||
172 | |||
173 | endmenu # <-- Was here before, it's the "Target packages" submenu | ||
174 | ``` | ||
175 | |||
176 | ## For everything else | ||
177 | |||
178 | - We create the directory `board/<company>/<board>` | ||
179 | - We put our additional files, patches, configurations, scripts, etc. in it | ||
180 | |||
181 | ::: notes | ||
182 | |||
183 | In our case, the board would be `raspberrypi2`. | ||
184 | |||
185 | ::: | ||
186 | |||
187 | # Adding single files | ||
188 | |||
189 | ## Overlays | ||
190 | |||
191 | A file hierarchy from the root directory that is going to get copied on top of | ||
192 | the built system | ||
193 | |||
194 | Can be used for: | ||
195 | |||
196 | - Startup scripts | ||
197 | - Program configuration files | ||
198 | - Files containing data (like sound) | ||
199 | |||
200 | ::: notes | ||
201 | |||
202 | However, if a startup script, configuration file, or data file is tied to | ||
203 | a given package, it is usually better to install it with the package, instead | ||
204 | of using an overlay. | ||
205 | |||
206 | Overlays are more meant for files that are not tied to any specific package. | ||
207 | |||
208 | ::: | ||
209 | |||
210 | ## How to add an overlay | ||
211 | |||
212 | - Create the directory `board/<company>/<board>/rootfs_overlay` | ||
213 | - Add your file in that directory, as if it were the root directory | ||
214 | - Configure Buildroot (`make menuconfig`) and set | ||
215 | `BR2_ROOTFS_OVERLAY`[^overlay-config] to | ||
216 | `board/<company>/<board>/rootfs-overlay`. | ||
217 | |||
218 | [^overlay-config]: | ||
219 | Under "System configuration", "Root filesystem overlay directories" | ||
220 | |||
221 | # Adding packages | ||
222 | |||
223 | ## Packages---Structure | ||
224 | |||
225 | - Create the directory `package/<company>/<my-package>/` | ||
226 | - Create the file `package/<company>/<my-package>/Config.in`[^config-files] | ||
227 | - Create the file `package/<company>/<my-package>/<my-package>.mk`[^mk-files] | ||
228 | |||
229 | [^config-files]: <https://buildroot.org/downloads/manual/manual.html#_config_files> | ||
230 | |||
231 | [^mk-files]: <https://buildroot.org/downloads/manual/manual.html#_the_literal_mk_literal_file> | ||
232 | |||
233 | <!-- _____ --> | ||
234 | |||
235 | ::: notes | ||
236 | |||
237 | - The `Config.in` will allow Buildroot to add an option to install your | ||
238 | package. This will also specify your dependencies (what is needed to build or | ||
239 | run your package). | ||
240 | - The `<my-package>.mk` is a Makefile which instructs how to compile and | ||
241 | install your package. | ||
242 | |||
243 | ::: | ||
244 | |||
245 | ## Packages---Configuration | ||
246 | |||
247 | Example configuration: | ||
248 | |||
249 | ```kconfig | ||
250 | config BR2_PACKAGE_DUMMY_PACKAGE | ||
251 | bool "dummy package" | ||
252 | default n | ||
253 | depends on BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_BASH | ||
254 | help | ||
255 | A dummy package for demonstration purposes | ||
256 | ``` | ||
257 | |||
258 | ## Packages---Makefile | ||
259 | |||
260 | Example Makefile configuration: | ||
261 | |||
262 | ```makefile | ||
263 | define DUMMY_PACKAGE_INSTALL_TARGET_CMDS | ||
264 | $(INSTALL) -m 0755 -D \ | ||
265 | $(DUMMY_PACKAGE_PKGDIR)/dummy_script.sh \ | ||
266 | $(TARGET_DIR)/usr/bin | ||
267 | endef | ||
268 | |||
269 | $(eval $(generic-package)) | ||
270 | ``` | ||
271 | |||
272 | ::: notes | ||
273 | |||
274 | - This "package" just installs a script that is in the same directory of the | ||
275 | `.mk` file | ||
276 | - It is important that all variables | ||
277 | |||
278 | ::: | ||
279 | |||
280 | ## Packages---More generic Makefile{.allowframebreaks} | ||
281 | |||
282 | ```makefile | ||
283 | LIBFOO_VERSION = 1.0 | ||
284 | LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz | ||
285 | LIBFOO_SITE = http://www.foosoftware.org/download | ||
286 | LIBFOO_LICENSE = GPL-3.0+ | ||
287 | LIBFOO_CONFIG_SCRIPTS = libfoo-config | ||
288 | LIBFOO_DEPENDENCIES = host-libaaa libbbb | ||
289 | |||
290 | # ---8<--- | ||
291 | ``` | ||
292 | |||
293 | \framebreak | ||
294 | |||
295 | If your package uses Makefiles to be built: | ||
296 | |||
297 | ```makefile | ||
298 | # ---8<--- | ||
299 | |||
300 | define LIBFOO_BUILD_CMDS | ||
301 | $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) all | ||
302 | endef | ||
303 | |||
304 | # ---8<--- | ||
305 | ``` | ||
306 | |||
307 | `$(@D)`{.makefile} is the directory containing the downloaded sources. | ||
308 | |||
309 | \framebreak | ||
310 | |||
311 | ```makefile | ||
312 | define LIBFOO_INSTALL_TARGET_CMDS | ||
313 | $(MAKE) \ | ||
314 | $(TARGET_CONFIGURE_OPTS) PREFIX=$(TARGET_DIR)/usr \ | ||
315 | -C $(@D) \ | ||
316 | install | ||
317 | # Or... | ||
318 | $(INSTALL) -D -m 0755 $(@D)/libfoo.so* $(TARGET_DIR)/usr/lib | ||
319 | $(INSTALL) -d -m 0755 $(TARGET_DIR)/etc/foo.d | ||
320 | endef | ||
321 | |||
322 | $(eval $(generic-packages)) | ||
323 | ``` | ||
324 | |||
325 | ::: notes | ||
326 | |||
327 | - In this instances, our package is called "libfoo" | ||
328 | - `TARGET_CONFIGURE_OPTS` sets options like the compiler to use, the | ||
329 | compilation flags and other things | ||
330 | |||
331 | ::: | ||
332 | |||
333 | ## Packages---Notes | ||
334 | |||
335 | - This was for a "generic package" | ||
336 | - For package using common build frameworks (e.g. python, autotools, cmake, | ||
337 | etc.), some things are already done for you[^mk-files] | ||
338 | - Don't forget to include the package's `Config.in` in | ||
339 | `package/my_company/Config.in` | ||
340 | |||
341 | # Adding a service | ||
342 | |||
343 | ## Buildroot's Busybox init | ||
344 | |||
345 | Every script or executable that is named like `/etc/init.d/S<something>` is | ||
346 | going to be started on boot | ||
347 | |||
348 | Two solutions then: | ||
349 | |||
350 | - Add a script to the overlay (if not tied to one of your own package) | ||
351 | - Install it with your package in the `<PACKAGE>_INSTALL_TARGET_CMDS` | ||
352 | |||
353 | # Adding users | ||
354 | |||
355 | ## Using the board directory | ||
356 | |||
357 | - Create the file `board/<company>/<board>/users.txt`[^adding-users] | ||
358 | - Fill it with lines using the "makeusers" syntax[^makeusers-syntax] | ||
359 | - Set `BR2_ROOTFS_USERS_TABLES`[^users-conf] to `board/<company>/<board>/users.tx` | ||
360 | |||
361 | [^adding-users]: <https://buildroot.org/downloads/manual/manual.html#customize-users> | ||
362 | |||
363 | [^makeusers-syntax]: <https://buildroot.org/downloads/manual/manual.html#makeuser-syntax> | ||
364 | |||
365 | [^users-conf]: Under "System Configuration", "Path to the users tables" | ||
366 | |||
367 | ## Using the board directory---Example | ||
368 | |||
369 | ```kconfig | ||
370 | # ,---------------------- name | ||
371 | # | ,------------- group | ||
372 | # | | ,------ password | ||
373 | # | | | | ||
374 | # vvv vvvvvv v | ||
375 | foo -1 libfoo -1 * - - - LibFoo daemon | ||
376 | # ^^ ^^ ^^^^^^^^^^^^^ | ||
377 | # | | | | ||
378 | # | | '--- comment | ||
379 | # | '------------------- GID | ||
380 | # '----------------------------- UID | ||
381 | ``` | ||
382 | |||
383 | ::: notes | ||
384 | |||
385 | - If UID or GID is "-1", buildroot will select an unused number | ||
386 | - If password is "\*", then there is no password you cannot login as this user | ||
387 | (but you can still execute programs as this user) | ||
388 | |||
389 | ::: | ||
390 | |||
391 | ## In a package | ||
392 | |||
393 | Inside the `.mk` file. | ||
394 | |||
395 | ```makefile | ||
396 | define LIBFOO_USERS | ||
397 | foo -1 libfoo -1 * - - - LibFoo daemon | ||
398 | endef | ||
399 | ``` | ||
400 | |||
401 | # Saving the configuration | ||
402 | |||
403 | ## Why it is important | ||
404 | |||
405 | - Right now, every modification to the configuration (added packages, overlay, | ||
406 | etc.) is only in the build directory | ||
407 | - We want to save it so that people cloning our modified Buildroot can have the | ||
408 | same configuration | ||
409 | - Please often verify that your modifications are saved by deleting your | ||
410 | `output` directory, or downloading and compiling or project again. | ||
411 | |||
412 | ::: notes | ||
413 | |||
414 | - This is necessary for me (the reviewer) since I want to build exactly what you | ||
415 | have. | ||
416 | |||
417 | ::: | ||
418 | |||
419 | ## How to save the Buildroot configuration | ||
420 | |||
421 | Once you have done your configuration of Buildroot (`make menuconfig`), execute | ||
422 | these commands: | ||
423 | |||
424 | - Make sure the `BR2_DEFCONFIG` option[^defconfig-option] is set to | ||
425 | `configs/<my_company_board>_defconfig` | ||
426 | - Execute `make savedefconfig` to save it | ||
427 | |||
428 | And commit your changes | ||
429 | |||
430 | [^defconfig-option]: Under "Build options", "Location to save buildroot config" | ||
431 | |||
432 | # References | ||
@@ -4,7 +4,10 @@ MARKDOWN_FILES := $(wildcard *.md) | |||
4 | TEX_FILES := $(patsubst %.md,build/%.tex,$(MARKDOWN_FILES)) | 4 | TEX_FILES := $(patsubst %.md,build/%.tex,$(MARKDOWN_FILES)) |
5 | PDF_FILES := $(patsubst %.md,build/%.pdf,$(MARKDOWN_FILES)) | 5 | PDF_FILES := $(patsubst %.md,build/%.pdf,$(MARKDOWN_FILES)) |
6 | 6 | ||
7 | .SECONDARY: $(TEX_FILES) | 7 | PLANTUML_FILES := $(wildcard res/plantuml/*.plantuml) |
8 | PLANTUML_OUTPUTS := $(patsubst %.plantuml,build/%.png,$(PLANTUML_FILES)) | ||
9 | |||
10 | .SECONDARY: $(TEX_FILES) $(PLANTUML_OUTPUTS) | ||
8 | 11 | ||
9 | all: $(PDF_FILES) | 12 | all: $(PDF_FILES) |
10 | 13 | ||
@@ -14,6 +17,9 @@ clean: | |||
14 | build: | 17 | build: |
15 | mkdir -p build | 18 | mkdir -p build |
16 | 19 | ||
20 | build/res/plantuml: | ||
21 | mkdir -p build/res/plantuml | ||
22 | |||
17 | lua-filters/minted/minted.lua: | 23 | lua-filters/minted/minted.lua: |
18 | git submodule update --init | 24 | git submodule update --init |
19 | 25 | ||
@@ -26,7 +32,7 @@ build/%.tex: %.md build beamer-template.tex lua-filters/minted/minted.lua | |||
26 | --biblatex \ | 32 | --biblatex \ |
27 | -so "$@" | 33 | -so "$@" |
28 | 34 | ||
29 | build/%.pdf: build/%.tex bibliography.bib | 35 | build/%.pdf: build/%.tex bibliography.bib $(PLANTUML_OUTPUTS) |
30 | cd build; latexmk \ | 36 | cd build; latexmk \ |
31 | -xelatex \ | 37 | -xelatex \ |
32 | -interaction=nonstopmode \ | 38 | -interaction=nonstopmode \ |
@@ -36,3 +42,6 @@ build/%.pdf: build/%.tex bibliography.bib | |||
36 | -output-directory=./build \ | 42 | -output-directory=./build \ |
37 | "$*.tex" | 43 | "$*.tex" |
38 | cp build/build/$*.pdf build | 44 | cp build/build/$*.pdf build |
45 | |||
46 | build/res/plantuml/%.png: res/plantuml/%.plantuml build/res/plantuml | ||
47 | PLANTUML_LIMIT_SIZE=8192 plantuml -tpng "$<" -o "$(PWD)/build/res/plantuml" | ||
diff --git a/bibliography.bib b/bibliography.bib index df9700c..9b18999 100644 --- a/bibliography.bib +++ b/bibliography.bib | |||
@@ -84,3 +84,24 @@ | |||
84 | url = "https://commons.wikimedia.org/wiki/File:GUID_Partition_Table_Scheme.svg", | 84 | url = "https://commons.wikimedia.org/wiki/File:GUID_Partition_Table_Scheme.svg", |
85 | } | 85 | } |
86 | 86 | ||
87 | @misc{ corkami:rfc791, | ||
88 | title = "RFC791", | ||
89 | year = "2017", | ||
90 | author = "corkami", | ||
91 | url = "https://github.com/corkami/pics/blob/master/tracing/rfc791.pdf", | ||
92 | } | ||
93 | |||
94 | @misc{ wikimedia:network1, | ||
95 | title = "Network1", | ||
96 | year = "2017", | ||
97 | author = "Tsedenjav.Sh", | ||
98 | url = "https://commons.wikimedia.org/wiki/File:Network1.jpg", | ||
99 | } | ||
100 | |||
101 | @misc{ wikimedia:dhcp, | ||
102 | title = "DHCP session", | ||
103 | year = "2015", | ||
104 | author = "Gelmo96", | ||
105 | url = "https://commons.wikimedia.org/wiki/File:DHCP_session.svg", | ||
106 | } | ||
107 | |||
diff --git a/res/DHCP_session.png b/res/DHCP_session.png new file mode 100644 index 0000000..60aada9 --- /dev/null +++ b/res/DHCP_session.png | |||
Binary files differ | |||
diff --git a/res/home-network.jpg b/res/home-network.jpg new file mode 100644 index 0000000..d2cfe38 --- /dev/null +++ b/res/home-network.jpg | |||
Binary files differ | |||
diff --git a/res/plantuml/buildroot-overview.plantuml b/res/plantuml/buildroot-overview.plantuml new file mode 100644 index 0000000..1b1277d --- /dev/null +++ b/res/plantuml/buildroot-overview.plantuml | |||
@@ -0,0 +1,34 @@ | |||
1 | @startuml | ||
2 | |||
3 | left to right direction | ||
4 | |||
5 | skinparam backgroundcolor transparent | ||
6 | skinparam component { | ||
7 | borderColor black | ||
8 | arrowColor #FA8100 | ||
9 | } | ||
10 | skinparam package { | ||
11 | backgroundcolor white | ||
12 | } | ||
13 | |||
14 | [Buildroot] #B794F6 | ||
15 | |||
16 | package "External projects" { | ||
17 | [coreutils\n(ls, cp, mkdir, ...)] as coreutils #C6F68D | ||
18 | [util-linux\n(mount, mkfs, ...)] as utillinux #C6F68D | ||
19 | [Other projects...] as other_projects #C6F68D | ||
20 | } | ||
21 | |||
22 | package "Outputs" { | ||
23 | [Flashable image] as image #F186C0 | ||
24 | [Other outputs...] as other_outputs #F186C0 | ||
25 | } | ||
26 | |||
27 | coreutils --> Buildroot | ||
28 | utillinux --> Buildroot | ||
29 | other_projects --> Buildroot | ||
30 | |||
31 | Buildroot --> image | ||
32 | Buildroot --> other_outputs | ||
33 | |||
34 | @enduml | ||
diff --git a/res/plantuml/buildroot-process.plantuml b/res/plantuml/buildroot-process.plantuml new file mode 100644 index 0000000..8fea3fe --- /dev/null +++ b/res/plantuml/buildroot-process.plantuml | |||
@@ -0,0 +1,41 @@ | |||
1 | @startuml | ||
2 | |||
3 | left to right direction | ||
4 | |||
5 | skinparam backgroundcolor transparent | ||
6 | skinparam component { | ||
7 | borderColor black | ||
8 | arrowColor #FA8100 | ||
9 | } | ||
10 | skinparam package { | ||
11 | backgroundcolor white | ||
12 | } | ||
13 | |||
14 | package "External projects" #C6F68D { | ||
15 | [...] as project1 | ||
16 | [...] as project2 | ||
17 | [...] as project3 | ||
18 | } | ||
19 | |||
20 | package "Buildroot" #B794F6 { | ||
21 | [build build tools\n(host)] as host_build | ||
22 | [build wanted projects\n(target)] as target_build | ||
23 | [post-build script] as post_build | ||
24 | [assemble the installation directory] as assemble | ||
25 | } | ||
26 | |||
27 | package "Outputs" { | ||
28 | [Flashable image] as image #F186C0 | ||
29 | [Other outputs...] as other_outputs #F186C0 | ||
30 | } | ||
31 | |||
32 | project1 --> host_build | ||
33 | project3 --> target_build | ||
34 | |||
35 | host_build -left-> target_build | ||
36 | target_build --> post_build | ||
37 | post_build -right-> assemble | ||
38 | assemble --> image | ||
39 | assemble --> other_outputs | ||
40 | |||
41 | @enduml | ||
diff --git a/res/plantuml/buildroot-project.plantuml b/res/plantuml/buildroot-project.plantuml new file mode 100644 index 0000000..e2e48cf --- /dev/null +++ b/res/plantuml/buildroot-project.plantuml | |||
@@ -0,0 +1,41 @@ | |||
1 | @startuml | ||
2 | |||
3 | left to right direction | ||
4 | |||
5 | skinparam backgroundcolor transparent | ||
6 | skinparam component { | ||
7 | borderColor black | ||
8 | arrowColor #FA8100 | ||
9 | } | ||
10 | skinparam package { | ||
11 | backgroundcolor white | ||
12 | } | ||
13 | |||
14 | package "External projects" #C6F68D { | ||
15 | [...] as project1 | ||
16 | [...] as project2 | ||
17 | [...] as project3 | ||
18 | } | ||
19 | |||
20 | package "Buildroot" #B794F6 { | ||
21 | [download] | ||
22 | [check integrity] as checksum | ||
23 | [build] | ||
24 | [install] | ||
25 | } | ||
26 | |||
27 | package "Outputs" { | ||
28 | [Flashable image] as image #F186C0 | ||
29 | [Other outputs...] as other_outputs #F186C0 | ||
30 | } | ||
31 | |||
32 | project1 --> download | ||
33 | |||
34 | download -left-> checksum | ||
35 | checksum --> build | ||
36 | build -right-> install | ||
37 | |||
38 | install --> image | ||
39 | install --> other_outputs | ||
40 | |||
41 | @enduml | ||
diff --git a/res/rfc791.pdf b/res/rfc791.pdf new file mode 100644 index 0000000..da91b92 --- /dev/null +++ b/res/rfc791.pdf | |||
Binary files differ | |||
diff --git a/res/rfc791.png b/res/rfc791.png new file mode 100644 index 0000000..77b836f --- /dev/null +++ b/res/rfc791.png | |||
Binary files differ | |||