这是sys下的信息:
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# ls
compatible gpios name
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# cat name
liya-gpio-key[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# hexdump gpios
0000000 0000 3200 0000 0100 0000 0100
000000c
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# cat compatible
liyadrv[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
这是加载驱动模块的打印:
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# ls
compatible gpios name
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# cat name
liya-gpio-key[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# hexdump gpios
0000000 0000 3200 0000 0100 0000 0100
000000c
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# cat compatible
liyadrv[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# insmod /mnt/
100ask_imx6ull-14x14.dtb gpio_key_drv.ko
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]# insmod /mnt/gpio_key_drv.ko
[ 394.521397] gpio_key_drv: loading out-of-tree module taints kernel.
[ 394.537540] Unable to handle kernel NULL pointer dereference at virtual address 00000084
[ 394.545714] pgd = 88880000
[ 394.548465] [00000084] *pgd=887b3835, *pte=00000000, *ppte=00000000
[ 394.554901] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
[ 394.560343] Modules linked in: gpio_key_drv(O+)
[ 394.565006] CPU: 0 PID: 282 Comm: insmod Tainted: G O 4.9.88 #1
[ 394.572097] Hardware name: Freescale i.MX6 UltraLite (Device Tree)
[ 394.578322] task: 88c9ac00 task.stack: 8865c000
[ 394.582922] PC is at __of_find_property+0x44/0x70
[ 394.587682] LR is at of_find_property+0x44/0x5c
[ 394.592267] pc : [<808adde4>] lr : [<808ade54>] psr: 20030093
[ 394.592267] sp : 8865dbe8 ip : 8865dc08 fp : 8865dc04
[ 394.603796] r10: 00000000 r9 : 00000006 r8 : 8865dc34
[ 394.609068] r7 : 7f0001b8 r6 : 8865dc34 r5 : 7f0001b8 r4 : 00000084
[ 394.615642] r3 : 00007049 r2 : 8865dc34 r1 : 7f0001b8 r0 : 881fb66c
[ 394.622218] Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment none
[ 394.629487] Control: 10c53c7d Table: 8888006a DAC: 00000051
[ 394.635278] Process insmod (pid: 282, stack limit = 0x8865c210)
[ 394.641244] Stack: (0x8865dbe8 to 0x8865e000)
[ 394.645663] dbe0: 8137dd60 881fb66c 40030013 7f0001b8 8865dc2c 8865dc08
[ 394.653908] dc00: 808ade54 808addac 8865dc64 881fb66c 7f0001b8 7f0001ac 7f000200 00000006
[ 394.662153] dc20: 8865dc54 8865dc30 808afd7c 808ade1c 8865dc54 8865dc40 881fb610 fffffffe
[ 394.670397] dc40: 7f000200 fffffdfb 8865dc9c 8865dc58 808aff48 808afd48 00000000 881fadc0
[ 394.678637] dc60: 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 394.686879] dc80: 00000000 00000000 00000006 881fb610 8865dcac 8865dca0 7f000068 808aff20
[ 394.695124] dca0: 8865dccc 8865dcb0 805a43a8 7f000040 881fb610 81375b60 812fd768 00000000
[ 394.703369] dcc0: 8865dd04 8865dcd0 805a1f38 805a4354 808b0b08 808af0ac 8865dd04 881fb644
[ 394.711613] dce0: 881fb610 7f000200 812fd690 00000000 00000000 88813824 8865dd24 8865dd08
[ 394.719857] dd00: 805a2284 805a1d30 00000000 7f000200 805a2174 812fd690 8865dd4c 8865dd28
[ 394.728102] dd20: 8059fce8 805a2180 8808de5c 881f1a34 80b86cdc 7f000200 887f5780 81277cb0
[ 394.736348] dd40: 8865dd5c 8865dd50 805a17a4 8059fc98 8865dd8c 8865dd60 805a123c 805a1784
[ 394.744593] dd60: 7f0001d4 888139c0 8865dd8c 7f000200 7f002000 ffffe000 888139c0 00000001
[ 394.752838] dd80: 8865dda4 8865dd90 805a3038 805a1078 00000000 7f002000 8865ddb4 8865dda8
[ 394.761082] dda0: 805a42f0 805a2fbc 8865ddc4 8865ddb8 7f002034 805a42ac 8865de3c 8865ddc8
[ 394.769327] ddc0: 80101cc4 7f00200c 887ee800 88001f00 ffffe000 8bc66dc0 887ee480 88001f00
[ 394.777572] dde0: ffffe000 0001b484 00000000 88813824 8865de2c 8865de00 8024c2e4 8024bed0
[ 394.785816] de00: 00000001 801ffc1c 00000001 00000002 887ee480 7f000340 00000001 7f000340
[ 394.794059] de20: 00000001 7f000340 888139c0 00000001 8865de64 8865de40 801ffc58 80101c7c
[ 394.802304] de40: 8865de64 8865de50 8865df44 00000001 7f000340 88813800 8865df1c 8865de68
[ 394.810548] de60: 801b84c4 801ffbf0 7f00034c 00007fff 7f000340 801b5a20 80ea5960 80eb49d8
[ 394.818793] de80: 00000000 7f000454 8865df44 80c0406c 7f000540 00000000 7f000388 7f000340
[ 394.827035] dea0: 8865deec 8865deb0 8025bc28 8025ba94 a0d7a000 00000000 00000000 00000000
[ 394.835275] dec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 394.843516] dee0: 00000000 00000000 00000000 00000000 7fffffff 00000000 00000003 00027897
[ 394.851760] df00: 0000017b 80109444 8865c000 00000000 8865dfa4 8865df20 801b8dc0 801b6538
[ 394.860004] df20: 7fffffff 00000000 00000003 8865df38 80220898 a0d7a000 00001714 00000000
[ 394.868250] df40: 00000000 a0d7a000 00001714 a0d7b1c4 a0d7b064 a0d7ace4 00000540 00000760
[ 394.876493] df60: 00000000 00000000 00000000 000006b0 0000001f 00000020 00000019 00000016
[ 394.884737] df80: 00000012 00000000 00000000 00000000 00000000 01cd6128 00000000 8865dfa8
[ 394.892980] dfa0: 80109280 801b8d08 00000000 00000000 00000003 00027897 00000000 01cd6128
[ 394.901225] dfc0: 00000000 00000000 01cd6128 0000017b 01cd5268 00000000 00000002 7e94cdc4
[ 394.909469] dfe0: 7e94cc00 7e94cbf0 0001ecd0 76e4e2e0 600e0010 00000003 00000000 00000000
[ 394.917757] [<808adde4>] (__of_find_property) from [<808ade54>] (of_find_property+0x44/0x5c)
[ 394.926288] [<808ade54>] (of_find_property) from [<808afd7c>] (of_phandle_iterator_init+0x40/0x8c)
[ 394.935338] [<808afd7c>] (of_phandle_iterator_init) from [<808aff48>] (of_count_phandle_with_args+0x34/0x68)
[ 394.945279] [<808aff48>] (of_count_phandle_with_args) from [<7f000068>] (gpio_key_probe+0x34/0x74 [gpio_key_drv])
[ 394.955648] [<7f000068>] (gpio_key_probe [gpio_key_drv]) from [<805a43a8>] (platform_drv_probe+0x60/0xbc)
[ 394.965297] [<805a43a8>] (platform_drv_probe) from [<805a1f38>] (driver_probe_device+0x214/0x450)
[ 394.974245] [<805a1f38>] (driver_probe_device) from [<805a2284>] (__driver_attach+0x110/0x12c)
[ 394.982941] [<805a2284>] (__driver_attach) from [<8059fce8>] (bus_for_each_dev+0x5c/0xac)
[ 394.991197] [<8059fce8>] (bus_for_each_dev) from [<805a17a4>] (driver_attach+0x2c/0x30)
[ 394.999274] [<805a17a4>] (driver_attach) from [<805a123c>] (bus_add_driver+0x1d0/0x274)
[ 395.007356] [<805a123c>] (bus_add_driver) from [<805a3038>] (driver_register+0x88/0x104)
[ 395.015525] [<805a3038>] (driver_register) from [<805a42f0>] (__platform_driver_register+0x50/0x58)
[ 395.024668] [<805a42f0>] (__platform_driver_register) from [<7f002034>] (gpio_key_init+0x34/0x40 [gpio_key_drv])
[ 395.034944] [<7f002034>] (gpio_key_init [gpio_key_drv]) from [<80101cc4>] (do_one_initcall+0x54/0x180)
[ 395.044339] [<80101cc4>] (do_one_initcall) from [<801ffc58>] (do_init_module+0x74/0x1f4)
[ 395.052516] [<801ffc58>] (do_init_module) from [<801b84c4>] (load_module+0x1f98/0x2620)
[ 395.060597] [<801b84c4>] (load_module) from [<801b8dc0>] (SyS_finit_module+0xc4/0xfc)
[ 395.068511] [<801b8dc0>] (SyS_finit_module) from [<80109280>] (ret_fast_syscall+0x0/0x48)
[ 395.076760] Code: e594400c e3540000 0a000007 e1a01005 (e5940000)
[ 395.082908] —[ end trace d9d3dd6743d64d58 ]—
[ 395.087585] note: insmod[282] exited with preempt_count 1
Segmentation fault
[root@imx6ull:/sys/firmware/devicetree/base/liya-gpio-key]#
这是驱动代码:
这是设备树节点:
救救孩子吧。。。。。我直接使用老师的代码也是这样。。。。。我哭了。。。。