Recent Posts

Python crypt 模块

Linux 下的用户名和密码是加盐哈希后保存在 /etc/shadow 文件里的。这里 有文件格式的介绍。

Python 标准库里,有一个 crypt 模块,可以用来生 …

Python 内置函数 pow 计算逆元

pow 是 Python 的内置函数,用来进行幂运行:

>>> help(pow)
pow(base, exp, mod=None)
    Equivalent to base**exp with 2 arguments or base**exp % mod with 3 arguments
    ...
>>> pow(5, 3)
125

Python 3.8 版本开始,在同 …

Cache 的组织和过程(VIVT、VIPT、PIPT)

1. VIVT

VA 里的 index 🡲 查找到 cache-line 🡲  VA 里的 tag 比较 :
* hit 🡲 返回(不经过 MMU)
* miss 🡲 [VA->MMU->]PA 访存,写回 cache-line;VA 里的 tag 更新到 cache-line 🡲 返回

有别名问题。

2. VIPT …

编译 devicetree source 文件

dts, dtb

device tree (dts) 是一种树形结构的、用来描述 SoC 设备的组成的文件。有 dts 格式的文本源文件,用 Device Tree Compiler (dtc),可以把 dts 编译生成 dtb …

Linux PWM 驱动的实现

0. PWM 概念

PWM 指的是脉冲宽度调制技术。 PWM 频率,指 1 秒的时间里 PWM 运行的次数。 PWM 周期,指一次完整的 PWM 输出所使用的时间 …

Linux clock tree 的实现

1. Linux 里已经预定义了几种 clock

  • clk-fixed-rate: basic fixed-rate clock that cannot gate, 比如固定频率的 oscillator
  • clk-fixed-factor: basic fixed multiplier and divider clock that cannot gate,比如从上一级按固定比例分频 …

ARM Watch Point 寄存器

Watch Point (WP) 有 6 个寄存器:

  • Address Value / Mask Register
  • Data Value / Mask Register
  • Control Value / Mask Register

其中,WP Address Value / Mask 是监控地址总线,WP Data Value / Mask 是监控数据总线。

断点用来标 …

Linux Kernel pr_debug(), dev_dbg() 以及动态调试

pr_err(), pr_info(), ... / dev_err(), dev_info(), ... 系列函数,在 pr_fmt / dev_fmt 的基础上,调用 vprintk_emit() 实现打印输出。但 pr_debug() / dev_dbg() 比较特殊,有不一样的代码路径。

文件:include/linux/printk.h

/* If you are writing …

Linux kernel printk 占位符 %p 和 %px

1. %p

Linux 内核里的 printk 可以打印指针地址,这和 printf() 是一样的:

void *p = 0x1234;
printk("p = %p\n", p);

这里是想打印所指向的地址。实际运行起来后 …

Linux kernel printk 以及 pr_err, dev_err 等包装函数

pr_err() 等包装函数

在 Linux 内核里打印信息,除了使用 printk,还可以用 pr_err() 等包装函数,比如:

pr_err("page allocation failed\n");

这个调用相当于 printk(KERN_ERR "page allocation failed\n …