MicroSD hangup

PaulFreund
Posts: 45
Joined: Wed Nov 15, 2017 9:07 pm

Re: MicroSD hangup

Postby PaulFreund » Fri Nov 16, 2018 9:20 am

Thank you for following up! I am testing currently with the ESP-IDF master because I need WPA2 enterprise fixes (I don't think they are included in a release so far).

@igrr: Heap poisoning is already set to comprehensive. I actually think this issue is because of verbose logging. Now that we have seen the sequence I go back to error and repeat the test to see if it crashes. For all other devices I change the frequency down to 10000 kHz hoping that it improves the situation. I just hope I don't need to change the layout to be able to power off and on the card :S

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

Re: MicroSD hangup

Postby PeterR » Fri Nov 16, 2018 10:28 am

@ESP_igrr
My bad: v3.2-beta1-34-gfb7ba1baa
The issue is described here: https://www.esp32.com/viewtopic.php?f=2&t=7960&start=10 and here https://github.com/espressif/esp-idf/issues/1651
My summary at the end of the first thread explains the mechanism (as I see it).
Perhaps you could add comments to that post?
& I also believe that IDF CAN should be fixed.

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

Re: MicroSD hangup

Postby ESP_igrr » Fri Nov 16, 2018 10:39 am

Unfortunately we were never able to reproduce https://github.com/espressif/esp-idf/issues/1651 based on the description provided there. If you have some code which can be used to reproduce this, and which you can share with us, that would be great!

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

Re: MicroSD hangup

Postby PeterR » Fri Nov 16, 2018 2:33 pm

Perhaps we should jump over to https://www.esp32.com/viewtopic.php?f=2&t=7960&start=10 before I get charged with post hijacking :oops:
I could not distill a small example. I think the mechanism described in my post is easy enough to review and follow though.
Essential there was no multi-core protection and so you can find yourself in a race.
Would love to get a second opinion - to put my paranoia at ease.
The beta changes are also quite interesting as they suggest broader protection has been addressed e.g. memory model.
& I also believe that IDF CAN should be fixed.

PaulFreund
Posts: 45
Joined: Wed Nov 15, 2017 9:07 pm

Re: MicroSD hangup

Postby PaulFreund » Fri Nov 16, 2018 3:04 pm

Don't worry, everybody want's their issues solved :)

I have now made another test that regulary writes and downloads from MicroSD with 20000 kHz on another device with another MicroSD and it does not crash so far so I think it is related to printing so much.

All other devices are running fine so far with the 10000 kHz setting. Maybe it really is an issue of the MicroSD? Unfortunately this is the only model I know that is at least 85 degC specified

PaulFreund
Posts: 45
Joined: Wed Nov 15, 2017 9:07 pm

Re: MicroSD hangup

Postby PaulFreund » Fri Nov 16, 2018 9:39 pm

Unfortunately lowering the speed also did not help :( I'm also trying to find simple reproduction code or procedure but so far it only happens in the field after some hours and my test device that was able to reproduce sometimes was accidentially sent to another plant :lol:

Next thing I will do is checking the actual init routine. I think there are some interesting points laid out in this SO answer:

https://electronics.stackexchange.com/a/238217/146576

Especially leaving the controller 8 cycles at the end which might be missing after a crash/corruption... Short outage is no problem for me as long as I can recover from it :S

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

Re: MicroSD hangup

Postby PeterR » Sat Nov 17, 2018 1:15 am

Printing frequency & especially the number of items you print at a time definitely makes a difference.
I was running with stacks at least 1.25K to small for ages without issue. Started debugging & enabled some verbose & boom.
Still finding my feet with ESP but back in the day 5K for a task with printf was reasonable. Most of my ESP tasks were 2k which I accepted as; I though that units were words (no, its bytes) & also the examples generally use that.
Maybe ESP printf is uber cool but suggest you go stupidly large to rule out stack.
& I also believe that IDF CAN should be fixed.

PaulFreund
Posts: 45
Joined: Wed Nov 15, 2017 9:07 pm

Re: MicroSD hangup

Postby PaulFreund » Wed Nov 21, 2018 10:40 pm

For completenes I attached some scope shots of the signal. The series resistors are not optimal for 20MHz, better with 10MHz or lower but even then the issue persists.
MicroSD_Scope.zip
(318.96 KiB) Downloaded 178 times

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

Re: MicroSD hangup

Postby ESP_igrr » Thu Nov 22, 2018 4:50 am

PaulFreund wrote:
Fri Nov 16, 2018 9:39 pm
I'm also trying to find simple reproduction code or procedure
That would really help! I tried some obvious ways to reproduce this (such as, place an abort() call into sdmmc driver, to simulate a crash while reading from the card; reset the ESP32 externally while read is in progress) but so far the card could be re-initialized every time.

PaulFreund
Posts: 45
Joined: Wed Nov 15, 2017 9:07 pm

Re: MicroSD hangup

Postby PaulFreund » Tue Feb 05, 2019 7:09 am

Unfortunately I am only now getting to work on this again. I noticed one thing and am wondering where it came from. I could not find something in the simplified SD spec but the example notes here https://github.com/espressif/esp-idf/tr ... ge/sd_card state: "10k pullup in SD mode"

Does this imply I should not have a 10k Pull-Up in SPI mode? Is the ESP actively driving this pin the whole time? Should I try to drive it low?

Who is online

Users browsing this forum: No registered users and 49 guests