And again someone who has problems with esp32 and sd cards

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

Re: And again someone who has problems with esp32 and sd cards

Postby loboris » Tue Aug 01, 2017 1:10 pm

ESP_igrr wrote:
WiFive wrote:
loboris wrote:The only "problem" I've ever had was that some SDHC/SDXC cannot operate in 1-line mode (but they do operate in 4-line and SPI modes).
Isn't it a requirement of SD standard? Could be handshake problem?
That is super weird indeed, given that the card is intialized in 1-line mode first, and then it is switched into 4-line mode.
Here are the logs for SunDisk Ultra UHS-I 8GB tested on ESP-WROVER-KIT v3
1-line mode (Error):

Code: Select all

D (60126) sdmmc_periph: peripheral version 5342270a, hardware config 03c44c83
D (60126) sdmmc_periph: slot=1 div=50 freq=400kHz
D (60126) sdmmc_periph: slot=1 width=1
D (60136) sdmmc_cmd: sdmmc_card_init
V (60136) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0
V (60146) sdmmc_req: make_hw_cmd: opcode=0, rexp=0, crc=0
V (60146) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (60156) sdmmc_req: process_events: state=SENDING_CMD
V (60166) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (60166) sdmmc_req: process_events state=IDLE next_state=IDLE
V (60176) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (60206) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0
V (60206) sdmmc_req: make_hw_cmd: opcode=0, rexp=0, crc=0
V (60206) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (60206) sdmmc_req: process_events: state=SENDING_CMD
V (60216) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (60226) sdmmc_req: process_events state=IDLE next_state=IDLE
V (60226) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (60256) sdmmc_cmd: sending cmd slot=1 op=8 arg=1aa flags=1c30 data=0x0 blklen=0 datalen=0
V (60256) sdmmc_req: make_hw_cmd: opcode=8, rexp=1, crc=1
V (60256) sdmmc_req: sdmmc_handle_event: evt 00000100 00000000
V (60256) sdmmc_req: process_events: state=SENDING_CMD
D (60266) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (60276) sdmmc_req: process_command_response: error 0x107  (status=00000100)
V (60276) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (60286) sdmmc_req: process_events state=IDLE next_state=IDLE
V (60296) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x107 state=0
D (60296) sdmmc_cmd: CMD8 timeout; not an SDHC/SDXC card
V (60306) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
E (60316) sdmmc_req: handle_idle_state_events unhandled: 00000004 00000000
V (60326) sdmmc_req: make_hw_cmd: opcode=55, rexp=1, crc=1
V (60326) sdmmc_req: sdmmc_handle_event: evt 00000100 00000000
V (60336) sdmmc_req: process_events: state=SENDING_CMD
D (60336) sdmmc_req: process_command_response: error 0x107  (status=00000100)
D (60346) sdmmc_req: process_command_response: error 0x107  (status=00000100)
V (60356) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (60356) sdmmc_req: process_events state=IDLE next_state=IDLE
V (60366) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x107 state=0
E (60376) sdmmc_cmd: sdmmc_card_init: send_op_cond (1) returned 0x107
4-line mode (OK):

Code: Select all

