星期日, 7月 25, 2021

Broadcom BCM2711 SoC

Broadcom BCM2711 (Quad core Cortex-A72 (ARMv8) 64-bit SoC @ 1.5GHz)

星期日, 7月 18, 2021

Cortex-A72

ARM Cortex-A72 採用 ARMv8-A 64-bit 指令集,3-way decode out-of-order superscalar pipeline,適合作為 SoC 整合 GPU, DSP 等。在 2015 發表,作為 Cortex-A57 後繼者,可節省 20% 電源、或提供多 90% 的效能。

Linux IIO

Linux IIO (Industrial IO) 系統支援的在某方面來說是 ADC/DAC 裝置,包括 Accelerometer、Gyro、IMU、Capacitance to Digital Converter (CDC)、壓力感測、Color, Light and Proximity Sensor、溫度感測、Magnetometers、DDS (Direct Digital Synthesis)、PLL (Phase Locked Loop)、Variable/Programmable Gain Amplifiers (VGA, PGA) 等,彌補 hwmon 和 input 子系統的不足。hwmon 偏向用在風扇速度控制和溫度量測等的低取樣率感測。input 著重在人機互動輸入裝置 -- Keyboard、Mouse、Touch Screen、和搖桿。典型 IIO 裝置是透過 SPI 或 I2C 連結,也包括 DMA 操作的高速同步序列 (McBSP, SPORT) 或並列 (EPI, PPI) 等實作在處理器平台的裝置。

IIO 功能

  • 基本裝置註冊和處理
  • 透過 sysfs polled access
  • Event chrdevs:類似 input 提供 userspace 硬體事件,目前只是一個 polling 存取的事件碼和 timestamp。
  • 支援硬體 ring buffer,有 event chrdev 傳遞類似半滿事件和 access chrdev 讀取資料。
  • 支援 trigger 和軟體 ring buffer (kfifo)

trigger driver

  • iio-trig-gpio Provides support for using GPIO pins as IIO triggers.
  • iio-trig-rtc Provides support for using periodic capable real time clocks as IIO triggers.
  • iio-trig-sysfs Provides support for using SYSFS entry as IIO triggers.
  • iio-trig-bfin-timer Provides support for using a Blackfin timer as IIO triggers.

參考

  1. https://wiki.analog.com/software/linux/docs/iio/iio

星期日, 7月 11, 2021

sFlow

sFlow (sampled flow) 是 L2 packet export 的工業標準,sFlow Agent 提供兩種取樣:

  1. Flow samples:隨機平均每 n 個封包或 application layer operations 取樣 1 次。
  2. counter samples:週期取樣界面計數器。(界面多時比 SNMP polling 有效率。)

包成 sFlow Datagram 送到 sFlow collector (預設 port 6343) 進行分析和回報。

sFlow Datagram 採用 XDR 格式。

參考
  1. https://en.wikipedia.org/wiki/SFlow
  2. https://datatracker.ietf.org/doc/html/rfc3176

星期六, 7月 10, 2021

Ubuntu 出現「System Program Problem Detected」

有系統程式 crash,但還沒到 panic 程度。

crash 回報檔存在 /var/crash 目錄,可移除。

編輯 /etc/default/apport 可關閉 Apport。

參考

  1. https://itsfoss.com/how-to-fix-system-program-problem-detected-ubuntu/

星期日, 7月 04, 2021

Docker

Docker 實作輕量級的作業系統虛擬化解決方案,以 Linux 容器 (LXC) 等技術為基礎,進一步封裝讓使用者不需要去關心容器的管理,使得操作更為簡便。Docker 最初是 dotCloud 公司內部的一個業餘專案,採用 Google 的 Go 語言實作。專案後來加入了 Linux 基金會,以 Apache 2.0 開源。

Docker get started:

  • Build and run an image as a container
  • Share images using Docker Hub
  • Deploy Docker applications using multiple containers with a database
  • Running applications using Docker Compose

scan images for security vulnerabilities.

安裝 Docker (精確地講 Docker Engine):在 Linux 稱 Server,在 macOS/Widnows 稱 Desktop。

  • Docker Server for Linux:提供 x86_64/amd64、arm64/aarch64、和 arm (32-bit) 架構,CentOS、Debian、Fedora、Raspbian、和 Ubuntu 的 .deb/.rpm 套件。
  • Docker Desktop for Widnows。
  • Docker Desktop for macOS amd64。
  • Docker Desktop for macOS arm64
    • 支援 x86 和 ARM 架構不需要複雜的 cross-compilation 開發環境。
    • docker buildx:seamlessly integrate multi-platform builds
    • Docker Hub:identify and share repositories that provide multi-platform images.

Docker Desktop for Linux 會在虛擬電腦下執行,不同於先前的 Linux Docker Engine,images 和 containers 也不適用。

參考

  • 虛擬機器
  • container 是一個隔離的 process. That isolation leverages kernel namespaces and cgroups, features that have been in Linux for a long time. Docker has worked to make these capabilities approachable and easy to use.
  • 來自 Aqua Security 的 Liz Rice 用 Go 語言從頭建立 Container:https://youtu.be/8fi7uSYlOdc

星期六, 7月 03, 2021

Ubuntu Install Docker Engine

支援 x86_64/amd64、armhf、和 arm64 架構。

Docker Engine 是一個 client-server 應用,包括

  • daemon server -- dockerd 和
  • CLI client -- docker,

透過 Docker REST API 溝通。

支援 overlay2、aufs、和 btrfs storage drivers。預設使用 overlay2,如果要用 aufs 需要手動設定。

安裝方式

  • 從 Docker’s repositories 安裝
  • 下載 DEB 檔手動安裝
  • 使用 script 安裝

會建立 docker 群組,但無使用者,需要 sudo 執行 docker 指令。

執行 hello-world image 驗證安裝成功。

sudo docker run hello-world

顯示下列訊息後結束

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:df5f5184104426b65967e016ff2ac0bfcd44ad7899ca3bbcf8e44e4461491a9e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

dockerd 以 root 身份執行,bind to 一個 Unix socket,需要 sudo 才能存取。加入 socker 群組的使用者可免除 sudo。Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

注意安全問題:執行 container 隱含執行 dockerd,只能開給信任的使用者。host 的目錄可共享給 container,例如 host 的 / 目錄,於是 container 可以沒有限制地更動。透過網路存取也要小心,需要加密或限制網域。

自動啟動 dockerd

設定檔:docker.service, containerd.service

參考

  1. https://docs.docker.com/engine/install/ubuntu/
  2. https://docs.docker.com/engine/install/linux-postinstall/
  • 非 root 執行 dockerd (rootless mode)
  • container 可視為應用程式一種標準包裝
  • REST API