SPI based GPIO Expander issue on IMX51.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI based GPIO Expander issue on IMX51.

2,278 Views
nit123
Contributor I

Hi

 

I am trying to make GPIO expander driver on IMX51.

I have a chip mcp23s17 i added the driver for the same.

 

But whenever its going in to the read function of the driver it throws the below error.

 

root@freescale/home/modules_install$ insmod mcp23s08.ko

Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = 80004000
[00000000] *pgd=00000000
Internal error: Oops: 17 [#1] PREEMPT
last sysfs file:
Modules linked in: mcp23s08(+)
CPU: 0    Not tainted  (2.6.35.3-g2d4b922-dirty #19)
PC is at mxc_spi_buf_tx_u8+0x8/0x14
LR is at spi_put_tx_data+0x24/0x50
pc : [<802794dc>]    lr : [<802795bc>]    psr: 80000013
sp : 9a1c7f28  ip : 00000008  fp : 00000000
r10: 9a0bf318  r9 : 9a0bf800  r8 : 9b86e004
r7 : 00000001  r6 : 9a0bf318  r5 : 00000002  r4 : 9b86e000
r3 : 00000000  r2 : 9a0bf318  r1 : 00000002  r0 : 9a0bf318
Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c5387d  Table: aa41c019  DAC: 00000017
Process mxc_spi.0 (pid: 249, stack limit = 0x9a1c62e8)
Stack: (0x9a1c7f28 to 0x9a1c8000)
7f20:                   9a0bf318 9a419e08 9a0bf800 00000001 9a419e2c 8027a248
7f40: 9a419e08 00000000 9a1c6000 9a419e4c 9a419e2c 80279168 9a1c6000 ffffffff
7f60: 80279600 9a0bf32c 9a1a02e0 9a1c6000 9a1a02e0 9a1a02e8 80278fe8 9a1c7f94
7f80: 9a0bf320 00000000 9a0bf31c 800786b0 9a1c6000 00000000 9a1bae60 8007c044
7fa0: 9a1c7fa0 9a1c7fa0 00000000 9a029e78 9a1c7fd4 80078530 9a1a02e0 00000000
7fc0: 00000000 00000000 00000000 8007bd00 00000000 00000000 9a1c7fd8 9a1c7fd8
7fe0: 00000000 9a029e78 8007bc88 800389e0 00000013 800389e0 ffffbfdf 00000002
[<802794dc>] (mxc_spi_buf_tx_u8+0x8/0x14) from [<802795bc>] (spi_put_tx_data+0x24/0x50)
[<802795bc>] (spi_put_tx_data+0x24/0x50) from [<8027a248>] (mxc_spi_transfer+0xdc/0x15c)
[<8027a248>] (mxc_spi_transfer+0xdc/0x15c) from [<80279168>] (bitbang_work+0x180/0x304)
[<80279168>] (bitbang_work+0x180/0x304) from [<800786b0>] (worker_thread+0x180/0x22c)
[<800786b0>] (worker_thread+0x180/0x22c) from [<8007bd00>] (kthread+0x78/0x80)
[<8007bd00>] (kthread+0x78/0x80) from [<800389e0>] (kernel_thread_exit+0x0/0x8)
Code: e5803050 e12fff1e e590304c e1a02000 (e4d30001)
---[ end trace 1b027d2e3a77bec4 ]---

 

 

 

 

So i am not getting any idea why this error is coming while trying to read some register value.

 

Any help will be thankful.

Tags (1)
0 Kudos
17 Replies

1,605 Views
nit123
Contributor I

Thanks Fabio the issue is got resolved with latest kernel.

But need to backport for old kernel also still.

Fabio Estevam said:

Ok, let us know how it goes.

Good luck!

0 Kudos

1,605 Views
fabio_estevam
NXP Employee
NXP Employee

Ok, let us know how it goes.

Good luck!

0 Kudos

1,605 Views
nit123
Contributor I

Thanks Fabio it got booted.

Now i will try for SPI GPIO expander issue on this kernel.

0 Kudos

1,605 Views
fabio_estevam
NXP Employee
NXP Employee

After you clone the u-boot-imx git:

make mx51evk_config

make u-boot.imx

Then copy u-boot.imx to the SD card:

sudo dd if=u-boot.imx of=/dev/mmcblk0 bs=512 seek=2

This process is explained at: http://git.denx.de/?p=u-boot/u-boot-imx.git;a=blob;f=doc/README.imximage;h=073e3fcb3c6ecc9a7dfa8af46...

Then boot the board and setup the env variables.

I used TFTP to transfer the kernel and NFS to mount the rootfs.

Good luck!

Regards,

Fabio Estevam

0 Kudos

1,605 Views
nit123
Contributor I

Ok Thanks i will try.

Fabio Estevam said:

You need to use the latest U-boot from the git I sent you.

0 Kudos

1,605 Views
fabio_estevam
NXP Employee
NXP Employee

You need to use the latest U-boot from the git I sent you.

0 Kudos

1,605 Views
nit123
Contributor I

Hi Fabio,

thanks for reply.

that toolchain problem is solved by just giving the latest arm tool chain path.

Now i am not able to boot the kernel strucking kernel boot with followin log.

As i am in hurry to solve the SPI GPIO expander issue so please give me your suggestion how you booted it properly with steps if possible.

 

## Booting kernel from Legacy Image at 90800000 ...
   Image Name:   Linux-3.3.0-rc2
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2972216 Bytes =  2.8 MB
   Load Address: 90008000
   Entry Point:  90008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

0 Kudos

1,605 Views
fabio_estevam
NXP Employee
NXP Employee

Please check my kernel log and you will see that I used gcc4.4.4 that comes with FSL BSP.

What are the errors you get when building the kernel?

Also, please use the latest U-boot from http://git.denx.de/?p=u-boot/u-boot-imx.git;a=summary

Regards,

Fabio Estevam

0 Kudos

1,605 Views
nit123
Contributor I

Hi Fabio

I compiled and trying to boot it.

but getting following messaage alone.

 

## Booting kernel from Legacy Image at 90800000 ...
   Image Name:   Linux-3.3.0-rc2
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2972216 Bytes =  2.8 MB
   Load Address: 90008000
   Entry Point:  90008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

0 Kudos

1,600 Views
nit123
Contributor I

Hi Fabio,

One more doubt i have which tool chain version u have used for it.

As i am getting some of the errors with existing toolchain for compilation of latest kernel.

And is it mendetory to take latest uboot also.Can i use my old uboot only.

if you downloaded uboot also somewhere please send me the link for the same.

0 Kudos

1,605 Views
nit123
Contributor I

Hi Fabio thanks for reply.

So are you able to get the prompt also?

0 Kudos

1,605 Views
fabio_estevam
NXP Employee
NXP Employee

I have just installed the latest u-boot from denx and latest kernel from kernel.org and my mx51evk boots fine.

make imx_v6_v7_defconfig  (this is the defconfig for all i.MX of v6 and v7 types, which include mx51)

make uImage LOADADDR=0x90008000  (The 0x90008000 address for mx51 can be verified at arch/mach-imx/Makefile.boot)

This will generate a uImage at arch/arm/boot . Then I copied uImage to /tftpboot so that U-boot can load it via TFTP

This is my bootlog:

U-Boot 2011.12-06915-g290b53f (Feb 07 2012 - 15:18:57)                          
                                                                                
CPU:   Freescale i.MX51 family rev3.0 at 800 MHz                                
Reset cause: POR                                                                
Board: MX51EVK                                                                  
DRAM:  512 MiB                                                                  
WARNING: Caches not enabled                                                     
MMC:   FSL_SDHC: 0, FSL_SDHC: 1                                                 
In:    serial                                                                   
Out:   serial                                                                   
Err:   serial                                                                   
Net:   FEC                                                                      
Warning: failed to set MAC address                                              
                                                                                
Hit any key to stop autoboot:  0                                                
** Partition 2 not valid on device 0 **                                         
                                                                                
** Unable to use mmc 0:2 for fatload **                                         
** Partition 2 not valid on device 0 **                                         
                                                                                
** Unable to use mmc 0:2 for fatload **                                         
Using FEC device                                                                
TFTP from server 192.168.1.100; our IP address is 192.168.1.101                 
Filename 'uImage'.                                                              
Load address: 0x90800000                                                        
Loading: #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         ############################################################           
done                                                                            
Bytes transferred = 2965656 (2d4098 hex)                                        
## Booting kernel from Legacy Image at 90800000 ...                             
   Image Name:   Linux-3.3.0-rc2+                                               
   Created:      2012-02-07  17:26:06 UTC                                       
   Image Type:   ARM Linux Kernel Image (uncompressed)                          
   Data Size:    2965592 Bytes = 2.8 MiB                                        
   Load Address: 90008000                                                       
   Entry Point:  90008000                                                       
   Verifying Checksum ... OK                                                    
   Loading Kernel Image ... OK                                                  
OK                                                                              
                                                                                
Starting kernel ...                                                             
                                                                                
Uncompressing Linux... done, booting the kernel.                                
Booting Linux on physical CPU 0                                                 
Linux version 3.3.0-rc2+ (fabio@fabio-Latitude-E6410) (gcc version 4.4.4 (4.4.42
CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c53c7d                 
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache        
Machine: Freescale MX51 Babbage Board                                           
Memory policy: ECC disabled, Data cache writeback                               
PERCPU: Embedded 7 pages/cpu @809a2000 s4928 r8192 d15552 u32768                
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048     
Kernel command line: console=ttymxc0,115200 root=/dev/nfs ip=dhcp nfsroot=192.1p
PID hash table entries: 2048 (order: 1, 8192 bytes)                             
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)                 
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)                  
Memory: 512MB = 512MB total                                                     
Memory: 513992k/513992k available, 10296k reserved, 0K highmem                  
Virtual kernel memory layout:                                                   
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)                               
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)                               
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)                               
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)                               
    modules : 0x7f000000 - 0x80000000   (  16 MB)                               
      .text : 0x80008000 - 0x804d3000   (4908 kB)                               
      .init : 0x804d3000 - 0x80509340   ( 217 kB)                               
      .data : 0x8050a000 - 0x80549fc0   ( 256 kB)                               
       .bss : 0x80549fe4 - 0x8059dc34   ( 336 kB)                               
SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1         
Hierarchical RCU implementation.                                                
NR_IRQS:436                                                                     
TrustZone Interrupt Controller (TZIC) initialized                               
CPU identified as i.MX51, silicon rev 3.0                                       
sched_clock: 32 bits at 66MHz, resolution 15ns, wraps every 64585ms             
Console: colour dummy device 80x30                                              
Calibrating delay loop... 795.44 BogoMIPS (lpj=3977216)                         
pid_max: default: 32768 minimum: 301                                            
Mount-cache hash table entries: 512                                             
CPU: Testing write buffer coherency: ok                                         
CPU0: thread -1, cpu 0, socket -1, mpidr 0                                      
Setting up static identity map for 0x903ca8e8 - 0x903ca958                      
Brought up 1 CPUs                                                               
SMP: Total of 1 processors activated (795.44 BogoMIPS).                         
devtmpfs: initialized                                                           
print_constraints: dummy:                                                       
NET: Registered protocol family 16                                              
gpiochip_add: registered GPIOs 0 to 31 on device: imx31-gpio.0                  
gpiochip_add: registered GPIOs 32 to 63 on device: imx31-gpio.1                 
gpiochip_add: registered GPIOs 64 to 95 on device: imx31-gpio.2                 
gpiochip_add: registered GPIOs 96 to 127 on device: imx31-gpio.3                
bio: create slab <bio-0> at 0                                                   
SCSI subsystem initialized                                                      
usbcore: registered new interface driver usbfs                                  
usbcore: registered new interface driver hub                                    
usbcore: registered new device driver usb                                       
Switching to clocksource mxc_timer1                                             
NET: Registered protocol family 2                                               
IP route cache hash table entries: 4096 (order: 2, 16384 bytes)                 
TCP established hash table entries: 16384 (order: 5, 131072 bytes)              
TCP bind hash table entries: 16384 (order: 5, 131072 bytes)                     
TCP: Hash tables configured (established 16384 bind 16384)                      
TCP reno registered                                                             
UDP hash table entries: 256 (order: 1, 8192 bytes)                              
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)                         
NET: Registered protocol family 1                                               
RPC: Registered named UNIX socket transport module.                             
RPC: Registered udp transport module.                                           
RPC: Registered tcp transport module.                                           
RPC: Registered tcp NFSv4.1 backchannel transport module.                       
VFS: Disk quotas dquot_6.5.2                                                    
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)                      
fuse init (API version 7.18)                                                    
msgmni has been set to 1003                                                     
io scheduler noop registered                                                    
io scheduler deadline registered                                                
io scheduler cfq registered (default)                                           
imx-sdma imx35-sdma: initialized                                                
Serial: IMX driver                                                              
imx21-uart.0: ttymxc0 at MMIO 0x73fbc000 (irq = 31) is a IMX                    
console [ttymxc0] enabled                                                       
imx21-uart.1: ttymxc1 at MMIO 0x73fc0000 (irq = 32) is a IMX                    
imx21-uart.2: ttymxc2 at MMIO 0x7000c000 (irq = 33) is a IMX                    
brd: module loaded                                                              
loop: module loaded                                                             
spi_imx imx51-ecspi.0: probed                                                   
FEC Ethernet Driver                                                             
fec_enet_mii_bus: probed                                                        
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver                      
mxc-ehci mxc-ehci.1: initializing i.MX USB Controller                           
mxc-ehci mxc-ehci.1: Freescale On-Chip EHCI Host Controller                     
mxc-ehci mxc-ehci.1: new USB bus registered, assigned bus number 1              
mxc-ehci mxc-ehci.1: irq 14, io mem 0x73f80200                                  
mxc-ehci mxc-ehci.1: USB 2.0 started, EHCI 1.00                                 
hub 1-0:1.0: USB hub found                                                      
hub 1-0:1.0: 1 port detected                                                    
Initializing USB Mass Storage driver...                                         
usbcore: registered new interface driver usb-storage                            
USB Mass Storage support registered.                                            
mousedev: PS/2 mouse device common for all mice                                 
i2c /dev entries driver                                                         
imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0)     
sdhci: Secure Digital Host Controller Interface driver                          
sdhci: Copyright(c) Pierre Ossman                                               
sdhci-pltfm: SDHCI platform and OF driver helper                                
mmc0: no vmmc regulator found                                                   
mmc0: SDHCI controller on sdhci-esdhc-imx51.0 [sdhci-esdhc-imx51.0] using DMA   
mmc1: no vmmc regulator found                                                   
mmc1: SDHCI controller on sdhci-esdhc-imx51.1 [sdhci-esdhc-imx51.1] using DMA   
usbcore: registered new interface driver usbhid                                 
usbhid: USB HID core driver                                                     
TCP cubic registered                                                            
NET: Registered protocol family 10                                              
IPv6 over IPv4 tunneling driver                                                 
NET: Registered protocol family 17                                              
Registering the dns_resolver key type                                           
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 2         
input: gpio-keys as /devices/platform/gpio-keys/input/input0                    
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)                         
eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=imx27-fec-1:00, )
ADDRCONF(NETDEV_UP): eth0: link is not ready                                    
mmc0: new high speed SDHC card at address 8551                                  
mmcblk0: mmc0:8551 SD08G 7.40 GiB                                               
 mmcblk0: p1                                                                    
