Useful_Info
Pat Beirne edited this page 1 year ago

4. Useful Info

LEDs

There are 3 green LED's located near between the camera connector and the USB-A connector. You can control them with GPIO pins, 1=lit.

  • LED2 = gpio_c30 = gpio126
  • LED3 = gpio_c29 = gpio125
  • LED5 = gpio_c_5 = gpio101

Method:

  cd /sys/class/gpio
  echo 125 > export
  cd gpio125
  echo out > direction
  echo 1/0 > value

  # or
  opio write 125 1
  opio write 125 0

NOTE With the current uboot/kernel combination, the LEDS start off in an indentermined state, which is not reflected properly with the opio leds command. Once you start using the LED's though, they operate properly.

ADC

There is an embedded ADC converter on the SOC chip (RDA8810), but we have no access to it directly.

If you wish, you can solder a wire from the 3-pin battery connector/pads (J302) over to a spare pin on the 40 pin i96 connector, and you can measure a voltage using channel 1 of the ADC (ac1 at 0x11a0.9054). Again, the software for ADC doesn't seem to be included in the existing Linux kernel.

To measure the voltage without a kernel driver, you can use these registers:

  devmem2 0x11a09054 w 0x80000000    # write to bit 31
                       # triggers   an ADC conversion....wait 50us
  devmem2 0x11a09054                 # read the lower 10 bits; bit 10 = DATA_VALID

Battery

It appears that you can connect a 1-cell LiPo battery to J302; this seems to bhe the 3 oval pads beside the micro-USB connector. I did not test this.

USB

It appears there is only one USB bus, shared by the typeA and micro connectors

UARTS

The microprocessor has 3 uarts. The datasheet numbers these uart1 (ttyS1), uart2 (ttyS2) and uart3 (ttyS0). The first two are available on the i96 connector, and the ttyS0 is the 'debug' serial connector, whose pins do not appear on the i96 connector. See below

If you don't need the CTS and RTS functions of uart1 (ttyS1), then you can leave these pins in GPIO state and access them through gpio40 and gpio41 respectively. See below

The debug serial port powers up at 921600 baud. If you would prefer the standard 115200, edit /media/boot/boot.cmd where the baud rate is set, then execute this: [verified]

mkimage -C none -A arm -T script -d /media/boot/boot.cmd /media/boot/boot.scr

Modem

Even though the 'modem' section of the microprocessor is not used, you must allow the modem driver to be installed. The modem chip includes the Wifi & Bluetooth functions. The microprocessor (RDA8810) will not function without the modem co-processor functioning.

Console Text Color

Immediately after a standard boot, the Ubuntu and Debian distribution will notify you with a red Welcome to orangepi banner. Following that, the screen text is usually a feint grey color. You can reset it to hard black with

   tput sgr0

