一、USB升级流程
通过代码及log分析,当前平台升级过程在PL阶段进行
USB download相关代码
mtk/modules/hal/boot/preloader/platform/flashc/
mtk/modules/hal/boot/preloader/platform/board_name/flash/
mtk/modules/hal/boot/preloader/platform/board_name/src/drivers/usb/da/
USB升级流程
从如下图中的main()进入PL阶段,完成对USB/PCIe初始化,
但当前PL阶段只支持USB下载模式,由brom_flags传入com_interface.init_uart以及com_interface.init来初始化Uart和USB com port,如下:
初始化时,经过USB_Config_Type()等操作,最终将USB在Host上枚举表现为COM Port,这样就可以将USB数据转换为串行数据格式,并呈现给操作系统和应用程序,就像连接了一个实际的串行设备一样。因此,从应用程序的角度来看,与CDC ACM设备的交互就像是与一个标准的串行端口交互,提供了向后兼容性和简化了Host Tool开发流程。
通过download log及上述代码逻辑来看,平台上电后都会先出download serial port,使用UsbTreeView获取该端口信息如下:
=========================== USB Port3 ===========================
Connection Status : 0x01 (Device is connected)
Port Chain : 1-3
Properties : 0x01
IsUserConnectable : yes
PortIsDebugCapable : no
PortHasMultiCompanions : no
PortConnectorIsTypeC : no
ConnectionIndex : 0x03 (Port 3)
CompanionIndex : 0
CompanionHubSymLnk : USB#ROOT_HUB30#4&2dd382eb&0&0#{f18a0e88-c30c-11d0-8815-00a0c906bed8}
CompanionPortNumber : 0x13 (Port 19)
-> CompanionPortChain : 1-19
========================== Summary =========================
Vendor ID : 0x0E8D (MediaTek Inc.)
Product ID : 0x2000
USB Version : 2.1
Port maximum Speed : High-Speed (Companion Port 1-19 supports SuperSpeed)
Device maximum Speed : SuperSpeed
Device Connection Speed : High-Speed
Self powered : yes
Demanded Current : 500 mA
Used Endpoints : 4
======================== USB Device ========================
+++++++++++++++++ Device Information ++++++++++++++++++
Friendly Name : PreLoader USB VCOM (Android) (COM94)
Device Description : PreLoader USB VCOM (Android)
Device Path 1 : \\?\USB#VID_0E8D&PID_2000#5&3aa1a3bd&0&3#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Device Path 2 : \\?\USB#VID_0E8D&PID_2000#5&3aa1a3bd&0&3#{86e0d1e0-8089-11d0-9ce4-08003e301f73} (GUID_DEVINTERFACE_COMPORT)
Kernel Name : \Device\USBPDO-4
Device ID : USB\VID_0E8D&PID_2000\5&3AA1A3BD&0&3
Hardware IDs : USB\VID_0E8D&PID_2000&REV_0100 USB\VID_0E8D&PID_2000
Driver KeyName : {
4d36e978-e325-11ce-bfc1-08002be10318}\0074 (GUID_DEVCLASS_PORTS)
Driver : \SystemRoot\system32\DRIVERS\usb2ser.sys (Version: 3.0.1504.0 Date: 2015-01-22 Company: MBB)
Driver Inf : C:\WINDOWS\inf\oem80.inf
Legacy BusType : PNPBus
Class : Ports
Class GUID : {
4d36e978-e325-11ce-bfc1-08002be10318} (GUID_DEVCLASS_PORTS)
Service : wdm_usb
Enumerator : USB
Location Info : Port_#0003.Hub_#0001
Address : 3
Location IDs : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(3), ACPI(_SB_)#ACPI(PCI0)#ACPI(XHC_)#ACPI(RHUB)#ACPI(HS03)
Container ID : {
f816d467-5468-11ef-8d99-005056c00008}
Manufacturer Info : MediaTek
Capabilities : 0x84 (Removable, SurpriseRemovalOK)
Status : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code : 0
Power State : D0 (supported: D0, D3, wake from D0)
COM-Port : COM94 (\Device\cdcacm1)
+++++++++++++++++ Registry USB Flags +++++++++++++++++
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\0E8D20000100
osvc : REG_BINARY 00 0