Issues when using SPI SD card

jjamjohnson
Posts: 9
Joined: Thu Nov 12, 2020 10:48 pm

Issues when using SPI SD card

Postby jjamjohnson » Thu Nov 12, 2020 11:31 pm

Hello, I am trying to setup SD CARD on ESP32 DevKit V1 board using esp-idf for some time but without success.

When I use Arduino IDE, the card works without issues (SD_Test example sketch).

When using esp-idf example sd_card, i get the following error message:

Code: Select all

I (347) example: Initializing SD card
I (347) example: Using SPI peripheral
I (357) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (407) sdspi_transaction: cmd=5, R1 response: command not supported
E (427) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
E (427) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).
I (427) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
E (437) example: Failed to initialize the card (ESP_ERR_TIMEOUT). Make sure SD card lines have pull-up resistors in place.
I have set the define:

Code: Select all

USE_SPI_MODE
and configured pins as following.

Code: Select all

#define PIN_NUM_MISO 19
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK  18
#define PIN_NUM_CS   5
Can someone help me out with this please?

This image shows how I connected the shield:
20201113_000600.jpg
Setup image (1)
20201113_000600.jpg (2.37 MiB) Viewed 15903 times
20201113_000327.jpg
Setup image (2)
20201113_000327.jpg (2.02 MiB) Viewed 15903 times

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Issues when using SPI SD card

Postby PeterR » Fri Nov 13, 2020 4:49 pm

Try a really, really slow SPI speed. Like 1MHz. This will help show that the issue is not hardware.
& I also believe that IDF CAN should be fixed.

chegewara
Posts: 2174
Joined: Wed Jun 14, 2017 9:00 pm

Re: Issues when using SPI SD card

Postby chegewara » Fri Nov 13, 2020 7:27 pm

This is 5V SD card adapter.

jjamjohnson
Posts: 9
Joined: Thu Nov 12, 2020 10:48 pm

Re: Issues when using SPI SD card

Postby jjamjohnson » Sat Nov 14, 2020 9:08 pm

PeterR wrote:
Fri Nov 13, 2020 4:49 pm
Try a really, really slow SPI speed. Like 1MHz. This will help show that the issue is not hardware.
Thanks! Once I decreased frequency it started working. I get max write speed (1024 to 4096 bytes chunks) at 41KBps. This seams low, any hints on how to improve?
chegewara wrote:
Fri Nov 13, 2020 7:27 pm
This is 5V SD card adapter.
It seams that this is not the issue.
Last edited by jjamjohnson on Sun Nov 15, 2020 11:49 pm, edited 1 time in total.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Issues when using SPI SD card

Postby PeterR » Sat Nov 14, 2020 10:23 pm

This is 5V SD card adapter.
lol, that would do it!
He says that this works under arduino. Why do you think that the switch of OS helps/hinders? Random life stuff?
& I also believe that IDF CAN should be fixed.

jjamjohnson
Posts: 9
Joined: Thu Nov 12, 2020 10:48 pm

Re: Issues when using SPI SD card

Postby jjamjohnson » Wed Dec 09, 2020 12:11 am

jjamjohnson wrote:
Sat Nov 14, 2020 9:08 pm
PeterR wrote:
Fri Nov 13, 2020 4:49 pm
Try a really, really slow SPI speed. Like 1MHz. This will help show that the issue is not hardware.
Thanks! Once I decreased frequency it started working. I get max write speed (1024 to 4096 bytes chunks) at 41KBps. This seams low, any hints on how to improve?
chegewara wrote:
Fri Nov 13, 2020 7:27 pm
This is 5V SD card adapter.
It seams that this is not the issue.
I have an issue with robustness of this solution to sometimes fail mounting or writing to the card. I solved this by reducing as much as possible wires between esp32 and SD module and so far have not experienced issues.

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Issues when using SPI SD card

Postby PeterR » Wed Dec 09, 2020 12:48 am

Tell me that you have checked the 3V / 5V comment?
That's an easy datasheet check.
You can get voltage level issues to 'work' when reducing MHz but you don't/should not use empirical results ahead of something as simple as a datasheet check (I'm not doing that check for you).
41Kbps is stupidly slow.
I have run SD on ESP at 4MHz using dupont held on with sticky tape & positive thinking ...
& I also believe that IDF CAN should be fixed.

jjamjohnson
Posts: 9
Joined: Thu Nov 12, 2020 10:48 pm

Re: Issues when using SPI SD card

Postby jjamjohnson » Thu Dec 10, 2020 8:48 pm

PeterR wrote:
Wed Dec 09, 2020 12:48 am
Tell me that you have checked the 3V / 5V comment?
That's an easy datasheet check.
You can get voltage level issues to 'work' when reducing MHz but you don't/should not use empirical results ahead of something as simple as a datasheet check (I'm not doing that check for you).
41Kbps is stupidly slow.
I have run SD on ESP at 4MHz using dupont held on with sticky tape & positive thinking ...
I did check and I am not sure - http://datalogger.pbworks.com/w/file/fe ... asheet.pdf:

Code: Select all

Power supply is 4.5V ~ 5.5V, 3.3V voltage regulator circuit board

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: Issues when using SPI SD card

Postby PeterR » Wed Dec 23, 2020 4:32 pm

Well the datasheet says that it has a level convertor but does not show you how to use 3.3V.
I would hunt for a tutorial.

If you run 5V into an ESP pin then the ESP won't love you for long.
& I also believe that IDF CAN should be fixed.

chegewara
Posts: 2174
Joined: Wed Jun 14, 2017 9:00 pm

Re: Issues when using SPI SD card

Postby chegewara » Sat Dec 26, 2020 3:28 pm

The reason i mentioned about 5V for this sd card module is because i am using exactly the same module and it was the issue i had with it. I found the same answer on arduino-esp32 github. Im not saying it is/was the issue in your case, but i thought its worth to mention.
This module is using AMS1117 which characteristics says that Vin >= Vout + 1,5V.

Who is online

Users browsing this forum: Bing [Bot] and 82 guests