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

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!

The number of GPIOH_4 is 431.

echo 431 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio431/direction
echo 1 > /sys/class/gpio/gpio431/direction/value
1 Like

Thank you Terry.
May I know that after we enable SPI port at that dts file and what are next steps to have a updated bootimage in AOSP which is downloaded by repo init -u https://github.com/khadas/android_manifest.git -b khadas-vims-pie.

I have succeeded to make and got updated kvim3_linux.dtb by using fenix on Ubuntu 20.4.
But there are two things I am wondering if I am making sense.
Firstly may I know my env/setenv.sh is right for VIM3 running Android Pie?

===========================================
#VERSION: 1.0.1
#KHADAS_BOARD=VIM3
#VENDOR=Amlogic
#CHIP=A311D
#LINUX=4.9
#UBOOT=2015.01
#DISTRIBUTION=Ubuntu
#DISTRIB_RELEASE=focal
#DISTRIB_TYPE=minimal
#DISTRIB_ARCH=arm64
#INSTALL_TYPE=EMMC
===========================================

Secondly about two files fenix/build/images_upgrade-df70a352d25388eff7e25e59d0efda80ad26bf2b/Amlogic/kvim.dtb and fenix/linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dtb. Are they same?

I also posted my topic on VIM3 Android P SPI device and I appreciate to have your support.

Thanks.

Fenix is only for Ubuntu, not for Android. So please use Fenix to build anything of android.

1 Like

I do not understand what’s the meaning of please use Fenix to build anything of android. Fenix serves Kernel build and AOSP have its huge build powered by a lot of GO and Android make stuff as I know.

I summarized my questions on this post currently. May I have your support to answer it?

Thank you very much.

Sorry, it’s please do not use Fenix to build anything of android

1 Like

Clear! Thank you @numbqq .

However I still need your help to answer my question on this post.

Because it got hard to understand how to update DTS file and kernel driver for Android developer when we realize the great fenix can not help AOSP.

Thanks.

Hi @Terry! I found directory spi in common/drivers in Android source code. Do I still need to add driver by myself?