OpenWrt Forum Archive

Topic: i2c Python smbus Segmentation fault

The content of this topic has been archived on 24 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am trying to run the Python script on BARRIER BREAKER (14.07, r42625)/ar71xx :

#!/usr/bin/env python
# -*- encoding: UTF8 -*-
from smbus import SMBus
b = SMBus(0) # 0 indicates /dev/i2c-0
b.read_byte(0x20)
b.write_byte(0x20,0xF0)

I am getting the following message :

"Segmentation fault"

Could someone please give me some help ???

i have same problem with smbus

I got this SegFault too, on my new Domino OpenWRT.

The python script is :

import time
import smbus

MCP23017_DEVADDR = 0x20

bus = smbus.SMBus(0)

bus.write_byte_data(MCP23017_DEVADDR,0x00,0x00) # Set all of bank A to outputs
bus.write_byte_data(MCP23017_DEVADDR,0x01,0x00) # Set all of bank B to outputs

while 1:
    bus.write_byte_data(address,0x13,0x80)
    time.sleep(0.5)
    bus.write_byte_data(address,0x13,0x00)
    time.sleep(0.5)

It crash at the first write_byte_data ... :-(

The strace is showing :

open("/lib/libgcc_s.so.1", O_RDONLY)    = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=78632, ...}) = 0
close(4)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=359583, ...}) = 0
close(4)                                = 0
open("/lib/libc.so.0", O_RDONLY)        = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=359583, ...}) = 0
close(4)                                = 0
open("/lib/ld-uClibc.so.0", O_RDONLY)   = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=28968, ...}) = 0
close(4)                                = 0
close(3)                                = 0
open("/dev/i2c-0", O_RDWR|O_LARGEFILE)  = 3
ioctl(3, 0x703, 0x20)                   = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---
+++ killed by SIGSEGV +++
Segmentation fault

My version of OpenWRT is :

DISTRIB_ID="OpenWrt"
DISTRIB_RELEASE="Barrier Breaker"
DISTRIB_REVISION="r45620"
DISTRIB_CODENAME="barrier_breaker"
DISTRIB_TARGET="ar71xx/generic"
DISTRIB_DESCRIPTION="OpenWrt Barrier Breaker 14.07"
DISTRIB_TAINTS="busybox"

The discussion might have continued from here.