VIM3 GPIO "WiringPI" SPI

Thank you @Frank .

Hi @jasonl and @Terry ,

I got building Android source code error on Ubuntu 20.04 VM.
However same steps I did on Ubuntu 18.04 worked well on my another Ubuntu 18.04 VM.

I have remove all of folder and run repo sync but get the same error message while running make -j2 otapackage on Ubuntu 20.04 VM.

I run repo init -u https://github.com/khadas/android_manifest.git -b khadas-vims-pie to have android source code.
Thanks and my console screen shot shown as below:

============================================
amo@ubuntu:~/workspace/vim3/bsp$ make -j2 otapackage
hardware/amlogic/wifi/configs/wifi.mk:43: warning: WIFI_MOUDLE is multiwifi
hardware/amlogic/wifi/configs/wifi.mk:47: warning: WIFI_BUILD_IN is false
hardware/amlogic/bluetooth/configs/bluetooth.mk:20: warning: BLUETOOTH_MODULE is BCMBT
hardware/amlogic/bluetooth/configs/bluetooth.mk:24: warning: BLUETOOTH_INF is not set
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
TARGET_PRODUCT=kvim3
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a9
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.8.0-41-generic-x86_64-Ubuntu-20.04.1-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PPR1.180610.011
OUT_DIR=out
============================================
[1/1] out/soong/.minibootstrap/minibp out/soong/.bootstrap/build.ninja
[55/56] glob prebuilts/ndk/stl.bp
[77/77] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
out/build-kvim3-cleanspec.ninja is missing, regenerating...
hardware/amlogic/wifi/configs/wifi.mk:43: warning: WIFI_MOUDLE is multiwifi
hardware/amlogic/wifi/configs/wifi.mk:47: warning: WIFI_BUILD_IN is false
hardware/amlogic/bluetooth/configs/bluetooth.mk:20: warning: BLUETOOTH_MODULE is BCMBT
hardware/amlogic/bluetooth/configs/bluetooth.mk:24: warning: BLUETOOTH_INF is not set
out/build-kvim3.ninja is missing, regenerating...
hardware/amlogic/wifi/configs/wifi.mk:43: warning: WIFI_MOUDLE is multiwifi
hardware/amlogic/wifi/configs/wifi.mk:47: warning: WIFI_BUILD_IN is false
hardware/amlogic/bluetooth/configs/bluetooth.mk:20: warning: BLUETOOTH_MODULE is BCMBT
hardware/amlogic/bluetooth/configs/bluetooth.mk:24: warning: BLUETOOTH_INF is not set
[5/954] including build/make/Android.mk ...
device/khadas/common/factory.mk:184: warning: echo "radio add dt and bootloader"
device/khadas/common/factory.mk:322: warning: will keep out/target/product/kvim3/update.img
device/khadas/common/factory.mk:465: warning: will keep out/target/product/kvim3/kvim3-fastboot-flashall-20210201.zip
[314/954] including hardware/amlogic/audio/Android.mk ...
"---------ott audio mode, compiler configure 2 channels output by default--------"
[317/954] including hardware/amlogic/camera/Android.mk ...
/bin/bash: ifconfig: command not found
************************************************************
pdk or not:    
target board:  g12b
git version:   "620d8d5f125aad285e53c797f48ee0e32fd774fb"
uncomment:     0 files
last changed:  "Date:   Sat Nov 7 17:50:25 2020 +0800"
build time:    " Mon Feb  1 00:10:37 PST 2021"
builder name:  " amo"
branch name:   "* (no branch)"
build mode:    userdebug
host name:     "ubuntu"
/bin/bash: ifconfig: command not found
host IP:       ""
path:          "/home/amo/workspace/vim3/bsp/hardware/amlogic/camera/v3/fake-pipeline2/tests"
************************************************************
[321/954] including hardware/amlogic/gralloc/Android.mk ...
hardware/amlogic/gralloc/Android.mk:79: warning: "the value of GPU_ARCH is bifrost"
hardware/amlogic/gralloc/Android.mk:135: warning: "the value of BOARD_RESOLUTION_RATIO is 1080"
hardware/amlogic/gralloc/Android.mk:141: warning: "the value of HWC_PRIMARY_DISP_SUPPORT_AFBC is false"
hardware/amlogic/gralloc/Android.mk:142: warning: "the value of HWC_EXTEND_DISP_SUPPORT_AFBC is true"
hardware/amlogic/gralloc/Android.mk:154: warning: "the value of GPU_TYPE is gondul"
[323/954] including hardware/amlogic/hwcomposer/Android.mk ...
"Build HWC 2.0"
[537/954] including system/sepolicy/Android.mk ...
system/sepolicy/Android.mk:79: warning: BOARD_SEPOLICY_VERS not specified, assuming current platform version
[908/954] including vendor/amlogic/common/LibTsPlayer/Android.mk ...
vendor/amlogic/common/LibTsPlayer/jni/compat/media_control/Android.mk:27: warning: 9
vendor/amlogic/common/LibTsPlayer/jni/compat/media_control/Android.mk:98: warning: 9
vendor/amlogic/common/LibTsPlayer/jni/test/Android.mk:5: warning: Kitkat
vendor/amlogic/common/LibTsPlayer/jni/test/Android.mk:6: warning: vendor/amlogic/common/LibTsPlayer/jni/test
[919/954] including vendor/amlogic/common/apps/NativeImagePlaye/Android.mk ...
vendor/amlogic/common/apps/NativeImagePlaye/jni/Android.mk:10: warning: libnativehelper/include_jni
[928/954] including vendor/amlogic/common/external/DTVKit/android-inputsource/Android.mk ...
vendor/amlogic/common/external/DTVKit/android-inputsource/logicdtvkit/src/jni/Android.mk:10: warning: libnativehelper/include_jni
build/make/core/java_common.mk:183: warning: vendor/amlogic/common/external/DTVKit/android-inputsource/app/src/main/Android.mk: inputsource: Unused source files: vendor/amlogic/common/external/DTVKit/android-inputsource/app/src/main/droidlogic/java
inputsource: platform 'amlogic'
[940/954] including vendor/amlogic/common/frameworks/Android.mk ...
vendor/amlogic/common/frameworks/core/jni/screencontrol/Android.mk:7: warning: libnativehelper/include_jni
vendor/amlogic/common/frameworks/core/jni/systemcontrol/Android.mk:10: warning: libnativehelper/include_jni
[941/954] including vendor/amlogic/common/gpu-lib/Android.mk ...
"the value of BOARD_INSTALL_VULKAN is "
TARGET_PRODUCT is kvim3
[946/954] including vendor/amlogic/common/prebuilt/Android.mk ...
"no bootaccelerate source code, add prebuilts"
"no exoplayer source code, add prebuilts"
[952/954] including vendor/amlogic/common/tv/tvserver/Android.mk ...
"have hardware/amlogic/media"
"have hardware/amlogic/media"
[954/954] including vendor/widevine/Android.mk ...
device/khadas/kvim3/Kernel.mk:174: warning: overriding commands for target `out/target/product/kvim3/obj/lib_vendor/mali.ko'
vendor/amlogic/common//gpu/gpu-v2.mk:23: warning: ignoring old commands for target `out/target/product/kvim3/obj/lib_vendor/mali.ko'
build/make/core/base_rules.mk:412: warning: overriding commands for target `out/target/product/kvim3/system/usr/icu/icudt60l.dat'
build/make/core/base_rules.mk:412: warning: ignoring old commands for target `out/target/product/kvim3/system/usr/icu/icudt60l.dat'
build/make/core/base_rules.mk:412: warning: overriding commands for target `out/host/linux-x86/usr/icu/icudt60l.dat'
build/make/core/base_rules.mk:412: warning: ignoring old commands for target `out/host/linux-x86/usr/icu/icudt60l.dat'
build/make/core/Makefile:28: warning: overriding commands for target `out/target/product/kvim3/obj/lib_vendor/ddr_window_64.ko'
device/khadas/kvim3/Kernel.mk:174: warning: ignoring old commands for target `out/target/product/kvim3/obj/lib_vendor/ddr_window_64.ko'
build/make/core/Makefile:28: warning: overriding commands for target `out/target/product/kvim3/vendor/etc/init/android.hardware.wifi@1.0-service.rc'
build/make/core/base_rules.mk:426: warning: ignoring old commands for target `out/target/product/kvim3/vendor/etc/init/android.hardware.wifi@1.0-service.rc'
[ 99% 1200/1201] glob vendor/amlogic/common/interfaces/tvserver/1.0/src
[  0% 6/71947] Yacc: dtc <= external/dtc/dtc-parser.y
external/dtc/dtc-parser.y: conflicts: 3 shift/reduce
[  0% 10/71947] host C: dtc <= external/dtc/checks.c
FAILED: out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/checks.o 
/bin/bash -c "PWD=/proc/self/cwd  prebuilts/clang/host/linux-x86/clang-4691093/bin/clang   	-I external/dtc -I out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates -I out/host/linux-x86/gen/EXECUTABLES/dtc_intermediates -I libnativehelper/include_jni \$(cat out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/import_includes)  -I system/core/include -I system/media/audio/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I libnativehelper/include -I frameworks/native/include -I frameworks/native/opengl/include -I frameworks/av/include  -c  -Wa,--noexecstack -fPIC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -fstack-protector-strong -m64 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g -fno-strict-aliasing -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-expansion-to-defined -Wno-zero-as-null-pointer-constant -fdebug-prefix-map=\$PWD/=   -target x86_64-linux-gnu -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin   -std=gnu99  -Wall -Werror -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -fPIE   -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type -Wno-tautological-constant-compare -Wno-null-pointer-arithmetic -Wno-enum-compare -Wno-enum-compare-switch -MD -MF out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/checks.d -o out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/checks.o external/dtc/checks.c"
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang.real: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
[  0% 11/71947] host C: dtc <= external/dtc/data.c
FAILED: out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/data.o 
/bin/bash -c "PWD=/proc/self/cwd  prebuilts/clang/host/linux-x86/clang-4691093/bin/clang   	-I external/dtc -I out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates -I out/host/linux-x86/gen/EXECUTABLES/dtc_intermediates -I libnativehelper/include_jni \$(cat out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/import_includes)  -I system/core/include -I system/media/audio/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I libnativehelper/include -I frameworks/native/include -I frameworks/native/opengl/include -I frameworks/av/include  -c  -Wa,--noexecstack -fPIC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS --gcc-toolchain=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 --sysroot prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/sysroot -fstack-protector-strong -m64 -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -no-canonical-prefixes -DNDEBUG -UDEBUG -fno-exceptions -Wno-multichar -O2 -g -fno-strict-aliasing -fdebug-prefix-map=/proc/self/cwd= -D__compiler_offsetof=__builtin_offsetof -Werror=int-conversion -Wno-reserved-id-macro -Wno-format-pedantic -Wno-unused-command-line-argument -fcolor-diagnostics -Wno-expansion-to-defined -Wno-zero-as-null-pointer-constant -fdebug-prefix-map=\$PWD/=   -target x86_64-linux-gnu -Bprebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/x86_64-linux/bin   -std=gnu99  -Wall -Werror -Wno-sign-compare -Wno-missing-field-initializers -Wno-unused-parameter -fPIE   -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -Werror=address-of-temporary -Werror=return-type -Wno-tautological-constant-compare -Wno-null-pointer-arithmetic -Wno-enum-compare -Wno-enum-compare-switch -MD -MF out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/data.d -o out/host/linux-x86/obj/EXECUTABLES/dtc_intermediates/data.o external/dtc/data.c"
prebuilts/clang/host/linux-x86/clang-4691093/bin/clang.real: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
ninja: build stopped: subcommand failed.
00:11:23 ninja failed with: exit status 1

#### failed to build some targets (02:14 (mm:ss)) ####

We have not used Ubuntu 20.04 to compile the code of android 9.0. The new version of the system is not necessarily suitable for compiling the old version of the SDK, because there are some tool and code compatibility issues.

1 Like

Understand! It’s acceptable for me to directly make an Ubuntu 18.04 VM to build android.
Thank you @Terry .

And I really 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.

Thank you very much.

For the newest commit of fenix these steps works for me to have /dev/spidev1.0 based on VIM3 ubuntu spi使用问题 - #2 by numbqq and suggestions above.

1.Modify /fenix/linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dts b/arch/arm64/boot/dts/amlogic/kvim3_linux.dts as below:

 &pwm_ef {
		status = "okay";
		pinctrl-names = "default";
		pinctrl-0 = <&pwm_f_pins1>;
 };

 ...	 

 &spicc1 {
		status = "enable";
		pinctrl-names = "default";
		pinctrl-0 = <&spicc1_pins>;
		cs-gpios = <&gpio GPIOH_6 0>;
 ...
  1. Run make kernel && make debs && make

  2. Replace /boot/zImage and /boot/dtb/kvim3_linux.dtb with Image and kvim3_linux.dtb which are built at step 2.

    $scp ./fenix/linux/arch/arm64/boot/Image khadas@192.168.XXX.XXX:/tmp
    $scp ./fenix/linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dtb  khadas@192.168.XXX.XXX:/tmp
    $ssh khadas@192.168.XXX.XXX
    $sudo mv /tmp/Image /boot/zImage
    $sudo mv /tmp/kvim3_linux.dtb /boot/dtb
    
  3. Update device tree overlay.

    vim /boot/env.txt
    to change this line: overlays=uart3 i2c3 os08a10 spi1

5.WiringPi check gpio.

`	khadas@Khadas:~$ gpio readall
 +------+-----+----------+------+---+----+---- Model  Khadas VIM3 --+----+---+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode |   Name   | wPi | GPIO |
 +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+
 |      |     |       5V |      |   |    |       |  1 || 21 |       |    |   |      | GND      |     |      |
 |      |     |       5V |      |   |    |       |  2 || 22 | P/U   |    | 1 | ALT1 | PIN.A15  | 6   |  475 |
 |      |     |   USB_DM |      |   |    |       |  3 || 23 | P/U   |    | 1 | ALT1 | PIN.A14  | 7   |  474 |
 |      |     |   USB_DP |      |   |    |       |  4 || 24 |       |    |   |      | GND      |     |      |
 |      |     |      GND |      |   |    |       |  5 || 25 | P/U   |    | 1 | ALT0 | PIN.AO2  | 8   |  498 |
 |      |     |   MCU3V3 |      |   |    |       |  6 || 26 | P/U   |    | 1 | ALT0 | PIN.AO3  | 9   |  499 |
 |      |     |  MCUNRST |      |   |    |       |  7 || 27 |       |    |   |      | 3V3      |     |      |
 |      |     |  MCUSWIM |      |   |    |       |  8 || 28 |       |    |   |      | GND      |     |      |
 |      |     |      GND |      |   |    |       |  9 || 29 | P/D   |    | 0 | ALT0 | PIN.A1   | 10  |  461 |
 |      |  18 |     ADC0 |      |   |    |       | 10 || 30 | P/D   |    | 1 | ALT0 | PIN.A0   | 11  |  460 |
 |      |     |      1V8 |      |   |    |       | 11 || 31 | P/D   |    | 0 | ALT0 | PIN.A3   | 12  |  463 |
 |      |  19 |     ADC1 |      |   |    |       | 12 || 32 | P/D   |    | 0 | ALT0 | PIN.A2   | 13  |  462 |
 |  506 |   1 | PIN.AO10 | ALT3 | 0 |    |   P/U | 13 || 33 | P/D   |    | 0 | ALT1 | PIN.A4   | 14  |  464 |
 |      |     |     GND3 |      |   |    |       | 14 || 34 |       |    |   |      | GND      |     |      |
 |  433 |   2 |   PIN.H6 |  OUT | 1 |    |   P/D | 15 || 35 | P/D   |    | 0 | ALT2 | PWM-F    | 15  |  432 |
 |  434 |   3 |   PIN.H7 | ALT2 | 0 |    |   P/D | 16 || 36 |       |    |   |      | RTC      |     |      |
 |      |     |      GND |      |   |    |       | 17 || 37 | P/D   |    | 0 | ALT2 | PIN.H4   | 16  |  431 |
 |  497 |   4 |  PIN.AO1 | ALT0 | 1 |    |   P/U | 18 || 38 |       |    |   |      | MCU-FA1  |     |      |
 |  496 |   5 |  PIN.AO0 | ALT0 | 1 |    |   P/U | 19 || 39 | P/D   |    | 0 | IN   | PIN.Z15  | 17  |  426 |
 |      |     |      3V3 |      |   |    |       | 20 || 40 |       |    |   |      | GND      |     |      |
 +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+

 `
  1. Check pins related to SPI.

    VIM3 SPI:
    PIN37: GPIOH_4/SPIB_MOSI     -> type ALT2
    PIN35: PWM_F/SPIB_MISO       -> type ALT2
    PIN15: UARTC_RX/SPIB_SS     -> type OUT
    PIN16: UARTC_TX/SPIB_SCLK -> type ALT2
    

Thanks @Frank and @numbqq and @OSHMUHA and @kwklaus.

3 Likes