D (37111) sdmmc_periph: peripheral version 5342270a, hardware config 03c44c83
D (37111) sdmmc_periph: slot=1 div=50 freq=400kHz
D (37111) sdmmc_periph: slot=1 width=1
D (37121) sdmmc_cmd: sdmmc_card_init
V (37121) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0
V (37131) sdmmc_req: make_hw_cmd: opcode=0, rexp=0, crc=0
V (37131) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (37141) sdmmc_req: process_events: state=SENDING_CMD
V (37151) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (37151) sdmmc_req: process_events state=IDLE next_state=IDLE
V (37161) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (37191) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0
V (37191) sdmmc_req: make_hw_cmd: opcode=0, rexp=0, crc=0
V (37191) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (37191) sdmmc_req: process_events: state=SENDING_CMD
V (37201) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (37211) sdmmc_req: process_events state=IDLE next_state=IDLE
V (37211) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (37241) sdmmc_cmd: sending cmd slot=1 op=8 arg=1aa flags=1c30 data=0x0 blklen=0 datalen=0
V (37241) sdmmc_req: make_hw_cmd: opcode=8, rexp=1, crc=1
V (37241) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (37241) sdmmc_req: process_events: state=SENDING_CMD
V (37251) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (37261) sdmmc_req: process_events state=IDLE next_state=IDLE
V (37261) sdmmc_cmd: cmd response 000001aa 00000000 00000000 00000000 err=0x0 state=0
D (37271) sdmmc_cmd: SDHC/SDXC card
V (37271) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (37281) sdmmc_req: make_hw_cmd: opcode=55, rexp=1, crc=1
V (37291) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (37291) sdmmc_req: process_events: state=SENDING_CMD
V (37301) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (37301) sdmmc_req: process_events state=IDLE next_state=IDLE
V (37311) sdmmc_cmd: cmd response 00000120 00000000 00000000 00000000 err=0x0 state=0
V (37321) sdmmc_cmd: sending cmd slot=1 op=41 arg=40ff8000 flags=1030 data=0x0 blklen=0 datalen=0
V (37331) sdmmc_req: make_hw_cmd: opcode=41, rexp=1, crc=0
V (37331) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (37341) sdmmc_req: process_events: state=SENDING_CMD
V (37341) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (37351) sdmmc_req: process_events state=IDLE next_state=IDLE
V (37361) sdmmc_cmd: cmd response 00ff8000 00000000 00000000 00000000 err=0x0 state=0
V (37371) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (37371) sdmmc_req: make_hw_cmd: opcode=55, rexp=1, crc=1
V (37381) sdmmc_req: sdmmc_handle_event: evt 00000004 00000000
V (37381) sdmmc_req: process_events: state=SENDING_CMD
V (37391) sdmmc_req: process_events state=SENDING_CMD next_state=IDLE
V (37401) sdmmc_req: process_events state=IDLE next_state=IDLE
V (37401) sdmmc_cmd: cmd response 00000120 00000000 00000000 00000000 err=0x0 state=0
SPI mode (OK):

Code: Select all

