sgjava Posted December 13, 2017 Posted December 13, 2017 I've built https://github.com/auto3000/RPi.GPIO_NP for the Duo running Armbian Ubuntu test image: cd /sys/class/gpio for i in gpiochip* ; do echo `cat $i/label`: `cat $i/base` ; done 1c20800.pinctrl: 0 1f02c00.pinctrl: 352 Has anyone actually got RPi.GPIO working on Duo? I'm trying to get luma.oled cranking and have SPI working fine, but need GPIO working as well.
raschid Posted December 13, 2017 Posted December 13, 2017 Try https://github.com/karabek/nanopi_duo_gpio_pyH3. I have not tried SPI, but I2C works rather nicely.
sgjava Posted December 13, 2017 Author Posted December 13, 2017 Thanks, I will. I2C was easy to configure for luma.oled since it doesn't really need RPi.GPIO, just i2c-dev. I really need the API to match RPi.GPIO for luma.oled SPI.
chwe Posted December 16, 2017 Posted December 16, 2017 On 13.12.2017 at 8:13 PM, raschid said: Try https://github.com/karabek/nanopi_duo_gpio_pyH3. I have not tried SPI, but I2C works rather nicely. The mapping of this fork is really a mess... There are GPIOs defined which are not accessible on the Duo. PA15, PA16, PL11 and PG11 which are accessible via pin header aren't defined. Numbering for using connector instead of port is useless, cause also wrong... If you need them go to pyGPIO ... (or go to pyGPIOs GitHub, search for the nanopiduo mapping, replace the one in this pyA20 fork and stay with it.. )
sgjava Posted December 16, 2017 Author Posted December 16, 2017 Haha, thanks. I was only testing the power LED blink with that one so far (looks like that was the only change). What I really need is a RPi.GPIO API. I'm looking at https://github.com/rm-hull/OPi.GPIO now, so I can use luma.oled. I've been able to get it to work with CHIP, Pine A64, ODROID C1, etc. with RPi.GPIO replacements. Having a hard time with Duo.
chwe Posted December 16, 2017 Posted December 16, 2017 looks quite easy... opi is more or less the same.. not? As long as this: Quote Only the basic GPIO functions are replicated, using sysfs: this allows the GPIO pins to be accessed from user space. matches to your needs. I think, you only have to adjust this one: https://github.com/rm-hull/OPi.GPIO/blob/master/OPi/pin_mappings.py reading the schematics and calculating sysfs pin numbers from here: http://linux-sunxi.org/GPIO#Accessing_the_GPIO_pins_through_sysfs_with_mainline_kernel
sgjava Posted December 17, 2017 Author Posted December 17, 2017 Yes, this is why I went down this route. I'll see if I can figure out the mappings. If I understand correctly then for example: (position of letter in alphabet - 1) * 32 + pin number CSUART3_TX/SPI1_CS/GPIOA13 would be: (1-1) * 32 + 13 = 13?
chwe Posted December 17, 2017 Posted December 17, 2017 2 hours ago, sgjava said: (1-1) * 32 + 13 = 13? should be correct From pyGPIOs mapping.h: J1 J2 (UART0_RX) |1| microUSB |1| 5V (UART0_TX) |·| |·| 5V GND |·| |·| 3.3V GPIO3 (TWI_SCL) |·| |·| GND GPIO2 (TWI_SDA) |·| |·| GPIO4 (IR_RX) GPIO23 (SPI1_CS) |·| |·| GPIO18 (IOG11) GPIO22 (SPI1_CLK) |·| |·| DM3 D- GPIO27 (SPI1_MISO) |·| |·| DM3 D+ GPIO17 (SPI1_MOSI) |·| |·| DM2 D- GPIO15(UART1_RX) |·| |·| DM2 D+ GPIO14 (UART1_TX) |·| |·| RDN (CVBS) |·| |·| RDP (LINEOUT_L) |·| |·| TXN (LINEOUT_R) |·| |·| TXP (MICP) |·| |·| LED-LINK (MICN) |·| microSD |·| LED-SPD */ {"J1", { { "GPIO3", SUNXI_GPA(11), 4 }, { "GPIO2", SUNXI_GPA(12), 5 }, { "GPIO23", SUNXI_GPA(13), 6 }, { "GPIO22", SUNXI_GPA(14), 7 }, { "GPIO27", SUNXI_GPA(16), 8 }, { "GPIO17", SUNXI_GPA(15), 9 }, { "GPIO15", SUNXI_GPG(6), 11 }, { "GPIO14", SUNXI_GPG(7), 10 }, { { 0, 0, 0} }, } }, {"J2", { { "GPIO18", SUNXI_GPL(11), 5 }, { "GPIO4", SUNXI_GPG(11), 6 }, { { 0, 0, 0} }, } }, Quote with XX being the number of the desired pin. To obtain the correct number you have to calculate it from the pin name (like PH18)[1]: (position of letter in alphabet - 1) * 32 + pin number E.g for PH18 this would be ( 8 - 1) * 32 + 18 = 224 + 18 = 242 (since 'h' is the 8th letter). 1 'GPIO3' --> PA11 --> (1-1)*32 + 11 = 11 'GPIO4' --> PG11 --> (7-1)32 + 11 = 203 ({ "GPIO4", SUNXI_GPG(11), 6 },)
sgjava Posted December 17, 2017 Author Posted December 17, 2017 Cool, thanks, I was able to read the button (GPIOL3) using: echo 355 > /sys/class/gpio/export echo in > /sys/class/gpio/gpio355/direction cat /sys/class/gpio/gpio355/value echo 355 > /sys/class/gpio/unexport Now I'm going to try hacking OPi.GPIO
chwe Posted December 17, 2017 Posted December 17, 2017 just for fun... I forked it and wrote the mapping for a nanopi duo (with minishield). Only the GPIOs no buttons no leds, no board to test... https://github.com/chwe17/OPi.GPIO If it works I might write a wrapper for the mappings from the pyGPIO and adjust the library a little bit to make it 'multiple boards' usable. Can you test it? in case you don't have the minishield: BCM naming should work and there is the 'naming scheme': J1 J2 (UART0_RX) |1| microUSB |1| 5V (UART0_TX) |·| |·| 5V GND |·| |·| 3.3V GPIO3 (TWI_SCL) |·| |·| GND GPIO2 (TWI_SDA) |·| |·| GPIO4 (IR_RX) GPIO23 (SPI1_CS) |·| |·| GPIO18 (IOG11) GPIO22 (SPI1_CLK) |·| |·| DM3 D- GPIO27 (SPI1_MISO) |·| |·| DM3 D+ GPIO17 (SPI1_MOSI) |·| |·| DM2 D- GPIO15(UART1_RX) |·| |·| DM2 D+ GPIO14 (UART1_TX) |·| |·| RDN (CVBS) |·| |·| RDP (LINEOUT_L) |·| |·| TXN (LINEOUT_R) |·| |·| TXP (MICP) |·| |·| LED-LINK (MICN) |·| microSD |·| LED-SPD in case you use the minishield (there you go... ):
sgjava Posted December 17, 2017 Author Posted December 17, 2017 I need it without mini shield. I'l look at what you did: There isn’t anything to compare. rm-hull:master and chwe17:master are identical.
sgjava Posted December 17, 2017 Author Posted December 17, 2017 How do you calculate the status LED using /sys/class/gpio?
chwe Posted December 18, 2017 Posted December 18, 2017 { "POWER_LED", SUNXI_GPL(10), 1 }, { "STATUS_LED", SUNXI_GPA(10), 2 }, POWER_LED is PL10 STATUS_LED is PA10 12 minutes ago, sgjava said: rm-hull:master and chwe17:master are identical. ooops.. was only on my local git... Now it should be there...
sgjava Posted December 20, 2017 Author Posted December 20, 2017 OK, this doesn't change the status LED: import OPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD) GPIO.setup(10, GPIO.OUT) GPIO.output(10, GPIO.HIGH) time.sleep(3) GPIO.output(10, GPIO.LOW) GPIO.cleanup()
chwe Posted December 20, 2017 Posted December 20, 2017 On 18/12/2017 at 12:09 AM, chwe said: Only the GPIOs no buttons no leds, no board to test...
sgjava Posted December 20, 2017 Author Posted December 20, 2017 How would you map the button and led then? I doesn't really have a pin number. I'm just going to hack some in the missing slots and see what happens. I'm trying to get something simple working before I wire up the SPI display I'm testing. I already have spi-dev working fine.
Larry Bank Posted December 20, 2017 Posted December 20, 2017 14 minutes ago, sgjava said: How would you map the button and led then? I doesn't really have a pin number. I'm just going to hack some in the missing slots and see what happens. I'm trying to get something simple working before I wire up the SPI display I'm testing. I already have spi-dev working fine. Send me a PM and maybe I'll send you a Duo and/or mini shield. I'm going to get some v1.1s. I have v1.0 now. I'll have to dig up the LEDs, but if they're used by the system then you won't be able to access them through the sysfs GPIO interface; you'll have you use the kernel LED driver. The button on the NanoPi Duo is GPIO 355
sgjava Posted December 20, 2017 Author Posted December 20, 2017 Look above and you'll see I've figured out the button. The status LED blinks with https://github.com/karabek/nanopi_duo_gpio_pyH3/blob/master/examples/blink_POWER_STATUS_PL10.py, so I thought it was possible through A10. Also, if you look at /sys/class/gpio you see gpiochip352 which is the power LED. I'm not saying you are wrong, but maybe I'll need to dig into the source I just mentioned. In any event I'm going to try a simple OPi.GPIO hack real quick.
sgjava Posted December 20, 2017 Author Posted December 20, 2017 OK, this is the same result that trying to access A10 from /sys/class/gpio which OPi.GPIO uses: UserWarning: Channel 99 is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. I mapped 99 to 10. Let me look at the working source. The main thing I need is gpio_DC="CSID1", gpio_RST="CSID0" for luma.oled (this is from my CHIP config) and I believe that will work fine. I just wanted to test without wiring and configuring (being lazy here).
Recommended Posts