How to make SD card (in SPI Mode) working with other SPI Devices

User avatar
Gfast2
Posts: 174
Joined: Fri Aug 11, 2017 1:52 am

How to make SD card (in SPI Mode) working with other SPI Devices

Postby Gfast2 » Sat Apr 13, 2019 6:15 am

Hello ESP-IDF,

Recently I decide to make a "gps camera" for myself. It has many parts. but its core is simple:
I read GPS Sentence from UART, If I push that button, I write this info into SD card.

But the problem is, I would like to use a Nokia 5510 Display for some information display. It would share the same SPI bus with SD card. And I believe it shouldn't impossible, because the beauty of SPI / I²C bus is in such cases. ;)

Automagic function "esp_vfs_fat_sdmmc_mount" would help me do the "spi_bus_initialize". But the same thing has been done by my Display driver too. I've tried to comment out the spi_bus_initialize behavier from function "sdspi_host_init_slot" which that automagic function leveradged for SD card initialization. but I still got panic.

The Trace is as follow:

Code: Select all

W (977) Display: Display init task ended
W (977) Display: task 'task_display_info'started
I (977) SD_CARD: Initializing SD card
I (977) SD_CARD: Using SPI peripheral
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x40084065  PS      : 0x00060031  A0      : 0x40082238  A1      : 0x3ffb0c60  
0x40084065: spi_intr at /home/gfast2/esp/esp-idf/components/driver/spi_master.c:764 (discriminator 1)

0x40082238: _xt_lowint1 at /home/gfast2/esp/esp-idf/components/freertos/xtensa_vectors.S:1154

A2      : 0x3ffb3ba4  A3      : 0x00000001  A4      : 0x00000000  A5      : 0x40089968  
0x40089968: _frxt_int_enter at /home/gfast2/esp/esp-idf/components/freertos/portasm.S:119

A6      : 0x0000759b  A7      : 0x00000000  A8      : 0x00000001  A9      : 0x3ffb0c40  
A10     : 0x00000000  A11     : 0x3ffb3bb8  A12     : 0x3ffb0c60  A13     : 0x3ffb3cc0  
A14     : 0x00060021  A15     : 0x00060021  SAR     : 0x00000017  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000005  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  
Core 1 was running in ISR context:
EPC1    : 0x40084065  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x00000000
0x40084065: spi_intr at /home/gfast2/esp/esp-idf/components/driver/spi_master.c:764 (discriminator 1)


ELF file SHA256: 5a8f59436ee9a81aa30e720e06bffed131da23ba2079517ba184d8e3f13153e9

Backtrace: 0x40084065:0x3ffb0c60 0x40082235:0x3ffb0c90 0x400e60de:0x3ffb9500 0x400e6347:0x3ffb9540 0x400e89d6:0x3ffb9590 0x400e934e:0x3ffb95e0 0x400eb31d:0x3ffb9620 0x400d31fd:0x3ffb9670 0x40087cf9:0x3ffb9770
0x40084065: spi_intr at /home/gfast2/esp/esp-idf/components/driver/spi_master.c:764 (discriminator 1)

0x40082235: _xt_lowint1 at /home/gfast2/esp/esp-idf/components/freertos/xtensa_vectors.S:1154

0x400e60de: spi_cal_clock at /home/gfast2/esp/esp-idf/components/driver/spi_master.c:566

0x400e6347: spi_bus_add_device at /home/gfast2/esp/esp-idf/components/driver/spi_master.c:449 (discriminator 4)

0x400e89d6: init_spi_dev at /home/gfast2/esp/esp-idf/components/driver/sdspi_host.c:220

0x400e934e: sdspi_host_init_slot at /home/gfast2/esp/esp-idf/components/driver/sdspi_host.c:287

0x400eb31d: esp_vfs_fat_sdmmc_mount at /home/gfast2/esp/esp-idf/components/fatfs/src/vfs_fat_sdmmc.c:73

0x400d31fd: sd_card_task(void*) at /home/gfast2/workspace/gpsrecorder/main/sd_card.cpp:93

0x40087cf9: vPortTaskWrapper at /home/gfast2/esp/esp-idf/components/freertos/port.c:403


CPU halted.


I'm very happy with the truth that I can tell you the source code. It's here ;)

A Off-Topic Question:
From SPI [url=https://docs.espressif.com/projects/esp ... aster.html]Master driver Documentation[url] I found this Note:
Half duplex transactions with both read and write phases are not supported when using DMA. See Known Issues for details and workarounds.
Should I watch out this for my application? At least in my trial I can't init SPI Bus correctlly when I try to use DMA when calling "spi_bus_initialize()" (-> '0' has to be set as the value of the last parameter)

Cheers

Gfast2
Attachments
20190413_075130.jpg
20190413_075130.jpg (3.61 MiB) Viewed 133 times


User avatar
Gfast2
Posts: 174
Joined: Fri Aug 11, 2017 1:52 am

Re: How to make SD card (in SPI Mode) working with other SPI Devices

Postby Gfast2 » Sat Apr 13, 2019 4:05 pm

Hi WiFive,

Thank you very much for the Quick reply. I will checkout the possible solution for my setup and may be post a nice little video if both of them works properly.

Cheers

Gfast2

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 16 guests