D (36117) sdspi_host: sdspi_host_init_slot: SPI2 miso=2 mosi=15 sck=14 cs=13 cd=-1 wp=-1, dma_ch=1
I (36117) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (36127) sdmmc_cmd: sdmmc_card_init
V (36127) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0
V (36137) sdspi_host: sdspi_host_start_command: slot=1, CMD0, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x4a
V (36147) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0xffffffff
V (36157) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (36187) sdmmc_cmd: sending cmd slot=1 op=0 arg=0 flags=20 data=0x0 blklen=0 datalen=0
V (36187) sdspi_host: sdspi_host_start_command: slot=1, CMD0, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x4a
V (36187) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36197) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36227) sdmmc_cmd: sending cmd slot=1 op=8 arg=1aa flags=1c30 data=0x0 blklen=0 datalen=0
V (36227) sdspi_host: sdspi_host_start_command: slot=1, CMD8, arg=0x000001aa flags=0x20, data=0x0, data_size=0 crc=0x43
V (36227) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xaa010000
V (36237) sdmmc_cmd: cmd response 000001aa 00000000 00000000 00000000 err=0x0 state=0
D (36247) sdmmc_cmd: SDHC/SDXC card
V (36247) sdmmc_cmd: sending cmd slot=1 op=59 arg=1 flags=1c00 data=0x0 blklen=0 datalen=0
V (36257) sdspi_host: sdspi_host_start_command: slot=1, CMD59, arg=0x00000001 flags=0x4, data=0x0, data_size=0 crc=0x41
D (36267) sdspi_host: data CRC set=1
V (36267) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36277) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36287) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (36297) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (36307) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36307) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36317) sdmmc_cmd: sending cmd slot=1 op=41 arg=40ff8000 flags=1030 data=0x0 blklen=0 datalen=0
V (36327) sdspi_host: sdspi_host_start_command: slot=1, CMD41, arg=0x40ff8000 flags=0x4, data=0x0, data_size=0 crc=0x0b
V (36337) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36347) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36357) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (36357) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (36367) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36377) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36387) sdmmc_cmd: sending cmd slot=1 op=41 arg=40ff8000 flags=1030 data=0x0 blklen=0 datalen=0
V (36397) sdspi_host: sdspi_host_start_command: slot=1, CMD41, arg=0x40ff8000 flags=0x4, data=0x0, data_size=0 crc=0x0b
V (36407) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36407) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36427) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (36427) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (36437) sdspi_transaction: r1 = 0x01 hw_cmd.r[0]=0xffffffff
V (36447) sdmmc_cmd: cmd response 00000001 00000000 00000000 00000000 err=0x0 state=0
V (36447) sdmmc_cmd: sending cmd slot=1 op=41 arg=40ff8000 flags=1030 data=0x0 blklen=0 datalen=0
V (36457) sdspi_host: sdspi_host_start_command: slot=1, CMD41, arg=0x40ff8000 flags=0x4, data=0x0, data_size=0 crc=0x0b
V (36467) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (36477) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (36487) sdmmc_cmd: sending cmd slot=1 op=58 arg=0 flags=1630 data=0x0 blklen=0 datalen=0
V (36487) sdspi_host: sdspi_host_start_command: slot=1, CMD58, arg=0x00000000 flags=0x10, data=0x0, data_size=0 crc=0x7e
V (36507) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0x0080ffc0
V (36507) sdmmc_cmd: cmd response c0ff8000 00000000 00000000 00000000 err=0x0 state=0
D (36517) sdmmc_cmd: host_ocr=0x40ff8000 card_ocr=0xc0ff8000
D (36527) sdmmc_cmd: sdmmc_card_init: host_ocr=40ff8000, card_ocr=c0ff8000
V (36527) sdmmc_cmd: sending cmd slot=1 op=10 arg=0 flags=50 data=0x3ffbb1b0 blklen=0 datalen=16
V (36537) sdspi_host: sdspi_host_start_command: slot=1, CMD10, arg=0x00000000 flags=0x5, data=0x3ffbb1b0, data_size=16 crc=0x0d
V (36547) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x03feff00
V (36557) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (36567) sdmmc_cmd: sending cmd slot=1 op=9 arg=0 flags=1c50 data=0x3ffbb1b0 blklen=0 datalen=16
V (36577) sdspi_host: sdspi_host_start_command: slot=1, CMD9, arg=0x00000000 flags=0x5, data=0x3ffbb1b0, data_size=16 crc=0x57
V (36587) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x40feff00
V (36587) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
V (36597) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (36607) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (36617) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (36627) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (36627) sdmmc_cmd: sending cmd slot=1 op=51 arg=0 flags=1c50 data=0x3fff0b28 blklen=8 datalen=8
V (36637) sdspi_host: sdspi_host_start_command: slot=1, CMD51, arg=0x00000000 flags=0x5, data=0x3fff0b28, data_size=8 crc=0x63
V (36647) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x01803502
V (36657) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
D (36667) sdmmc_cmd: switching to DS bus mode
D (36667) sdspi_host: Setting card clock to 20000 kHz
V (36677) sdmmc_cmd: sending cmd slot=1 op=55 arg=0 flags=1c00 data=0x0 blklen=0 datalen=0
V (36687) sdspi_host: sdspi_host_start_command: slot=1, CMD55, arg=0x00000000 flags=0x4, data=0x0, data_size=0 crc=0x32
V (36697) sdspi_transaction: r1 = 0x00 hw_cmd.r[0]=0xffffffff
V (36697) sdmmc_cmd: cmd response 00000000 00000000 00000000 00000000 err=0x0 state=0
V (36707) sdmmc_cmd: sending cmd slot=1 op=51 arg=0 flags=1c50 data=0x3fff0b28 blklen=8 datalen=8
V (36717) sdspi_host: sdspi_host_start_command: slot=1, CMD51, arg=0x00000000 flags=0x5, data=0x3fff0b28, data_size=8 crc=0x63
V (36727) sdspi_transaction: r1 = 0xff hw_cmd.r[0]=0x01803502
V (36737) sdmmc_cmd: cmd response 000000ff 00000000 00000000 00000000 err=0x0 state=0
Maybe the Error reason is UHS-I, other SDHC/SDXC cards (for example Kingmax class 10 16 MB) works well in 1-line mode.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: And again someone who has problems with esp32 and sd cards

