1. 程式人生 > >全志 H6 Orange Pi Lite 2 Android 7.0 OTG配置

全志 H6 Orange Pi Lite 2 Android 7.0 OTG配置

問題原因

因為之前沒有電源線,一直使用OTG口進行供電,找到了條PSP的電源線,發現可以使用,也算是閒置物品再利用吧。測試時發現OTG功能用不了,接下來繼續解決。 這裡寫圖片描述

檢視原理圖,確認管腳

檢視原理圖可以確認,OTG部分使用的是USB0模組,並且有IDDET,檢測埠,這個埠是用來區分OTG所扮演的角色,是HOST還是Device。電平觸發。IDDET管腳連線到晶片的PC6口。 這裡寫圖片描述 這裡寫圖片描述

sys_config.fex配置

找到OTG配置項

;--------------------------------
;[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 = 是否使能 usb_port_type = USB埠型別,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配置 usb_det_vbus_gpio = usb det vbus pin配置 usb_drv_vbus_gpio = usb drv vbus pin配置 usb_host_init_state = host only模式下,host埠初始化狀態,0-初始化後usb不工作,1-初始化後usb工作 usb_regulator_io = usb供電的regulator gpio usb_wakeup_suspend = 是否支援usb喚醒功能 usb_luns = 使用mass storage功能時碟符數量 usb_serial_unique = usb device的序列號是否唯一:1唯一,使用chip id;0相同,使用usb_serial_number制定 usb_serial_number = usb device的序列號 rndis_wceis = wireless rndis使能標誌,1使能;0禁止。

從程式碼中看到,USB0預設被配置成為host模式,目前沒有OTG接頭,無法測試Host模式,接下來我們需要按照原理圖配置成OTG模式

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

修改完程式碼,重新編譯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
----------------------------------------

編譯完Kernel,還需對映象進行打包,這樣才可以燒寫到SD卡中。

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

測試

這裡我們可以看到,用USB線連線電腦,會出現相應的裝置。連線Total Control,可以方便沒有螢幕的情況下進行除錯。因為板載的是無線網絡卡,往往跟我們電腦不是同一個IP段,不能使用WIFI ADB,這裡我們配置成OTG口,就可以使用USB ADB,方便除錯,不需要每次都連線串列埠。 這裡寫圖片描述 這裡寫圖片描述 這裡寫圖片描述