VIM3 GPIO's, SPI, UART, with Android 9 Pie

Hei again,

is somebody here, maybe from Khadas- Team with a answer to these question,
How can I use the GPIO’s like GPIO- Pins, UART, SPI and so on…?
Android Studio 3.6.1 supports only NXP or Raspberry derivate!

@Frank give the Tip ask @Terry

maybe there are an little bit more… I hope for some good tip’s
Thanks for reading….

@kwklaus About android GPIO control , @Terry will tell you .

Hi @kwklaus
I think the link below will be helpful for you:

Good day!

@Frank Thanks for this message I will wait for Terrys answer!

good day also for you.

Ps: for all another interested users, here are some Links about this Thema.

Hei,
@khadas, @Frank, @numbqq, @Terry
my questions about GPIO’s, SPI… with Android 9 stay until now in room!!

About how to use the uart on Android, you can refer to this demo

In addition, Which gpio do you want to use ? Please list it.

first is, we decided to use only SPI, because this is the best way to communicate with our pigy-back board.
Is SPI Device in Rom and what have we to do to activate SPI_B Pin 15, 16, 35, 37

to use UART together with one or more GPIO’s is only a way for Plan B, SPI don’t work!
only if we need this combination we wont use UARTC Pin 15/16 and GPIOH_4 Pin 37.

Only for Information your example for UART is from 2009, Android Studio was to this
time under development (not born) today we have 2020 and Android 9!
Thanks for your help.

The Pin 15,16 is also for UARTC, and is configured as a serial port by default on our ROM.
You need to build your rom if you want to use SPI. Also Maybe you need to add driver support for your pigy-back board.
Thanks!

In addition, about the uart control demo, it’s only the reference for you.

@Terry thanks for the reply.
We have been researched for a few days in the area of ​​Android 9, Android Studio and hardware like SPI etc.
As we understand it, Android Things can only be used for certain hardware supported by Google.
To use other hardware like UART or SPI, it’s mainly required to write its own driver, unless it’s part of the Andriod Linux kernel.
I assume that the SPI interface of the VIM3 on the 40pin GPIO connector SPI_B pin 15, 16, 35, 37, part of the ROM is.
The standard SPI driver can be used.
Is it necessary to integrate the SPI device in the “dts” file…? like
& spi_0 {
spidev @ 1 {

address-cells = <1>; # size-cells = <1>; compatible = “linux, spidev”; spi-max-frequency = <20000000>; reg = <1>; };};Does Khadas have rules or instructions on how to do oneSPI device in an Android environment that integrates an activity.I think we are not alone with this problem becauseeveryone who uses a standard interface like I2C, UART, or SPIwould like to have this problem.Thanks for Anwer!

Accessing GPIO/UART/SPI on Android

Hi,
Is the PeripheralManagerService object the way to access the GPIO and peripherals?
Is it supported on supplied Android?
Thanks,
Nahum

nahumb

Mar '17

Terry Khadas Team wrote:

The PeripheralManagerService object is not the way to access the GPIO and peripherals on Vim .

It is only supported by raspberry Pi.

We will add the support on supplied Android and also will release the docs about it .

Thanks.

Now we have 23. Mar‘20 and I have in principle still the same Problem / Questions ‘

You can enable the SPI port at dts file, but you need to add driver control by yourself.

diff --git a/arch/arm/boot/dts/amlogic/kvim3.dts b/arch/arm/boot/dts/amlogic/kvim3.dts
index daeff50..9e9eb7f 100644
--- a/arch/arm/boot/dts/amlogic/kvim3.dts
+++ b/arch/arm/boot/dts/amlogic/kvim3.dts
@@ -1437,7 +1437,7 @@
 };
 
 &uart_C {
-       status = "okay";
+       status = "disabled";
 };
 
 &pcie_A {
@@ -1449,3 +1449,9 @@
        status = "okay";
 };
 
+&spicc1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&spicc1_pins>;
+       cs-gpios = <&gpio GPIOH_6 0>;
+};

How about control GPIO on Android application, you can refer to this.

@Terry Thnaks!

Ok, I will try it.
so I understand, is the SPI driver part of ROM and I can use them.
i only have to control the driver.
but commands like

void read (byte[] buffer, int length)
write(byte[], int)
void transfer(byte[], byte[], int
void setMode (int mode)
void setFrequency (int frequencyHz)

and so on I can use in Programm (Andriod Studio 3.6.1…?

You can’t do that, and need to add driver support on kernel. please refer to this.

1 Like

@Terry
Thanks for help!
I will try it to implement in Linux Kernel.

Hei together,
@Terry
Thanks for help in SPI, UART with Android 9 Pie!

UART:
We installed an Android Module for supporting UART_B and UART_C an VIM3 boards,
using C++ and CMake to communicate with the included Linux UART- Driver.
Module works with all three UART’s ttyS1, ttyS2, and ttyS3.

SPI:
This part is (was) not so easy to realise.
To change something in .dts file is very easy but before you can do this,
you have to download round about 250 GB Sourcecode + 150 GB extra
diskspace for recompiling this code. Download needs around 8…10 hours
and one compiling approximately 6…8 hours, to get a new Android image.
Result, it works…!

Now, my last question, maybe you can help again…?
We wont use PIN 37 GPIOH_4 of VIM3’s 40 PIN connector as Output PIN.
Is this possible, is this PIN 37 aktuell defined as GPIO PIN under Android 9.
We searched for an easy example, but we didn’t find some.

Thanks for help again.

@Terry
Hei again,

my last question was,

  • can I use VIM3 GPIO PIN37- GPIOH_4 (175) as Output Pin with Android 9…?
    The Example Hei again,

my last question was,

  • can I use VIM3 GPIO PIN37- GPIOH_4 ( 175 ) as Output Pin …?
    the example in https://github.com/terry2droid/Wiringpi is mainly for VIm1
    but is is it software example similar to VIM3…?
    Thanks for help!