2022年6月7日 星期二

ffmpeg 測試 video4linux2 攝影機 [未成功]

# 取得webcam支援的攝錄格式資訊

sudo ffmpeg \
    -f video4linux2 \
    -list_formats all \
    -i /dev/video0




# 顯示麥克風音效卡

sudo arecord -l




# 開始錄影

sudo ffmpeg \
    -f video4linux2 \
    -vcodec mjpeg \
    -s 1920x1080 \
    -r 30 \
    -i /dev/video0 \
    -f alsa -ac 2 -i hw:1,0 \
    output.mkv



# Ref: https://trac.ffmpeg.org/wiki/Capture/Desktop


若有需要可以試試別的




2022年5月10日 星期二

讓VirtualBox的虛擬機器在背景執行


cd C:\Program Files\Oracle\VirtualBox 


VBoxManage.exe startvm "VM_NAME" --type headless



"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "VM_NAME" --type headless




2022年5月1日 星期日

2022年4月30日 星期六

Linux 清除系統日誌

cd /var/log

sudo su

> lastlog

> wtmp

> dpkg.log 

> kern.log

> syslog

exit

sudo systemctl restart syslog


註:指令中必須包含  >  符號


參考資料

https://askubuntu.com/questions/515146/very-large-log-files-what-should-i-do

2022年4月26日 星期二

GDB 基本操作

編譯 (要加入debug資訊)

gcc xxxxx.c -g --static


啟動

gdb -tui ./a.out


切換窗格

Ctrl + X , O 


執行一次

r
run


加入中斷點

b <行號>
b <標籤名>
break <行號>
break <標籤名>


移除中斷點

(gdb) b 25 
Breakpoint 5 at 0x7a4: file main.c, line 27.
(gdb) info break
Num     Type           Disp Enb Address            What
5       breakpoint     keep y   0x00000000000007a4 in main at main.c:27
(gdb) del 5
(gdb) info break
No breakpoints or watchpoints.


單步執行

s
step


執行下一行指令

n
next


顯示暫存器

info all-registers
info reg X0


顯示字元陣列

print str
print str[13]
x/13cb str


開啟內建說明

help







Ubuntu 20.04 安裝 GitHub CLI

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0

sudo apt-add-repository https://cli.github.com/packages

sudo apt update

sudo apt install gh

使用vscode來閱讀Linux內核原始程式碼

新增 .vscode/c_cpp_properties.json 檔案
內容如下:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/include",
                "${workspaceFolder}/include/linux",
                "${workspaceFolder}/arch/arm64/include"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4

或是

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${workspaceFolder}/include/**",
                "${workspaceFolder}/include/linux/**",
                "${workspaceFolder}/arch/arm64/include/**",
                "${workspaceFolder}/arch/x86/include/**"
            ],
            "defines": [
                "__KERNEL__",
                "_GNU_SOURCE"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu11",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-clang-arm64"
        }
    ],
    "version": 4
}

2022年1月14日 星期五

chrome 深色模式

 https://www.google.com/


https://www.google.com.tw/preferences#appearance

chrome://flags/#enable-force-dark

2022年1月7日 星期五

編譯 Linux Kernal (on Ubuntu 20.04)

# Ubuntu 20.04.3


# 更新與下載套件

sudo apt update

sudo apt upgrade

sudo apt install vim net-tools git flex bison python3-dev build-essential cmake cppcheck cscope docker docker.io dwarves gcc-aarch64-linux-gnu gdb-multiarch kernelshark libncurses5-dev libssl-dev openssl openjdk-13-jre qemu-system-arm trace-cmd universal-ctags libelf-dev zstd


# 下載與解壓縮 Linux Kernel

## Linux Kernel 版本建議選擇比目前新的,不然有些 Driver 可能會沒有!

wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.13.tar.xz

tar -Jxf linux-5.15.13.tar.xz

cd linux-5.15.13/


# 複製與編輯設定檔

## 複製設定檔

cp /boot/config-5.11.0-44-generic .config

## 讀進複製過來的設定檔

make menuconfig

<Save> <Exit>

# make clean

## 編輯設定檔

nano .config


^W

CONFIG_SYSTEM_TRUSTED_KEYS=""

# CONFIG_X86_X32=y

^X


scripts/config --disable SYSTEM_TRUSTED_KEYS

scripts/config --disable SYSTEM_REVOCATION_KEYS


# 編譯

cat /proc/cpuinfo

make modules -j8

make -j8


# 安裝

# Ref: https://blog.csdn.net/clh14281055/article/details/112294167

sudo make INSTALL_MOD_STRIP=1 modules_install

# sudo make modules_install

sudo make install

2021年12月2日 星期四

解決 GPU 被佔用問題

import tensorflow as tf

gpus = tf.config.experimental.list_physical_devices('GPU')

for gpu in gpus:

    tf.config.experimental.set_memory_growth(gpu, True) 

2021年5月13日 星期四

Go Modules、Private Repository

go mod init github.com/okh8609/{PROJECT_NAME}

go env -w GOPRIVATE=github.com/okh8609


申請 Personal Access Token

git config --global url."https://$USERNAME:$ACCESS_TOKEN@github.com".insteadOf "https://github.com"