All-in-one H6 Orange Pi Lite 2 Android 7.0 OTG configuration

problem reason

Because there is no power cord before, I have been using OTG port for power supply, found the power line of PSP, found that it can be used, it can be regarded as idle items. Let's use it again. When testing, I found that the OTG function could not be used, and then continued to solve it. 这里写图片描述

View schematic, confirm the pin

View schematic can confirm, OTG part uses USB0 module, and has IDDET, detection port, this port is used to distinguish the role played by OTG, is HOST Still Device. Level triggering. The IDDET pin is connected to the PC6 port of the chip. 这里写图片描述 这里写图片描述

sys_config.fexConfigure

Found OTG Configuration Item

;--------------------------------
;[usbc0]: usbc0 configuration.
;usb_used: usb controller enable. 0-disable, 1-enable.
;usb_port_type: usb mode. 0-device, 1-host, 2-otg.
;usb_detect_type: usb hotplug detect mode. 0-none, 1-vbus/id detect, 2-id/dpdm detect.
;usb_detect_mode: usb otg switch has two config. 0-thread scan, 1-id gpio interrupt.
;usb_id_gpio: usb id detect IO.
;usb_det_vbus_gpio: USB DET_VBUS has two config. (1)gpio pin; (2)"axp_ctrl", use axp intf.
;usb_drv_vbus_gpio: USB DRY_VBUS has two config. (1)gpio pin; (2)"axp_ctrl", use axp intf.
;--------------------------------
;--------------------------------
;--- USB0 CONFIG
;--------------------------------
[usbc0]
usbc0_used = 1
usb_port_type = 1
usb_detect_type = 1
usb_detect_mode = 0
usb_id_gpio =
usb_det_vbus_gpio =
usb_drv_vbus_gpio = port:PL05<1><0><default><1>
usb_host_init_state = 1
usb_regulator_io = "nocare"
usb_wakeup_suspend = 0
;--- USB Device
usb_luns = 3
usb_serial_unique = 0
usb_serial_number = "20080411"
rndis_wceis = 1

Usbc0_used = Is it enabled? Usb_port_type = USB port type, 0-device only, 1-host only, 2-otg Usb_detect_type = usb hotplug detect mode. 0-none, 1-vbus/id detect, 2-id/dpdm detect. Usb_detect_mode = usb otg switch has two config. 0-thread scan, 1-id gpio interrupt. Usb_id_gpio = usb id pin configuration Usb_det_vbus_gpio = usb det vbus pin configuration Usb_drv_vbus_gpio = usb drv vbus pin configuration Usb_host_init_state = host only mode, host port initialization state, 0 - usb does not work after initialization, 1-us after initialization Usb_regulator_io = usb powered regulator gpio Usb_wakeup_suspend = Whether to support usb wakeup function Usb_luns = number of drive letters when using mass storage Usb_serial_unique = usb device serial number is unique: 1 unique, using chip id; 0 is the same, using usb_serial_number Usb_serial_number = serial number of usb device Rndis_wceis = wireless rndis enable flag, 1 enable; 0 disable.

Seen from the code, USB0 is configured to be host mode by default. There is no OTG connector at present, and the Host mode cannot be tested. Next we need to configure the OTG mode according to the schematic diagram.

lemon@ubuntu:~/Develop/OrangePi_Lite2/lichee$ git diff tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
diff --git a/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex b/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
index 0e43e22..dc74d30 100755
--- a/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
+++ b/lichee/tools/pack/chips/sun50iw6p1/configs/petrel-p1/sys_config.fex
@@ -1100,12 +1100,12 @@ network_led_light = 1
 ;--------------------------------
 [usbc0]
 usbc0_used = 1
-usb_port_type = 1
+usb_port_type = 2
 usb_detect_type = 1
-usb_detect_mode = 0
-usb_id_gpio =
+usb_detect_mode = 1
+usb_id_gpio = port:PC06<1><0><default><1>
 usb_det_vbus_gpio =
-usb_drv_vbus_gpio = port:PL05<1><0><default><1>
+usb_drv_vbus_gpio =
 usb_host_init_state = 1
 usb_regulator_io = "nocare"
 usb_wakeup_suspend = 0

Modify the code and recompile Kernel.

[email protected]:~/Develop/OrangePi_Lite2/lichee$ ./build.sh config

Welcome to mkscript setup progress
All available chips:
   0. sun50iw1p1
   1. sun50iw2p1
   2. sun50iw6p1
   3. sun8iw11p1
   4. sun8iw12p1
   5. sun8iw6p1
   6. sun8iw7p1
   7. sun8iw8p1
   8. sun9iw1p1
Choice: 2
All available platforms:
   0. android
   1. dragonboard
   2. linux
   3. eyeseelinux
