I followed this link and successfully download riscv firmware to duos:
But I could not do this with the v2 sdk:
After spending sometime to debug the code, I found the USB in arm u-boot version could not work properly. The problem occurs in cvi_ep0_setup->cvi_fifo_read.
Here is the correct version in riscv:
start usb task!
cvi_usb_hw_init[23]: val 0xfffff7fc
cvi_usb_hw_init[29]: val 0xfffffffc
cvi_usb_hw_init[34]: val 0x3c1
cvi_usb_hw_init[42]: cvi_usb_hw_init
acm_app[1394]: waiting for connection …
acm_app[1401]: detect vbus …
print_buf_addr[181]: bulkBufAlloc: 000000009427d980
print_buf_addr[182]: cmdBufAlloc: 0000000094280a40
print_buf_addr[183]: ep0BuffAlloc: 000000009427dbc0
print_buf_addr[184]: setup_buf: 000000009427dc40
print_buf_addr[185]: handler: 0000000094280c80
print_buf_addr[186]: cb0_buf: 000000009427dc90
print_buf_addr[187]: cb1_buf: 0000000094281090
print_buf_addr[188]: cb2_buf: 0000000094281120
print_buf_addr[189]: rsp_buf: 000000009427d930
print_buf_addr[190]: acm_buf: 00000000942811b0
plat_cvi_gpio_read[1344]: Overwrite fip_src to FIP_SRC_USB
acm_app[1408]: fip_src 6
udc_reinit: 0000000094280c80
cviusb_gadget_register_driver: no name
bind[922]: bind()
Registered gadget driver cvi-udc
udc_enable: 0000000094280c80
udc_reinit: 0000000094280c80
cvi_udc_pre_setup : Prepare Setup packets.
cvi_udc_pre_setup:EP0 ZLP DIEPCTL0 = 0x8000
cvi_udc_pre_setup:EP0 ZLP DOEPCTL0 = 0x80008000
CVI USB 2.0 OTG Controller Core Initialized : 0x800c3800
requestMemAlloc[346]: requestMemAlloc: ptr 000000009427dc90, size 88, mem_alloc_cnt 0
acm_app[1438]: Initializing OK! 1438
acm_app[1441]: ts: 0
*** cvi_udc_irq : GINTSTS=0x4008c20(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x0, DAINTMSK : 0x10001
Early suspend interrupt
Suspend interrupt :(DSTS):0x400003
*** cvi_udc_irq : GINTSTS=0x4809020(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x0, DAINTMSK : 0x10001
Reset interrupt - (GOTGCTL):0xd0000
OTG core got reset!!
*** cvi_udc_irq : GINTSTS=0x400a028(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x0, DAINTMSK : 0x10001
Speed Detection interrupt
High Speed Detection : 0x0
*** cvi_udc_irq : GINTSTS=0x4088028(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x10000, DAINTMSK : 0x10001
*** process_ep_out_intr: EP OUT interrupt : DAINT = 0x10000
EP0-OUT : DOEPINT = 0x8009
SETUP packet arrived
cvi_handle_ep0: WAIT_FOR_SETUP
cvi_fifo_read: bytes=8, ep_index=0 0x000000009427dc40
cvi_ep0_setup: bmRequestType = 0x80(IN), bRequest = 0x6, wLength = 0x12, wValue = 0x100, wIndex= 0x0
cvi_ep0_setup: *** USB_REQ_GET_DESCRIPTOR
cvi_ep0_setup:usb_ctrlreq will be passed to fsg_setup()
And here is the version in arm64:
Start USB downloading…
start usb task!
cvi_usb_hw_init[22]: val 0xfffff7fc
cvi_usb_hw_init[26]: val 0xfffffffc
cvi_usb_hw_init[31]: val 0x3c1
cvi_usb_hw_init[39]: cvi_usb_hw_init
acm_app[1394]: waiting for connection …
acm_app[1401]: detect vbus …
print_buf_addr[181]: bulkBufAlloc: 0000000094267640
print_buf_addr[182]: cmdBufAlloc: 000000009426a780
print_buf_addr[183]: ep0BuffAlloc: 0000000094267880
print_buf_addr[184]: setup_buf: 0000000094267900
print_buf_addr[185]: handler: 000000009426a9c0
print_buf_addr[186]: cb0_buf: 0000000094267950
print_buf_addr[187]: cb1_buf: 00000000942679e0
print_buf_addr[188]: cb2_buf: 000000009426add0
print_buf_addr[189]: rsp_buf: 000000009426a730
print_buf_addr[190]: acm_buf: 000000009426ae60
plat_cvi_gpio_read[1344]: Overwrite fip_src to FIP_SRC_USB
acm_app[1408]: fip_src 6
udc_reinit: 000000009426a9c0
cviusb_gadget_register_driver: no name
bind[922]: bind()
Registered gadget driver cvi-udc
udc_enable: 000000009426a9c0
udc_reinit: 000000009426a9c0
cvi_udc_pre_setup : Prepare Setup packets.
cvi_udc_pre_setup:EP0 ZLP DIEPCTL0 = 0x8000
cvi_udc_pre_setup:EP0 ZLP DOEPCTL0 = 0x80008000
CVI USB 2.0 OTG Controller Core Initialized : 0x800c3800
requestMemAlloc[347]: requestMemAlloc: ptr 0000000094267950, size 88, mem_alloc_cnt 0
acm_app[1438]: Initializing OK! 1438
acm_app[1441]: ts: 0
*** cvi_udc_irq : GINTSTS=0x4008c20(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x0, DAINTMSK : 0x10001
Early suspend interrupt
Suspend interrupt :(DSTS):0x400003
*** cvi_udc_irq : GINTSTS=0x4809020(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x0, DAINTMSK : 0x10001
Reset interrupt - (GOTGCTL):0xd0000
OTG core got reset!!
*** cvi_udc_irq : GINTSTS=0x400a028(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x0, DAINTMSK : 0x10001
Speed Detection interrupt
High Speed Detection : 0x0
*** cvi_udc_irq : GINTSTS=0x4088028(on state WAIT_FOR_SETUP), GINTMSK : 0x800c3800,DAINT : 0x10000, DAINTMSK : 0x10001
*** process_ep_out_intr: EP OUT interrupt : DAINT = 0x10000
EP0-OUT : DOEPINT = 0x8009
SETUP packet arrived
cvi_handle_ep0: WAIT_FOR_SETUP
cvi_fifo_read: bytes=8, ep_index=0 0x0000000094267900
cvi_ep0_setup: bmRequestType = 0x0(OUT), bRequest = 0x0, wLength = 0x0, wValue = 0x0, wIndex= 0x0
cvi_udc_get_status: *** USB_REQ_GET_STATUS
Could anyone fix this?