Using SDCard in SPI mode & spi_master at the same time

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Using SDCard in SPI mode & spi_master at the same time

Postby loboris » Sat Dec 02, 2017 5:43 pm

It looks like spi_master and sd card in spi mode (sdpi_host) cannot be used at the same time.

I've tested combining the spi master example and sd card example and I cannot get both working.
Test configuration:
  • SDcard and display use the different pins for spi interface.
  • Display uses HSPI_HOST and DMA channel 1.
  • SDCard uses VSPI_HOST an DMA channel 2.
Depending on which one is accessed first, either sdcard or display does not work.

________________________

When the sdcard is mounted first, sd card is detected, card info is correct, file can be opened, read, written...
Then the display is initialized.
After that, trying to open the file fails with:

Code: Select all

E (2800) sdspi_host: sdspi_host_start_command: cmd=24 error=0x107
D (2800) sdmmc_cmd: sdmmc_req_run returned 0x107
E (2800) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x107
E (2810) diskio_sdmmc: sdmmc_write_blocks failed (263)
Display work with no problem.

________________________

When the display is intialized first, after the initialization the first display test works as expected, display is initialized and the pattern drawn.
Then the sdcard is mounted and works as expected, card info is correct, file can be opened, read, written...
After the sdcard intialization the display no longer works.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Using SDCard in SPI mode & spi_master at the same time

Postby loboris » Mon Dec 18, 2017 8:59 am

Is there anything that can be done about this issue?
It is not very useful to have SD Card SPI mode driver if we cannot use the SPI peripheral for other tasks at the same time.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Using SDCard in SPI mode & spi_master at the same time

Postby loboris » Fri Jan 05, 2018 5:14 pm

It is more than two months since I've posted this question/issue and still no response.

I would expect fom someone from Espressif team to at least give an opinion is it that I'm doing something wrong, or is there a real bug in esp-idf.

Thank you.

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: Using SDCard in SPI mode & spi_master at the same time

Postby ESP_Sprite » Fri Jan 05, 2018 8:38 pm

Sorry, it's pretty hard to say from your post, especially if you don't give any code. Also, if you think this is a bug, you're better off posting it on the esp-idf Github as an issue; unlike posts here on the forum which may fall in the gaps between responsibilities of various engineers, we track the issues there.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Using SDCard in SPI mode & spi_master at the same time

Postby loboris » Fri Jan 05, 2018 9:25 pm

ESP_Sprite wrote:Sorry, it's pretty hard to say from your post, especially if you don't give any code. Also, if you think this is a bug, you're better off posting it on the esp-idf Github as an issue; unlike posts here on the forum which may fall in the gaps between responsibilities of various engineers, we track the issues there.
I've posted on GitHub (TW#16816) on Dec 1., got simple response "Okay, we'll check this."

I'm always using the SD mode for SDCard access, so it is not much of a problem for me.
As the SDCard in SPI mode is officially supported in esp-idf, it should work with spi-master.
I've reported the issue, I've just wanted the confirmation that I'm doing something wrong. Obviously, no one ever tested SDCard in SPI mode & spi_master at the same time.
I've tested combining the spi-master example and sd card example, quite a simple test, I dont think it is necessary to provide any code.

ESP_Sprite
Posts: 9040
Joined: Thu Nov 26, 2015 4:08 am

Re: Using SDCard in SPI mode & spi_master at the same time

Postby ESP_Sprite » Fri Jan 05, 2018 10:14 pm

Hmm, I do agree that we could've picked this up a bit quicker. I'll see if I can poke a colleague to look at this. Still, if you can, I would appreciate it if you could whittle your code down to the smallest size that still fails for you and attach that to the issue; that way, if you indeed are doing something wrong, we can easily spot it; if the flaw is on our side, we at least have something that can reproduce this.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: Using SDCard in SPI mode & spi_master at the same time

Postby loboris » Fri Jan 05, 2018 10:38 pm

Ok, I'll try to prepare the simple example for ESP-WROVER-KIT, it has both sdcard interface and spi display for spi-master test.
Thanks.

Who is online

Users browsing this forum: No registered users and 145 guests