棋理

最近和朋友的孩子下了几盘棋,在惊叹现在孩子的聪慧和学习能力之余,也深感自己的“棋艺”着实有待提高。便又拣起荒废已久的弈城账号,想下几盘找找感觉,结果又一次应了那句,“业精于勤,荒于嬉”。失落之余,索性去 B 站,重看邱百瑞老师的带你零基础学围棋.
再看确实有不一样的感受。围棋的奥妙和那些千古流传的棋理自不必多说,我想自己学习下棋,试着了解棋理的原因,也是被围棋这种“方寸之间有天地,黑白之处显乾坤”的魅力所折服。

Read more »

Communication is hard, especially with all the different personalities, languages, and
cultures involved in an international community like this.

Faith Ekstrand

It is rules and not our individual smarts that keep us from making mistakes.

Faith Ekstrand

Read more »

Scent of a woman (1992)

No mistakes in the Tango, not like life. It’s simple, that’s what makes the Tango so great. If you make a mistake, get all tangled up, just Tango on.

Rudy (1993)

Having dreams is what makes life tolerable

The Shawshank Redemption (1994)

Get busy living or get busy dying

Cache

音同 cash, 不管是在硬件还是软件都是影响性能的一个重要因素之一。Cache 无论是 CPU cache 还是 GPU cache 一般都分级, L1,L2, 在 Multi-processor CPU/GPU 架构中, L1 一般是分开的,每个 Processor 有一个自己的 L1 Cache, 而 L2 Cache 是全局的,所有 processors 共享的。

Read more »

环境准备

WSL2 作为上位机

识别 Windows 11 Host 的 USB Serial Device

分别在 Windows 11 上安装 usbipd-win, 在 WSL2 上安装 user space tools for USB/IP

1
2
3
4
5
6
7
Microsoft Windows [版本 10.0.22621.1702]
(c) Microsoft Corporation。保留所有权利。

C:\Windows\System32>usbipd wsl list
BUSID VID:PID DEVICE STATE
1-9 046d:c534 USB 输入设备 Not attached
1-13 04e2:1410 USB 串行设备 (COM4) Not attached

WSL2 Ubuntu-20.04 创建 /dev/ttyUSB0

1
2
3
4
5
6
7
8
9
10
11
[Thu Jun 15 19:19:44 2023] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3)
[Thu Jun 15 19:19:44 2023] vhci_hcd vhci_hcd.0: devid(65546) speed(2) speed_str(full-speed)
[Thu Jun 15 19:19:44 2023] vhci_hcd vhci_hcd.0: Device attached
[Thu Jun 15 19:19:45 2023] vhci_hcd: vhci_device speed not set
[Thu Jun 15 19:19:45 2023] usb 1-1: new full-speed USB device number 2 using vhci_hcd
[Thu Jun 15 19:19:45 2023] vhci_hcd: vhci_device speed not set
[Thu Jun 15 19:19:45 2023] usb 1-1: SetAddress Request (2) to port 0
[Thu Jun 15 19:19:45 2023] usb 1-1: New USB device found, idVendor=04e2, idProduct=1410, bcdDevice= 0.03
[Thu Jun 15 19:19:45 2023] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[Thu Jun 15 19:19:45 2023] xr_serial 1-1:1.0: xr_serial converter detected
[Thu Jun 15 19:19:45 2023] usb 1-1: xr_serial converter now attached to ttyUSB0

Recovery 模式应该连接哪个 Type-C (USB SERIAL) 接口

HiKey970 有两个 Type-C 接口,而且当板子被设置为 Recovery 模式时,两个接口均会被识别为“串口”。在左手边的 (J3101) 是用来访问 Debug UART 的,而在 HDMI 和 USB 中间的那个(J1801)是在 Recovery 模式下使用的。而且这两个接口是两个不同厂家提供的芯片,使用完全不同的内核驱动模块

USB-to-Serial on Hikey970

  • 前者(J3101):
    Bus 001 Device 003: ID 04e2:1410 Exar Corp. XR21V1410 USB-UART IC

Select CONFIG_USB_SERIAL_XR on WSL2 Kernal config

  • 后者(J1801):
    Bus 001 Device 002: ID 12d1:3609 Huawei Technologies Co., Ltd. USB SER

Select CONFIG_USB_SERIAL_OPTION on WSL2 Kernal config

显示

flowchart LR
    DPE["Display Engine<br>(display controller)"]
    DSI["Display Serial Interface"]
    HDMI["external HDMI converter"]

    subgraph in-chip
      DPE -- RGB timing --> DSI
    end

    DSI --> HDMI

参考

系统调用是 Linux 用户态程序与内核通信的接口。 每个特定的文件系统都会在自己的 file_operations 里提供各种文件操作接口,像 .open, .close, .ioctl。系统调用会通过 VFS 的接口调用这些具体的实现,而对于应用程序来说,一般不会直接使用系统调用,而是调用 C 库函数 (C routines).

ioctl 这个系统调用的声明大概是这样:

1
COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, compat_ulong_t, arg)

ioctl 的 C 库函数 (Aarch64 实现):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
	.text
ENTRY(__ioctl)
/* move ioctl syscall number to x8 register */
mov x8, #__NR_ioctl
/* sign extend w0 to x0 */
sxtw x0, w0
/* issue software interrupt to invoke syscall */
svc #0x0
/* add 4095 to x0 and set flags according to result */
cmn x0, #4095
/* if carry bit is set (previous addition carrys out), branch to Lsyscall_error */
b.cs .Lsyscall_error
ret
PSEUDO_END (__ioctl)

/* symbol management, making __ioctl and ioctl effectively the same function */
libc_hidden_def (__ioctl)
weak_alias (__ioctl, ioctl)
Read more »

CONFIG_DEBUG_FS

如何在 WSL2 上启用 debugfs

确认下内核是否开启了 debugfs

1
zcat /proc/config.gz | grep CONFIG_DEBUG_FS

要想使用 debugfs,首先要挂载它到 /sys/kernel/debug

1
mount -t debugfs none /sys/kernel/debug/
Read more »
0%