[efi] Disconnect USB gadget on fastboot stop

gbl_efi_fastboot_transport.c:stop() previously ran `usb reset` after
g_dnl_unregister(), resetting and scanning XHCI host ports (~3.2 s) on
every exit from GBL fastboot because dwc_pcd_ops omitted .pullup and
usb_gadget_unregister_driver() skipped driver->disconnect(). In
addition, start() overwrote out_req->buf with rx_buffer_a without
restoring the original buffer before unbind, which would free
rx_buffer_a inside fastboot_disable() once disconnect() runs.

Wire f_dwc_otg_pullup() into dwc_pcd_ops.pullup, keep DCTL.sftdiscon
asserted during f_dwc_core_init(), and initialize the PCD before
driver->bind() so usb_gadget_connect() enables pull-up only after the
PHY and DWC2 core are ready. In usb_gadget_unregister_driver(), call
usb_gadget_disconnect() and driver->disconnect() before unbind(). In
stop(), dequeue and restore out_req->buf before g_dnl_unregister() and
drop `usb reset`.

Test: Built kvim3_zircon, flashed VIM3, and verified fastboot continue
      and fastboot boot trigger immediate host USB disconnect (~1 ms),
      cut stop() from 3.18 s to 8 ms, and boot Fuchsia cleanly.
Change-Id: I979c1dbb8fbe619429bf208c1ded7e0847f1f1a9
Reviewed-on: https://turquoise-internal-review.googlesource.com/c/third_party/u-boot/+/1855781
Lint: android-build-ayeaye@system.gserviceaccount.com <android-build-ayeaye@system.gserviceaccount.com>
Commit-Queue: Dov Shlachter <dovs@google.com>
Reviewed-by: David Pursell <dpursell@google.com>
GitOrigin-RevId: b960472dbe7246c34bf0e6734b2436162912068c
2 files changed
tree: 82553bc0a0993626bbe2530c3607fb9d0bc20827
  1. api/
  2. arch/
  3. bl2/
  4. bl30/
  5. bl31/
  6. bl31_1.3/
  7. board/
  8. common/
  9. configs/
  10. disk/
  11. doc/
  12. drivers/
  13. dts/
  14. examples/
  15. fip/
  16. fs/
  17. include/
  18. lib/
  19. Licenses/
  20. net/
  21. post/
  22. scripts/
  23. test/
  24. tools/
  25. vim3_aml_tools/
  26. .checkpatch.conf
  27. .clang-format
  28. .gitignore
  29. .mailmap
  30. amlogic_help.sh
  31. check_compile.sh
  32. config.mk
  33. fuchsia_build.py
  34. fuchsia_upload.py
  35. Kbuild
  36. Kconfig
  37. MAINTAINERS
  38. MAKEALL
  39. Makefile
  40. mk
  41. README
  42. README.md
  43. snapshot.commit
README.md

This is a version of u-boot, modified to support Fuchsia on the Khadas vim3

Building vim3 Bootloader for Fuchsia

To build the vim3 bootloader for Fuchsia:

CIPD access. All build tools are downloaded to cipd_deps.

Run the build script from repo root

./fuchsia_build.py

Options:

  • --clean-cipd option can be used to make sure CIPD checkout is clean. It will remove cipd_deps directory and download dependencies again.
  • --gbl-path <path> option specifies a path to a local GBL (gbl.efi) binary. If provided, CIPD GBL is not used; otherwise, the script downloads GBL from CIPD and uses gbl_aarch64_dev.efi.

You now have a build/u-boot.bin.unsigned that you can flash to a target using fastboot.

Releasing and Uploading

go/fuchsia-firmware-licensing-publishing