Author Topic: Cubieboard2 96 pin definition  (Read 7269 times)

Offline dvanf

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-2
    • View Profile
Cubieboard2 96 pin definition
« on: December 09, 2013, 09:06:19 am »
On ubuntuone.com one can find a document "Cubieboard 96 Extended Pins Definition.pdf" with a picture of the board and connectors and a list of the pin numbers and data available on that pin.
For instance on connector U14 the pin 1 = PD0, pin 2 = GND, pin 3 = PD2, etcetera, up to pin 48 = PI13.
There is also a document with the pin lay-out on https://github.com/cubieplayer/Cubian/wiki/GPIO-Introduction, but on that picture the numbering is quite different.
What is actually pin 1 (PD0) is numbered 32, pin 2 (GND) is not numbered, pin 3 (PD2) is number 30, pin 37 (PH7) is number 67, and so on. So numbering greater than 48!
Which of the pictures is correct? The available data is the same in both documents.
What is the relation between the pin numbers and the data given in script.bin like this: gpio_pin_28 = port:PD04<1><default><default><1>?
Is the numbering (here 28) in script.bin just for your own use and not directly related to something else?
The data of a pin can be set with echo 28 > /sys/class/gpio/export, which will create a file /sys/class/gpio/gpio28. With further commands the output can be set to 1 or 0 and also the pin can be defined and used as input.
For this to get working, one must have module gpio_sunxi defined in /etc/modules, check this first, not every Linux distribution does has this line.
Any more information about the GPIO pins and usage would be very nice.
I want to use the data PD0 - PD27 for a mix of input and output, for that I disabled the lcd0 entry in script.bin and I would like to add lines gpio_pin1 up to gpio_pin28, but other numbers would not matter if that is necessary. The thing is to get it working.
Thanks, dvanf (Dick van Fulpen, Houten [NL])

Offline dvanf

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-2
    • View Profile
Re: Cubieboard2 96 pin definition
« Reply #1 on: December 17, 2013, 02:06:27 pm »
After a week of reading documents on this forum and further experiments, I think I know how it works.
In /etc/modules one must have (or add) a line to load the gpio module:
...
# GPIO module to be loaded
gpio_sunxi
...
In script.bin one must add or modify the options needed for the use of the GPIO-pins on the external connector.
I have modified script.bin to set PD0 - PD13 as digital output and PD14 - PD27 as input like this:
I the original script.bin PD0-PD27 were in use for LCD0, which settings I have set out of use:
...
[lcd0_para]
lcd_used = 0
...
[gpio_para]
gpio_used = 1
gpio_num = 28
gpio_pin_1 = port:PD00<1><default><default><0>
gpio_pin_2 = port:PD01<1><default><default><0>
gpio_pin_3 = port:PD02<1><default><default><0>
gpio_pin_4 = port:PD03<1><default><default><0>
gpio_pin_5 = port:PD04<1><default><default><0>
gpio_pin_6 = port:PD05<1><default><default><0>
and so on up to:
gpio_pin_24 = port:PD23<0><default><default><0>
gpio_pin_25 = port:PD24<0><default><default><0>
gpio_pin_26 = port:PD25<0><default><default><0>
gpio_pin_27 = port:PD26<0><default><default><0>
gpio_pin_28 = port:PD27<0><default><default><0>

The term 'pin' in these lines is not a reference to an actual pin of a circuit or chip, it is just a enumerated list, starting with 1 up to 28 in this case, check the line: gpio_num = 28 which defines the maximum number of 'pins' to be used.
In the Linux distribution I have (Linux cubieez 3.4.43) one must have super user rights to use the data pins PD0 - PD27.
When I login as user cubie, I use su to get the proper rights for these commands:
echo 1 > /sys/class/gpio/export
This will define a directory /sys/class/gpio/gpio1_pd0.
echo out > /sys/class/gpio/gpio1_pd0/direction
This will define PD0 as output.
Now you can set the output to 1 (3.3 V) or 0 (0 V) and use this to control a led or use it otherwise to control something.
echo 1 > /sys/class/gpio/gpio1_pd0/value
Don't forget to use a resistor of about 470 ohm to limit the current through the led.
I have written a Python program to control a two digit 7 segment display (Monsanto MAN6610, common anode).
This will do all the necessary definitions of the output and input pins PD0 - PD27.
PD0 - PD13 are used to control the leds of the display.
See attached digit.py file, it is rather good documented, I think.
It will set each segment of the two digits on, one by one, and then turn them off.
Then it will use to two digits as a counter from 00 - FF, wait a few seconds and turn the displays off.
Remember: you must be root or use su from user cubie to run this program.
Check the directory for the defined pins with ls /sys/class/gpio, looks interesting.
Script.bin details can be found with these comands:
cubie@cubieez:~$ cd /media
cubie@cubieez:/media$ cd FE56-8552/ : I guess this directory can be different on other distributions.
cubie@cubieez:/media/FE56-8552$ cat script.fex | grep gpio | less : you will see all the lines with gpio in it.
cubie@cubieez:/media/FE56-8552$ cat script.fex | grep lcd | less : you will see all the lines with lcd in it.
cubie@cubieez:/media/FE56-8552$
Use bin2fex and fex2bin to convert script.bin to a text file and back to binary after editing.
Make a copy before you change script.bin and reboot after modifying it.
Good luck,
dvanf

Offline fred5426

  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Cubieboard2 96 pin definition
« Reply #2 on: January 08, 2014, 05:05:21 pm »
Thanks a lot for your explanation in the second message.
 ;D
fred (FR)

Offline mcecilia

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Cubieboard2 96 pin definition
« Reply #3 on: January 22, 2014, 03:31:19 am »
Hello Sirs,

I need some help with this. When I try, with Android, to put PD1 for example ON and measure the voltaje with a polymeter, I really do not know where to take the Ground. Can you help me?

Thanks


Offline dvanf

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-2
    • View Profile
Re: Cubieboard2 96 pin definition
« Reply #4 on: January 22, 2014, 05:05:55 am »
mcecilia,

You can find GND on the pins 2, 9, 38, 42 of connector U14 and on the pin s 19, 20, 25 and 37 of connector U15.
The connectors U14 and U15 are positioned differently, so check where pin 1 is!
Good luck.

dvanf

Offline mihi

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Cubieboard2 96 pin definition
« Reply #5 on: May 31, 2014, 06:43:52 pm »
Attachment digit.py in you previous post is not accesible any more. Could you pls. post it again or provide some other URL?
404 - Attachment Not Found

thanks for posting explanation.

Thanks,
mihi


After a week of reading documents on this forum and further experiments, I think I know how it works.
In /etc/modules one must have (or add) a line to load the gpio module:
...
# GPIO module to be loaded
gpio_sunxi
...
...

See attached digit.py file, it is rather good documented, I think.
It will set each segment of the two digits on, one by one, and then turn them off.

...
Make a copy before you change script.bin and reboot after modifying it.
Good luck,
dvanf

Offline dvanf

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-2
    • View Profile
Re: Cubieboard2 96 pin definition
« Reply #6 on: June 02, 2014, 11:36:29 am »
Mihi,

Attached the file to this post, I hope it will be helpful for you.
Good luck, DvanF.

magno

  • Guest
Re: Cubieboard2 96 pin definition
« Reply #7 on: June 04, 2014, 07:12:39 am »
What about connecting step motors in GPIO?
Will be nice to control little robots ...