Choice: 0
All available business:
   0. 5.1
   1. 4.4
   2. 7.x
Choice: 2
LICHEE_BUSINESS=7.x
using kernel 'linux-3.10':
select arch by kernel version and chip
==================================
INFO: ----------------------------------------
INFO: build lichee ...
INFO: chip: sun50iw6p1
INFO: platform: android
INFO: business: 7.x
INFO: kernel: linux-3.10
INFO: arch: arm64
INFO: board: 
INFO: output: out/sun50iw6p1/android/
INFO: ----------------------------------------
INFO: build buildroot ...
external toolchain has been installed
external toolchain_32 has been installed
INFO: build buildroot OK.

regenerate rootfs cpio
15757 blocks
17099 blocks
build_ramfs
Copy boot.img to output directory ...
Copy modules to target ...

sun50iw6p1 compile Kernel successful


INFO: build kernel OK.
INFO: build rootfs ...
INFO: skip make rootfs for android
INFO: build rootfs OK.
----------------------------------------
build sun50iw6p1 android 7.x lichee OK
----------------------------------------

Compile Kernel, you need to package the image so that you can burn it to the SD card.

lemon@ubuntu:~/Develop/OrangePi_Lite2/lichee$ cd ..
lemon@ubuntu:~/Develop/OrangePi_Lite2$ cd android/
lemon@ubuntu:~/Develop/OrangePi_Lite2/android$ export LC_ALL=C
lemon@ubuntu:~/Develop/OrangePi_Lite2/android$ source ./build/envsetup.sh 
including device/asus/fugu/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-mips64/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/google/dragon/vendorsetup.sh
including device/htc/flounder/vendorsetup.sh
including device/huawei/angler/vendorsetup.sh
including device/lge/bullhead/vendorsetup.sh
including device/linaro/hikey/vendorsetup.sh
including device/moto/shamu/vendorsetup.sh
including device/softwinner/cheetah-cmcc-p1/vendorsetup.sh
including device/softwinner/cheetah-p1/vendorsetup.sh
including device/softwinner/common/vendorsetup.sh
including device/softwinner/petrel-cmcc-p1/vendorsetup.sh
including device/softwinner/petrel-p1/vendorsetup.sh
including sdk/bash_completion/adb.bash
lemon@ubuntu:~/Develop/OrangePi_Lite2/android$ lunch petrel_fvd_p1-eng

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=7.0
TARGET_PRODUCT=petrel_fvd_p1
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a7
TARGET_2ND_ARCH=
TARGET_2ND_ARCH_VARIANT=
TARGET_2ND_CPU_VARIANT=
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.15.0-33-generic-x86_64-with-Ubuntu-18.04-bionic
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=NRD91N
OUT_DIR=out
============================================
lemon@ubuntu:~/Develop/OrangePi_Lite2/android$ extract-bsp
/home/lemon/Develop/OrangePi_Lite2/android/device/*/petrel-p1/bImage copied!
/home/lemon/Develop/OrangePi_Lite2/android/device/*/petrel-p1/modules copied!
lemon@ubuntu:~/Develop/OrangePi_Lite2/android$ pack
copying tools file
copying configs file
./out/aultls32.fex
./out/aultools.fex
./out/boot_package.cfg
./out/boot_package.fex
./out/cardscript.fex
./out/cardscript_secure.fex
./out/cardtool.fex
./out/diskfs.fex
./out/env.cfg
./out/env_burn.cfg
./out/env_dragon.cfg
./out/esm.fex
./out/image.cfg
./out/parameter.fex
./out/split_xxxx.fex
./out/sunxi.fex
./out/sys_config.fex
./out/sys_partition.fex
./out/sys_partition_dragonboard.fex
./out/sys_partition_dump.fex
./out/sys_partition_linux.fex
./out/sys_partition_private.fex
./out/sysrecovery.fex
./out/test_config.fex
./out/toc0.fex
./out/toc1.fex
./out/usbtool.fex
./out/usbtool_test.fex
./out/verity_block.fex
copying boot resource
cp: cannot stat 'out/boot-resource/bootlogo.jpg': No such file or directory
lzma: out/bootlogo.jpg: No such file or directory
lzma: out/bempty.bmp: No such file or directory
lzma: out/battery_charge.bmp: No such file or directory
copying boot file
Conver script to dts ok.
update scp
pack boot package
GetPrivateProfileSection read to end
content_count=10
no used multi config
packing for android
normal
mbr count = 4

partitation file Path=/home/lemon/Develop/OrangePi_Lite2/lichee/tools/pack/out/sys_partition.bin
mbr_name file Path=/home/lemon/Develop/OrangePi_Lite2/lichee/tools/pack/out/sunxi_mbr.fex
download_name file Path=/home/lemon/Develop/OrangePi_Lite2/lichee/tools/pack/out/dlinfo.fex

