iMX233-OLinuXino GPIO Python Libraries


Soon after we released A13-GPIO for Python we got requests to do same for iMX233.

iMX233_GPIO is released on PyPi now
it works identical to pyA13 you can use same commands:

import iMX233_GPIO as GPIO
#init module
#configure module
#set GPIO high
GPIO.output(GPIO.PIN#, 1)
#set GPIO low
GPIO.output(GPIO.PIN#, 0)
#read input
state = GPIO.input(GPIO.PIN#)

due to the GPIO multiplexing we add only these GPIOs in the base package:

PIN9, PIN10, PIN11, PIN12, PIN13, PIN14, PIN15, PIN16, PIN17, PIN18, PIN23, PIN24, PIN25, PIN26, PIN27, PIN28, PIN29, PIN31

you can use this as template, and if you for instance disable LCD in your linux image you can have access to all LCD pins too.

After you download the package from PyPi do as follows to install it:

#tar -zxvf iMX233_GPIO-0.1.0.tar.gz
#cd iMX233_GPIO-0.1.0.tar.gz
#sudo python install

after the installation you can use it this way:

#sudo python
>>> import iMX233_GPIO as GPIO
>>> GPIO.init() #init GPIOs
>>> GPIO.getcfg(GPIO.PIN31) #config PIN31 as GPIO
>>> GPIO.setcfg(GPIO.PIN31, GPIO.OUTPUT) #config PIN31 as output
>>> GPIO.output(GPIO.PIN31, GPIO.HIGH) #set PIN31 high
>>> GPIO.output(GPIO.PIN31, GPIO.LOW) #set PIN31 low
>>> GPIO.setcfg(GPIO.PIN31, GPIO.INPUT) #config PIN31 as input
>>> GPIO.input(GPIO.PIN31) #read PIN31

PINxx assignments is exactly as per imx233-OLinuXino-MAXI schematic

Maximum iMX233 GPIO toggle speed via Python is 15,6 kHz, which is kind of dissapointing, as /dev/mem C approach achieve about 5.7 6 Mhz, but Python is running slow on imx233 so this probably cause the slow GPIOs access.

On A13 is opposite /dev/mem is running slower at 1Mhz but pyA13 GPIO achieve up to 100 kHz as Python is running faster on A13.

7 Comments (+add yours?)

  1. MikeV
    Apr 23, 2013 @ 21:02:18

    Thanks for implementing this! I ran ‘python install’ and then tried to run the test program, but got this:

    Traceback (most recent call last):
    File “./”, line 3, in
    import iMX233_GPIO as GPIO
    ImportError: dynamic module does not define init function (PyInit_iMX233_GPIO)

    I then tried to rename initiMX233_GPIO to PyInit_iMX233_GPIO which fixed the init error; but now I run into this:

    Traceback (most recent call last):
    File “./”, line 3, in
    import iMX233_GPIO as GPIO
    ValueError: module functions cannot set METH_CLASS or METH_STATIC

    Would you expect this code to work with Python3? I’m using Python 3.3.1, running on an ArchLinux distro on the OLinuXino-mini board.

    Thanks for your help!


  2. MikeV
    Apr 24, 2013 @ 01:37:33

    FYI I also noticed a bug – PIN23 is not included in the init routine PyModule_AddObject, so there’s an off by 1 mapping error starting with PIN24. I fixed that in the commit below (oh, and added mappings for PIN7 & PIN8, which I needed for my project):


  3. lucianoventura
    Apr 24, 2013 @ 15:37:11

    Hi Olimex guys!
    There is a faster python alternative:


  4. Cougar
    Jan 01, 2014 @ 19:04:13

    Hi! I fixed some bugs and made it work with Python3. You can find the module source here:

    in iMX233 you can use it like this:

    import iMX233_GPIO as GPIO
    import time
    GPIO.output(GPIO.LED, 0)
    GPIO.output(GPIO.LED, 1)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: