emard / ulx3s

PCB for ULX3S FPGA R&D board
Other
372 stars 62 forks source link

Example code of using SD card in SDIO mode #16

Open troibe opened 3 years ago

troibe commented 3 years ago

I got SPI mode to work in Litex but had no luck with SDIO mode. Is that supported? If yes do you have some sample code for it?

emard commented 3 years ago

If you want to use 4-bit mode then all sd_d[3:0] lines need to have pullups enabled from SD card side.

If you are using 1-bit (SPI) mode probably the best is to explicitely drive 1 unused bits sd_d[2:1] = 2'b11

On 6/12/21, developandplay @.***> wrote:

I got SPI mode to work in Litex but had no luck with SDIO mode. Is that supported? If yes do you have some sample code for it?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/emard/ulx3s/issues/16

emard commented 3 years ago

additional explaination

If you want to use 4-bit mode then all sd_d[3:0] lines need to have pullups enabled from FPGA constraints.

For pullups to be active, all sd_d lines must be used in the design (connected to some logic).

If any sd_d line is not connected anywhere the pullup will be also removed by router/optimizer.

On 6/12/21, D EMARD @.***> wrote:

If you want to use 4-bit mode then all sd_d[3:0] lines need to have pullups enabled from SD card side.

If you are using 1-bit (SPI) mode probably the best is to explicitely drive 1 unused bits sd_d[2:1] = 2'b11

On 6/12/21, developandplay @.***> wrote:

I got SPI mode to work in Litex but had no luck with SDIO mode. Is that supported? If yes do you have some sample code for it?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/emard/ulx3s/issues/16

emard commented 3 years ago

Similar holds for FLASH. If it is used in 1-bit mode, unused lines must be driven 1

pullup is not enough for flash, unused lines must be driven

  1. If unused lines are left floating. line crosstalk will happen and some FLASH chips will work, but some will be confused by crosstalk noise and will not work making FLASH boot not work for all users and boards.

On 6/13/21, D EMARD @.***> wrote:

additional explaination

If you want to use 4-bit mode then all sd_d[3:0] lines need to have pullups enabled from FPGA constraints.

For pullups to be active, all sd_d lines must be used in the design (connected to some logic).

If any sd_d line is not connected anywhere the pullup will be also removed by router/optimizer.

On 6/12/21, D EMARD @.***> wrote:

If you want to use 4-bit mode then all sd_d[3:0] lines need to have pullups enabled from SD card side.

If you are using 1-bit (SPI) mode probably the best is to explicitely drive 1 unused bits sd_d[2:1] = 2'b11

On 6/12/21, developandplay @.***> wrote:

I got SPI mode to work in Litex but had no luck with SDIO mode. Is that supported? If yes do you have some sample code for it?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/emard/ulx3s/issues/16

troibe commented 3 years ago

What does this comment mean?

IOBUF PORT "sd_d[2]" PULLMODE=NONE IO_TYPE=LVCMOS33 DRIVE=4; # WiFi GPIO12 pulldown bootstrapping without 3.3V efuse

emard commented 3 years ago

SD card is shared (connected together) with FPGA and ESP32.

sd_d[2] goes to esp32 wifi_gpio12

SD default is normally all pins pull up, but factory default ESP32 has internal pull down to wifi_gpio12 to boot properly, that's why FPGA sets pull to none to let esp32 boot. wifi_gpio12 controls the voltage (1.8V or 3.3V) esp32 will apply to its internal flash.

ESP32 efuse can be programmed to apply 3.3V and ignore wifi_gpio12 - that's described in the manual. efuse is one-time-programmable, setting can't be undone so users must be careful not to brick esp32

On 6/15/21, developandplay @.***> wrote:

What does this comment mean?

IOBUF PORT "sd_d[2]" PULLMODE=NONE IO_TYPE=LVCMOS33 DRIVE=4; # WiFi GPIO12 pulldown bootstrapping without 3.3V efuse

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/emard/ulx3s/issues/16#issuecomment-861790322

troibe commented 3 years ago

Just to make sure I understand correctly: So my ulx3s is currently still in factory default mode. If I just want to use the SD card with the FPGA I don't need to set the efuse right?

goran-mahovlic commented 3 years ago

If you have board from CrowdSupply - then efuse is already set (burned) to 3.3V as this is done in the selftest script before delivery

troibe commented 3 years ago

I got mine on Mouser and the ESP32-WROOM-32 is used if that makes a difference...

emard commented 3 years ago

You can see if 3.3V efuse is already set when esptool.py programs the esp32 it will show "VRef calibration in efuse",

Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None

that means that gpio12 is free to be used regardless of its powern on pull up/down state.

Usualy problem is that some SD cards do internal pull ups and prevent esp32 from booting or programming when SD is inserted.

to prevent user's problems intergalaktik burns efuse to correct state before shipment

On 6/16/21, developandplay @.***> wrote:

I got mine on Mouser and the ESP32-WROOM-32 is used if that makes a difference...

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/emard/ulx3s/issues/16#issuecomment-862118790