lupus666 Posted July 15, 2016 Posted July 15, 2016 Hi, I need to use uart (for a gps receiver) and i2c (for some sensors) for my project via the gpio pins. Fortunately i2c is enabled in the images by default. I hope it is also enabled if I recompile armbian for the orangepi lite by default? Afaik I have to enable UART in the following file: https://github.com/igorpecovnik/lib/blob/master/config/fex/orangepilite.fex . Unfurtunately I do not understand which pins on the gpio header correspond to the ports defined in this file. For example: uart_tx = port:PG06<2><1><default><default> uart_rx = port:PG07<2><1><default><default> Can I use UART on any pins on the gpio header? I would like to use UART on the same pins as in https://www.element14.com/community/servlet/JiveServlet/previewBody/73950-102-10-339300/pi3_gpio.png How do I do that?
martinayotte Posted July 15, 2016 Posted July 15, 2016 The UART available on pin 8 and 10 on the Pi header is the UART3, while the UART2 is located on pin 11 and 13. So, in the FEX, for the UART3, you simply need to enable it (uart_used = 1) and remove the corresponding pins (PA13/PA14) from the GPIO list. For the UART2, the pins to remove from GPIO list are PA00/PA01/PA02/PA03.
gnasch Posted July 15, 2016 Posted July 15, 2016 Nice image here: http://www.cnx-software.com/2015/09/26/status-of-orange-pi-boards-gpio-support/
zador.blood.stained Posted July 15, 2016 Posted July 15, 2016 Nice image here: http://www.cnx-software.com/2015/09/26/status-of-orange-pi-boards-gpio-support/ For the reference - this image is from schematics for on of H3 Orange Pi boards. Edit: It is stated in the article. Edit 2: BTW, It doesn't reference port/pin numbers for UART, I2C and SPI interfaces, so you still need to check original schematics to disable appropriate GPIOs.
lupus666 Posted July 16, 2016 Author Posted July 16, 2016 Thank you for your replies. I have now tried to enable UART2 and UART3 and remove the corresponding pins from the GPIO list. Unfortunately the Orange Pi does not boot with the new image and the screen is just black. The green led is also off. Here are the changes I have made in the orangepilite.fex: [uart2] uart_used = 1 uart_port = 2 uart_type = 2 uart_tx = port:PA00<2><1><default><default> uart_rx = port:PA01<2><1><default><default> ;uart_rts = port:PA02<2><1><default><default> ;uart_cts = port:PA03<2><1><default><default> [uart3] uart_used = 1 uart_port = 3 uart_type = 2 uart_tx = port:PA13<3><1><default><default> uart_rx = port:PA14<3><1><default><default> ;uart_rts = port:PA15<3><1><default><default> ;uart_cts = port:PA16<3><1><default><default> and [gpio_para] gpio_used = 1 gpio_num = 16 gpio_pin_1 = port:PA06<1><default><default><0> gpio_pin_2 = port:PD14<1><default><default><0> gpio_pin_3 = port:PA03<1><default><default><0> gpio_pin_4 = port:PC04<1><default><default><0> gpio_pin_5 = port:PC07<1><default><default><0> gpio_pin_6 = port:PA02<1><default><default><0> gpio_pin_7 = port:PA21<1><default><default><0> gpio_pin_8 = port:PA07<1><default><default><0> gpio_pin_9 = port:PA08<1><default><default><0> gpio_pin_10 = port:PG08<1><default><default><0> gpio_pin_11 = port:PA09<1><default><default><0> gpio_pin_12 = port:PA10<1><default><default><0> gpio_pin_13 = port:PG09<1><default><default><0> gpio_pin_14 = port:PG06<1><default><default><0> gpio_pin_15 = port:PG07<1><default><default><0> Here are the fex file excerpts before I modified them: [uart2] uart_used = 0 uart_port = 2 uart_type = 4 uart_tx = port:PA00<2><1><default><default> uart_rx = port:PA01<2><1><default><default> uart_rts = port:PA02<2><1><default><default> uart_cts = port:PA03<2><1><default><default> [uart3] uart_used = 0 uart_port = 3 uart_type = 4 uart_tx = port:PA13<3><1><default><default> uart_rx = port:PA14<3><1><default><default> uart_rts = port:PA15<3><1><default><default> uart_cts = port:PA16<3><1><default><default> and [gpio_para] gpio_used = 1 gpio_num = 19 gpio_pin_1 = port:PA06<1><default><default><0> gpio_pin_2 = port:PA13<1><default><default><0> gpio_pin_3 = port:PA14<1><default><default><0> gpio_pin_4 = port:PA01<1><default><default><0> gpio_pin_5 = port:PD14<1><default><default><0> gpio_pin_6 = port:PA00<1><default><default><0> gpio_pin_7 = port:PA03<1><default><default><0> gpio_pin_8 = port:PC04<1><default><default><0> gpio_pin_9 = port:PC07<1><default><default><0> gpio_pin_10 = port:PA02<1><default><default><0> gpio_pin_11 = port:PA21<1><default><default><0> gpio_pin_12 = port:PA07<1><default><default><0> gpio_pin_13 = port:PA08<1><default><default><0> gpio_pin_14 = port:PG08<1><default><default><0> gpio_pin_15 = port:PA09<1><default><default><0> gpio_pin_16 = port:PA10<1><default><default><0> gpio_pin_17 = port:PG09<1><default><default><0> gpio_pin_18 = port:PG06<1><default><default><0> gpio_pin_19 = port:PG07<1><default><default><0> What have I done wrong?
martinayotte Posted July 16, 2016 Posted July 16, 2016 I don't see why editing the FEX with only the above changes would prevent from booting properly. Maybe the whole image is badly written or the SDCard defective. Try to redo the whole image, make sure it is booting, and then redo the FEX changes.
lupus666 Posted July 16, 2016 Author Posted July 16, 2016 I rewrote the image and it worked. Thank you for your reply.
Pop Andrei Lucian Posted July 12, 2017 Posted July 12, 2017 Hello, Is UART I2C communication available via WiringPI or how do you manage to actually communicate with a device via I2C protocol using an OPI board and C language? I want to read data from an I2C sensor using C script. Did someone managed to do this? Can you please tell me what can I try? Thanks.
martinayotte Posted July 12, 2017 Posted July 12, 2017 What do you mean exactly ? UART and I2C as nothing in common, except if you mean that you are using an I2C-to-UART bridge chip such SC16IS752, which Linux kernel is able to manage with proper kernel custom build configs and overlays. This means that WiringPi is not used for this case.
Pop Andrei Lucian Posted July 13, 2017 Posted July 13, 2017 Sorry for getting confused. I do have an I2C sensor that I am trying to manage to send data to the Orange PI Zero/Lite. I want to read data from an I2C sensor using C script. Thanks.
martinayotte Posted July 13, 2017 Posted July 13, 2017 You can also check https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 This is a python library, but inside it, you can see that it is using C for i2c_lib.
Pop Andrei Lucian Posted July 13, 2017 Posted July 13, 2017 Thanks a lot, I will check it out. Cheers!
milaad Posted February 12, 2018 Posted February 12, 2018 On 7/15/2016 at 6:43 PM, martinayotte said: The UART available on pin 8 and 10 on the Pi header is the UART3, while the UART2 is located on pin 11 and 13. So, in the FEX, for the UART3, you simply need to enable it (uart_used = 1) and remove the corresponding pins (PA13/PA14) from the GPIO list. For the UART2, the pins to remove from GPIO list are PA00/PA01/PA02/PA03. i have orange pi lite when i go to /boot/boot0_OPI.fex what i must be do?
martinayotte Posted February 12, 2018 Posted February 12, 2018 (edited) You need to use bin2fex/fex2bin tools to decompile/recompile current /boot/script.bin. Edited February 13, 2018 by chwe corrected vin2fex to bin2fex
Recommended Posts