Postby ESP_igrr » Tue Aug 01, 2017 1:15 pm

Great to see that you have the 1-line mode working! I suggest following this procedure... If you get an issue at any step, please stop and don't go further until the issue is resolved. From your previous post I see that you have some confusion between the issues you are having (i.e. you are doing a step to troubleshoot issue 1 and then mentioning that you still have an error indicative of issue 3) and you seem to be trying things at random, rather than focusing on a single issue at hand and resolving it.

1. Disconnect SD card hardware and pullups from the ESP32 board, including the connection between IO2 and IO0.
2. Make sure you can flash programs using 'make flash'
3. Run espefuse.py as discussed above
4. Connect SD card adapter and pullups, but don't insert an SD card yet.
5. Ignore the previous suggestion about bridging IO0 and IO2. You board seems to have an LED on IO0, which interferes with SD card D0 line if you connect IO2 and IO0. Instead, connect a jumper between IO2 and GND
6. Flash the SD card example, with SDMMC (not SPI) mode, modified to set frequency to SDMMC_FREQ_PROBING.
7. Remove the IO2-GND jumper
8. Insert the SD card
9. run "make monitor" (this also restarts the ESP)

At this point you should either get one of the following outcomes:
- success
- a "send_scr" error, indicating that there is still an issue with data lines (D0-D3)

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: And again someone who has problems with esp32 and sd cards

Postby ESP_igrr » Tue Aug 01, 2017 1:19 pm

loboris wrote: Here are the logs for SunDisk Ultra UHS-I 8GB tested on ESP-WROVER-KIT v3
Thanks for the logs... I have a few UHS-1 and UHS-II cards here but I wasn't able to reproduce this yet. It seems that sometimes we can't get the card to respond to the first command after placing it into idle state. It is interesting that this happens when you select 1-line mode but not 4-line mode, though, as the code path which depends on 4-line mode being enabled is after the command which fails in 1-line mode.
I'll order another pack of cards and try to reproduce this.

Staubgeborener
Posts: 20
Joined: Sat Jul 22, 2017 11:59 am

Re: And again someone who has problems with esp32 and sd cards

Postby Staubgeborener » Tue Aug 01, 2017 3:20 pm

Thanks igrr, for helping (and everyone in this thread). Well, 1bit worked, 4bit not.
Step 3 espefuse.py is still not possible. It hang up in this step. Is gpio_pullup_en(GPIO_NUM_12); doing the same?

What i found out: When connecting IO2 to GND with jumper (or just leavin IO2 disconnected from GND or IO0), the blue led stop glowing. When connecting to IO0 its glowing. Yo yeah, the LED on IO0 should be true.

When i do your guide step by step (except espefuse.py) i'll get
E (427) sdmmc_cmd: sdmmc_card_init: send_scr returned 0x109
E (427) example: Failed to initialize the card (265). Make sure SD card lines have pull-up resistors in place.
When leaving IO2 to GND connected
E (247) sdmmc_cmd: sdmmc_card_init: send_scr returned 0xffffffff
E (247) example: Failed to mount filesystem. If you want the card to be formatted, set format_if_mount_failed = true.

I tried the same for 1 bit. No matter if i leave GND or disconnect IO2 from GND, it's the same as above.
But when i leave IO2 connected to IO0 (blue LED glowing), 1 bit is working.

Staubgeborener
Posts: 20
Joined: Sat Jul 22, 2017 11:59 am

Re: And again someone who has problems with esp32 and sd cards

Postby Staubgeborener » Wed Aug 02, 2017 7:37 pm

Well, what can i say? It's happening again.

So basically the only setup thats working here was connecting IO0 to IO2 the whole time. I was getting a blue LED, but it worked (don't know why - i don't have to do this when i normaly flash a project to the ESP32).

