neovim

安装 参考 https://github.com/neovim/neovim/blob/master/INSTALL.md 配置文件 nvim 的配置文件目录在 ~/.config/nvim 下,默认读取该目录下的init.lua 文件。

2025-09-08 · 1 min

USB_Reset_Suspend_Resume

Reset 整个reset过程,host需要拉低D+的时间\(T_{DRST}\) 至少 > 10ms。 High-speed capable hubs and devices在reset过程中还会执行一套reset protocol: Hub确认接的设备不是Low-speed, 如果是low-speed,不会有下面的reset握手协议。 Hub把D+拉低,进入SE0状态。 Device检测到SE0: 如果device是从suspend状态进入reset,那么device在不少于2.5us后进行high-speed detection handshake。 如果device是从non-suspend full-speed状态进入reset,那么device需要在2.5us~3ms之间进入handshake。 如果device是从non-suspend high-speed状态进入reset,那么device必须在3ms~3.125ms之间恢复full-spped,通过断开高速终端电阻以及重新接上D+的上拉电阻。接着在100us-875us内开始检测SE0状态,进入handshake。 Device往D-灌电流,形成一个800mv左右的ChripK信号, 该信号保持1~7ms。 Hub检测到ChripK信号后,100us内需要发送三对KJ(k-J-K-J-K-J)。每个单独的J或K都要保持40~60us。KJ对打完之后,在500us内断开D+上拉电阻,使能高速终端电阻,进入高速状态。 Suspend Device有两种进入suspend的方式: 如果连续3帧没有收到SOF包(1ms一帧),device会进入suspend状态。 host driver发送SET_PORT_FEATURE(PORT_SUSPEND)给hub,hub再发送给指定的device。 Resume 从suspend状态resume起来需要保持ChripK状态20ms以上,也有两种方式: Device remote wakeup,device drive K-state 1~15ms。Hub会在1ms内,接管D+, D-,继续产生resume信号直到20ms。 host发送CLEAR_PORT_FEATURE( PORT_SUSPSEND)给hub,hub drive K-state 20ms。 Reference Reset, Suspend, and Resume Commands USB全速设备的挂起、唤醒Resume USB2.0设备从全速模式到高速模式的识别过程及速率协商 USB spec 7.1.7.5~7.1.7.7, 11.9

2024-03-29 · 1 min

Vim and Vim plugins

VIM Starting VIM :w file.txt Buffers, Windows, and Tabs Buffers Buffers 是一个内存空间,您可以在其中写入和编辑一些文本。当你在 Vim 中打开一个文件时,数据被绑定到一个缓冲区。当你在 Vim 中打开 3 个文件时,你有 3 个缓冲区。 # 展示缓冲区的三个命令 :buffers :ls :files # 跳转缓冲区 :bnext # 下一个缓冲区 :buffer + file name :buffer + buffer number Ctrl-^ # 删除缓冲区 :bdelete + file name :bdelete + buffer number # 退出所有缓冲区 :qall :qall! :wqall Windows windows 是展示 buffer 的显示 UI. :split filename :vsplit filename :new filename Ctrl-W H/J/K/L # move to left/below/upper/right window Ctrl-W V/S # open a vertical/horizontal split Ctrl-W C # close a window Ctrl-W O # make the current window the only one on screen Tabs Tab 是一系列 windows。...

2023-12-13 · 2 min

Tmux

常用快捷键 ~/.tmux.conf 可修改 tmux 配置。 tmux: open a new session. C-b -> C-a C-b %: 左右分屏。改为-> C-a | C-b ": 上下分屏。-> C-a - C-b <arrow key>:在 panes 间移动。-> alt + arrow exit or hit Ctrl-d:退出当前 pane。 C-b c: new window. C-b p: previous window. C-b n: next window. C-b <number> : move to window n. C-b ?: help message. C-b z: make a pane go full screen. Hit C-b z again to shrink it back to its previous size...

2023-12-13 · 1 min

DFU(Device Firmware Upgrade)

