2011-05-02 09:11:41 Module Example, Null Pointer Access?
rifat tursen (UNITED STATES)
Message: 100340
Hello,
I am learning about kernel modules. I have compiled the sample module example from the wiki but whenever I load the module I get a null pointer access. I must be missing something very basic. To make matters more confusing for me, I have tried loading an example module from the Linux Device Drivers and it run without problems.
My platform is BF537 Stamp and I am using the 2010R1-RC5 distribution. I attach the error log that I receive when I issue the command "insmod sample_module.ko"
thank you for your help
rifat
root:/home> insmod sample_module.ko
NULL pointer access
Kernel OOPS in progress
Deferred Exception context
CURRENT PROCESS:
COMM=insmod PID=178 CPU=0
TEXT = 0x02c00040-0x02c4d3c0 DATA = 0x02c4d3e0-0x02c60570
BSS = 0x02c60570-0x02c61f30 USER-STACK = 0x02c6af5c
return address: [0x000ad9d6]; contents of:
0x000ad9b0: 6000 0127 0010 e410 fffe 2fee 3209 05fc
0x000ad9c0: 3220 0167 6fa6 af4d 3210 6fc4 0c45 1825
0x000ad9d0: 0000 0000 0000 [9968] 0c00 181a 0000 0000
0x000ad9e0: 0000 e417 fffe 2005 6cc5 9968 0c00 1810
ADSP-BF537-0.2(Detected 0.3) 500(MHz CCLK) 125(MHz SCLK) (mpu off)
Linux version 2.6.34.7-ADI-2010R1 (root@eight) (gcc version 4.3.5 (ADI-2010R1-R0
SEQUENCER STATUS: Tainted: P
SEQSTAT: 00002027 IPEND: 8008 IMASK: ffff SYSCFG: 0006
EXCAUSE : 0x27
physical IVG3 asserted : <0xffa007d8> { _trap + 0x0 }
physical IVG15 asserted : <0xffa010bc> { _evt_system_call + 0x0 }
logical irq 6 mapped : <0xffa003ec> { _bfin_coretmr_interrupt + 0x0 }
logical irq 10 mapped : <0x000bdfc0> { _bfin_rtc_interrupt + 0x0 }
logical irq 18 mapped : <0x000a99d4> { _bfin_serial_dma_rx_int + 0x0 }
logical irq 19 mapped : <0x000a972c> { _bfin_serial_dma_tx_int + 0x0 }
logical irq 24 mapped : <0x000b94f0> { _bfin_mac_interrupt + 0x0 }
RETE: <0x00000000> /* Maybe null pointer? */
RETN: <0x02b83de4> /* kernel dynamic memory (maybe user-space) */
RETX: <0x00000480> /* Maybe fixed code section */
RETS: <0x000acb8c> { ___driver_attach + 0x14 }
PC : <0x000ad9d6> { _platform_match + 0x1a }
DCPLB_FAULT_ADDR: <0x00000001> /* Maybe null pointer? */
ICPLB_FAULT_ADDR: <0x000ad9d6> { _platform_match + 0x1a }
PROCESSOR STATE:
R0 : 00185c04 R1 : 02ad6d00 R2 : 00000000 R3 : 00000180
R4 : 02c1acb2 R5 : 02ad6d00 R6 : 02b83e28 R7 : 00000000
P0 : 02940d80 P1 : 02ad6d00 P2 : 00185c04 P3 : 02ad6d00
P4 : 00185bfc P5 : 00000001 FP : 02938200 SP : 02b83d08
LB0: ffa01808 LT0: ffa01808 LC0: 00000000
LB1: 000949e0 LT1: 000949d4 LC1: 00000000
B0 : 00000000 L0 : 00000000 M0 : 00000000 I0 : 02aeae34
B1 : 00000000 L1 : 00000000 M1 : 00000000 I1 : 02abc8ec
B2 : 00000000 L2 : 00000000 M2 : 00000000 I2 : 00000000
B3 : 00000000 L3 : 00000000 M3 : 00000000 I3 : 00000000
A0.w: 00000000 A0.x: 00000000 A1.w: 00000000 A1.x: 00000000
USP : 02c6ae5c ASTAT: 00003005
Hardware Trace:
0 Target : <0x00003efc> { _trap_c + 0x0 }
Source : <0xffa0076c> { _exception_to_level5 + 0xa4 } CALL pcrel
1 Target : <0xffa006c8> { _exception_to_level5 + 0x0 }
Source : <0xffa0057c> { _bfin_return_from_exception + 0x20 } RTX
2 Target : <0xffa0055c> { _bfin_return_from_exception + 0x0 }
Source : <0xffa00620> { _ex_trap_c + 0x74 } JUMP.S
3 Target : <0xffa005ac> { _ex_trap_c + 0x0 }
Source : <0xffa00484> { _ex_workaround_261 + 0x1c } JUMP.S
4 Target : <0xffa00468> { _ex_workaround_261 + 0x0 }
Source : <0xffa00840> { _trap + 0x68 } JUMP (P4)
5 Target : <0xffa007f6> { _trap + 0x1e }
Source : <0xffa007f2> { _trap + 0x1a } IF CC JUMP pcrel
6 Target : <0xffa007d8> { _trap + 0x0 }
FAULT : <0x000ad9d6> { _platform_match + 0x1a } R0 = B[P5] (X)
Source : <0xffa0057c> { _bfin_return_from_exception + 0x20 } RTX
7 Target : <0xffa0055c> { _bfin_return_from_exception + 0x0 }
Source : <0xffa0047a> { _ex_workaround_261 + 0x12 } IF !CC JUMP pcrel
8 Target : <0xffa00468> { _ex_workaround_261 + 0x0 }
Source : <0xffa00840> { _trap + 0x68 } JUMP (P4)
9 Target : <0xffa007f6> { _trap + 0x1e }
Source : <0xffa007f2> { _trap + 0x1a } IF CC JUMP pcrel
10 Target : <0xffa007d8> { _trap + 0x0 }
Source : <0x000ad9d4> { _platform_match + 0x18 } NOP
11 Target : <0x000ad9bc> { _platform_match + 0x0 }
Source : <0x000acb8a> { ___driver_attach + 0x12 } CALL (P2)
12 Target : <0x000acb78> { ___driver_attach + 0x0 }
Source : <0x000ac476> { _bus_for_each_dev + 0x42 } CALL (P5)
13 Target : <0x000ac468> { _bus_for_each_dev + 0x34 }
Source : <0x000ac484> { _bus_for_each_dev + 0x50 } IF !CC JUMP pcrel (BP)
14 Target : <0x000ac480> { _bus_for_each_dev + 0x4c }
Source : <0x00114d02> { _klist_next + 0x62 } RTS
15 Target : <0x00114cf8> { _klist_next + 0x58 }
Source : <0x00114cf2> { _klist_next + 0x52 } IF CC JUMP pcrel
Kernel Stack
Stack info:
SP: [0x02b83cc8] <0x02b83cc8> /* kernel dynamic memory (maybe user-space) */
Memory from 0x02b83cc0 to 02b84000
02b83cc0: 02029060 0202908c [00000000] 02029620 020297a0 02029060 02b83d08
02b83ce0: 00000000 ffa00770 00176000 00008008 00002027 02ad6d00 02c1acb2
02b83d00: 00000001 00000480 00000480 00008008 00002027 00000000 02b83de4
02b83d20: 000ad9d6 <000acb8c> 00185c04 00003005 000949e0 ffa01808 000949d4
02b83d40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83d60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83d80: 00000000 00000000 00000000 00000000 02abc8ec 02aeae34 02c6ae5c
02b83da0: 00000001 00185bfc 02ad6d00 00185c04 02ad6d00 02940d80 00000000
02b83dc0: 02ad6d00 02c1acb2 00000180 00000000 02ad6d00 00185c04 00185c04
02b83de0: 00000006 00000000 0007a2c2 02938200 <000acb8c> 00185c04 02ad6d00
02b83e00: 02c1acb2 02b83e08 02938200 <000ac478> 000acb78 0018defc 00000000
02b83e20: 0018defc 00090e8e 020055d8 02037530 000ac96e 02ad6d34 02b90004
02b83e40: 00000000 000abe76 02b83e68 000abeb0 000acb78 000abece 00000000
02b83e60: 000002d0 001431ac 02ad6cf0 02070800 000ace10 02ad6d34 0017400c
02b83e80: 02b90004 00008e29 02c1acb2 00000280 02921720 <00001028> 02ad6d34
02b83ea0: 0017002e 02b90004 00008e29 00000000 00000000 000254a8 02ad6d34
02b83ec0: 02c6ae68 00030478 02ad6d34 00000080 0000002e 02b90004 00008e29
02b83ee0: 2938a066 000452ea 00000000 020b01c0 ffffe000 <ffa0097a> 000303d4
02b83f00: 00000000 ffffe000 00000104 02949ff3 02029620 00000001 00008e29
02b83f20: 00000104 02c02e0c 00008000 00002000 00000000 02b84000 02c02e0c
02b83f40: 02c1b52a ffa01120 02001044 02991fcf 02c0ca05 02991fc4 02c0ca04
02b83f60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83f80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83fa0: 00000000 00000000 00000000 00000000 02c6af6c 02c6ae5c 02c6ae68
02b83fc0: 02c6af60 0000002e 02b98e2d 02b99ff4 00000080 02b90004 02c60110
02b83fe0: 02c1acb2 00008e29 02c60110 00008e29 02b90004 02b90004 00000080
Return addresses in stack:
address : <0x000acb8c> { ___driver_attach + 0x14 }
address : <0x000acb8c> { ___driver_attach + 0x14 }
address : <0x000ac478> { _bus_for_each_dev + 0x44 }
address : <0x00001028> { _do_one_initcall + 0x28 }
address : <0xffa0097a> { _system_call + 0x6a }
Modules linked in: sample_module(+) [last unloaded: hello]
Kernel panic - not syncing: Kernel exception
Hardware Trace:
Stack info:
SP: [0x02b83c2c] <0x02b83c2c> /* kernel dynamic memory (maybe user-space) */
Memory from 0x02b83c20 to 02b84000
02b83c20: 0000000b 02b83c2c 00000013 [00144ed0] 001162ea 02b83d08 00144ed0
02b83c40: 001793ce 001793ce 02b83c5c 00004334 02b83d08 00008008 02b83d08
02b83c60: 0000003f ffffffff 00000044 0003000b 0000ce6c 00189620 02029620
02b83c80: 0202964c 00000000 00000001 001868fc 00000000 002625a0 02b83cc8
02b83ca0: 0202908c 00186928 02029094 02b83cd4 02b83cd8 0000ce08 001868fc
02b83cc0: 02029060 0202908c 00000000 02029620 020297a0 02029060 02b83d08
02b83ce0: 00000000 ffa00770 00176000 00008008 00002027 02ad6d00 02c1acb2
02b83d00: 00000001 00000480 00000480 00008008 00002027 00000000 02b83de4
02b83d20: 000ad9d6 <000acb8c> 00185c04 00003005 000949e0 ffa01808 000949d4
02b83d40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83d60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83d80: 00000000 00000000 00000000 00000000 02abc8ec 02aeae34 02c6ae5c
02b83da0: 00000001 00185bfc 02ad6d00 00185c04 02ad6d00 02940d80 00000000
02b83dc0: 02ad6d00 02c1acb2 00000180 00000000 02ad6d00 00185c04 00185c04
02b83de0: 00000006 00000000 0007a2c2 02938200 <000acb8c> 00185c04 02ad6d00
02b83e00: 02c1acb2 02b83e08 02938200 <000ac478> 000acb78 0018defc 00000000
02b83e20: 0018defc 00090e8e 020055d8 02037530 000ac96e 02ad6d34 02b90004
02b83e40: 00000000 000abe76 02b83e68 000abeb0 000acb78 000abece 00000000
02b83e60: 000002d0 001431ac 02ad6cf0 02070800 000ace10 02ad6d34 0017400c
02b83e80: 02b90004 00008e29 02c1acb2 00000280 02921720 <00001028> 02ad6d34
02b83ea0: 0017002e 02b90004 00008e29 00000000 00000000 000254a8 02ad6d34
02b83ec0: 02c6ae68 00030478 02ad6d34 00000080 0000002e 02b90004 00008e29
02b83ee0: 2938a066 000452ea 00000000 020b01c0 ffffe000 <ffa0097a> 000303d4
02b83f00: 00000000 ffffe000 00000104 02949ff3 02029620 00000001 00008e29
02b83f20: 00000104 02c02e0c 00008000 00002000 00000000 02b84000 02c02e0c
02b83f40: 02c1b52a ffa01120 02001044 02991fcf 02c0ca05 02991fc4 02c0ca04
02b83f60: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83f80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000
02b83fa0: 00000000 00000000 00000000 00000000 02c6af6c 02c6ae5c 02c6ae68
02b83fc0: 02c6af60 0000002e 02b98e2d 02b99ff4 00000080 02b90004 02c60110
02b83fe0: 02c1acb2 00008e29 02c60110 00008e29 02b90004 02b90004 00000080
Return addresses in stack:
address : <0x000acb8c> { ___driver_attach + 0x14 }
address : <0x000acb8c> { ___driver_attach + 0x14 }
address : <0x000ac478> { _bus_for_each_dev + 0x44 }
address : <0x00001028> { _do_one_initcall + 0x28 }
address : <0xffa0097a> { _system_call + 0x6a }
QuoteReplyEditDelete
2011-05-02 12:55:34 Re: Module Example, Null Pointer Access?
Mike Frysinger (UNITED STATES)
Message: 100342
post the actual code you're compiling and loading
QuoteReplyEditDelete
2011-05-02 14:30:36 Re: Module Example, Null Pointer Access?
rifat tursen (UNITED STATES)
Message: 100344
Hello, the code is taken directly from the wiki
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/platform_device.h>
MODULE_DESCRIPTION("sample module");
MODULE_LICENSE("GPL");
static int sample_module_drv_probe(struct device *dev)
{
printk(KERN_DEBUG "probe sample module device\n");
return 0;
}
static int sample_module_drv_remove(struct device *dev)
{
printk(KERN_DEBUG "remove sample module device\n");
return 0;
}
static struct device_driver sample_module_driver = {
.name = "sample_module",
.bus = &platform_bus_type,
.probe = sample_module_drv_probe,
.remove = sample_module_drv_remove,
};
static int __init sample_module_init(void)
{
printk(KERN_DEBUG "init sample module device\n");
return driver_register(&sample_module_driver);
}
static void __exit sample_module_cleanup(void)
{
printk(KERN_DEBUG "cleanup sample module device\n");
driver_unregister(&sample_module_driver);
}
module_init(sample_module_init);
module_exit(sample_module_cleanup);
thanks a lot
QuoteReplyEditDelete
2011-05-02 14:40:35 Re: Module Example, Null Pointer Access?
Mike Frysinger (UNITED STATES)
Message: 100345
that is the old way for registering a platform device driver. look at drivers/watchdog/bfin_wdt.c as a simple way of registering a platform driver.
QuoteReplyEditDelete
2011-05-02 15:18:33 Re: Module Example, Null Pointer Access?
rifat tursen (UNITED STATES)
Message: 100346
okey,
thanks a lot for the info. I will change the code according to this.
QuoteReplyEditDelete
2011-05-05 21:53:52 Re: Module Example, Null Pointer Access?
Sergio Morales (COLOMBIA)
Message: 100448
hi Mike, could you upgrade the page to create modules with a smaller version of watchdog code please?, that would be really helpful and could prevent me from doing many stupid questions.
thanks in advance