But now, without changing code or circuit, it's not working. Instead i'll get a brownout error. When deactivating brownout detection, my ESP32 just loose the connection to my pc.

Code: Select all

Traceback (most recent call last):
  File "D:/msys32/mingw32/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "D:/msys32/mingw32/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "D:/msys32/home/Staubgeborener/esp/esp-idf/tools/idf_monitor.py", line 116, in _run_outer
    self.run()
  File "D:/msys32/home/Staubgeborener/esp/esp-idf/tools/idf_monitor.py", line 192, in run
    data = self.serial.read(self.serial.in_waiting or 1)
  File "D:/msys32/mingw32/lib/python2.7/site-packages/serial/serialwin32.py", line 273, in read
    raise SerialException("ClearCommError failed ({!r})".format(ctypes.WinError()))
SerialException: ClearCommError failed 

So i was doing your guide again (still without setting flash voltage to 3.3V, cause the script hangs up). But it's not working. After doing everything and disconnect IO2 from GND and make monitor i'll get

Code: Select all

E (2218) sdmmc_cmd: sdmmc_card_init: send_scr returned 0x109
... and a blue led glowing


Edit: Ok. What i found out: The jumper between IO0 and IO2 is still working (why?). But as soon, as i initialize wifi (esp_wifi_start()) i'll get a brownout. I tested this with a 5 seconds delay.

Code: Select all

Name: SS08G
Type: SDHC/SDXC
Speed: default speed
Size: 7583MB
CSD: ver=1, sector_size=512, capacity=15529984 read_bl_len=9
SCR: sd_spec=2, bus_width=5
I (8478) wifi: wifi firmware version: 0e33bec
I (8478) wifi: config NVS flash: enabled
I (8478) wifi: config nano formating: disabled
I (8478) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (8488) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (8508) wifi: Init dynamic tx buffer num: 32
I (8508) wifi: Init data frame dynamic rx buffer num: 32
I (8508) wifi: Init management frame dynamic rx buffer num: 32
I (8508) wifi: wifi driver task: 3ffcd2f8, prio:23, stack:4096
I (8518) wifi: Init static rx buffer num: 10
I (8518) wifi: Init dynamic rx buffer num: 32
I (8528) wifi: Init rx ampdu len mblock:7
I (8528) wifi: Init lldesc rx ampdu entry mblock:4
I (8538) wifi: wifi power manager task: 0x3ffded8c prio: 21 stack: 2560
E (8538) wifi: wifi_set_chan_range 1733 ret=1
I (8548) wifi: wifi timer task: 3ffdfde4, prio:22, stack:3584

Brownout detector was triggered

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0010,len:4
load:0x3fff0014,len:5108
load:0x40078000,len:0
load:0x40078000,len:12664
entry 0x40078f50
-> reboot



Edit from 04.08.17: Bought a new ESP32. Now i have truly to connect IO2 with IO0 while flashing. But still, only SPI and 1 line works. No 4 line. Circuit should be right, set flash voltage to 3.3V still not working (hangs up).

kearins
Posts: 21
Joined: Sun Jul 23, 2017 11:48 pm

Re: And again someone who has problems with esp32 and sd cards

Postby kearins » Thu Sep 07, 2017 3:54 am

Friends, can anybody say me about read/write speed of SD cards in practise? I've connected a SD card via SPI (esp-idf/examples/storage/sd_card) and have tried to write 1Mb, it took about 10 seconds per megabyte. Is it normal?
I used microSDHC 32Gb and microSDHC 2Gb, host.max_freq_khz = 32000. SD Cards reported csd.tr_speed=25000000.
What about speed in case of direct connection (1 wire/4 wire)?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: And again someone who has problems with esp32 and sd cards

Postby ESP_igrr » Thu Sep 07, 2017 6:32 am

Here is some data i got in a recent test. Test done on a 32GB Sandisk Extreme UHS-3 micro SDHC card, formatted on a PC. Connection between ESP32 and SD card is 4-line, SD mode is used.

1. FATFS filesystem read/write speed test:

Code: Select all