2. Overview 四个阶段: Enumeration device告知host具备的能力。通过Run-Time Descriptor中增加的DFU class-interface descriptor和functional descriptor实现。 Reconfiguration host和device同意初始固件升级。host会发送一次USB reset,设备会exports DFU descriptors出来。 Transfer Manifestation device告知设备完成升级,host会再次发送USB reset, 重新枚举设备,运行新固件。 总体流程: 3. Requests bRequest分别从DFU_DETACH: 0 ~ DFU_ABORT: 6 4. Enumeration Phase 4.1 Run-Time Descriptor Set 支持DFU的设备,在run-time时需要额外增加两个描述符: A single DFU class interface descriptor A single functional descriptor 因此Configuration descriptor的bNumInterfaces域需要加1。 Run-time DFU Interface Descriptor DFU Functional Descriptor static void PrepareDFUFunDesc(DFUFunDesc_t *pDFUFunDesc) { pDFUFunDesc->bLength = sizeof(DFUFunDesc_t); pDFUFunDesc->bDescriptorType = 0x21; pDFUFunDesc->bmAttributes = g_DFUVar.bmAttributes; /// BIT0 | BIT1 | BIT2 | BIT3 pDFUFunDesc->wDetachTimeOut = 200; pDFUFunDesc->wTransferSize = g_DFUVar....

2023-08-15 · 2 min

linux usb driver

USB function driver f_loopback.c USB composite driver zero.c usb_composite_driver struct usb_composite_driver { const char *name; // "zero" const struct usb_device_descriptor *dev; // device_desc struct usb_gadget_strings **strings; // dev_strings enum usb_device_speed max_speed; // USB_SPEED_SUPER unsigned needs_serial:1; int (*bind)(struct usb_composite_dev *cdev); // zero_bind int (*unbind)(struct usb_composite_dev *); // zero_unbind void (*disconnect)(struct usb_composite_dev *); /* global suspend hooks */ void (*suspend)(struct usb_composite_dev *); // zero_suspend void (*resume)(struct usb_composite_dev *); // zero_resume struct usb_gadget_driver gadget_driver; // composite_driver_template }; 提供usb_configuration usb_device_descriptor...

2023-06-15 · 2 min

usb spec

Questions USB-IF Others USB标准名称变更: USB 1.0 -> USB 2.0 Low-Speed USB 1.1 -> USB 2.0 Full-Speed USB 2.0 -> USB 2.0 High-Speed USB 3.0 -> USB 3.1 Gen1 -> USB 3.2 Gen1 USB 3.1 -> USB 3.1 Gen2 -> USB 3.2 Gen2 × 1 USB 3.2 -> USB 3.2 Gen2 × 2 USB OTG中增加了一种MINI USB接头,使用5条线,比标准USB多一条身份识别线。 USB协议规定,设备在未配置前,可以从Vbus最多获取100mA电流,配置之后,最多可以获得500mA电流。Vbus是5V的电压。 枚举就是从设备读取各种描述符信息。 Control transfer:低速8字节,高速64字节,全速8/16/32/64字节。 Isochronous Transfer:全速1023字节,高速1024字节,低速不支持。 Interrupt Transfer:低速上限8字节,全速上限64字节,高速上限1024字节。 Bulk transfer:高速512字节,全速8/16/32/64字节,低速不支持。 Chapter3 Background USB 接口可用于连接多达 127 种外设。...

2023-06-15 · 3 min

GDB

Stepping step(s)/stepi(si) + <n>: 执行 n 行 c/assembly 代码, 会跳进函数。 next(n)/nexti(ni) + <n>: 执行 n 行 c/assembly 代码,不会跳进函数。 Running run/r: run code 直到遇到 breakpoint。程序跑完接着 run 会 restart 程序。 continue/c: 继续执行。 finish: run code 直到当前函数 return。 advance <location>: run code 直到指令到达。和设置 breakpoint 然后 Breakpoints break <location>: 设置断点,location 可以是内存地址"*0x7c00"或者名称"mon_backtrace", "monitor.c:71" break <location> if <condition>: 只有 condition 满足的时候才会 break。 cond <number> <condition>: 给某个断点增加 condition。 info breakpoints/b: 查看断点 delete <n>: 删除编号为 n 的断点 Watchpoints watch <expression>: 表达式值发生改变时,会停止执行指令。...

2023-05-08 · 2 min

Buildroot

Buildroot User Manual https://buildroot.org/downloads/manual/manual.html https://www.cnblogs.com/fuzidage/p/12049442.html Chapter 4 Buildroot quick start make menuconfig make make menuconfig 进入选择菜单,可以选择编译 kernel, bootloader, rootfs。 编译完成后内容会放到output目录下,其中: image: 包括 kernel image, bootloader and root filesystem images build: host: staging: 软链接,指向/host/<toolchain>/sysroot target: 就是目标板的文件系统,和 staging 相比,developing files(header, etc.)被省略了,binaries are stripped, 去除了 debug info。 PARTⅡ User Guide Chapter 6 Buildroot configuration 6.1 Cross-compilation toolchain Buildroot 提供两种 toolchain: internal toolchain backend, Buildroot toolchain in menuconfig. external toolchain backend. External toolchain in menuconfig....

2023-04-13 · 10 min

正则表达式

笔记一 笔记源自 RegexOne 需要转义的特殊字符: * . ? + $ ^ [ ] ( ) { } | \ / \s 匹配所有空格字符,等同于: [\t\n\f\r\p{Z}] \f 换页符 \n 换行符 \r 回车符 \t 制表符 \p 等同于\r\n, CRLF DOS 行终止符 Tutorials Lesson 1 The 123s \d any single digit character \D any single non-digit character Lesson 2: The Dot . any single character \. period Lesson 3: Matching specific characters [abc] only a, b, c single character...

2023-01-12 · 2 min