Category: Linux

  • TIL: ARRAY_SIZE in Linux kernel

    from net/mac80211/sta_info.c, define at include/linux/kernel.h /** * ARRAY_SIZE – get the number of elements in array @arr * @arr: array to be sized */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) __must_be_array: 檢查 a 是否為 array,當 a 為 array 時,會因為 &(a)[0] 變成 pointer,而讓 __same_type 產生 0 的結果,反之如果 a 為 pointer,因為 &(a)[0] 仍然是 pointer, __same_type 回傳…

  • Qualcomm ath9k 驅動程式解析 (二) – 幾個重要結構

    ieee80211_local *local 用途: contains information about the real hardware, and is created when the interface is first added. (Daniel Caps Mur, Linux Wi-Fi open source drivers-mac80211,ath9k/ath5k-, pp.1) each instance of these (hw is embedded into local) represents a wireless driver, ieee80211_hw is the part of the ieee80211_local that is visible to drivers, contains all operating…

  • Qualcomm ath9k 驅動程式解析 (一) – 初始化過程

    以 linux-4.19-rc2 為例,平台為 TP-Link WDR4300。程式碼以 linux-4.19-rc2 為準,有特別標示者以 OpenWrt/LEDE 為準。 1. ath9k 驅動程式註冊點:ath9k/init.c#ath9k_init(void) static int __init ath9k_init(void) { int error; error = ath_pci_init(); if (error < 0) { pr_err(“No PCI devices found, driver not installed\n”); error = -ENODEV; goto err_out; } error = ath_ahb_init(); if (error < 0) { error = -ENODEV; goto err_pci_exit; } dmi_check_system(ath9k_quirks);…

  • TIL: ALIGN in Linux kernel

    from include/uapi/linux/kernel.h and scripts/dtc/dtc.h #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))a – 1) #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) or #define ALIGN(x, a) (((x) + (a) – 1) & ~((a) – 1))  

  • Perf tracing wireless driver on LEDE/OpenWRT

    Perf tracing wireless driver on LEDE/OpenWRT

    1. Config LEDE/OpenWRT with CONFIG_PACKAGE_perf=y CONFIG_KERNEL_PERF_EVENTS=y 2. Add dynamic probe with external modules $ perf probe -a -m /lib/modules/4.9.109/ath9k.ko ‘ath_tx*’ $ perf probe -a -m /lib/modules/4.9.109/ath9k.ko ‘ath9k_wake_tx_queue’ $ perf probe -a -m /lib/modules/4.9.109/mac80211.ko ‘fq_*’ $ perf probe -a -m /lib/modules/4.9.109/mac80211.ko ‘ieee80211_tx*’ 3. Perf Recording # Sample CPU stack traces, only with “probe:” events, by ping,…

  • 在 Linux 上處理 Samsung Gear 360 影片的辦法與比較

    在 Linux 上處理 Samsung Gear 360 影片的辦法與比較

    藉由此文總結一下我在 Linux 環境下處理 Samsung Gear 360 影片的方式,以及比較。Samsung Gear 360 (2017) 相比於目前市面上的 360 度相機而言,並不算畫質特別好的機子,許多 youtuber 都只給了 meh 或是 don’t buy 的評價,基於其畫面沒有前一代好、同價位有其他選項、拍攝影片曝光會變動、焦距會隨著移動的物體改變而讓影片不能用等原因。 但,這台機子有個絕大的優點,就是其影片可以在 Linux 上無 GUI 的狀況下操作,合併、以及有開放 iOS/Android SDK 申請。其他的攝影機的後製解決方案幾乎都只有支援 Windows 或是 macOS 而已,這讓這臺機子多了一點……不多人需要的特點。 先講結論: 用手機 Wi-Fi 傳輸然後轉成 360 影片比較快 用手機 Wi-Fi 傳輸然後轉成 360 影片畫質比較好 用手機 Wi-Fi 傳輸然後轉成 360 影片接合比較好 在 Linux 上接合爆炸慢 在 Linux 上畫質輸一大截 有看到…

  • Develop process in Linux ath10k driver with LEDE

    Develop process in Linux ath10k driver with LEDE

    ath repo: https://bitbucket.org/mlouielu/ath LEDE repo: https://github.com/lede-project/source, commit: 99be4170cb27e ath repo: git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git, commit: e72acb704e94   Modify ATH10k Most of the time ath repo’s ath10k source code will surpass LEDE’s ath10k source code, you will need to know this and change the code when building got conflict. The step I use is: Change code for ath10k driver git…

  • 修正 Arch Linux locale 無法 generate 以及 tmux mosh 出現錯誤

    修正 Arch Linux locale 無法 generate 以及 tmux mosh 出現錯誤

    問題 我在 Raspberry pi 3 上的 Arch Linux 出現以下錯誤,讓 mosh 以及 tmux 還有 locale 都無法使用: mosh: ➜ ~ mosh [email protected] [email protected]’s password: The locale requested by LC_CTYPE=en_US.UTF-8 isn’t available here. Running `locale-gen en_US.UTF-8′ may be necessary. mosh-server needs a UTF-8 native locale to run. Unfortunately, the local environment ([no charset variables]) specifies the character set “US-ASCII”,…

  • ArchLinux 上更新 BladeRF x40 的 firmware 以及 fpga image

    ArchLinux 上更新 BladeRF x40 的 firmware 以及 fpga image

    在 ArchLinux 上運行 BladeRF x40 還滿簡單的。bladerf 在 Arch 的 community 庫中,包含了 driver, userspace, fpga & firmware 等東西 yaourt -S bladerf 接著使用 bladerf command line tool 打開畫面 $ sudo bladeRF-cli -i bladeRF> version bladeRF-cli version: 1.4.0-git-096984a4 libbladeRF version: 1.7.1-git Firmware version: 1.8.0 FPGA version: Unknown (FPGA not loaded)   接著要下載 firmware 以及 fpga image: $ wget…

  • 在 ArchLinux 上安裝 Lavarel 5

    在 ArchLinux 上安裝 Lavarel 5

    有幾個步驟一定要記得:1. 到 /etc/php/php.ini 把相關的 extension 打開。2. 建立 ~/.composer/vendor/bin/ 資料夾。3. 安裝相關的 php 套件。 1. 安裝相關套件 yaourt -S php composer php-mcrypt 2. 在 /etc/php/php.ini 打開 php extension 找到以下幾個 extension, 將前面的 ; 給去除 extension=mcrypt.so extension=pdo_mysql.so extension=mysqli.so extension=xmlrpc.so extension=zip.so 注意,你不需要把 openssl.so 給打開,在 php7 已經內建。打開的話會觸發錯誤: PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/modules/openssl.so’ – /usr/lib/php/modules/openssl.so: cannot open shared object file: No such…