Alternatively, you can edit the offending banner file at /etc/update-motd.d/100-fs-warning and change the last escape code from \033[37m into \033[0m. [verified]

Wifi

Lockup

There are cases where the connection between the RDA and the Wifi chip gets locked up, and the system will loop with messages like:

[170837.809875] [RDAWLAN_ERR]:<wland_sdio_send_pkt,480>: wland_sdio_flow_ctrl failed!
[170837.810791] [RDAWLAN_ERR]:<wland_proto_cdc_data,232>: set_dcmd failed status: -5
[170837.811706] [RDAWLAN_ERR]:<wland_run_escan,773>: SCAN error (-12)

One possible solution is to remove-&-reinstall the driver module. As root:

rmmod rdawfmac
modprobe rdawfmac
Unstable MAC Address

The default install of Ubuntu and Debian will generate a new MAC address for the Wifi device every time the system powers up. If you are running inside a home network, the DHCP server will probably assign a new IPv4 address after ever power-reboot, which can make it tricky to locate the device on your network.

[As the kernel boots, the wireless driver queries the modem for the MAC address. This processor is intended to be used in a smartphone, with a permanent battery on the modem, so it can remember its MAC address between reboots. Since we have no battery, the modem returns "invalid" and the wireless device starts up with a random IP address.]

Various of finding your i96 device on your LAN:

  • if you have access to the DHCP server, you may be able to look up the IP address for the device after it connects
  • if your DHCP server also provides DNS services, you may be able to look up the hostname of your device
    • the default hostname is orangepii96, but you can change that with nmtui
  • give it a static address
    • modify /etc/network/interfaces....do not use nmtui
    • you may need to be careful with the DNS nameserver; the default is 8.8.8.8, which may not be appropriate for your local use
  • you could wait until the Wifi connection is up, and then send an Email/SMS to your phone, or scp a status file onto a web server somewhere

Alternatively, I have re-built the Linux kernel module for the wifi so that it uses a fixed MAC address. Download it and store it on your OrangePi-i96 at /lib/modules/3.10.62-rel5.0.2+/kernel/drivers/net/wireless/rdaw80211/rdawlan/

At module-init time, it uses the first 6 bytes of the file at /data/misc/wifi/WLANMAC as the MAC address. Make sure to put something unique into that file so that you don't have multiple i96 boards with the same MAC address. I suggest that the first 2 bytes be 00:00, that seems to work best.

If you decide to build this kernel module yourself, the relevent flag is WLAND_MACADDR_DYNAMIC (defined) and USE_MAC_FROM_RDA_NVRAM (undefined)

Wifi AP

Some people have asked about running hostapd and changing the i96 board into an Access Point (AP). Even though the device driver seems to be written to allow it, and the driver reports AP in its capability list, I don't think anyone has succeeded in creating an Access Point.

More GPIO

If there are sections of the i96 bus special functions that you don't need, you can recover these pins for use as GPIO pins.

For example, I do not use the i2s feature of the board, so pins 16,18,20 & 22 (i96 connector) can be converted to GPIO

Pins 16,18,20 and 22 correspond to RDA gpio_a10, gpio_a9, gpio_a13 and gpio_a11. To change these pins into GPIO, we need to write a '1' into the IOMUX register for group A. The bit mask is 0b0010.1110.0000.0000 = 0x2e00, and the IOMUX register for group A is 0x11a0.900c.

  devmem2 0x11a0900c
  Value at address 0x11a0900c: 0x7e5290a0
  # read the result and use a bit-wise OR with 0x2e00 to set the bits
  devmem2 0x11a0900c w 7e52bea0

After this operation, you can access the four pins using the linux gpio mechanism at /sys/class/gpio and address gpio10, gpio9, gpio13 and gpio11 respectively

Function Group RDA Pins LInux GPIO Change to GPIO Change to Special Function
uart2 c7,c8 103,104 *0x11a0.9008 |= 0x0000.0180 *0x0x11a0.9008 &= 0xFFFF.FE7F
-- also uart2 b8, b9 40,41 *0x11a0.9010 |= 0x0000.0300 *0x0x11a0.9010 &= 0xFFFF.FCFF
uart1 c6 102 *0x11a0.9008 |= 0x0000.0040 *0x0x11a0.9008 &= 0xFFFF.FFBF
-- also uart1 a14 14 *0x11a0.900c |= 0x0000.4000 *0x0x11a0.900c &= 0xFFFF.BFFF
i2c2 a0, a1 0,1 *0x11a0.900c |= 0x0000.0003 *0x0x11a0.900c &= 0xFFFF.FFFC
i2c3 b6, b7 38,39 *0x11a0.9010 |= 0x0000.00C0 *0x0x11a0.9010 &= 0xFFFF.FF3F
spi2 a2, a3, a4, a6 2,3,4,6 *0x11a0.900c |= 0x0000.005C *0x0x11a0.900c &= 0xFFFF.FFA3
i2s/pcm a9, a10, a11, a13 9,10,11,13 *0x11a0.900c |= 0x0000.2E00 *0x0x11a0.900c &= 0xFFFF.D1FF

This chip RDA8810 does not have PWM on the GPIO pins. The fastest you can change them as outputs is at OS speeds. I wouldn't count on anything faster than 2sec, since the Linux OS may be doing other things when you require a GPIO pin to change.

Appendix: Known usage of GPIO pins

c2 = [IN] hi "boot from TF card", low "boot from nand"
c5 = [OUT] high lights LED5
c29 = hi to light LED3
c30 = hi to light LED2

a7 = [IN] headset detect (n/a)
a17 = [IN] otg_power_enable
a5/b0/c1/c2/c3/c4 = [IN] internal solder pads to select RDA chip version
a8 = 32kHz clock out (internal connection)
a12 = i2s_d1 (not connected)
a18/19/21/23/31 = not connected
b1 = bt_sleep, connect to modem
b2 = wf_intn, connect to modem
b4 = [IN] tf_detect, low when sd card is present
b5 = connected to the plug_in pin, set to 0v in sd_card boot mode (switch U3-7)
b10-23 = connected to the camera interface
b25-29 = n/c
b30-31 = i2c bus to talk to camera & modem
c9-20 = sdcard (internal connection)
c21/22/23/24 = spi1 (not connected)
c25-28 = n/c
d4 = n/c