please choosego to mobile | Continue to access the PC version
Author: phreon

I have a love hate relationship going with OP PC

[Copy link]

3

threads

44

posts

1118

credits

Gold member

Rank: 6Rank: 6

credits
1118
 Author| Published in 2016-1-7 02:34:58 | Show all floors
snowbody, the 13 wiringPi port numbers that are listed in gpio readall are mapped in my table above. There are 15 pins that we do not know how to use through wiringPi. That means we can't use them in a program yet.
We can only access them from the kernel. How do we figure out those other 15 pins?

3

threads

44

posts

1118

credits

Gold member

Rank: 6Rank: 6

credits
1118
 Author| Published in 2016-1-7 04:25:39 | Show all floors
There are still 15 pins that are not mapped in wiringPi.

3

threads

44

posts

1118

credits

Gold member

Rank: 6Rank: 6

credits
1118
 Author| Published in 2016-1-7 20:56:41 | Show all floors
Edited by phreon at 2016-1-8 01:06

Update:
Thanks to bronco's suggestions above I was able to map the gpio in the table above.
I fell on to this while looking in the files in the WiringPi I installed:

>man gpio

This explains a lot!
However, some gpio commands do not work yet.
I tried wired a LED and resistor to pin 40 and used the following to turn the LED on and off:

>gpio write 16 1
>gpio write 16 0

I tried gpio reset and got:

gpio: Unable to open GPIO export interface

Oh well, I will keep on banging away. I suspect I need to export something but I am not sure.

12

threads

30

posts

150

credits

Registered member

Rank: 2

credits
150
Published in 2016-1-8 21:18:31 | Show all floors
in order to switch a port :
gpio mode 16 out
gpio write 16 1
if you execute "gpio readall" you can see next to physical pin 40 the Value "1"
(you do not even have to connect Leds ;))




12

threads

30

posts

150

credits

Registered member

Rank: 2

credits
150
Published in 2016-1-8 21:32:17 | Show all floors
Look what happens if you execute this on the raspberry pi :

GPIO Reset is dangerous and has been removed from the gpio command.
- Please write a shell-script to reset the GPIO pins into the state
   that you need them in for your applications.

So my advise is : cherish you relationship with the Orange pi;)

I would not worry either about the pins that are not usable from within the gpio command.
Underneath those pins is usually a port that you can address in another way. (eg serials ports, spi, i2c etc)

3

threads

44

posts

1118

credits

Gold member

Rank: 6Rank: 6

credits
1118
 Author| Published in 2016-1-8 22:56:38 | Show all floors
Thanks snowbody, it turns out that just about all of the 30 gpio pins can be read as gpio. Some can be uart, I2C,  PWM, etc. They can still be gpio and I need to find out how to set them to read or write in a program.  I need at least 20 readable pins and several writable pins for an alarm project. I will need to be able to to get to most of the 30 pins in a program I need to write.

7

threads

30

posts

388

credits

Intermediate member

Rank: 3Rank: 3

credits
388
Published in 2016-1-9 04:09:39 | Show all floors
my tip is to cross reference the electronic schematic and the soc datasheet. the datasheet in particular is very useful, detailing all the registers you need to know!

3

threads

44

posts

1118

credits

Gold member

Rank: 6Rank: 6

credits
1118
 Author| Published in 2016-1-13 04:50:28 | Show all floors
snowbody - "I would not worry either about the pins that are not usable from within the gpio command.
Underneath those pins is usually a port that you can address in another way. (eg serials ports, spi, i2c etc)"

Do you know how to make those other pins readable from a program?

12

threads

30

posts

150

credits

Registered member

Rank: 2

credits
150
Published in 2016-1-13 22:14:10 | Show all floors
I'm not really sure I understand your question.
My guess is that you want to go beyond the wiringOP solution, because you need many I/O ports, and you want to program?

this is the way it works on the orange pi :
modprobe gpio_sunxi
cd /sys/devices/platform/gpio_sw.0/gpio_sw/PL10
echo 1 > data
(switch onboard led on/off)

here is shown how it can be programmed on a cubieboard (the second solutions seems really cool)
http://docs.cubieboard.org/tutorials/common/gpio_on_lubuntu

#define SW_PORTC_IO_BASE  0x01c20800data |= 1<<20;                              //green led connect PH20
*(unsigned int *)(ptr+0x10c) = data;
--------------------I had a look at wiringOP if I could find address -------------------------
https://github.com/zhaolei/WiringOP/blob/h3/wiringPi/wiringPi.c
// for mmap BananaPro #define        MAX_PIN_NUM                (0x40)  //64#define SUNXI_GPIO_BASE (0x01C20800)
----------------------------------------------
so guess IO_BASE is the same
data |= 1<<10;  (switch led on PL10)

I'm puzzled by (ptr+0x10c), where 0x10c would indicatie port H? on a cubieboard
If so, what would be the offset for port L on the orange pi ?













https://www.adafruit.com/product/732

12

threads

30

posts

150

credits

Registered member

Rank: 2

credits
150
Published in 2016-1-14 22:19:01 | Show all floors
I did consult the Allwinner H3 datasheet.
On page 316  you'll find the exact offsets for each port : PL_DAT 0x24+0x10
For example port A : PAxx  the offset = 0x10
*(unsigned int *)(ptr+0x10) = data; (adapt cubieboard example)
This way you can read and write ports that are not listed in wiringOP

Important : first you'll need to execute :
modprobe gpio_sunxi

I think this way the control-register of the H3 gets set.
(in the control register you can define how a port should behave)

I wonder how one can set the control register oneself?
(writing directly to the register was not the thing todo ...)


Port L is something special because it starts at a different address -- I managed to blink the onboard LED with the cubieboard-program after adapting the address
(page 345) port L
0x01F02C00
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list