mbr size = 16384
mbr magic softw411
disk name=bootloader
filename = bootloader.fex 
dl_file_size = 16058 sector
part_size = 32768 sector
disk name=env
filename = env.fex 
dl_file_size = 256 sector
part_size = 32768 sector
disk name=boot
filename = boot.fex 
dl_file_size = 33644 sector
part_size = 65536 sector
disk name=system
filename = system.fex 
dl_file_size = 1232405 sector
part_size = 3145728 sector
disk name=verity_block
filename = verity_block.fex 
dl_file_size = 2082 sector
part_size = 32768 sector
disk name=misc
disk name=recovery
filename = recovery.fex 
dl_file_size = 38504 sector
part_size = 65536 sector
disk name=sysrecovery
filename = sysrecovery.fex 
dl_file_size = 0 sector
part_size = 3145728 sector
disk name=private
disk name=alog
disk name=Reserve0
disk name=Reserve1
disk name=Reserve2
disk name=cache
disk name=UDISK
this is not a partition key
update_for_part_info 0
crc 0 = c8b8d2aa
crc 1 = 5d0583f7
crc 2 = 38b37651
crc 3 = ad0e270c
update mbr file ok
/home/lemon/Develop/OrangePi_Lite2/lichee/tools/pack/pctools/linux/eDragonEx/
/home/lemon/Develop/OrangePi_Lite2/lichee/tools/pack/out
Begin Parse sys_partion.fex
Add partion bootloader.fex BOOTLOADER_FEX00
Add partion very bootloader.fex BOOTLOADER_FEX00
FilePath: bootloader.fex
FileLength=7d7400Add partion env.fex ENV_FEX000000000
Add partion very env.fex ENV_FEX000000000
FilePath: env.fex
FileLength=20000Add partion boot.fex BOOT_FEX00000000
Add partion very boot.fex BOOT_FEX00000000
FilePath: boot.fex
FileLength=106d800Add partion system.fex SYSTEM_FEX000000
Add partion very system.fex SYSTEM_FEX000000
FilePath: system.fex
FileLength=259c2a74Add partion verity_block.fex VERITY_BLOCK_FEX
Add partion very verity_block.fex VERITY_BLOCK_FEX
FilePath: verity_block.fex
FileLength=1045b4Add partion recovery.fex RECOVERY_FEX0000
Add partion very recovery.fex RECOVERY_FEX0000
FilePath: recovery.fex
FileLength=12cd000Add partion sysrecovery.fex SYSRECOVERY_FEX0
Add partion diskfs.fex DISKFS_FEX000000
sys_config.fex Len: 0x10232
board.fex Len: 0x400
config.fex Len: 0xcc00
split_xxxx.fex Len: 0x200
sys_partition.fex Len: 0x124b
sunxi.fex Len: 0x18800
boot0_nand.fex Len: 0xc000
boot0_sdcard.fex Len: 0x8000
u-boot.fex Len: 0x138000
toc1.fex Len: 0x8
toc0.fex Len: 0x8
fes1.fex Len: 0x4340
boot_package.fex Len: 0x1ac000
usbtool.fex Len: 0x23600
aultools.fex Len: 0x2847b
aultls32.fex Len: 0x24d23
cardtool.fex Len: 0x11e00
cardscript.fex Len: 0x779
sunxi_mbr.fex Len: 0x10000
dlinfo.fex Len: 0x4000
arisc.fex Len: 0x6
bootloader.fex Len: 0x7d7400
Vbootloader.fex Len: 0x4
env.fex Len: 0x20000
Venv.fex Len: 0x4
boot.fex Len: 0x106d800
Vboot.fex Len: 0x4
system.fex Len: 0x259c2a74
Vsystem.fex Len: 0x4
verity_block.fex Len: 0x1045b4
Vverity_block.fex Len: 0x4
recovery.fex Len: 0x12cd000
Vrecovery.fex Len: 0x4
sysrecovery.fex Len: 0xb
diskfs.fex Len: 0x200
BuildImg 0
Dragon execute image.cfg SUCCESS !
----------image is at----------

/home/lemon/Develop/OrangePi_Lite2/lichee/tools/pack/sun50iw6p1_android_petrel-p1_uart0.img

pack finish

测试

Here we can see that when the computer is connected with a USB cable, the corresponding device will appear. Connect to Total Control for easy debugging without a screen. Because the onboard is a wireless network card, it is often not the same IP segment as our computer. We can't use WIFI ADB. Here we can configure it as OTG port, you can use USB ADB to facilitate debugging. You don't need to connect the serial port every time.这里写图片描述 这里写图片描述 这里写图片描述