Jay's some notes - driver
type: channel
link: https://notes.leconiot.com/category/driver
items: Ubuntu wireless-ac 9560 驱动异常
items: linux 看门狗
items: a64 io 中断初始化失败
items: Overview of the V4L2 driver framework
items: linux gpio libc
items: arm级vp9 编解码cpu概况
items: linux cooling device

Ubuntu wireless-ac 9560 驱动异常
type: item
date: 2020-02-20T16:30:00+08:00
description: Ubuntu 19.10 Intel wireless-ac 9560 driver exception重启电脑后发现wifi不能使用了，网络设置里面提示未发现网络适配器。电脑比较新，之前安装ubuntu18.10 低版本kernel 版本就发现不识别wifi设备，更新到ubuntu19.10 后正常，不过正常安装后也反复重启过使用了一段时间。Detected Intel(R) Wireless-AC 9560, REV=0x354；Ubuntu 19.10 5.3.0-40-generic；小米笔记本pro 15；排查第一时间排查dmesg 发现有iwlwifi 内核模块报错。主动搜索报错码-110毫无头绪，电脑比较新，系统也比较新。[四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: Collecting data: trigger 15 fired. [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: Start IWL Error Log Dump: [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: Status: 0x00000000, count: -19956050 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: Loaded firmware version: 48.4fa0041f.0 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xC5AC4F26 | ADVANCED_SYSASSERT [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xCB9998C3 | trm_hw_status0 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x244D7603 | trm_hw_status1 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x2926F87E | branchlink2 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x3E2895D3 | interruptlink1 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xD09F20D1 | interruptlink2 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x08AC288C | data1 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xF3FBD753 | data2 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xF966C3F5 | data3 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xDD57C165 | beacon time [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x5547C020 | tsf low [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x4E82E2A7 | tsf hi [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x6B3477FA | time gp1 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x0820283A | time gp2 [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x34D26108 | uCode revision type [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x7F42F5CA | uCode version major [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0xD8F2FAEE | uCode version minor [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x48305889 | hw version [四 2月 20 10:03:59 2020] iwlwifi 0000:00:14.3: 0x90466212 | board versi…

linux 看门狗
type: item
date: 2019-09-17T16:55:00+08:00
description: 目录 [隐藏] kernel driversunxi watchdogforce fscktroubleshooting linux watchdog基于debian8 的linux设备会低概率的出现的系统完整死机，这里思考给linux添加完整的看门狗策略。debian8已经采用systemd用以初始化系统和守护、管理系统进程。这里同时存在systemd 的watchdog和keepalive 单元文件，以及sysv init的watchdog keepavlie 初始化脚本，同时systemd也直接看门狗启动，那么该如何选择呢？systemd直接支持看门狗启动；pi@350-tf-s2 ~$ cat /etc/systemd/system.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # See systemd-system.conf(5) for details #RuntimeWatchdogSec=0 #ShutdownWatchdogSec=10mindebain8同时支持systemd和sysv init的看门狗以及保活机制。/lib/systemd/system/watchdog.service /lib/systemd/system/wd_keepalive.service /etc/init.d/watchdog /etc/init.d/wd_keepalivekernel driverDevice Drivers-> Watchdog Timer Support./drivers/watchdog/Kconfigmenuconfig WATCHDOG bool "Watchdog Timer Support" ---help--- 用以控制看门狗配置集合使能 config WATCHDOG_CORE bool "WatchDog Timer Driver Core" ---help--- 看门狗核心功能使能，如果Y，会创建/dev/watchdog 设备。 config WATCHDOG_NOWAYOUT bool "Disable watchdog shutdown on close" ---help--- 默认看门狗行为是一旦关闭/dev/wathdog 文件句柄则停止看门狗计时，也就是不再触发复位， 但是使能该选项后意关闭看门狗后不能停止计时，也就意味着开启看门狗后不能再停止。 config SOFT_WATCHDOG 软件看门狗所以这里只需要使能CONFIG_WATCHDOG=y CONFIG_WATCHDOG_CORE=ysunxi watchdog如上使能了过后还是没有出现看门狗设备，参考sunxi 主核发布说明确定4.17之后a64才加入看门狗功能，这里涉及sunxi_wdt和dts和驱动移植。errordrivers/watchdog/sunxi_wdt.c:206:2: error: unknown field 'restart' specified in initializer .restart = sunxi_wdt_restart, ^ drivers/watchdog/sunxi_wdt.c:206:13: warning: initialization from incompatible pointer type .restart = sunxi_wdt_restart, ^ drivers/watchdog/sunxi_wdt.c:206:13: warning: (near initialization for 'sunxi_wdt_ops.get_timeleft') drivers/watchdog/sunxi_wdt.c: In function 'sunxi_wdt_probe': drivers/watchdog/sunxi_wdt.c:244:2: error: implicit declaration of function 'of_device_get_ match_data' [-Werror=implicit-function…

a64 io 中断初始化失败
type: item
date: 2019-09-17T16:50:00+08:00
description: a64 gpio interrupt init failed如下pc0，gpio64 设置中断触发边沿失败。~$ tree /sys/class/gpio/gpio64/ ├── active_low ├── device -> ../../../1c20800.pinctrl ├── direction ├── power │ ├── async │ ├── autosuspend_delay_ms │ ├── control │ ├── runtime_active_kids │ ├── runtime_active_time │ ├── runtime_enabled │ ├── runtime_status │ ├── runtime_suspended_time │ └── runtime_usage ├── subsystem -> ../../../../../class/gpio ├── uevent └── value对比，pb0 gpio32，这里没有edge 属性。~$ tree /sys/class/gpio/gpio32 /sys/class/gpio/gpio32 ├── active_low ├── device -> ../../../1c20800.pinctrl ├── direction ├── edge ├── power │ ├── async │ ├── autosuspend_delay_ms │ ├── control │ ├── runtime_active_kids │ ├── runtime_active_time │ ├── runtime_enabled │ ├── runtime_status │ ├── runtime_suspended_time │ └── runtime_usage ├── subsystem -> ../../../../../class/gpio ├── uevent └── value对比3.21.2.1. PB Configure Register 0 (Default Value: 0x77777777) 和3.21.2.10. PC Configure Register 0 (Default Value: 0x77777777) 这里pc0 确实不支持中断。提示：Allwinner_A64_User_Manual_V1.1_decrypted.pdf->Chapter 3 System->3.21. Port Controller(CPUx-PORT)

Overview of the V4L2 driver framework
type: item
date: 2018-11-26T18:02:00+08:00
description: 目录 [隐藏] IntroductionStructure of a driverStructure of the frameworkstruct v4l2_devicestruct v4l2_subdevV4L2 sub-device userspace APII2C sub-device driversstruct video_deviceioctls and lockingvideo_device registrationvideo_device cleanupvideo_device helper functionsvideo buffer helper functionsstruct v4l2_fhV4L2 events Overview of the V4L2 driver frameworkThis text documents the various structures provided by the V4L2 framework and their relationships.IntroductionThe V4L2 drivers tend to be very complex due to the complexity of the hardware: most devices have multiple ICs, export multiple device nodes in /dev, and create also non-V4L2 devices such as DVB, ALSA, FB, I2C and input (IR) devices.Especially the fact that V4L2 drivers have to setup supporting ICs to do audio/video muxing/encoding/decoding makes it more complex than most. Usually these ICs are connected to the main bridge driver through one or more I2C busses, but other busses can also be used. Such devices are called 'sub-devices'.For a long time the framework was limited to the video_device struct for creating V4L device nodes and video_buf for handling the video buffers (note that this document does not discuss the video_buf framework).This meant that all drivers had to do the setup of device instances and connecting to sub-devices themselves. Some of this is quite complicated to do right and many drivers never did do it correctly.There is also a lot of common code that could never be refactored due to the lack of a framework.So this framework sets up the basic building blocks that all drivers need and this same framework should make it much easier to refactor common code into utility functions shared by all drivers.Structure of a driverAll drivers have the following structure:A struct for each device instance containing the device state.A way of initializing and commanding sub-devices (if any).Creating V4L2 device nodes (/dev/videoX, /dev/vbiX and /dev/radioX) and keeping track of device-node specific d…

linux gpio libc
type: item
date: 2018-11-26T18:02:00+08:00
description: gpio对linux c app里面的一个gpio操作云里雾里半天，是时候好好理理了。https://www.kernel.org/doc/Documentation/gpio/sysfs.txthttps://www.kernel.org/doc/Documentation/gpio/gpio-legacy.txt主要是这gpio number是如何同pin number 一一对应的。256 root@mxj-zbcs-310:#tree /sys/class/gpio . |-- export |-- gpio120 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio120 |-- gpio228 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio228 |-- gpio229 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio229 |-- gpio232 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio232 |-- gpio32 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio32 |-- gpio33 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio33 |-- gpio359 -> ../../devices/soc.0/1f02c00.pinctrl/gpio/gpio359 |-- gpio64 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpio64 |-- gpiochip0 -> ../../devices/soc.0/1c20800.pinctrl/gpio/gpiochip0 |-- gpiochip1024 -> ../../devices/soc.0/pinctrl.1/gpio/gpiochip1024 |-- gpiochip352 -> ../../devices/soc.0/1f02c00.pinctrl/gpio/gpiochip352 `-- unexport奇怪，今天发现sys/class/gpio 下面的gpio没有了。只剩下gpiochip了。原来需要在应用export 对应io number。 fd = open("/sys/class/gpio/export", O_WRONLY); len = snprintf(buffer, sizeof(buffer), "%d", pin); if (write(fd, buffer, len) < 0) { }这里的export和unport以及之后对 io number value的read write 操作都是在gpiolibc 上实现的。 snprintf(path, sizeof(path), "/sys/class/gpio/gpio%d/value", pin); fd = open(path, O_WRONLY); if (fd < 0) { } if (write(fd, &values_str[value == 0 ? 0 : 1], 1) < 0) { } 接下来需要理一理gpiolibc 的实现,gpiolibc 所有操作都是基于gpio_desc *desc 变量。改变量通过gpio_desc 结构体定义这里的数组。数组索引就对应我们这里的io number。static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];这个结构体的实现主要是是通过gpio_chip来操作的，例如gpiod_set_value 是通过gpio_desc 获取到gpio_chip 然后在通过gpio_chip->set() 实现IO的读写。static void gpiod_set_value(struct gpio_desc *desc, int value) { struct gpio_chip *chip; if (!desc) return; chip = desc->chip; /* Should be using gpio_set_value_cansleep() */ WARN_ON(chip->can_sleep); trace_gpio_value(desc_to_gpio(desc), 0, value); if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) _gpio_set_open_drain_value(d…

arm级vp9 编解码cpu概况
type: item
date: 2018-11-26T18:02:00+08:00
description: 目录 [隐藏] allwinner h6allwinner a63hi3798 docsvp9 decoder test vp9 decoder cpu summary这里系统了解全志和海思的解码能力。allwinner h6https://pan.baidu.com/s/1aA-jRLSWtjaUq6BhXxq8mw em4jhttp://linux-sunxi.org/H6从Allwinner_H6_V200_User_Manual_V1.1_decrypted->Chapter 2 Overview->2.2.6. Video Engine ->2.2.6.1. Video Decoder 从User Manual 来看，能够达到4k@30fps的帧率，但是实际测试在6fps。allwinner a63暂时无其他资料，等待供应商提供。http://www.allwinnertech.com/uploads/pdf/2017120511150522.pdfhttps://pan.baidu.com/s/1FeZYy1alH7_n6nq-I8yeDA q9nhhi3798 docshi3798 区分M和C系列，现在看来hi3798c v100 支持vp8，hi3798cv200 支持vp9。http://www.hisilicon.com/en/Products/ProductList/STBhttps://pan.baidu.com/s/1kcMvlGeNHi-aMNGyZPTVqA w11fHi3798C V200.pdf-> Key Specifications vp9 decoder test了解下vp9的解码安卓测试。vp9 wiki vp9 官方网站vp9levels and decoder testing

linux cooling device
type: item
date: 2018-11-26T01:02:00+08:00
description: 目录 [隐藏] thermal sensorgovernorcooling devicetest script linux cooling device这里详细介绍并理解基于 allwinner a64 linux 下根据热量传感器 采集的温度用以自动调频 原理。thermal sensorhttp://linux-sunxi.org/Thermal_Sensora64集两个热量传感器分别监控gpu和cpu温度。The thermal sensors have become common elements in wide range of modern system on chip (SOC) platform. Thermal sensors are used to constantly monitor the temperature on the chip. A64 embeds three thermal sensors in possible hot spots on the die, sensor0 located in the CPU, sensor1 and sensor2 located in the GPU. The thermal sensor Generates interrupt to SW to lower temperature via DVFS, on reaching a certain thermal threshold提示：Allwinner_A64_User_Manual_V1.1_decrypted.pdf->3.18. Thermal Sensor Controller ->3.18.1. Overview。挂载在sysfs数据属性pi@350-tf-s2 ~$ tree /sys/class/thermal/thermal_zone0/ /sys/class/thermal/thermal_zone0/ ├── mode #enalbed 、disabled ，可读写 ├── policy #step_wise ├── temp #温度值 ├── trip_point_0_hyst #0 看起来像一个调节范围 ├── trip_point_0_temp #65 温度阈值 ├── trip_point_0_type #passive ├── ...... ├── trip_point_6_hyst #0 ├── trip_point_6_temp #110 ├── trip_point_6_type #critical ├── type #soc_thermal └── ueventgovernor CPU frequency and voltage scaling code in the Linux(TM) kernelhttp://linux-sunxi.org/Cpufreq挂载sysfs 数据属性。pi@350-tf-s2 ~$ tree /sys/devices/system/cpu/cpu0/cpufreq/ /sys/devices/system/cpu/cpu0/cpufreq/ ├── affected_cpus #0 1 2 3 ├── boot_lock #0 ├── cpuinfo_boot_freq #1152000 ├── cpuinfo_cur_freq ├── cpuinfo_max_freq #1344000 ├── cpuinfo_min_freq #480000 ├── cpuinfo_transition_latency #2000000 ├── related_cpus #0 1 2 3 ├── scaling_available_frequencies #480000 600000 720000 816000 1008000 1104000 1152000 1200000 1344000 ├── scaling_available_governors #interactive conservative ondemand userspace powersave performance ├── scaling_cur_freq #当前cpu频率 ├── scaling_driver #cpufreq-sunxi ├── scaling_governor #ondemand ├── scaling_max_freq #调节范围最大值 ├── scaling_min_freq #调节范围最小值 ├── scaling_setspeed #<unsupported> └── stats ├── time_in_state ├── total_trans…