usb 1-1: new high-speed USB device number 2 using mxc-ehci                      
hub 1-1:1.0: USB hub found                                                      
hub 1-1:1.0: 7 ports detected                                                   
PHY: imx27-fec-1:00 - Link is Up - 100/Full                                     
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready                               
Sending DHCP requests ., OK                                                     
IP-Config: Got DHCP answer from 192.168.1.1, my address is 192.168.1.101        
IP-Config: Complete:                                                            
     device=eth0, addr=192.168.1.101, mask=255.255.255.0, gw=192.168.1.1,       
     host=192.168.1.101, domain=cps.virtua.com.br, nis-domain=(none),           
     bootserver=192.168.1.1, rootserver=192.168.1.100, rootpath=                
usb 1-1.6: new high-speed USB device number 3 using mxc-ehci                    
scsi0 : usb-storage 1-1.6:1.0                                                   
scsi 0:0:0:0: Direct-Access     USB TO I DE/SATA Device   0009 PQ: 0 ANSI: 0    
sd 0:0:0:0: [sda] Test WP failed, assume Write Enabled                          
sd 0:0:0:0: [sda] Asking for cache data failed                                  
sd 0:0:0:0: [sda] Assuming drive cache: write through                           
sd 0:0:0:0: [sda] Test WP failed, assume Write Enabled                          
sd 0:0:0:0: [sda] Asking for cache data failed                                  
sd 0:0:0:0: [sda] Assuming drive cache: write through                           
sd 0:0:0:0: [sda] Attached SCSI disk                                            
usb 1-1.1: new high-speed USB device number 4 using mxc-ehci                    
usb-storage 1-1.1:1.0: Quirks match for vid 0457 pid 0151: 80                   
scsi1 : usb-storage 1-1.1:1.0                                                   
scsi 1:0:0:0: Direct-Access     Ut163    USB2FlashStorage 0.00 PQ: 0 ANSI: 2    
sd 1:0:0:0: [sdb] 248000 512-byte logical blocks: (126 MB/121 MiB)              
sd 1:0:0:0: [sdb] Write Protect is off                                          
sd 1:0:0:0: [sdb] Asking for cache data failed                                  
sd 1:0:0:0: [sdb] Assuming drive cache: write through                           
sd 1:0:0:0: [sdb] Asking for cache data failed                                  
sd 1:0:0:0: [sdb] Assuming drive cache: write through                           
 sdb: sdb1                                                                      
sd 1:0:0:0: [sdb] Asking for cache data failed                                  
sd 1:0:0:0: [sdb] Assuming drive cache: write through                           
sd 1:0:0:0: [sdb] Attached SCSI removable disk       

0 Kudos

1,605 Views
nit123
Contributor I

Is any body know about this type of issue.I am still not finding any solution for it.

0 Kudos

1,605 Views
nit123
Contributor I

Yes i tried to boot the kernel 3.2.1 version,but it did not boot.so it needs some more extra effot and for imx51.Pls tell if somebody have compiled and used the latest kernel for imx51 target and tell me the customization procedure as i am running out of time so i can not dig it more due to my current task for spi gpio expander.

Fabio Estevam said:

Can you try this with the latest kernel from kernel.org?

Regards,

Fabio Estevam

0 Kudos

1,605 Views
fabio_estevam
NXP Employee
NXP Employee

Can you try this with the latest kernel from kernel.org?

Regards,

Fabio Estevam

0 Kudos

1,605 Views
KursadOney
NXP Employee
NXP Employee

You need to enable CONFIG_DEBUG_INFO so you can use addr2line to find out exactly where the crash is. If you also enable CONFIG_KCORE_ELF, you can run gdb on your /proc/kcore file and inspect the memory. See this link for various kernel debugging techniques.

0 Kudos

1,605 Views
nit123
Contributor I

I have patched also mcp23s08 driver for mcp23s17 chip.

I tried to test alone spi functionality with spi test program but i did not get any spi device for testing spi1.2.

so from user space application for testing the spidev functionality also i could not get any solution,as i could not get any device for testing using it.

my device is connected to spi1 chip select2.

 

So please advise me how i can proceed further.As i am running out of time so i need to solve it urgently and complete the driver.

0 Kudos