Wrote 4194304 bytes (block size 4096) in 1242.874ms (3.218 MB/s)
Wrote 4194304 bytes (block size 8192) in 907.626ms (4.407 MB/s)
Wrote 4194304 bytes (block size 16384) in 660.896ms (6.052 MB/s)
Read 4194304 bytes (block size 4096) in 2745.439ms (1.457 MB/s)
Read 4194304 bytes (block size 8192) in 2743.306ms (1.458 MB/s)
Read 4194304 bytes (block size 16384) in 2745.264ms (1.457 MB/s)
Max read speed: 1.458 MB/s, max write speed: 6.052 MB/s

2. RAW (no filesystem) read/write speed test:

Code: Select all

Name: SE32G
Type: SDHC/SDXC
Speed: high speed
Size: 30436MB
CSD: ver=1, sector_size=512, capacity=62333952 read_bl_len=9
SCR: sd_spec=2, bus_width=5
  sector  | count | align | size(kB)  | wr_time(ms) | wr_speed(MB/s)  |  rd_time(ms)  | rd_speed(MB/s)
        1 |   16  |   4   |     8.0   |     1.67    |       4.69      |      0.67     |     11.64
       16 |   32  |   4   |    16.0   |     1.60    |       9.74      |      1.10     |     14.17
       48 |   64  |   4   |    32.0   |     4.48    |       6.97      |      1.97     |     15.90
      128 |  128  |   4   |    64.0   |     8.81    |       7.10      |      3.68     |     17.01
 62333888 |   32  |   4   |    16.0   |     3.88    |       4.03      |      1.10     |     14.18
 62333888 |   64  |   4   |    32.0   |     4.51    |       6.93      |      1.96     |     15.94
 31166976 |   16  |   4   |     8.0   |     1.51    |       5.19      |      0.67     |     11.63
 31166976 |   32  |   4   |    16.0   |     3.71    |       4.21      |      1.10     |     14.15
 31166976 |   64  |   4   |    32.0   |     4.81    |       6.50      |      1.97     |     15.90
 31166976 |  128  |   4   |    64.0   |     6.54    |       9.55      |      3.70     |     16.91
Max read speed: 17.01 MB/s, Mac write speed: 9.74 MB/s

That's with the current IDF master.

ipsilondev
Posts: 6
Joined: Thu Sep 07, 2017 3:41 pm

Re: And again someone who has problems with esp32 and sd cards

Postby ipsilondev » Thu Sep 07, 2017 3:52 pm

ESP_igrr wrote:Here is some data i got in a recent test. Test done on a 32GB Sandisk Extreme UHS-3 micro SDHC card, formatted on a PC. Connection between ESP32 and SD card is 4-line, SD mode is used.

1. FATFS filesystem read/write speed test:

Code: Select all

Wrote 4194304 bytes (block size 4096) in 1242.874ms (3.218 MB/s)
Wrote 4194304 bytes (block size 8192) in 907.626ms (4.407 MB/s)
Wrote 4194304 bytes (block size 16384) in 660.896ms (6.052 MB/s)
Read 4194304 bytes (block size 4096) in 2745.439ms (1.457 MB/s)
Read 4194304 bytes (block size 8192) in 2743.306ms (1.458 MB/s)
Read 4194304 bytes (block size 16384) in 2745.264ms (1.457 MB/s)
Max read speed: 1.458 MB/s, max write speed: 6.052 MB/s

2. RAW (no filesystem) read/write speed test:

Code: Select all

