blprasad Posted October 4, 2018 Posted October 4, 2018 Hi , I am finding trouble using orange pi gpios, here my approach I am trying to scan 4x4 kepad using gpio how am I writing 0 to a particular gpio pin? step 1 : sunxi_gpio_set_cfgpin(pin, SUNXI_GPIO_OUTPUT); step 2: sunxi_gpio_pullup(pin ,SUNXI_PULL_DOWN); I am not sure whether I am correct here. I am not sure if I have to use UP or DOWN or NONE here in pull up call,but I tried UP and DOWN so for. step 3: sunxi_gpio_output(pin,val); here I am using val = 0 or 1 making pin low and high depending on my requrement. in my attempts I get vague results as output. Please let me know if I am missing anything in my approach. to scan a particular colum I am making one column high(=1) and rest three columns to low (=0) at a time in loop. but I am unable to do it ,because though I write 0 to rest of the three , some of them still stay in high, because of this I am unable to get proper key scanned. Plese suggest how to resolve this. and I would also like to know , what is driver for gpio access ? is it linux-sunxi/drivers/gpio/gpio-sunxi.c ? Can I make it loadable module ?, if yes how to remove this module ,I mean what is the module name for this driver module. I want to modify the module according to my need,because ,I am getting unstable results while accessing gpio. Some gpios don't work as expected with gpio_lib.c . Has anyone faced samilar issue? am I the only one here?
blprasad Posted October 4, 2018 Author Posted October 4, 2018 here are the gpios I am using for the purpose. #define R1 SUNXI_GPA(06) #define R2 SUNXI_GPA(00) #define R3 SUNXI_GPA(13) #define R4 SUNXI_GPA(10) #define C1 SUNXI_GPA(19) #define C2 SUNXI_GPA(07) #define C3 SUNXI_GPG(07) #define C4 SUNXI_GPA(06)
blprasad Posted October 4, 2018 Author Posted October 4, 2018 I found mistake in my code I configured R1,and C4 both assigning same pin ,now I corrected it ,there comes some relief. C4 actually I connected to SUNXI_GPG(06) but my SUNXI_GPA(13) is not working at all ,it never goes HIGH. I used same logic to rest of the pins they work fine but this pirticular pin never worked so far.
martinayotte Posted October 4, 2018 Posted October 4, 2018 4 hours ago, blprasad said: but my SUNXI_GPA(13) is not working at all PA13 could be "in-use" as SPI1_CS, are you using SPI1 overlay ?
blprasad Posted October 4, 2018 Author Posted October 4, 2018 No ,I don't have much idea of what SPI1 overlay is,I am not using this pin for any other purpose, how can I make this pin work as normal GPIO?, how to disable the SPI and make work as GPIO. thanks for comment.
martinayotte Posted October 4, 2018 Posted October 4, 2018 5 minutes ago, blprasad said: how to disable the SPI and make work as GPIO If you don't load SPI overlay, then it is not the issue. Another thing that could prevent PA13 to stay as GPIO is if you have UART3 overlay, since it use PA13 as UART3_TX ... Is it the case ?
blprasad Posted October 5, 2018 Author Posted October 5, 2018 13 hours ago, martinayotte said: If you don't load SPI overlay, then it is not the issue. Another thing that could prevent PA13 to stay as GPIO is if you have UART3 overlay, since it use PA13 as UART3_TX ... Is it the case ? I am using debug port for debugging, now I expect that could be UART3 overlay. Is it? If I don't use it as debug port then will it automatically get converted into gpio?
blprasad Posted October 5, 2018 Author Posted October 5, 2018 I may have to modify the overlay explicitly!!, any reference regarding that is appreciated.
martinayotte Posted October 5, 2018 Posted October 5, 2018 12 hours ago, blprasad said: I am using debug port for debugging, now I expect that could be UART3 overlay. Is it? If I don't use it as debug port then will it automatically get converted into gpio? I don't understand your goal here : Default debug port is UART0 on the 3 pins header. If you currently have UART3 overlay, and if you removed it, GPIO should come back to normal ... Did you tried it ?
blprasad Posted October 10, 2018 Author Posted October 10, 2018 Sorry for delay in reply,debug port is UART0 the 3 pin header!!, I understood it wrongly,I thought it as UART3. So there is no UART3 as such?. I read orange pi has 3 UARTS ,so I wrongly expected them as UART1,UART2,UART3. Now I think they are UART0,UART1,UART2. If that is the case how this UART3 comes into picture?, I am only using default debug port i.e., UART0 for debugging, and I am not explicitly changing any settings or configuration of the board.I am trying to access the the GPIO normally with all default configuration of the board. I dont understand "UART3 overlay,since it use PA13 as UART3_TX ..." , please give more details. Correct me if I am wrong in my understanding.
martinayotte Posted October 10, 2018 Posted October 10, 2018 1 hour ago, blprasad said: I read orange pi has 3 UARTS ,so I wrongly expected them as UART1,UART2,UART3. Now I think they are UART0,UART1,UART2. Nope ! The SoC H2+ or H3 has 4 uarts, so UART0, which is the 3 pins header, UART1 and UART2, exposed "as is" on 26 headers, but UART3 is also there but TX/RX pins are exposed as SPI1_CS and SPI1_CLK. Device tree only activate UART0 by default, so the 3 pins header. To activate the 3 other uarts, you need to use 3 uart overlays located in /boot/dtb/overlay by editing armbianEnv.txt and adding the following line, save and reboot : overlays=uart1 uart2 uart3 If only one uart is needed, simply write the above line for the specific single uart ... But beware, those 3 uarts are not for debug, since UART0 is used for that, they are plain uarts to talk with other devices ...
blprasad Posted October 23, 2018 Author Posted October 23, 2018 https://github.com/armbian/build/blob/master/config/fex/orangepizero.fex [spi1] spi_used = 1 spi_cs_bitmap = 1 spi_cs0 = port:PA13<2><1><default><default> spi_sclk = port:PA14<2><default><default><default> spi_mosi = port:PA15<2><default><default><default> spi_miso = port:PA16<2><default><default><default> After looking at above my understanding is that PA13 is not configured as gpio by default. so I tried to get PA13 as gpio by using overlay , after studying https://docs.armbian.com/Hardware_Allwinner_overlays/#overlay-pinmux-conflicts gave a try with .dts here is my overlay gpiotrail.dts file /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&spi1>; __overlay__ { gpio: gpio { pins = "PA13"; function = "gpio_in"; bias-pull-up; }; }; }; I don't know that the above .dts is correct or not , I tried to it after searching for different examples on internet and I tried add this overlay as below root@orangepizero:~# armbian-add-overlay gpiotrail.dts Overlays are supported only on A10, A20, H3, H5 and A64 based boards then I got above message !!! , I am in desperate need of gpios, I don't know how to proceed. I have plans to recompile kernel by disabling spi1 in .fex, I tried to compile kernel few days ago but it's not compiling on my 32 bit host PC. so I need look for another approach. Please suggest if you have any Ideas.
martinayotte Posted October 23, 2018 Posted October 23, 2018 59 minutes ago, blprasad said: I have plans to recompile kernel by disabling spi1 in .fex, Useless ! FEX are only used by Legacy kernel, not Mainline which only use DT... 1 hour ago, blprasad said: I don't know that the above .dts is correct or not It is not correct at all syntaxically, and useless since it is already managed by existing overlays and main DT. Did you try adding "overlays=uart1 uart2 uart3" to /boot/armbianEnv.txt like I've suggested before ?
blprasad Posted October 24, 2018 Author Posted October 24, 2018 you need to use 3 uart overlays located in /boot/dtb/overlay by editing armbianEnv.txt and adding the following line, save and reboot : I did not find any "/boot/dtb/overlay" file on my orange pi zero. But I gave a try by editing armbianEnv.txt here are the contents: verbosity=7 console=both machid=1029 bootm_boot_mode=sec rootdev=UUID=7dd0c931-6f7e-4fbd-83f6-544d0e1b2765 rootfstype=ext4 overlays=uart1 uart2 uart3 usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u saved the file ,and rebooted but I could not get any change , I could not understand why you mentioned uarts in overlay. Is it UARTs which took the control of PA13?. I thought it was SPI correct me if I am wrong in understanding.
martinayotte Posted October 24, 2018 Posted October 24, 2018 10 hours ago, blprasad said: I did not find any "/boot/dtb/overlay" file on my orange pi zero. If you don't have those, then the image you are using is NOT an Armbian image ... 10 hours ago, blprasad said: Is it UARTs which took the control of PA13?. I thought it was SPI correct me if I am wrong in understanding. Main DT has PA13 assigned on both SPI and UART3, it is the overlays that will switch status of SPI or UART3 from "disabled" to "okay". Of course, you won't be able to have both SPI and UART3 at the same time...
blprasad Posted October 24, 2018 Author Posted October 24, 2018 ___ ____ _ _____ / _ \ _ __ __ _ _ __ __ _ ___ | _ \(_) |__ /___ _ __ ___ | | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | / // _ \ '__/ _ \ | |_| | | | (_| | | | | (_| | __/ | __/| | / /| __/ | | (_) | \___/|_| \__,_|_| |_|\__, |\___| |_| |_| /____\___|_| \___/ |___/ Welcome to ARMBIAN 5.36 user-built Ubuntu 16.04.3 LTS 3.4.113-sun8i System load: 0.37 0.16 0.07 Up time: 5 min Memory usage: 11 % of 241MB IP: CPU temp: 42�°C Usage of /: 98% of 1.8G I got as above when I login in to my orange pi0, It shows ARMBIAN 5.36!!!
martinayotte Posted October 24, 2018 Posted October 24, 2018 5 hours ago, blprasad said: Welcome to ARMBIAN 5.36 user-built Ubuntu 16.04.3 LTS 3.4.113-sun8i This is Legacy, not Mainline !!! There is no DeviceTree or Overlays in Legacy, only in Mainline ... So, you will have to use old BIN2FEX and FEX2BIN method of tweaking GPIOs ...
Recommended Posts