[mmc] Fix async eMMC multi-descriptor chain and sticky error state

In aml_sd_rw_async(), continuation descriptors (i > 0) previously left
no_cmd = 0 and cmd_index = CMD18/CMD25, causing the Amlogic SD/eMMC DMA
engine to transmit an illegal CMD18/CMD25 on the CMD line every 256
blocks while the eMMC card was already streaming in 'data'/'rcv' state.
While Samsung eMMC on VIM3 V12 ignored the mid-transfer command on
DAT[7:0] and only latched JEDEC R1_ILLEGAL_COMMAND in Card Status,
FORESEE eMMC on VIM3 V15 aborts its data stream (rxd_err = 0xff,
status=0x1ff20ff), causing GBL to panic with UnificationError(DeviceError).

Additionally, once an async I/O failed, aml_priv->io_info.error remained
latched after pending became false, causing subsequent synchronous MMC
commands (such as reading durable_boot ABR metadata during UEFI
ResetSystem()) to fail with 'Async IO err'.

Fix both issues:
- Set no_cmd = 1 and no_resp = 1 on continuation descriptors (i > 0),
  expect R1 on i == 0 (no_resp = 0, resp_num = 1), and configure a
  per-descriptor hardware timeout (0xc = 4096 ms).
- Flush desc_buf before DMA and re-invalidate the read data buffer after
  DMA completion.
- Check JEDEC R1 data error bits (MMC_R1_DATA_ERR_MASK) on CMD12's R1b
  response so card-side protocol/ECC errors are caught across all eMMC
  vendors.
- Make aml_sd_sync() a no-op when no async I/O is pending, consume
  io_info.error once in aml_sd_poll_io(), and restore MMC_HWPART_USER /
  reset disk->status in efi_aml_sd_emmc.c error and reset paths.

Bug: 584803959
Test: Built with ./fuchsia_build.py; reproduced R1_ILLEGAL_COMMAND +
      ResetSystem() failure on VIM3 and verified cold boot, 4-blk/desc
      (12,934-descriptor) stress boot, GBL fastboot flash, and post-error
      ResetSystem() ABR read.
Change-Id: I8baa931ed5f971012ad30fdf577d05f089814283
Reviewed-on: https://turquoise-internal-review.googlesource.com/c/third_party/u-boot/+/1823613
Commit-Queue: Yecheng Zhao <zyecheng@google.com>
Reviewed-by: Sergii Parubochyi <sergiip@google.com>
Lint: android-build-ayeaye@system.gserviceaccount.com <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-by: David Pursell <dpursell@google.com>
GitOrigin-RevId: 4e6cc1558377579a3fc519f5c1bccf75ec340ea3
3 files changed
tree: 279a868b3a216c2b185e7cc225fee9f82d6f0af9
  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