@@ -134,6 +134,8 @@ ld.lld --version
134
134
135
135
` make ARCH=arm64 LLVM=1 WERROR=0 O=build -j$nproc ` 就这样正常编译就行了
136
136
137
+ 注意"环境变量"要写到make后面,如果写到make的前面的话效果就不一样了
138
+
137
139
## 不加 O=build 会出现一堆奇怪编译报错
138
140
139
141
```
@@ -163,13 +165,13 @@ Command 'mkimage' not found, but can be installed with:
163
165
apt install u-boot-tools
164
166
165
167
# O=build would generate build/.config, not .config
166
- make ARCH=arm64 LLVM=1 bsta1000b_defconfig O=build
167
- make ARCH=arm64 LLVM=1 bsta1000b_defconfig
168
+ make ARCH=arm64 LLVM=1 O=build bsta1000b_defconfig
168
169
169
- make ARCH=arm64 LLVM=1 WERROR=0 O=build -j$nproc
170
+ # ubuntu 上编译不用加 WERROR=0
171
+ make ARCH=arm64 LLVM=1 O=build -j$nproc
170
172
171
173
# make modules_install 不会修改内核
172
- make ARCH=arm64 LLVM=1 O=build modules_install INSTALL_MOD_PATH=modules_install INSTALL_MOD_STRIP=1
174
+ make ARCH=arm64 LLVM=1 O=build INSTALL_MOD_PATH=modules_install INSTALL_MOD_STRIP=1 modules_install
173
175
174
176
# 看门狗驱动内嵌在内核中,似乎 NOC 要手动 insmod
175
177
tree build/modules_install/lib/modules/6.1.12+2-rt7/kernel/ | grep noc
@@ -210,6 +212,22 @@ make ARCH=arm64 && make defconfig && make rust-analyzer
210
212
211
213
bear + O=build 的编译倒是没有特别困难
212
214
215
+ ```
216
+ make[1]: Entering directory '/home/wuaoxiang/linux-rust/build'
217
+ Traceback (most recent call last):
218
+ File "../scripts/generate_rust_analyzer.py", line 141, in <module>
219
+ main()
220
+ File "../scripts/generate_rust_analyzer.py", line 134, in main
221
+ "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src),
222
+ File "../scripts/generate_rust_analyzer.py", line 107, in generate_crates
223
+ if f"{name}.o" not in open(path.parent / "Makefile").read():
224
+ FileNotFoundError: [Errno 2] No such file or directory: '../drivers/block/nvme_mq/Makefile'
225
+ make[2]: *** [../rust/Makefile:392: rust-analyzer] Error 1
226
+ make[1]: *** [/home/wuaoxiang/linux-rust/Makefile:1850: rust-analyzer] Error 2
227
+ ```
228
+
229
+ touch drivers/block/nvme_mq/Makefile 就解决这个报错
230
+
213
231
## 一个内核模块报错
214
232
我搜索 drivers/soc 下面 module_init 找到 NOC 芯片的驱动代码? 的入口函数
215
233
@@ -297,3 +315,50 @@ USB协议也支持一种特殊的模式,即On-The-Go(OTG)模式。在OTG
297
315
298
316
## MTD=Memory Technology Device
299
317
为原始闪存设备(例如NAND,OneNAND,NOR 等)提供了一个抽象层。 这些不同类型的Flash都可以使用相同的API
318
+
319
+ ## platform device
320
+
321
+ Linux源码学习之platform_driver
322
+
323
+ 按照驱动probe用的结构体的不同去分类驱动
324
+ 驱动可分为usb_serial_driver,platform_driver等等
325
+ 基本上各种不同的驱动结构体都"继承"了device,device_driver
326
+
327
+ platform_driver适用于特定硬件平台
328
+ 如图中所示树莓派的GPIO名字跟树莓派官网下载的dtb设备树文件中完全一致
329
+
330
+ ```
331
+ [w@ww rpi_linux]$ git remote -v
332
+ origin https://github.com/raspberrypi/linux.git (fetch)
333
+ origin https://github.com/raspberrypi/linux.git (push)
334
+ [w@ww rpi_linux]$ dtc bcm2711-rpi-4-b.dtb -o rpi4.dtc 2>/dev/null
335
+ [w@ww rpi_linux]$ grep gpiomem rpi4.dtc
336
+ gpiomem {
337
+ compatible = "brcm,bcm2835-gpiomem";
338
+ [w@ww rpi_linux]$ grep -n -r "brcm,bcm2835-gpiomem" drivers/
339
+ drivers/char/broadcom/bcm2835-gpiomem.c:237: {.compatible = "brcm,bcm2835-gpiomem",},
340
+ [w@ww rpi_linux]$ grep -B1 -A12 -n -H -h -r "brcm,bcm2835-gpiomem" drivers/
341
+ 236-static const struct of_device_id bcm2835_gpiomem_of_match[] = {
342
+ 237: {.compatible = "brcm,bcm2835-gpiomem",},
343
+ 238- { /* sentinel */ },
344
+ 239-};
345
+ 240-
346
+ 241-MODULE_DEVICE_TABLE(of, bcm2835_gpiomem_of_match);
347
+ 242-
348
+ 243-static struct platform_driver bcm2835_gpiomem_driver = {
349
+ 244- .probe = bcm2835_gpiomem_probe,
350
+ 245- .remove = bcm2835_gpiomem_remove,
351
+ 246- .driver = {
352
+ 247- .name = DRIVER_NAME,
353
+ 248- .owner = THIS_MODULE,
354
+ 249- .of_match_table = bcm2835_gpiomem_of_match,
355
+ ```
356
+
357
+ ##
358
+
359
+ Linux源码学习之bindings_helpers
360
+
361
+ C函数签名带static的不会暴露在动态库/静态库的符号中,约等于"私有函数"
362
+
363
+ 例如ioremap只好创建一个非static的rust_helper_ioremap函数当作wrapper把私有函数包一层
364
+ 另外一种办法是static inline函数内一般都是调用一个公开的函数,要不就直接调里面的函数也行
0 commit comments