contributed by < YLowy
>
使用 Ubuntu 20.10 (Groovy Gorilla)
Learn More →
這邊我下載的是
Raspberry Pi Generic (64-bit ARM) preinstalled server image For modern Raspberry Pi boards (Pi 2, Pi 3 and Pi 4)
.
下載燒錄軟體balenaEtcher
Learn More →
Learn More →
Learn More →
Learn More →
設定新密碼
原始預設密碼 :
login as: ubuntu
password: ubuntu
用 putty 連進此樹梅派
先在此電腦下載 net-tools 以方便先觀察目前 IP
由於目前與實驗室申請 固定 IP,故先對此進行修改,之後可以透過 putty 對此進行 SSH 操作
先以 ifconfig
確認是否有取得 DHCP 給定 IP
生成設定 config 檔案 50-cloud-init.yaml
sudo netplan generate
對於 50-cloud-init.yaml 寫入 IP 設定
ubuntu@ubuntu:~$ cd /etc/netplan/
ubuntu@ubuntu:/etc/netplan$ ls
50-cloud-init.yaml
ubuntu@ubuntu:/etc/netplan$ cat 50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
eth0:
addresses: [192.168.79.95/24]
gateway4: 192.168.79.253
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2
更新 apt-get
sudo apt-get upgrade
sudo apt-get update
下載 openSSH 套件
sudo apt-get install -y openssh-server
以確認 SSH 是已經開啟狀態
sudo service ssh status
ubuntu@ubuntu:/etc/netplan$ sudo service ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-11-25 09:05:09 UTC; 2h 4min ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 1799 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
Main PID: 1811 (sshd)
Tasks: 1 (limit: 4434)
CGroup: /system.slice/ssh.service
└─1811 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Nov 25 09:05:09 ubuntu systemd[1]: Starting OpenBSD Secure Shell server...
Nov 25 09:05:09 ubuntu sshd[1811]: Server listening on 0.0.0.0 port 22.
Nov 25 09:05:09 ubuntu sshd[1811]: Server listening on :: port 22.
Nov 25 09:05:09 ubuntu systemd[1]: Started OpenBSD Secure Shell server.
Nov 25 09:08:20 ubuntu sshd[1883]: Accepted password for ubuntu from 192.168.79.85 port 7044 ssh2
Nov 25 09:08:20 ubuntu sshd[1883]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
Nov 25 11:03:33 ubuntu sshd[2097]: Accepted password for ubuntu from 192.168.79.85 port 8264 ssh2
Nov 25 11:03:33 ubuntu sshd[2097]: pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
透過 PuTTY 嘗試連線
login as: ubuntu
ubuntu@192.168.79.95's password:
Welcome to Ubuntu 20.10 (GNU/Linux 5.8.0-1006-raspi aarch64)
以上可以成功連線至遠端 Raspberry Pi
本篇以 clock 進行操作
Clone the repository
$ git clone git://github.com/lpereira/lwan
$ cd lwan
Create the build directory
$ mkdir build
$ cd build
Build Lwan
$ make
接下對於進行測試 src/samples/clock/clock
進入所建立的 clock 檔案目錄下,按照文件所述建立 clock.conf
及 wwwroot
資料夾
clock.conf
內容使用 lwan.conf
預設內容
# Timeout in seconds to keep a connection alive.
keep_alive_timeout = 15
# Set to true to not print any debugging messages. (Only effective in
# release builds.)
quiet = false
# Set SO_REUSEPORT=1 in the master socket.
reuse_port = false
# Value of "Expires" header. Default is 1 month and 1 week.
expires = 1M 1w
# Number of I/O threads. Default (0) is number of online CPUs.
threads = 0
# Disable HAProxy's PROXY protocol by default. Only enable if needed.
proxy_protocol = false
# Enable straitjacket by default. The `drop_capabilities` option is `true`
# by default. Other options may require more privileges.
straitjacket
listener *:8080 {
serve_files / {
path = ./wwwroot
# When requesting for file.ext, look for a smaller/newer file.ext.gz,
# and serve that instead if `Accept-Encoding: gzip` is in the
# request headers.
serve precompressed files = true
}
}
雖然這邊沒用到,但是套用在原先 lwan.conf
檔案所需求的目錄
mkdir wwwroot
執行在 sample 中的 clock 執行檔 ,使其可以不斷接受服務
ubuntu@ubuntu:~/lwan/lwan/build/src/samples/clock$ ./clock
Loading configuration file: clock.conf
Using 4 threads, maximum 262144 sockets per thread
Listening on http://0.0.0.0:8080
Ready to serve
可以觀察對於一開始遠端 SSH (22) port 以及後來 https (8080) port 的開啟
ylowy@YYCs-MacBook-Air ~ % nmap 192.168.79.95
Starting Nmap 7.91 ( https://nmap.org ) at 2020-11-26 16:41 CST
Nmap scan report for 192.168.79.95
Host is up (0.0028s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
8080/tcp open http-proxy
Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds
在網頁瀏覽器中輸入 192.168.79.95:8080
Debug always make developer sad, especially in a big system. How to debug in Linux Kernel? Tracing In early kernel patch, we have some tracing tools, e.g. strace, gdb. They are all based on the old tracing system call: ptrace. GDB gdb -q test.o strace
Jul 8, 2022refer: https://thenewstack.io/how-io_uring-and-ebpf-will-revolutionize-programming-in-linux/ io_uring Classic IO system call For UDP's receive system call, it can be divided into two stages, wait for data and copy data to user space. Kernel offered the following blocking system calls to deal with file descriptors, be they storage files or sockets: size_t read(int fd, void *buf, size_t count); size_t write(int fd, const void *buf, size_t count);
Jun 15, 20221. uclib vs glib uclib ->https://git.uclibc-ng.org/git/uclibc-ng.git uClibc-ng is a small C library for developing embedded Linux systems. It is much smaller than the GNU C Library, but nearly all applications supported by glibc also work perfectly with uClibc-ng. In strlen() function, the "finding zero in long size string" is different between glib and uclib. See Here //uclib
Jun 6, 2022We often use the strlen(str) function to get the length of the string. This is broad-use, and simply implemented. In C, we cannot consider a string as an object. We need to find the '\0'(NULL) character to determine the end of the string. C11 6.4.5 6. a byte or code of value zero is appended to each multibyte character sequence that results from a string literal or literals. C11 7.1.1 A string is a contiguous sequence of characters terminated by and including the first null character. The term multibyte string is sometimes used instead to emphasize special processing given to multibyte characters contained in the string or to avoid confusion with a wide string. A pointer to a string is a pointer to its initial (lowest addressed)
May 22, 2022or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up