目前共有10篇帖子。
![]() |
備兩份內核代碼。
一份專門用來用./build.sh生成鏡像並燒錄,設備樹也在這裏面改。 另一份專門用來編譯內核模塊,不用改裏面的設備樹。 cp -r /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/kernel /home/oct1158/Documents/Code/C/kernel_for_modules cd /home/oct1158/Documents/Code/C/kernel_for_modules make luckfox_rv1106_linux_defconfig ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf- make ARCH=arm CROSS_COMPILE=/home/oct1158/Documents/Code/C/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf- |
![]() |
修改設備樹後重新編譯內核: 然後用另一份沒有改設備樹的內核代碼重新編譯驅動模塊: 上傳到板子上運行: 查看新增的設備樹節點: |
![]() |
從打印輸出裏面可以看到,編譯好的設備樹文件最終是放到boot.img鏡像裏面的。 Image: resource.img (with rv1103g-luckfox-pico-mini.dtb logo.bmp logo_kernel.bmp) is ready |
![]() |
設備樹文件rv1103g-luckfox-pico-mini.dts的修改內容: / {}裏面添加 mytest { |
![]() |
內核模塊test.c的代碼: #include <linux/gpio/consumer.h> // gpiod_set_value static int mytestdriver_probe(struct platform_device *pdev) static int mytestdriver_remove(struct platform_device *pdev) static const struct of_device_id mytestdriver_match_ids[] = { static struct platform_driver mytestdriver = { module_platform_driver(mytestdriver); MODULE_AUTHOR("Oct1158"); |
![]() |
內核模塊Makefile文件: KDIR := /home/oct1158/Documents/Code/C/kernel_for_modules obj-m := test.o build: clean:
|
![]() |
[root@luckfox root]# cat /sys/firmware/devicetree/base/mytest/compatible && echo [root@luckfox root]# insmod test.ko [root@luckfox root]# rmmod test |
![]() |
【解決辦法】編譯linux內核或模塊時遇到錯誤不顯示報錯信息:https://zh.purasbar.com/post.php?t=31654
|
文檔上寫的:Search for a property in a device tree node and retrieve a null terminated string value (pointer to data, not a copy).