Skip to content

anyka: EV200: SD card on the gwell camera (GPIO 34, SPI pad function) - #47

Merged
dimerr merged 1 commit into
openipc-anykafrom
anyka/ev200-sd
Oct 21, 2026
Merged

dimerr merged 1 commit into
openipc-anykafrom
anyka/ev200-sd

Conversation

@dimerr

@dimerr dimerr commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

The SD card on a gwell AK3918EV200 camera never answered in U-Boot (Card did not respond to voltage select! : -110). Every response came back all zeros with RESPEND set, i.e. CMD held low, while Linux on the same board read the card.

I set the registers Linux leaves (from devmem) in U-Boot one at a time on the camera. The card answers only with both of these:

  • GPIO 34 low, with its pad a GPIO. GPIO 34 is wifi_en in the EV200 reference board's DT, on the pad that is otherwise SD DAT1. The boot ROM leaves that pad's field (0x080000DC 11:10) at 11. The SD driver now muxes the pad to GPIO and drives it low (EV200 only).
  • SPI0 pads 35/36 at function 2 (0xDC 13:12 = 10), as the EV200 DT's spiflash_pins and Linux set them, instead of the gwell vendor U-Boot's 0x3003 (11). ak_sflash now writes 0x2003 on EV200.

Tested on the camera: the card is found at boot with no manual writes, flash reads are stable, the kernel boots from flash, and reset works. In qemu-hisilicon (no pin model): SD and flash still work on ak3918ev200, and all six images build.

GPIO 34 comes from the reference design. An EV200 board that uses GPIO 34 for something else would need a different value.

On a gwell AK3918EV200 camera the SD card never answered in U-Boot
("Card did not respond to voltage select! : -110"; every response all
zeros with RESPEND set, i.e. CMD held low), while Linux read it. Setting
the registers Linux leaves (devmem) in U-Boot one by one, the card
answers only with both of these:

- GPIO 34 low, its pad a GPIO. GPIO 34 is wifi_en in the EV200 reference
  board's device tree, on the pad that is otherwise SD DAT1, and Linux
  drives it low. The boot ROM leaves that pad's field (0x080000DC 11:10)
  at 11. The SD driver now muxes the pad to GPIO and drives it low.
- SPI0's pads 35/36 at function 2 (0x080000DC 13:12 = 10), as the EV200
  device tree's spiflash_pins and Linux set them, not the 11 of the gwell
  vendor U-Boot's 0x3003. ak_sflash now writes 0x2003 there on the EV200.

On the camera: the card is found at boot with no manual writes, flash
reads stay stable and the kernel boots from flash, reset works. Under
qemu-hisilicon (no pin model): SD and flash still work on ak3918ev200,
and all six images build.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

anyka: Restore SD card responses on the gwell AK3918EV200

🐞 Bug fix 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Drive EV200 GPIO 34 low so the gwell camera’s SD card can respond.
Diagram

graph TD
  Flash["SPI flash probe"] --> SPI["SPI pad function"] --> Mux["Shared pin mux"] --> Card(["SD card"])
  MMC["MMC host init"] --> GPIO["GPIO 34 low"] --> Card
  MMC --> Mux
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Make GPIO 34 board-specific
  • ➕ Avoids driving a pin that another EV200 board may use differently.
  • ➖ Requires board-level configuration plumbing for a currently fixed, non-DM MMC driver.

Recommendation: The driver-local, EV200-gated changes are appropriate for the tested camera and preserve EV300/EV330 behavior. GPIO 34 is a reference-board assumption, however; make that pin board-configurable if additional EV200 boards with different wiring are supported.

Files changed (3) +37 / -8

Bug fix (2) +28 / -6
ak_mmc.cMux EV200 pad 34 to GPIO and drive it low +17/-1

Mux EV200 pad 34 to GPIO and drive it low

• MMC host initialization clears pad 34’s function field, then configures GPIO 34 as a low output. The behavior is limited to EV200 builds and also applies when the host is reinitialized.

drivers/mmc/ak_mmc.c

ak_sflash.cSelect EV200 SPI0 pad function 2 +11/-5

Select EV200 SPI0 pad function 2

• SPI flash initialization now clears and sets the EV200 pad field to 0x2003 instead of setting 0x3003. EV300 retains its existing set-only behavior, and EV330 remains unchanged.

drivers/mtd/spi/ak_sflash.c

Documentation (1) +9 / -2
CLAUDE.mdDocument the EV200 pin settings required for SD +9/-2

Document the EV200 pin settings required for SD

• Records the EV200 SPI pad function and GPIO 34 setting, including why the gwell camera needs both for SD responses.

CLAUDE.md

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@dimerr
dimerr merged commit ab3f8a3 into openipc-anyka Oct 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant