1*4882a593Smuzhiyun------------- 2*4882a593SmuzhiyunSDP in U-Boot 3*4882a593Smuzhiyun------------- 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunSDP stands for serial download protocol. It is the protocol used in NXP's 6*4882a593Smuzhiyuni.MX SoCs ROM Serial Downloader and provides means to download a program 7*4882a593Smuzhiyunimage to the chip over USB and UART serial connection. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunThe implementation in U-Boot uses the USB Downloader Gadget (g_dnl) to 10*4882a593Smuzhiyunprovide a SDP implementation over USB. This allows to download program 11*4882a593Smuzhiyunimages to the target in SPL/U-Boot using the same protocol/tooling the 12*4882a593SmuzhiyunSoC's recovery mechanism is using. 13*4882a593Smuzhiyun 14*4882a593SmuzhiyunThe SDP protocol over USB is a USB HID class protocol. USB HID class 15*4882a593Smuzhiyunprotocols allow to access a USB device without OS specific drivers. The 16*4882a593SmuzhiyunU-Boot implementation has primarly been tested using the open source 17*4882a593Smuzhiyunimx_loader utility (https://github.com/toradex/imx_loader). 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunThe host side utilities are typically capable to interpret the i.MX 20*4882a593Smuzhiyunspecific image header (see doc/README.imximage). There are extensions 21*4882a593Smuzhiyunfor imx_loader's imx_usb utility which allow to interpret the U-Boot 22*4882a593Smuzhiyunspecific legacy image format (see mkimage(1)). Also the U-Boot side 23*4882a593Smuzhiyunsupport beside the i.MX specific header the U-Boot legacy header. 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunUsage 26*4882a593Smuzhiyun----- 27*4882a593Smuzhiyun 28*4882a593SmuzhiyunThis implementation can be started in U-Boot using the sdp command 29*4882a593Smuzhiyun(CONFIG_CMD_USB_SDP) or in SPL if Serial Downloader boot mode has been 30*4882a593Smuzhiyundetected (CONFIG_SPL_USB_SDP_SUPPORT). 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunA typical use case is downloading full U-Boot after SPL has been 33*4882a593Smuzhiyundownloaded through the boot ROM's Serial Downloader. Using boot mode 34*4882a593Smuzhiyundetection the SPL will run the SDP implementation automatically in 35*4882a593Smuzhiyunthis case: 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun # imx_usb SPL 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunTargets Serial Console: 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun Trying to boot from USB SDP 42*4882a593Smuzhiyun SDP: initialize... 43*4882a593Smuzhiyun SDP: handle requests... 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunAt this point the SPL reenumerated as a new HID device and emulating 46*4882a593Smuzhiyunthe boot ROM's SDP protocol. The USB VID/PID will depend on standard 47*4882a593SmuzhiyunU-Boot configurations CONFIG_G_DNL_(VENDOR|PRODUCT)_NUM. Make sure 48*4882a593Smuzhiyunimx_usb is aware of the USB VID/PID for your device by adding a 49*4882a593Smuzhiyunconfiguration entry in imx_usb.conf: 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun 0x1b67:0x4fff, mx6_usb_sdp_spl.conf 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunAnd the device specific configuration file mx6_usb_sdp_spl.conf: 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun mx6_spl_sdp 56*4882a593Smuzhiyun hid,uboot_header,1024,0x910000,0x10000000,1G,0x00900000,0x40000 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunThis allows to download the regular U-Boot with legacy image headers 59*4882a593Smuzhiyun(u-boot.img) using a second invocation of imx_usb: 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun # imx_usb u-boot.img 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunFurthermore, when U-Boot is running the sdp command can be used to 64*4882a593Smuzhiyundownload and run scripts: 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun # imx_usb script.scr 67*4882a593Smuzhiyun 68*4882a593Smuzhiyunimx_usb configuration files can be also used to download multiple 69*4882a593Smuzhiyunfiles and of arbitrary types, e.g. 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun mx6_usb_sdp_uboot 72*4882a593Smuzhiyun hid,1024,0x10000000,1G,0x00907000,0x31000 73*4882a593Smuzhiyun full.itb:load 0x12100000 74*4882a593Smuzhiyun boot.scr:load 0x12000000,jump 0x12000000 75*4882a593Smuzhiyun 76*4882a593SmuzhiyunThere is also a batch mode which allows imx_usb to handle multiple 77*4882a593Smuzhiyunconsecutive reenumerations by adding multiple VID/PID specifications 78*4882a593Smuzhiyunin imx_usb.conf: 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun 0x15a2:0x0061, mx6_usb_rom.conf, 0x1b67:0x4fff, mx6_usb_sdp_spl.conf 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunIn this mode the file to download (imx_usb job) needs to be specified 83*4882a593Smuzhiyunin the configuration files. 84*4882a593Smuzhiyun 85*4882a593Smuzhiyunmx6_usb_rom.conf: 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun mx6_qsb 88*4882a593Smuzhiyun hid,1024,0x910000,0x10000000,1G,0x00900000,0x40000 89*4882a593Smuzhiyun SPL:jump header2 90*4882a593Smuzhiyun 91*4882a593Smuzhiyunmx6_usb_sdp_spl.conf: 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun mx6_spl_sdp 94*4882a593Smuzhiyun hid,uboot_header,1024,0x10000000,1G,0x00907000,0x31000 95*4882a593Smuzhiyun u-boot.img:jump header2 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunWith that SPL and U-Boot can be downloaded with a single invocation 98*4882a593Smuzhiyunof imx_usb without arguments: 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun # imx_usb 101