SDcard in SPI mode using Loboris port?
Re: SDcard in SPI mode using Loboris port?
If you have couple od SMD 10K resistors, it will be easier to use.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: SDcard in SPI mode using Loboris port?
With all these posts it seems that reading a microsd card on an ESP32 in python should be doable I don't have a microsd-SD card adapter and I'd like to be able to use my microsdcard board so I have tried again now that I (think I) fully understand the pullup thing and that I know that the microsdcard might be the origin of error.
The first thing I wanted to try was coming back to SPI mode based on OutoftheBOTS_ message that shows that it can work. So far I have replicated the assembling in the post (plus added a 10k pullup on MOSI/D15 because it seems to be required according to this page). And I have two errors. If I try to replicate the code given by OutoftheBOTS_ :
The latest step gives me the following error :
If I remove the parameter "/sd" it's fine, any idea why (even if I don't think it's my main issue, I'd like to understand what is going wrong)?
As I don't think it is the main issue, I am trying without the "/sd" parameter. What seems to appear now is that it might be, as loboris suggested an issue with my SDCard? Indeed if I try with a sandisk 2Gb (that I got with a lowcost gopro, not sure it is really a legacy SanDisk), the error I get is :
If I replace the card with a 16Gb philips, the message is a bit different as cmd=51 is replaced by cmd=10. These two values, 51 and 10 are constant if I re-run the command, each one associated with one of the card. 51 for the sandisk, 10 for the philips.
Does anybody know what this value mean? Can I assume that my mounting is correct and the process just stops at a specific point depending on the quality of the card, and that a "perfect" card might be able to finish the process? I only have got these 2 microsd card available at the moment, but I might try to find another one if it seems to be a possibility.
Thanks for all the messages that have already been posted, I am confident I will get to the point I can read my microsd card
The first thing I wanted to try was coming back to SPI mode based on OutoftheBOTS_ message that shows that it can work. So far I have replicated the assembling in the post (plus added a 10k pullup on MOSI/D15 because it seems to be required according to this page). And I have two errors. If I try to replicate the code given by OutoftheBOTS_ :
Code: Select all
>>> import uos
>>> import os
>>> uos.sdconfig(uos.SDMODE_SPI, clk=14, mosi=15, miso=2, cs=13)
>>> os.mountsd("/sd")
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't convert str to int
As I don't think it is the main issue, I am trying without the "/sd" parameter. What seems to appear now is that it might be, as loboris suggested an issue with my SDCard? Indeed if I try with a sandisk 2Gb (that I got with a lowcost gopro, not sure it is really a legacy SanDisk), the error I get is :
Code: Select all
>>> uos.mountsd()
E (267388) sdspi_host: sdspi_host_start_command: cmd=51 error=0x108
E (267389) sdmmc_cmd: sdmmc_card_init: send_scr (2) returned 0x108
E (267392) vfs_native: Failed to initialize SDcard: invalid response).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 5] EIO
Does anybody know what this value mean? Can I assume that my mounting is correct and the process just stops at a specific point depending on the quality of the card, and that a "perfect" card might be able to finish the process? I only have got these 2 microsd card available at the moment, but I might try to find another one if it seems to be a possibility.
Thanks for all the messages that have already been posted, I am confident I will get to the point I can read my microsd card
Re: SDcard in SPI mode using Loboris port?
uos.mountsd() does not expect a string argument as describe in the Wiki.symac wrote: ↑Sat Mar 24, 2018 4:43 pmThe latest step gives me the following error :If I remove the parameter "/sd" it's fine, any idea why (even if I don't think it's my main issue, I'd like to understand what is going wrong)?Code: Select all
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't convert str to int
SD Card is always mounted on /sd.
The only argument (optional) that can be accepted is True or False.
If True is given, directory is changed to /sd after successful mount.
If you get the error in uos.mountsd(), it means the communication with sdcard is unsuccessful or it cannot be properly initialized for the requested mode.
Re: SDcard in SPI mode using Loboris port?
May I ask for the reason of pullup resistors on all SPI pins? I read some other sources online that have pins pulled to a well-defined state is good in general and when there is no sd card or when booting up. I tried to find sd specifications but didn't find the right files for physical specifications.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: SDcard in SPI mode using Loboris port?
I have edited my prevoius post to correct the os.mountsd(True) so other following the post will get correct info.
I made a typo when typing in code into the repl so had to retype 1 line of code so when I cut and paste to post here I cut around the typo but also mistakenly cut out os.chdir("/sd") that I used so I edited my post and instead of added the line I just changed the os.mountsd() but didn't realize when changing directory during mounting you don't specify the directory but rather pass True.
I did just make a 2 minute video of me doing the whole process for other to see it working properly https://youtu.be/y_rFSaA5XeQ
I made a typo when typing in code into the repl so had to retype 1 line of code so when I cut and paste to post here I cut around the typo but also mistakenly cut out os.chdir("/sd") that I used so I edited my post and instead of added the line I just changed the os.mountsd() but didn't realize when changing directory during mounting you don't specify the directory but rather pass True.
I did just make a 2 minute video of me doing the whole process for other to see it working properly https://youtu.be/y_rFSaA5XeQ
Re: SDcard in SPI mode using Loboris port?
Thanks for the explanation, I was thinking that I had read it without being woken up as I didn't understand where I had copied this line fromOutoftheBOTS_ wrote: ↑Sat Mar 24, 2018 9:32 pmI have edited my prevoius post to correct the os.mountsd(True) so other following the post will get correct info.
Thanks for the video, really seems to be exactly what I am doing, so I definitely suspect a microsd card error because of this cmd=51 / cmd=10 that depends on the card used. I am going to try today to go back to 1-line mode and see if anything changes, otherwise, I will try to get some sandisk micro sd cards as suggested by Loboris.OutoftheBOTS_ wrote: ↑Sat Mar 24, 2018 9:32 pmI did just make a 2 minute video of me doing the whole process for other to see it working properly https://youtu.be/y_rFSaA5XeQ
Re: SDcard in SPI mode using Loboris port?
I am continuing trying this. With two new microsd cards :
- A Sandisk 2go (from a blackberry smartphone), freshly formatted Fat32, I get the same error message than previously with the cmd=51 error code :
- A Sandisk 16Go bought yesterday and Fat32 formatted, I get another error message :
I have tried a bit using the 1-SD mode but I can't get more positive result. Will be away from computer for 2 weeks, leaving that extra information here in case someone has some clue. Otherwise, I will give a try to @liudr's solution now that I have an extra SD/MicroSD basic card adapter that came with the 16Gb card I bought yesterday, because I'd like to skip the "reading from a microsd card" step to go further with my micropython's experiments
S.
- A Sandisk 2go (from a blackberry smartphone), freshly formatted Fat32, I get the same error message than previously with the cmd=51 error code :
Code: Select all
E (69025) sdspi_host: sdspi_host_start_command: cmd=51 error=0x108
E (69026) sdmmc_cmd: sdmmc_card_init: send_scr (2) returned 0x108
E (69029) vfs_native: Failed to initialize SDcard: invalid response).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 5] EIO
Code: Select all
E (84436) sdmmc_cmd: sdmmc_card_init: send_if_cond (1) returned 0x108
E (84437) vfs_native: Failed to initialize SDcard: invalid response).
S.
Re: SDcard in SPI mode using Loboris port?
I hope OP found how to run the SD card by now. It's both funny and sad that I am running into the same problem now with my own prototype. In hoping to test the sd card, I had to use the dev board in the photo I posted on this thread (couldn't remember how I wired it without this photo). Took me a while to find this thread and the photo. Card works on the dev board but not my own design board