一、 USB烧写NK.BIN流程:
OEMPlatformInit->CheckUSBDownload()->USBDownload()->ecvPacket()->processPacket()->WriteRawImageToBootMedia()->TOC_Write()
->EBOOT_COMMAND_NOTIFY_STARTDOWNLOADING()->OEMPreDownload ()->DownloadImag()->DownloadSignedBin()->OEMReadData()->WriteImageToFlash()->OEMWriteFlash()->WriteFlashNK()->TOC_Write()
二、烧写(升级)镜像流程:
eboot目录下main.c中:OEMPlatformInit-> download.c中:CheckUSBDownload-> USBInit-> InitOTG-> if(USBIsCableAttached)-> USBDownload
USBDownload-> if(IsUSBRequest()==TRUE)-> recvPacket-> processPacket
在processPacket中有很多的处理USB传输过来每帧(0x800=2K)的命令字。每帧前16个字节分别是:
BytesToDWORD(pRxBuffer, &cmd);
BytesToDWORD(pRxBuffer+4, &address);
BytesToDWORD(pRxBuffer+8, &length);
BytesToDWORD(pRxBuffer+12, &rxChecksum);
且校验和为2K-16个字节后面字节的累加和。函数为:download.c中的CheckSum。
大致流程是:eboot目录下的USB.C中的OTGDEV_RdPktBulkOutEp()函数里的接收到ATUD->后发送OKUD。然后上位机发送2K字节的每一帧数据。每一帧数据的前16个字节为协议信息。
USB-Monitor下来的前2帧的命令分别是:EBOOT_COMMAND_NOTIFY_STARTDOWNLOADING(07)输出LOG提示信息,然后是:EBOOT_COMMAND_GETVERSION(13)获取EBOOT版本号,第三帧就开始传输NK.BIN.
dragin和210通讯详细流程:
0.进入 USBDownload()
1.上位机发送ATUD四个字节->210回送OKUD四个字节
2.上位机发送Eboot version请求(cmd=EBOOT_COMMAND_GETVERSION)->210回送0x31313030
3.上位机发送cmd=EBOOT_COMMAND_NOTIFY_STARTDOWNLOADING和address=0 ->210回送CheckSum
4.上位机发送cmd=EBOOT_COMMAND_WRITETOMEM(2k帧为 cmd+address+length+checksum+nk.bin)->210回送CheckSum
5.上位机发送cmd=EBOOT_COMMAND_FLASH_BOOTLOADER(dwDLType == 0)->210回送CheckSum
6.上位机发送cmd=EBOOT_COMMAND_OPENSTL->210回送CheckSum
7.上位机发送cmd=EBOOT_COMMAND_NOTIFY_STARTDOWNLOADING 和address=1 ->210回送CheckSum
8.上位机发送cmd=EBOOT_COMMAND_WRITETOMEM(2k帧为 cmd+address+length+checksum+nk.bin)->210回送CheckSum
9.上位机发送cmd=EBOOT_COMMAND_FLASH_BOOTLOADER(dwDLType == 1跟第5步执行不同的操作)->210回送CheckSum
10.退出 USBDownload()
注:以上是下载bootloader和nk.bin流程 如果只想下载nk.bin只需要1 2 6 7 8 9其中2也可以省略掉
三、附dragin烧写工具信息记录:
---------------------------------------------------------------------------------------
Notify Connecting USB(Type : USB SERIAL)
---------------------------------------------------------------------------------------
USB requests to connect is received
Attempting to open \\?\usb#vid_0547&pid_2720#5&2bf451f8&0&2#{25dbce51-6c8f-4a72-8a6d-b54c2b4fc835}
To open \\?\usb#vid_0547&pid_2720#5&2bf451f8&0&2#{25dbce51-6c8f-4a72-8a6d-b54c2b4fc835} is success
The end of ENUM
USB device name : 5&2bf451f8&0&2
USBSeral COM port : 0
A device requested to connect
---------------------------------------------------------------------------------------
BOOT VERSION = 11.00
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Notify Downloading(Type : BOOT, Downloads : 267)
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Flash image(Type : BOOT, Blocks : 3)
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Notify Downloading(Type : OS, Downloads : 48896995)
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Flash Image(Type : OS, Blocks : 187)
---------------------------------------------------------------------------------------
Real Blocks : 1
---------------------------------------------------------------------------------------
Launch image(Launch Address : 0x80028000)
-----------------------------------------------
---------------------------------------------------------------------------------------
Notify Connecting USB(Type : USB SERIAL)
---------------------------------------------------------------------------------------
USB requests to connect is received
Attempting to open \\?\usb#vid_0547&pid_2720#5&2bf451f8&0&2#{25dbce51-6c8f-4a72-8a6d-b54c2b4fc835}
To open \\?\usb#vid_0547&pid_2720#5&2bf451f8&0&2#{25dbce51-6c8f-4a72-8a6d-b54c2b4fc835} is success
The end of ENUM
USB device name : 5&2bf451f8&0&2
USBSeral COM port : 0
A device requested to connect
---------------------------------------------------------------------------------------
BOOT VERSION = 11.00
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Notify Downloading(Type : BOOT, Downloads : 267)
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Flash image(Type : BOOT, Blocks : 3)
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Notify Downloading(Type : OS, Downloads : 48883007)
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
Flash Image(Type : OS, Blocks : 187)
---------------------------------------------------------------------------------------
Real Blocks : 1
---------------------------------------------------------------------------------------
Launch image(Launch Address : 0x80028000)
---------------------------------------------------------------------------------------
转载自:http://blog.csdn.net/zhengmeifu/article/details/7320602