Name: SE32G
Type: SDHC/SDXC
Speed: high speed
Size: 30436MB
CSD: ver=1, sector_size=512, capacity=62333952 read_bl_len=9
SCR: sd_spec=2, bus_width=5
  sector  | count | align | size(kB)  | wr_time(ms) | wr_speed(MB/s)  |  rd_time(ms)  | rd_speed(MB/s)
        1 |   16  |   4   |     8.0   |     1.67    |       4.69      |      0.67     |     11.64
       16 |   32  |   4   |    16.0   |     1.60    |       9.74      |      1.10     |     14.17
       48 |   64  |   4   |    32.0   |     4.48    |       6.97      |      1.97     |     15.90
      128 |  128  |   4   |    64.0   |     8.81    |       7.10      |      3.68     |     17.01
 62333888 |   32  |   4   |    16.0   |     3.88    |       4.03      |      1.10     |     14.18
 62333888 |   64  |   4   |    32.0   |     4.51    |       6.93      |      1.96     |     15.94
 31166976 |   16  |   4   |     8.0   |     1.51    |       5.19      |      0.67     |     11.63
 31166976 |   32  |   4   |    16.0   |     3.71    |       4.21      |      1.10     |     14.15
 31166976 |   64  |   4   |    32.0   |     4.81    |       6.50      |      1.97     |     15.90
 31166976 |  128  |   4   |    64.0   |     6.54    |       9.55      |      3.70     |     16.91
Max read speed: 17.01 MB/s, Mac write speed: 9.74 MB/s

That's with the current IDF master.
Sorry for asking this on this thread, but what would be the reason that the read velocity is so low with fat and sdio? this is a hardware limitation or software? i saw benchmarks of stm32f4 boards that has soid to near 15/20mb/s and with spi on 3/4mb/s. i was looking for esp32 as a better platform for something i want to build, but i need 7/10mb/s reading times on SD.

Thanks!.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: And again someone who has problems with esp32 and sd cards

Postby ESP_igrr » Fri Sep 08, 2017 3:04 am

Theoretical maximum read throughput for SD 4-line mode should be approaching 25MByte/sec, for sufficiently large read block sizes. Since ESP32 can only generate SDIO clocks which are 160MHz/n, it is impossible to generate 50MHz precisely. We use 40MHz as the highest compliant clock speed, hence the read throughput becomes capped at 20MByte/sec.

We get around 17MByte/sec, which might as well be limited by the unit test (as it verifies each word of the data read — that may take some time).

However FATFS library often reads just a single block of data from the card (512 bytes), so read throughput when using FAT is very low. There might be some tuning that can be done in FATFS library, but we haven't explored that.

If you can point me to these benchmarks of 15-20MByte/sec reads from FATFS on STM32, that would be very valuable to see (as in, there might be some low hanging fruit in terms of FATFS performance improvement).

ipsilondev
Posts: 6
Joined: Thu Sep 07, 2017 3:41 pm

Re: And again someone who has problems with esp32 and sd cards

Postby ipsilondev » Fri Sep 08, 2017 3:58 pm

ESP_igrr wrote:Theoretical maximum read throughput for SD 4-line mode should be approaching 25MByte/sec, for sufficiently large read block sizes. Since ESP32 can only generate SDIO clocks which are 160MHz/n, it is impossible to generate 50MHz precisely. We use 40MHz as the highest compliant clock speed, hence the read throughput becomes capped at 20MByte/sec.

We get around 17MByte/sec, which might as well be limited by the unit test (as it verifies each word of the data read — that may take some time).

However FATFS library often reads just a single block of data from the card (512 bytes), so read throughput when using FAT is very low. There might be some tuning that can be done in FATFS library, but we haven't explored that.

If you can point me to these benchmarks of 15-20MByte/sec reads from FATFS on STM32, that would be very valuable to see (as in, there might be some low hanging fruit in terms of FATFS performance improvement).
all the benchmarks are based on sd-fat lib, not FATFS https://github.com/greiman/SdFat. i suppose that sd-far doesn't work on esp32.

here is a benchmark using spi, at 36mhz, getting around 3mb/s: http://stm32duino.com/viewtopic.php?f=1 ... 120#p17911

here is a benchmark using SDIO with teensy 3.6 at 240mhz, getting 20mb/s: https://forum.pjrc.com/threads/36737-Tr ... post115239

here are benchmarks with SDIO on stm32f4 boards, from 5mb/s to 10mb/s depending the card: http://www.stm32duino.com/viewtopic.php ... eed#p31000

hope it helps :) i suppose i would need to buy a board and see if i can make work sd-fat on the esp32 to figure this out :)

Who is online

Users browsing this forum: Google [Bot], pacucha42 and 95 guests