Recent Posts

编译 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,比如从上一级按固定比例分频 …

定制 SoC 的 U-Boot SPL image type 类型

开发板 SoC 系统上电启动时,从 boot rom 开始运行、并加载后续程序;被加载的通常是 U-Boot SPL,它运行并加载其他后续的程序。按先后 …

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 …

Linux kernel printk log level

1. Log level 的定义

在 Linux 内核里,printk 经常用来格式化输出,类似于常见的 printf。需要注意的是,printk 有一个 log level 的参数,使用的时候经常 …

RISC-V 链接问题:relocation truncated to fit: R_RISCV_PCREL_HI20

问题

在一个基于 RISC-V 架构的项目里,遇到了如下的链接问题:

xxx/file:xxx:(.text.startup+0x74): relocation truncated to fit: R_RISCV_PCREL_HI20 against symbol xxx ...
collect2: error: ld returned 1 exit status
make: *** [Makefile:xx: xxx.elf …